User avatar
bleep42
Posts: 135
Joined: Wed Mar 07, 2012 12:43 pm
Location: Sussex
Contact: Website

Simple Word Clock, new Word layout

Mon Jul 16, 2018 5:23 pm

IMG_1713.jpg
Finished Word Clock.
IMG_1713.jpg (59.27 KiB) Viewed 264 times

Link to all Images, Videos, Word Docs, and the code.https://www.dropbox.com/sh/fbt3zslpcoiq ... zUw4a?dl=0

I recently found I had an old dusty PiB+ (1CPU 500MB) laying around not doing anything useful, so I decided to build a Word Clock, there seem to be loads of different ones around, but I wanted it to be reasonably small, neat and good looking.
Unfortunately I don't have access to nice laser cutter and such like, so I decided to buy a kit, with the intention of then customising it.
The one I found which I liked the look of and wasn't ridiculously expensive, was the Cyntech Word Clock https://shop.cyntech.co.uk/collections/wordclock based on the WS2812 panel 8x8 RGB led matrix.
Their instructions worked very well, I built the case very quickly, installed a standard Stretch image on a flash card, then followed their set up procedure, everything worked very nicely.
Video of original. https://www.dropbox.com/s/vul5frhanabvl ... l.mp4?dl=0
Once fired up the clock worked very well, but I didn't really like the lettering layout, so after doing a lot of searches and finding that this layout was basically universal for an 8x8 matrix, I set about relaying it to something I preferred, this took quite a while! I'm not much good at crosswords.
Doc file of new layout. https://www.dropbox.com/s/4rpv4xat7qgfe ... k.doc?dl=0
Luckily the Cyntech kit also comes supplied with two straight 8x8 grid front plates, one with round holes the other with square, as well as the word clock front, so I word processed up my layout, so that it exactly lined up with the grid, this worked nicely. I was then able to re-write the Python code for my new layout, I included a ticking cursor, the potential to have a PM indication, and some Easter eggs, which appear about every few hours for about 20 seconds, along with a test flag to step through all combinations reasonably fast. I have now added over night dimming, which adjust with the month.
Video of new layout. https://www.dropbox.com/s/dtn16p6w239z8 ... t.mp4?dl=0
I then though it would be even better if I could get a proper laser cut front plate, so I asked Jason at Cyntech if he would be willing to make one up for me to buy, which he very kindly did, so here it is the finished item, using an old PiB+ under clocked to 500MHz to save (a very small amount of) heat/power, a WiFi dongle to get the time and an old phone charger. I'll probably try adding some extra Easter Eggs over time, just because I can. :-) I suppose anyone not having an old Pi, could easily use a Pi Zero, or newer.
Video of finished Word Clock, with redesigned, laser cut, face. https://www.dropbox.com/s/3f6uvkc3yc7nn ... d.mp4?dl=0

Code: Select all

from neopixel import *
from time import sleep
from datetime import datetime
import math
import struct
from random import randint

panel = Adafruit_NeoPixel(64, 18, 800000, 5, False, 50)

panel.begin()

# go through all patterns rapidly
test = 0

r = 0
g = 60
b = 200
rinc = 1
ginc = 1
binc = 1
min = 0
hour = 0
lasthour = 42
tick = 1
bright=50
# Cordinates to create a star * shape
star = [
       [27,36,37,26,25,38,24,39],
       [27,36,37,26,17,46,16,47],
       [27,36,45,18,17,46,8,55],
       [27,36,45,18,9,54,0,63],
       [27,36,44,18,10,53,1,62],
       [27,36,45,19,10,53,2,61],
       [27,36,44,19,11,52,3,60],
       [28,35,43,20,12,51,4,59],
       [28,35,43,20,13,50,5,58],
       [28,35,42,21,13,50,6,57],
       [28,35,42,21,14,49,7,56],
       [28,35,42,21,22,41,15,48],
       [28,35,34,29,22,41,23,40],
       [28,35,34,29,30,33,31,32]
       ]


def mfive(colour):
  panel.setPixelColor(12,colour)
  panel.setPixelColor(13,colour)
  panel.setPixelColor(14,colour)
  panel.setPixelColor(15,colour)

def mten(colour):
  panel.setPixelColor(7,colour)
  panel.setPixelColor(15,colour)
  panel.setPixelColor(23,colour)

def quarter(colour):
  panel.setPixelColor(8,colour)
  panel.setPixelColor(16,colour)
  panel.setPixelColor(17,colour)
  panel.setPixelColor(18,colour)
  panel.setPixelColor(19,colour)
  panel.setPixelColor(20,colour)
  panel.setPixelColor(21,colour)
  panel.setPixelColor(22,colour)

def twenty(colour):
  panel.setPixelColor(1,colour)
  panel.setPixelColor(2,colour)
  panel.setPixelColor(3,colour)
  panel.setPixelColor(4,colour)
  panel.setPixelColor(5,colour)
  panel.setPixelColor(6,colour)

def half(colour):
  panel.setPixelColor(9,colour)
  panel.setPixelColor(10,colour)
  panel.setPixelColor(11,colour)
  panel.setPixelColor(12,colour)

def past(colour):
  panel.setPixelColor(25,colour)
  panel.setPixelColor(26,colour)
  panel.setPixelColor(27,colour)
  panel.setPixelColor(28,colour)

def to(colour):
  panel.setPixelColor(28,colour)
  panel.setPixelColor(29,colour)



def one(colour):
  panel.setPixelColor(61,colour)
  panel.setPixelColor(62,colour)
  panel.setPixelColor(63,colour)

def two(colour):
  panel.setPixelColor(32,colour)
  panel.setPixelColor(40,colour)
  panel.setPixelColor(48,colour)

def three(colour):
  panel.setPixelColor(56,colour)
  panel.setPixelColor(57,colour)
  panel.setPixelColor(58,colour)
  panel.setPixelColor(59,colour)
  panel.setPixelColor(60,colour)

def four(colour):
  panel.setPixelColor(35,colour)
  panel.setPixelColor(36,colour)
  panel.setPixelColor(37,colour)
  panel.setPixelColor(38,colour)

def five(colour):
  panel.setPixelColor(35,colour)
  panel.setPixelColor(43,colour)
  panel.setPixelColor(51,colour)
  panel.setPixelColor(59,colour)

def six(colour):
  panel.setPixelColor(39,colour)
  panel.setPixelColor(47,colour)
  panel.setPixelColor(55,colour)

def seven(colour):
  panel.setPixelColor(41,colour)
  panel.setPixelColor(42,colour)
  panel.setPixelColor(51,colour)
  panel.setPixelColor(52,colour)
  panel.setPixelColor(53,colour)

def eight(colour):
  panel.setPixelColor(42,colour)
  panel.setPixelColor(43,colour)
  panel.setPixelColor(44,colour)
  panel.setPixelColor(45,colour)
  panel.setPixelColor(46,colour)

def nine(colour):
  panel.setPixelColor(53,colour)
  panel.setPixelColor(54,colour)
  panel.setPixelColor(62,colour)
  panel.setPixelColor(63,colour)

def ten(colour):
  panel.setPixelColor(32,colour)
  panel.setPixelColor(33,colour)
  panel.setPixelColor(34,colour)

def eleven(colour):
  panel.setPixelColor(49,colour)
  panel.setPixelColor(50,colour)
  panel.setPixelColor(59,colour)
  panel.setPixelColor(51,colour)
  panel.setPixelColor(52,colour)
  panel.setPixelColor(53,colour)

def twelve(colour):
  panel.setPixelColor(32,colour)
  panel.setPixelColor(40,colour)
  panel.setPixelColor(49,colour)
  panel.setPixelColor(50,colour)
  panel.setPixelColor(51,colour)
  panel.setPixelColor(52,colour)

def update():
  panel.show()

def clear():
  for i in range(0,64):
    panel.setPixelColor(i,Color(0,0,0))


def display_time(rate):

  global tick, hour, lasthour, min, r, g, b, rinc, ginc, binc, test, bright

  if test:
# Cycle hours and five minute intervals
    if tick == 0:
      hour += 1
      min += 5

    if hour >= 24:
      hour = 0

    if min >= 60:
      min = 0
  else:
# Display real time
    time = datetime.now().time()
    hour,min,sec = str(time).split(":")
    hour = int(hour)
    min = int(min)

  date = datetime.now().date()

# Update the LED brightness every hour time and month dependent
  if hour <> lasthour:
    lasthour=hour
    bright=15
    # Jan, Nov or Dec
    if date.month==1 or date.month==11 or date.month==12:
      if hour>=7 and hour<=16:
        bright=150
    # May, June, July
    elif date.month==5 or date.month==6 or date.month==7:
      if hour>=4 and hour<=20:
        bright=150
    # Feb, Oct
    elif date.month==2 or date.month==10:
      if hour>=6 and hour<=17:
        bright=150
    # March, Sept
    elif date.month==3 or date.month==9:
      if hour>=5 and hour<=19:
        bright=150
    # April, Aug
    elif date.month==4 or date.month==8:
      if hour>=5 and hour<=20:
        bright=150

  panel.setBrightness(bright)

# Randomise the display colour
  if r >= 250:
    rinc = 0
  if r <= 5:
    rinc = 1
  if rinc == 1:
    r += randint(0,5)
  else:
    r -= randint(0,5)

  if g >= 250:
    ginc = 0
  if g <= 5:
    ginc = 1
  if ginc == 1:
    g += randint(0,5)
  else:
    g -= randint(0,5)

  if b >= 250:
    binc = 0
  if b <= 5:
    binc = 1
  if binc == 1:
    b += randint(0,5)
  else:
    b -= randint(0,5)

  clear()

  col = Color(g,r,b)

  if 3 <= min <= 7:
    mfive(col)
    past(col)

  if 8 <= min <= 12:
    mten(col)
    past(col)

  if 13 <= min <= 17:
    quarter(col)
    past(col)

  if 18 <= min <= 22:
    twenty(col)
    past(col)

  if 23 <= min <= 27:
    twenty(col)
    mfive(col)
    past(col)

  if 28 <= min <= 32:
    half(col)
    past(col)

  if 33 <= min <= 37:
    twenty(col)
    mfive(col)
    to(col)

  if 38 <= min <= 42:
    twenty(col)
    to(col)

  if 43 <= min <= 47:
    quarter(col)
    to(col)

  if 48 <= min <= 52:
    mten(col)
    to(col)

  if 53 <= min <= 57:
    mfive(col)
    to(col)

  if test == 0:
    if min > 32:
      hour = hour + 1



  if hour == 1 or hour == 13:
    one(col)
  if hour == 2 or hour == 14:
    two(col)
  if hour == 3 or hour == 15:
    three(col)
  if hour == 4 or hour == 16:
    four(col)
  if hour == 5 or hour == 17:
    five(col)
  if hour == 6 or hour == 18:
    six(col)
  if hour == 7 or hour == 19:
    seven(col)
  if hour == 8 or hour == 20:
    eight(col)
  if hour == 9 or hour == 21:
    nine(col)
  if hour == 10 or hour == 22:
    ten(col)
  if hour == 11 or hour == 23:
    eleven(col)
  if hour == 12 or hour == 0:
    twelve(col)

# Create the seconds indicator
  tick += 1

  if tick == 1:
    panel.setPixelColor(0,col)
  elif tick == 2:
    panel.setPixelColor(24,col)
  elif tick == 3:
    panel.setPixelColor(31,col)
  else:
    panel.setPixelColor(24,col)
    tick = 0

# AM/PM indication
# if hour >= 12:
#   panel.setPixelColor(30,Color(0,200,0))
# else:
#   panel.setPixelColor(30,Color(0,0,0))

  update()
  sleep(rate)


def next_colour(pix):
  r = pix[0]
  g = pix[1]
  b = pix[2]

# New rainbow colour calculation, in steps of 10
  if r > 245:
    if (g <= 245 and b < 10):
      g += 10
    if (b >= 10 and g < 10):
      b -= 10

  if g > 245:
    if (r >= 10 and b < 10):
      r -= 10
    if (b <= 245 and r < 10):
      b += 10

  if b > 245:
    if (g >= 10 and r < 10):
      g -= 10
    if (r <= 245 and g < 10):
      r += 10

  pix[0] = r
  pix[1] = g
  pix[2] = b


def rainbow_diagonal(repeat,delay):
# Initialise the rainbow colours borrowed from Sense HAT examples
  pixels = [
      [255,0,0],   [255,0,0],  [255,87,0],  [255,196,0], [205,255,0], [95,255,0], [0,255,13], [0,255,122],
      [255,0,0],   [255,96,0], [255,205,0], [196,255,0], [87,255,0], [0,255,22], [0,255,131], [0,255,240],
      [255,105,0], [255,214,0], [187,255,0], [78,255,0], [0,255,30], [0,255,140], [0,255,248], [0,152,255],
      [255,223,0], [178,255,0], [70,255,0], [0,255,40],  [0,255,148], [0,253,255], [0,144,255], [0,34,255],
      [170,255,0], [61,255,0],  [0,255,48], [0,255,157], [0,243,255], [0,134,255], [0,26,255], [83,0,255],
      [52,255,0],  [0,255,57], [0,255,166], [0,235,255], [0,126,255], [0,17,255], [92,0,255], [201,0,255],
      [0,255,66],  [0,255,174], [0,226,255], [0,117,255], [0,8,255], [100,0,255], [210,0,255], [255,0,192],
      [0,255,183], [0,217,255], [0,109,255], [0,0,255],  [110,0,255], [218,0,255], [255,0,183], [255,0,74]
  ]
  for i in range(repeat):
# Output the array to the LEDs
    x = 0
    for pix in pixels:
      panel.setPixelColor(x,Color(pix[1],pix[0],pix[2]))
      x += 1
# Calculate the new LED colour
      next_colour(pix)

    update()
    sleep(delay)


# colour, clear each itteration, repeat, step delay
def prop_rotate(colour,clr,repeat,delay):

  for i in range(repeat):
    for row in star:
      for pix in range(8):
        panel.setPixelColor(row[pix],colour)
      panel.show()
      if clr:
        for pix in range(8):
          panel.setPixelColor(row[pix],Color(0,0,0))

      sleep(delay)


# Colour, diameter (4,6,8), repeats, delay
def star_rotate(colour,diam,repeat,delay):

  for i in range(repeat):
    clear()
    point=0
    for row in star:
      point = point+1
      if point==1 or point==5 or point==9 or point==13:
        for pix in range(diam):
          panel.setPixelColor(row[pix],colour)
    panel.show()
    clear()
    sleep(delay)
    point=0
    for row in star:
      point = point+1
      if point==2 or point==6 or point==10 or point==14:
        for pix in range(diam):
          panel.setPixelColor(row[pix],colour)
    panel.show()
    clear()
    sleep(delay)
    point=0
    for row in star:
      point = point+1
      if point==3 or point==7 or point==11:
        for pix in range(diam):
          panel.setPixelColor(row[pix],colour)
    panel.show()
    clear()
    sleep(delay)
    point=0
    for row in star:
      point = point+1
      if point==4 or point==8 or point==12:
        for pix in range(diam):
          panel.setPixelColor(row[pix],colour)
    panel.show()
    sleep(delay)


def rainbow_effect(pos):
# Generate rainbow colors across 0-255 colour range.
    if pos >= 170:
        pos -= 170
        return Color(0, pos * 3, 255 - pos * 3)
    if pos >= 85:
        pos -= 85
        return Color(255 - pos * 3, 0, pos * 3)
    else:
        return Color(pos * 3, 255 - pos * 3, 0)


def rainbow_up(repeat,delay):
#  Draw upward moving rainbow spread across all pixels, scaled to 0-255.
    for i in range(256*repeat):
        for j in range(64):
            panel.setPixelColor(j, rainbow_effect((int(j * 4) + i) & 255))
        panel.show()
        sleep(delay)


def matrix_code(repeat,delay):
# Draw 'Matrix' falling code display
  for i in range(repeat):
# Insert a new random 'code'
    column = randint(0,7)
    panel.setPixelColor(column,Color(255,50,40))
    update()

# Move the 'code' down one line
    for x in range(55,-1,-1):
      panel.setPixelColor(x+8,panel.getPixelColor(x))

# Calculate the new colour for top row.
    for column in range(8):
# extract the green colour only and fade it as 'code' drops
      green_pix = (panel.getPixelColor(column) >> 16) & 0xff
      if green_pix > 200:
         green_pix -= 157
      elif green_pix >= 13:
         green_pix -= 13

      panel.setPixelColor(column,Color(green_pix,0,0))

    sleep(delay)


def fast_time(repeat,delay):

  global bright

  # save current brightness incase it gets changed
  orig_bright=bright

  for i in range(repeat):
    display_time(delay)

  # restore current brightness
  bright=orig_bright


def zoom(start_colour,repeat,delay):

  for i in range(repeat):

    for x in range(8):
      panel.setPixelColor(x,start_colour)
      panel.setPixelColor(x+56,start_colour)

    for x in range(0,56,8):
      panel.setPixelColor(x,start_colour)
      panel.setPixelColor(x+7,start_colour)

    update()
    clear()
    sleep(delay)

# Fade original colour
    colour = start_colour & 0x5f5f5f5f

    for x in range(9,14):
      panel.setPixelColor(x,colour)
      panel.setPixelColor(x+40,colour)

    for x in range(9,50,8):
      panel.setPixelColor(x,colour)
      panel.setPixelColor(x+5,colour)

    update()
    clear()
    sleep(delay)

# Fade original colour
    colour = colour & 0x3f3f3f3f

    for x in range(18,21):
      panel.setPixelColor(x,colour)
      panel.setPixelColor(x+24,colour)

    for x in range(18,43,8):
      panel.setPixelColor(x,colour)
      panel.setPixelColor(x+3,colour)

    update()
    clear()
    sleep(delay)

# Fade original colour
    colour = colour & 0x1f1f1f1f

    panel.setPixelColor(27,colour)
    panel.setPixelColor(28,colour)

    panel.setPixelColor(35,colour)
    panel.setPixelColor(36,colour)

    update()
    clear()
    sleep(delay)


def rainbow_theater_chase(repeat,delay):
#  Rainbow theater light style chaser animation.
    for i in range(repeat):
      for q in range(4):
        for j in range(0, 64, 4):
          panel.setPixelColor(j+q, rainbow_effect(((j*4)+(i*4)) % 255))
        panel.show()
        sleep(delay)
        for j in range(0, 64, 4):
          panel.setPixelColor(j+q, 0)


def colour_run(colour,delay):
#  Run a color across display and downwards one pixel at a time.
    for i in range(64):
      panel.setPixelColor(i, colour)
      panel.show()
      sleep(delay)


# colour, clear each itteration, repeat, step delay
def diag_colour_swipe(colour,clr,r2l,repeat,delay):

#  Swipe colour diagonally accross the screen

  for i in range(repeat):
    for k in range(0,7,1):
      if r2l:
        j = 62-k
      else:
        j = k+56
      for x in range(j,0,-7):
        panel.setPixelColor(x,colour)
      if j == 56:
        panel.setPixelColor(0,colour)
        panel.setPixelColor(63,colour)
      panel.show()
      if clr:
        for x in range(j,0,-7):
          panel.setPixelColor(x,Color(0,0,0))
        if j == 56:
          panel.setPixelColor(0,Color(0,0,0))
          panel.setPixelColor(63,Color(0,0,0))

      sleep(delay)


# colour, clear each itteration, direction, repeat, step delay
def colour_scroll(colour,clr,t2b,repeat,delay):

#  Swipe colour accross the screen T->B or B->T

  for i in range(repeat):
    for k in range(0,57,8):
      if t2b:
        j = k
      else:
        j = 56-k
      for x in range(j,(j+8),1):
        panel.setPixelColor(x,colour)
      panel.show()
      if clr:
        for x in range(j,(j+8),1):
          panel.setPixelColor(x,Color(0,0,0))

      sleep(delay)


# colour, clear each itteration, direction, repeat, step delay
def colour_swipe(colour,clr,r2l,repeat,delay):

#  Swipe colour accross the screen R->L or L->R

  for i in range(repeat):
    for k in range(0,8,1):
      if r2l:
        j = 7-k
      else:
        j = k
      for x in range(j,(j+57),8):
        panel.setPixelColor(x,colour)
      panel.show()
      if clr:
        for x in range(j,(j+57),8):
          panel.setPixelColor(x,Color(0,0,0))

      sleep(delay)


easter = 0
if test:
  mult = 1
else:
  mult = 10000

while True:

  # Reduce day brightness when doing Easter egg to reduce power drain
  if bright > 50:
    panel.setBrightness(bright/3)
  else:
    panel.setBrightness(bright)

  easter += 1

  if easter == (5*mult):
# colour, clear each itteration, right2left, repeat, step delay
    diag_colour_swipe(Color(255,0,200),0,0,1,0.1)  # diagonal cyan wipe
    diag_colour_swipe(Color(255,0,200),1,1,4,0.1)  # diagonal cyan swipe
    diag_colour_swipe(Color(255,0,200),0,0,0,0.1)  # diagonal cyan wipe
    diag_colour_swipe(Color(0,255,255),0,1,1,0.1)  # diagonal magenta wipe
    diag_colour_swipe(Color(0,255,255),1,0,4,0.1)  # diagonal magenta swipe
    diag_colour_swipe(Color(0,255,255),0,1,1,0.1)  # diagonal magenta wipe
    diag_colour_swipe(Color(255,255,0),0,0,1,0.1)  # diagonal yellow wipe
    diag_colour_swipe(Color(255,255,0),1,1,4,0.1)  # diagonal yellow swipe
    diag_colour_swipe(Color(255,255,0),0,0,1,0.1)  # diagonal yellow wipe
    diag_colour_swipe(Color(255,0,0),0,1,1,0.1)    # diagonal green swipe
    diag_colour_swipe(Color(255,0,0),1,0,4,0.1)    # diagonal green wipe
    diag_colour_swipe(Color(255,0,0),0,1,1,0.1)    # diagonal green wipe
    diag_colour_swipe(Color(0,255,0),0,0,1,0.1)    # diagonal red wipe
    diag_colour_swipe(Color(0,255,0),1,1,4,0.1)    # diagonal red swipe
    diag_colour_swipe(Color(0,255,0),0,0,1,0.1)    # diagonal red wipe
    matrix_code(20,0.25)
  elif easter == (10*mult):
    for rep in range(20):
      for i in range(8,1,-2):
# Colour, diameter (4,6,8), repeats, delay
        star_rotate(Color(36*(i-1),255,0),i,1,0.025)
      for i in range(4,9,2):
        star_rotate(Color(36*(i-1),255,0),i,1,0.025)
    if not test:
      matrix_code(20,0.25)
  elif easter == (15*mult):
# repeat, step delay
    fast_time(650,0.02)
    if not test:
      matrix_code(20,0.25)
  elif easter == (20*mult):
# colour, step delay
    colour_run(Color(20, 20, randint(20,150)),0.02)
    colour_run(Color(randint(20,255), 20, 20),0.02)
    colour_run(Color(20, randint(20,255), 20),0.02)
    colour_run(Color(randint(20,255), randint(20,255), randint(20,150)),0.02)
    colour_run(Color(20, 20, randint(20,150)),0.02)
    colour_run(Color(randint(20,255), 20, 20),0.02)
    colour_run(Color(20, randint(20,255), 20),0.02)
    colour_run(Color(randint(20,255), randint(20,255), randint(20,150)),0.02)
    colour_run(Color(20, 20, randint(20,150)),0.02)
    colour_run(Color(randint(20,255), 20, 20),0.02)
    colour_run(Color(20, randint(20,255), 20),0.02)
    colour_run(Color(randint(20,255), randint(20,255), randint(20,150)),0.02)
    colour_run(Color(20, 20, randint(20,150)),0.02)
    colour_run(Color(randint(20,255), 20, 20),0.02)
    if not test:
      matrix_code(20,0.25)
  elif easter == (25*mult):
# repeat, step delay
    rainbow_theater_chase(90,0.05)
    if not test:
      matrix_code(20,0.25)
  elif easter == (30*mult):
# colour, clear each itteration, right2left, repeat, step delay
    colour_swipe(Color(255, 0, 0),0,0,1,0.1)    # Green wipe l2r
    colour_swipe(Color(0, 255, 0),1,1,2,0.1)    # Red swipe r2l
    colour_swipe(Color(0, 255, 0),0,0,1,0.1)    # Red wipe l2r
    colour_swipe(Color(255, 0, 0),1,0,1,0.1)    # Green swipe l2r
    colour_swipe(Color(255, 0, 200),0,0,1,0.1)  # Cyan wipe l2r
    colour_swipe(Color(0, 255, 225),1,1,2,0.1)  # Magenta swipe r2l
    colour_swipe(Color(0, 255, 225),0,1,1,0.1)  # Magenta wipe r2l
    colour_swipe(Color(255, 0, 200),1,0,1,0.1)  # Cyan swipe l2r
    colour_swipe(Color(255, 255, 0),0,0,1,0.1)  # Yellow wipe l2r
    colour_swipe(Color(0, 0, 255),1,1,2,0.1)    # Blue swipe r2l
    colour_swipe(Color(255, 0, 200),0,0,1,0.1)  # Cyan wipe l2r
    colour_swipe(Color(0, 0, 255),0,1,1,0.1)    # Blue swipe r2l
    colour_swipe(Color(0, 255, 0),0,1,1,0.1)    # Red wipe r2l
    colour_swipe(Color(255, 255, 0),1,0,1,0.1)  # Yellow swipe l2r
    colour_swipe(Color(0, 0, 255),0,0,1,0.1)    # Blue wipe l2r
    colour_swipe(Color(0, 255, 0),1,1,2,0.1)    # Red swipe r2l
    colour_swipe(Color(0, 255, 0),0,0,1,0.1)    # Red wipe l2r
    colour_swipe(Color(255, 0, 200),0,1,1,0.1)  # Cyan wipe r2l
    colour_swipe(Color(0, 255, 255),0,0,1,0.1)  # Magenta wipe l2r
    if not test:
      matrix_code(20,0.25)
  elif easter == (35*mult):
# colour, clear each itteration, repeat, step delay
    prop_rotate(Color(255, 255, 255),1,30,0.01)
    prop_rotate(Color(0, 0, 255),1,30,0.01)
    prop_rotate(Color(255, 0, 200),1,30,0.01)
    prop_rotate(Color(255, 255, 0),1,30,0.01)
    prop_rotate(Color(255, 255, 0),0,1,0.01)
    if not test:
      matrix_code(20,0.25)
  elif easter == (40*mult):
# repeat, step delay
    rainbow_up(5,0.005)
    if not test:
      matrix_code(20,0.25)
  elif easter == (45*mult):
# colour, clear each itteration, repeat, step delay
    prop_rotate(Color(20, 20, randint(20,150)),1,1,0.1)
    prop_rotate(Color(20, 20, randint(20,150)),0,1,0.1)
    prop_rotate(Color(randint(20,255), 20, 20),0,1,0.1)
    prop_rotate(Color(randint(20,255), 20, 20),1,1,0.1)
    prop_rotate(Color(20, randint(20,255), 20),0,1,0.1)
    prop_rotate(Color(20, randint(20,255), 20),1,1,0.1)
    prop_rotate(Color(randint(20,255), randint(20,255), randint(20,150)),0,1,0.1)
    prop_rotate(Color(randint(20,255), randint(20,255), randint(20,150)),0,1,0.1)
    prop_rotate(Color(20, 20, randint(20,150)),1,1,0.1)
    prop_rotate(Color(20, 20, randint(20,150)),0,1,0.1)
    prop_rotate(Color(randint(20,255), 20, 20),1,1,0.1)
    prop_rotate(Color(randint(20,255), 20, 20),0,1,0.1)
    prop_rotate(Color(20, randint(20,255), 20),0,1,0.1)
    prop_rotate(Color(200, randint(20,255), 20),0,1,0.1)
    if not test:
      matrix_code(20,0.25)
  elif easter == (50*mult):
# repeat, step delay
    matrix_code(100,0.25)
  elif easter == (55*mult):
# colour, repeat, step delay
    zoom(Color(255,0,0),20,0.05)
    zoom(Color(0,255,0),20,0.05)
    zoom(Color(0,0,255),20,0.05)
    zoom(Color(255,200,0),20,0.05)
    if not test:
      matrix_code(20,0.25)
  elif easter == (60*mult):
# Repeat 1000 times, approx 20sec on Pi1 adjust as necessary
# repeat, step delay
    rainbow_diagonal(1000,0.008)
    if not test:
      matrix_code(20,0.25)
  elif easter == (65*mult):
# colour, clear each itteration, top2bottom, repeat, step delay
    colour_scroll(Color(255, 0, 0),0,0,1,0.1)    # Green wipe b2t
    colour_scroll(Color(0, 255, 0),1,1,2,0.1)    # Red swipe t2b
    colour_scroll(Color(0, 255, 0),0,1,1,0.1)    # Red wipe t2b
    colour_scroll(Color(255, 0, 0),1,0,2,0.1)    # Green swipe b2t
    colour_scroll(Color(255, 0, 200),0,0,1,0.1)  # Cyan wipe b2t
    colour_scroll(Color(0, 255, 225),1,1,2,0.1)  # Magenta swipe t2b
    colour_scroll(Color(0, 255, 225),0,1,1,0.1)  # Magenta wipe t2b
    colour_scroll(Color(255, 0, 200),1,0,2,0.1)  # Cyan swipe b2t
    colour_scroll(Color(255, 255, 0),0,0,1,0.1)  # Yellow wipe b2t
    colour_scroll(Color(0, 0, 255),1,1,2,0.1)    # Blue swipe t2b
    colour_scroll(Color(0, 0, 255),0,1,1,0.1)    # Blue wipe t2b
    colour_scroll(Color(255, 255, 0),1,0,2,0.1)  # Yellow swipe b2t
    colour_scroll(Color(255, 0, 200),0,0,1,0.1)  # Cyan wipe b2t
    colour_scroll(Color(0, 255, 0),0,1,1,0.1)    # Red wipe t2b
    colour_scroll(Color(0, 0, 255),0,0,1,0.1)    # Blue wipe b2t
    colour_scroll(Color(255, 0, 200),0,1,1,0.1)  # Cyan wipe t2b
    colour_scroll(Color(0, 255, 255),0,0,1,0.1)  # Magenta wipe b2t
    if not test:
      matrix_code(20,0.25)
  elif easter >= (70*mult):
# Colour, diameter (4,6,8), repeats, delay
    star_rotate(Color(255,255,0),8,20,0.025)
    star_rotate(Color(0,255,0),8,20,0.025)
    star_rotate(Color(0,255,255),8,20,0.025)
    star_rotate(Color(0,0,255),8,20,0.025)
    star_rotate(Color(255,0,0),8,20,0.025)
    star_rotate(Color(255,0,200),8,20,0.025)
    star_rotate(Color(255,255,255),8,20,0.025)
    if not test:
      matrix_code(20,0.25)
    easter = 0

  display_time(0.5)
Link to Python file to run clock.https://www.dropbox.com/s/ru61ilsu563pu ... ck.py?dl=0
I'm not a Python coder, so this is far from optimal. ;-)

I'm much happy ;-) and I for one, think it looks lovely.
Presumably, anyone else liking this layout could also get one by asking Cyntech nicely. ;-)

And when you get bored with it being a word clock, you can always re-purpose it using the square or round hole matrix to do something else. :-)

PS. Code updated with extra Easter eggs and over night dimming.

User avatar
bleep42
Posts: 135
Joined: Wed Mar 07, 2012 12:43 pm
Location: Sussex
Contact: Website

Re: Simple Word Clock, new Word layout

Wed Aug 29, 2018 8:02 am

Code updated with automatic over night dimming, which adjusts with the month and extra easter eggs.

Return to “Other projects”

Who is online

Users browsing this forum: No registered users and 13 guests