-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_wclock_table.py
92 lines (82 loc) · 2.35 KB
/
gen_wclock_table.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# Dictionary of all LED strings and their 32-bit position
LED_Bit_Dictionary = {
"IT IS": 8,
"A QUA": 9,
"RTER": 10,
"TENm": 11,
"TWEm": 12,
"NTY": 13,
"FIVEm": 14,
"MINU": 0,
"TES": 1,
"HALF": 2,
"PAST": 3,
"TO": 4,
"ONE": 5,
"TWO": 6,
"THR": 7,
"EE": 24,
"FOUR": 26,
"FIVE": 25,
"SIX": 27,
"SEV": 28,
"EN": 29,
"EIG": 30,
"HT": 31,
"NINE": 16,
"TEN": 17,
"ELE": 18,
"VEN": 19,
"TWE": 20,
"LVE": 21,
"OCL": 22,
"OCK": 23,
}
# LED Strings "IT IS", "O'CL", "OCK" are always on
LED_Template = ["IT IS", "OCL", "OCK"]
# LED Strings for hours "ONE" ... "TWELVE"
LED_Hours = [
["ONE"], # 1 - "ONE"
["TWO"], # 2 - "TWO"
["THR", "EE"], # 3 - "THREE"
["FOUR"], # 4 - "FOUR"
["FIVE"], # 5 - "FIVE"
["SIX"], # 6 - "SIX"
["SEV", "EN"], # 7 - "SEVEN"
["EIG", "HT"], # 8 - "EIGHT"
["NINE"], # 9 - "NINE"
["TEN"], # 10 - "TEN"
["ELE", "VEN"], # 11 - "ELEVEN"
["TWE", "LVE"], # 12 - "TWELVE"
]
# LED Strings for five minute intervals
LED_Minutes = [
#(words, hour inc)
([], 0), # 00
(["FIVEm", "MINU", "TES", "PAST"], 0), # 05 - "FIVE" "PAST"
(["TENm", "MINU", "TES", "PAST"], 0), # 10 - "TEN" "PAST"
(["A QUA", "RTER", "PAST"], 0), # 15 - "A QUARTER" "PAST"
(["TWEm", "NTY", "MINU", "TES", "PAST"], 0), # 20 - "TWENTY" "PAST"
(["TWEm", "NTY", "FIVEm", "MINU", "TES", "PAST"],0), # 25 - "TWENTY" "FIVE" "PAST"
(["HALF", "PAST"], 0), # 30 - "HALF" "PAST"
(["TWEm", "NTY", "FIVEm", "MINU", "TES", "TO"], 1), # 35 - "TWENTY" "FIVE" "TO"
(["TWEm", "NTY", "MINU", "TES", "TO"], 1), # 40 - "TWENTY" "TO"
(["A QUA", "RTER", "TO"], 1), # 45 - "A QUARTER" "TO"
(["TENm", "MINU", "TES", "TO"], 1), # 50 - "TEN" "TO"
(["FIVEm", "MINU", "TES", "TO"], 1), # 55 - "FIVE" "TO"
]
def led_bit_lookup(words):
bits = 0
for w in words:
bits = bits | (1 << LED_Bit_Dictionary[w])
return bits
print "led_time_table:"
for hours in range(12):
for minutes in range(60/5):
(led_min_words, inc) = LED_Minutes[minutes]
led_hour_words = LED_Hours[(hours+inc) % 12]
led_bits = led_bit_lookup(LED_Template) | led_bit_lookup(led_min_words) | led_bit_lookup(led_hour_words)
led_bits_high = (led_bits & 0xFFFF0000) >> 16
led_bits_low = (led_bits & 0xFFFF)
offset = (hours*12) + minutes
print "\t.word 0x%04X, 0x%04X\t; %02d:%02d:00 Offset: %d" % (led_bits_high, led_bits_low, hours+1, minutes*5, offset << 2)