Compare commits

16 Commits

Author SHA1 Message Date
Jan
f147bc55c6 wip: intergrating clockyconfig in main code 2019-09-27 17:34:25 +02:00
Jan
dd1355509b Merge branch 'clockyconfig' 2019-09-27 11:44:34 +02:00
Jan
124ab39f82 Expanded verbose options 2019-09-26 23:39:32 +02:00
Jan
eaaeadf642 Fixed bug where modulo functions returned float instead of int 2019-09-26 20:44:02 +02:00
Jan
ce9a4837e1 Updated changes.txt and README.md 2019-09-26 17:57:14 +02:00
Jan
c25733b64c Added SIGHUP signal handling, adjusted reloading of file changes, added return value of CheckTrackList() 2019-09-26 17:41:05 +02:00
Jan
88dce016de Added tracklist code to replace readmp3 routine 2019-09-26 16:03:19 +02:00
Jan
20f0eb71b9 Merge branch 'clockytracklist' 2019-09-26 14:01:03 +02:00
Jan
77c06ee493 Changed code to python3, add README.md 2019-09-26 13:41:04 +02:00
Jan
52a0af1d91 v0.1.0: added max7219 support, added signal handling 2019-09-26 10:17:02 +02:00
Jan
4a5498866c added ChecktTrackList 2019-09-25 17:11:51 +02:00
Jan
1555050909 1st setup for tracklist reading 2019-09-25 16:43:37 +02:00
Jan
3edf9ba34c 1st test of track stuff 2019-09-25 12:32:18 +02:00
Jan
e65eadb2d0 Added clockyconfig.py for better config file handling. (also conftest.py to test this) 2019-09-25 11:28:03 +02:00
Jan
930a517982 Revert "Added clockyconfig.py for better config file handling. (also conftest.py to test this)"
This reverts commit 3d31aacfd1.
2019-09-25 11:17:16 +02:00
Jan
3d31aacfd1 Added clockyconfig.py for better config file handling. (also conftest.py to test this) 2019-09-25 11:08:03 +02:00
11 changed files with 1267 additions and 388 deletions

58
README.md Normal file
View File

@@ -0,0 +1,58 @@
# Clocky
A minimal, Raspberry Pi based, music playing alarmclock.
## Getting Started
### Prerequisites
Clocky is build with python 3 and is using the following libraries:
[RPi.GPIO](http://sourceforge.net/projects/raspberry-gpio-python/) - handling hardware I/O for the buttons and 7-segment display
[Luma.LED_Matrix](https://github.com/rm-hull/luma.led_matrix) - for driving the matrix display
[Pygame](https://www.pygame.org/) - for playing audio
Needed to install before running Clocky:
```
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python3-pip3
sudo apt-get install build-essential python-dev python-pip libfreetype6-dev libjpeg-dev libopenjp2-7 libtiff5
pip3 install RPI.GPIO
pip3 install luma.led_matrix
pip3 install pygame
```
### Installing
A step by step series of examples that tell you how to get a development env running
Say what the step will be
```
Give the example
```
### Users Manual
Button 1:
short press: show alarm time
long press: enter edit mode
Button 1 & Button 2 simutaneous:
long press: turn alarm off
### Hardware
Overview of used hardware:
[Raspberry Pi Zero-W](https://www.raspberrypi.org/products/raspberry-pi-zero-w/)
max7219 4*8*8 LED Matrix module
tm1637 4*7-Segment dispplay

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
import time
import RPi.GPIO as GPIO
@@ -9,15 +9,16 @@ GPIO.setmode(GPIO.BCM) # set up BCM GPIO numbering
#GPIO.setup(20, GPIO.IN, pull_up_down = GPIO.PUD_UP)
class Button:
'Handle button stuff'
"""Handle clocky button stuff"""
starttime=0
ispushed=0
waspushed=0
presstime=0
ignore=0
def __init__(self, gpio):
print "initialize button on gpio %d"%gpio
def __init__(self, gpio,verbose=False):
if verbose:
print("initialize button on gpio %d" %gpio)
self.gpio = gpio
GPIO.setup(self.gpio, GPIO.IN, pull_up_down = GPIO.PUD_UP)
GPIO.add_event_detect(self.gpio, GPIO.BOTH, callback=self.my_callback)

28
changes.txt Normal file
View File

@@ -0,0 +1,28 @@
v0.2.5 * Changed readmp3s routine to clockytracklist (merge)
v0.2.0 * Adjusted code for python 3
v0.1.0 * added max7219 support, added signal handling
* Added additional logging messages for end of alarm
* implemented SIGINT (Ctrl-C) handling to exit gracefully
v0.0.5 * initial working version
* show alarmtime in startup
------------------------------------------------------------
issues
------
* alarmtime 15min -> 30min
* max7219 1st second of alarm 100% brightness issue
* address more than the 1st 10 tracks
* more clear log entry when demoing sample track editing tracklist
* change 5 seconds of track demo to on-off click method
todo
----
changes config file format to json
make documentation

527
clocky-font.py Normal file
View File

@@ -0,0 +1,527 @@
#: Bit patterns for SIXBYEIGHT_FONT,
#: source: https://www.urbanfonts.com/fonts/Led_8x6.font
#:
#: NOTE: Only characters 0x30 - 0x39 are 6x8
#: All others will appear as blanks
SIXBYEIGHT_FONT = [
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x00
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x01
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x02
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x03
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x04
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x05
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x06
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x07
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x08
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x09
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x0A
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x0B
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x0C
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x0D
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x0E
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x0F
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x10
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x11
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x12
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x13
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x14
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x15
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x16
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x17
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x18
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x19
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x1A
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x1B
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x1C
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x1D
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x1E
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x1F
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # ' '
[0x00, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x00], # '!'
[0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00], # '"'
[0x00, 0x24, 0x7E, 0x24, 0x24, 0x7E, 0x24, 0x00], # '#'
[0x00, 0x2E, 0x2A, 0x7F, 0x2A, 0x3A, 0x00, 0x00], # '$'
[0x00, 0x46, 0x26, 0x10, 0x08, 0x64, 0x62, 0x00], # '%'
[0x00, 0x20, 0x54, 0x4A, 0x54, 0x20, 0x50, 0x00], # '&'
[0x00, 0x00, 0x00, 0x04, 0x02, 0x00, 0x00, 0x00], # '''
[0x00, 0x00, 0x00, 0x3C, 0x42, 0x00, 0x00, 0x00], # '('
[0x00, 0x00, 0x00, 0x42, 0x3C, 0x00, 0x00, 0x00], # ')'
[0x00, 0x10, 0x54, 0x38, 0x54, 0x10, 0x00, 0x00], # '*'
[0x00, 0x10, 0x10, 0x7C, 0x10, 0x10, 0x00, 0x00], # '+'
[0x00, 0x00, 0x00, 0x80, 0x60, 0x00, 0x00, 0x00], # '
[0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00], # '-'
[0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x00], # '.'
[0x00, 0x40, 0x20, 0x10, 0x08, 0x04, 0x00, 0x00], # '/'
[0x7E, 0xFF, 0x81, 0x81, 0xFF, 0x7E, 0x00, 0x00], # '0'
[0x00, 0x82, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00], # '1'
[0xC2, 0xE3, 0xB1, 0x99, 0x8F, 0x86, 0x00, 0x00], # '2'
[0x42, 0xC3, 0x81, 0x89, 0xFF, 0x76, 0x00, 0x00], # '3'
[0x38, 0x3C, 0x26, 0xF3, 0xF1, 0x20, 0x00, 0x00], # '4'
[0x4F, 0xCF, 0x89, 0x89, 0xF9, 0x71, 0x00, 0x00], # '5'
[0x7E, 0xFF, 0x89, 0x89, 0xFB, 0x72, 0x00, 0x00], # '6'
[0x03, 0x03, 0xF1, 0xF9, 0x0F, 0x07, 0x00, 0x00], # '7'
[0x76, 0xFF, 0x89, 0x89, 0xFF, 0x76, 0x00, 0x00], # '8'
[0x46, 0xCF, 0x89, 0x89, 0xFF, 0x7E, 0x00, 0x00], # '9'
[0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x00], # ':'
[0x00, 0x00, 0x80, 0x64, 0x00, 0x00, 0x00, 0x00], # ';'
[0x00, 0x00, 0x10, 0x28, 0x44, 0x00, 0x00, 0x00], # '<'
[0x00, 0x28, 0x28, 0x28, 0x28, 0x28, 0x00, 0x00], # '='
[0x00, 0x00, 0x44, 0x28, 0x10, 0x00, 0x00, 0x00], # '>'
[0x00, 0x04, 0x02, 0x02, 0x52, 0x0A, 0x04, 0x00], # '?'
[0x00, 0x3C, 0x42, 0x5A, 0x56, 0x5A, 0x1C, 0x00], # '@'
[0x7C, 0x12, 0x12, 0x12, 0x12, 0x7C, 0x00, 0x00], # 'A'
[0x7E, 0x4A, 0x4A, 0x4A, 0x4A, 0x34, 0x00, 0x00], # 'B'
[0x3C, 0x42, 0x42, 0x42, 0x42, 0x24, 0x00, 0x00], # 'C'
[0x7E, 0x42, 0x42, 0x42, 0x24, 0x18, 0x00, 0x00], # 'D'
[0x7E, 0x4A, 0x4A, 0x4A, 0x4A, 0x42, 0x00, 0x00], # 'E'
[0x7E, 0x0A, 0x0A, 0x0A, 0x0A, 0x02, 0x00, 0x00], # 'F'
[0x3C, 0x42, 0x42, 0x52, 0x52, 0x34, 0x00, 0x00], # 'G'
[0x7E, 0x08, 0x08, 0x08, 0x08, 0x7E, 0x00, 0x00], # 'H'
[0x00, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x00, 0x00], # 'I'
[0x30, 0x40, 0x40, 0x40, 0x40, 0x3E, 0x00, 0x00], # 'J'
[0x7E, 0x08, 0x08, 0x14, 0x22, 0x40, 0x00, 0x00], # 'K'
[0x7E, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00], # 'L'
[0x7E, 0x04, 0x08, 0x08, 0x04, 0x7E, 0x00, 0x00], # 'M'
[0x7E, 0x04, 0x08, 0x10, 0x20, 0x7E, 0x00, 0x00], # 'N'
[0x3C, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00], # 'O'
[0x7E, 0x12, 0x12, 0x12, 0x12, 0x0C, 0x00, 0x00], # 'P'
[0x3C, 0x42, 0x52, 0x62, 0x42, 0x3C, 0x00, 0x00], # 'Q'
[0x7E, 0x12, 0x12, 0x12, 0x32, 0x4C, 0x00, 0x00], # 'R'
[0x24, 0x4A, 0x4A, 0x4A, 0x4A, 0x30, 0x00, 0x00], # 'S'
[0x02, 0x02, 0x02, 0x7E, 0x02, 0x02, 0x02, 0x00], # 'T'
[0x3E, 0x40, 0x40, 0x40, 0x40, 0x3E, 0x00, 0x00], # 'U'
[0x1E, 0x20, 0x40, 0x40, 0x20, 0x1E, 0x00, 0x00], # 'V'
[0x3E, 0x40, 0x20, 0x20, 0x40, 0x3E, 0x00, 0x00], # 'W'
[0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x00, 0x00], # 'X'
[0x02, 0x04, 0x08, 0x70, 0x08, 0x04, 0x02, 0x00], # 'Y'
[0x42, 0x62, 0x52, 0x4A, 0x46, 0x42, 0x00, 0x00], # 'Z'
[0x00, 0x00, 0x7E, 0x42, 0x42, 0x00, 0x00, 0x00], # '['
[0x00, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00, 0x00], # backslash
[0x00, 0x00, 0x42, 0x42, 0x7E, 0x00, 0x00, 0x00], # '
[0x00, 0x08, 0x04, 0x7E, 0x04, 0x08, 0x00, 0x00], # '^'
[0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00], # '_'
[0x3C, 0x42, 0x99, 0xA5, 0xA5, 0x81, 0x42, 0x3C], # '`'
[0x00, 0x20, 0x54, 0x54, 0x54, 0x78, 0x00, 0x00], # 'a'
[0x00, 0x7E, 0x48, 0x48, 0x48, 0x30, 0x00, 0x00], # 'b'
[0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x00, 0x00], # 'c'
[0x00, 0x30, 0x48, 0x48, 0x48, 0x7E, 0x00, 0x00], # 'd'
[0x00, 0x38, 0x54, 0x54, 0x54, 0x48, 0x00, 0x00], # 'e'
[0x00, 0x00, 0x00, 0x7C, 0x0A, 0x02, 0x00, 0x00], # 'f'
[0x00, 0x18, 0xA4, 0xA4, 0xA4, 0xA4, 0x7C, 0x00], # 'g'
[0x00, 0x7E, 0x08, 0x08, 0x08, 0x70, 0x00, 0x00], # 'h'
[0x00, 0x00, 0x00, 0x48, 0x7A, 0x40, 0x00, 0x00], # 'i'
[0x00, 0x00, 0x40, 0x80, 0x80, 0x7A, 0x00, 0x00], # 'j'
[0x00, 0x7E, 0x18, 0x24, 0x40, 0x00, 0x00, 0x00], # 'k'
[0x00, 0x00, 0x00, 0x3E, 0x40, 0x40, 0x00, 0x00], # 'l'
[0x00, 0x7C, 0x04, 0x78, 0x04, 0x78, 0x00, 0x00], # 'm'
[0x00, 0x7C, 0x04, 0x04, 0x04, 0x78, 0x00, 0x00], # 'n'
[0x00, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00], # 'o'
[0x00, 0xFC, 0x24, 0x24, 0x24, 0x18, 0x00, 0x00], # 'p'
[0x00, 0x18, 0x24, 0x24, 0x24, 0xFC, 0x80, 0x00], # 'q'
[0x00, 0x00, 0x78, 0x04, 0x04, 0x04, 0x00, 0x00], # 'r'
[0x00, 0x48, 0x54, 0x54, 0x54, 0x20, 0x00, 0x00], # 's'
[0x00, 0x00, 0x04, 0x3E, 0x44, 0x40, 0x00, 0x00], # 't'
[0x00, 0x3C, 0x40, 0x40, 0x40, 0x3C, 0x00, 0x00], # 'u'
[0x00, 0x0C, 0x30, 0x40, 0x30, 0x0C, 0x00, 0x00], # 'v'
[0x00, 0x3C, 0x40, 0x38, 0x40, 0x3C, 0x00, 0x00], # 'w'
[0x00, 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, 0x00], # 'x'
[0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C, 0x00, 0x00], # 'y'
[0x00, 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, 0x00], # 'z'
[0x00, 0x08, 0x08, 0x76, 0x42, 0x42, 0x00, 0x00], # '{'
[0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00], # '|'
[0x00, 0x42, 0x42, 0x76, 0x08, 0x08, 0x00, 0x00], # '}'
[0x00, 0x00, 0x04, 0x02, 0x04, 0x02, 0x00, 0x00], # '~'
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x7F
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x80
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x81
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x82
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x83
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x84
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x85
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x86
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x87
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x88
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x89
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x8A
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x8B
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x8C
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x8D
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x8E
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x8F
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x90
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x91
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x92
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x93
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x94
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x95
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x96
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x97
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x98
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x99
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x9A
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x9B
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x9C
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x9D
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x9E
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x9F
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xA0
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xA1
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xA2
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xA3
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xA4
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xA5
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xA6
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xA7
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xA8
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xA9
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xAA
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xAB
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xAC
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xAD
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xAE
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xAF
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xB0
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xB1
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xB2
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xB3
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xB4
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xB5
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xB6
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xB7
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xB8
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xB9
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xBA
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xBB
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xBC
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xBD
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xBE
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xBF
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xC0
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xC1
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xC2
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xC3
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xC4
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xC5
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xC6
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xC7
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xC8
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xC9
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xCA
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xCB
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xCC
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xCD
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xCE
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xCF
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xD0
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xD1
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xD2
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xD3
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xD4
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xD5
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xD6
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xD7
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xD8
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xD9
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xDA
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xDB
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xDC
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xDD
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xDE
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xDF
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xE0
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xE1
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xE2
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xE3
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xE4
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xE5
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xE6
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xE7
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xE8
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xE9
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xEA
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xEB
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xEC
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xED
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xEE
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xEF
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xF0
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xF1
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xF2
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xF3
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xF4
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xF5
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xF6
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xF7
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xF8
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xF9
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xFA
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xFB
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xFC
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xFD
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xFE
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xFF
]
SIXBYEIGHTTHIN_FONT = [
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x00
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x01
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x02
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x03
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x04
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x05
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x06
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x07
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x08
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x09
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x0A
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x0B
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x0C
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x0D
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x0E
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x0F
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x10
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x11
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x12
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x13
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x14
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x15
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x16
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x17
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x18
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x19
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x1A
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x1B
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x1C
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x1D
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x1E
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x1F
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # ' '
[0x00, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x00], # '!'
[0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00], # '"'
[0x00, 0x24, 0x7E, 0x24, 0x24, 0x7E, 0x24, 0x00], # '#'
[0x00, 0x2E, 0x2A, 0x7F, 0x2A, 0x3A, 0x00, 0x00], # '$'
[0x00, 0x46, 0x26, 0x10, 0x08, 0x64, 0x62, 0x00], # '%'
[0x00, 0x20, 0x54, 0x4A, 0x54, 0x20, 0x50, 0x00], # '&'
[0x00, 0x00, 0x00, 0x04, 0x02, 0x00, 0x00, 0x00], # '''
[0x00, 0x00, 0x00, 0x3C, 0x42, 0x00, 0x00, 0x00], # '('
[0x00, 0x00, 0x00, 0x42, 0x3C, 0x00, 0x00, 0x00], # ')'
[0x00, 0x10, 0x54, 0x38, 0x54, 0x10, 0x00, 0x00], # '*'
[0x00, 0x10, 0x10, 0x7C, 0x10, 0x10, 0x00, 0x00], # '+'
[0x00, 0x00, 0x00, 0x80, 0x60, 0x00, 0x00, 0x00], # '
[0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00], # '-'
[0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x00], # '.'
[0x00, 0x40, 0x20, 0x10, 0x08, 0x04, 0x00, 0x00], # '/'
[0x7E, 0x81, 0x81, 0x81, 0x81, 0x7E, 0x00, 0x00], # '0'
[0x00, 0x00, 0x82, 0xFF, 0x80, 0x00, 0x00, 0x00], # '1'
[0xC2, 0xA1, 0x91, 0x91, 0x91, 0x8E, 0x00, 0x00], # '2'
[0x42, 0x81, 0x81, 0x89, 0x89, 0x76, 0x00, 0x00], # '3'
[0x18, 0x14, 0x12, 0x11, 0xFF, 0x10, 0x00, 0x00], # '4'
[0x4F, 0x89, 0x89, 0x89, 0x89, 0x71, 0x00, 0x00], # '5'
[0x7C, 0x8A, 0x89, 0x89, 0x89, 0x70, 0x00, 0x00], # '6'
[0x03, 0x01, 0xF1, 0x09, 0x09, 0x07, 0x00, 0x00], # '7'
[0x76, 0x89, 0x89, 0x89, 0x89, 0x76, 0x00, 0x00], # '8'
[0x06, 0x89, 0x89, 0x89, 0x49, 0x3E, 0x00, 0x00], # '9'
[0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x00], # ':'
[0x00, 0x00, 0x80, 0x64, 0x00, 0x00, 0x00, 0x00], # ';'
[0x00, 0x00, 0x10, 0x28, 0x44, 0x00, 0x00, 0x00], # '<'
[0x00, 0x28, 0x28, 0x28, 0x28, 0x28, 0x00, 0x00], # '='
[0x00, 0x00, 0x44, 0x28, 0x10, 0x00, 0x00, 0x00], # '>'
[0x00, 0x04, 0x02, 0x02, 0x52, 0x0A, 0x04, 0x00], # '?'
[0x00, 0x3C, 0x42, 0x5A, 0x56, 0x5A, 0x1C, 0x00], # '@'
[0x7C, 0x12, 0x12, 0x12, 0x12, 0x7C, 0x00, 0x00], # 'A'
[0x7E, 0x4A, 0x4A, 0x4A, 0x4A, 0x34, 0x00, 0x00], # 'B'
[0x3C, 0x42, 0x42, 0x42, 0x42, 0x24, 0x00, 0x00], # 'C'
[0x7E, 0x42, 0x42, 0x42, 0x24, 0x18, 0x00, 0x00], # 'D'
[0x7E, 0x4A, 0x4A, 0x4A, 0x4A, 0x42, 0x00, 0x00], # 'E'
[0x7E, 0x0A, 0x0A, 0x0A, 0x0A, 0x02, 0x00, 0x00], # 'F'
[0x3C, 0x42, 0x42, 0x52, 0x52, 0x34, 0x00, 0x00], # 'G'
[0x7E, 0x08, 0x08, 0x08, 0x08, 0x7E, 0x00, 0x00], # 'H'
[0x00, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x00, 0x00], # 'I'
[0x30, 0x40, 0x40, 0x40, 0x40, 0x3E, 0x00, 0x00], # 'J'
[0x7E, 0x08, 0x08, 0x14, 0x22, 0x40, 0x00, 0x00], # 'K'
[0x7E, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00], # 'L'
[0x7E, 0x04, 0x08, 0x08, 0x04, 0x7E, 0x00, 0x00], # 'M'
[0x7E, 0x04, 0x08, 0x10, 0x20, 0x7E, 0x00, 0x00], # 'N'
[0x3C, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00], # 'O'
[0x7E, 0x12, 0x12, 0x12, 0x12, 0x0C, 0x00, 0x00], # 'P'
[0x3C, 0x42, 0x52, 0x62, 0x42, 0x3C, 0x00, 0x00], # 'Q'
[0x7E, 0x12, 0x12, 0x12, 0x32, 0x4C, 0x00, 0x00], # 'R'
[0x24, 0x4A, 0x4A, 0x4A, 0x4A, 0x30, 0x00, 0x00], # 'S'
[0x02, 0x02, 0x02, 0x7E, 0x02, 0x02, 0x02, 0x00], # 'T'
[0x3E, 0x40, 0x40, 0x40, 0x40, 0x3E, 0x00, 0x00], # 'U'
[0x1E, 0x20, 0x40, 0x40, 0x20, 0x1E, 0x00, 0x00], # 'V'
[0x3E, 0x40, 0x20, 0x20, 0x40, 0x3E, 0x00, 0x00], # 'W'
[0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x00, 0x00], # 'X'
[0x02, 0x04, 0x08, 0x70, 0x08, 0x04, 0x02, 0x00], # 'Y'
[0x42, 0x62, 0x52, 0x4A, 0x46, 0x42, 0x00, 0x00], # 'Z'
[0x00, 0x00, 0x7E, 0x42, 0x42, 0x00, 0x00, 0x00], # '['
[0x00, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00, 0x00], # backslash
[0x00, 0x00, 0x42, 0x42, 0x7E, 0x00, 0x00, 0x00], # '
[0x00, 0x08, 0x04, 0x7E, 0x04, 0x08, 0x00, 0x00], # '^'
[0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00], # '_'
[0x3C, 0x42, 0x99, 0xA5, 0xA5, 0x81, 0x42, 0x3C], # '`'
[0x00, 0x20, 0x54, 0x54, 0x54, 0x78, 0x00, 0x00], # 'a'
[0x00, 0x7E, 0x48, 0x48, 0x48, 0x30, 0x00, 0x00], # 'b'
[0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x00, 0x00], # 'c'
[0x00, 0x30, 0x48, 0x48, 0x48, 0x7E, 0x00, 0x00], # 'd'
[0x00, 0x38, 0x54, 0x54, 0x54, 0x48, 0x00, 0x00], # 'e'
[0x00, 0x00, 0x00, 0x7C, 0x0A, 0x02, 0x00, 0x00], # 'f'
[0x00, 0x18, 0xA4, 0xA4, 0xA4, 0xA4, 0x7C, 0x00], # 'g'
[0x00, 0x7E, 0x08, 0x08, 0x08, 0x70, 0x00, 0x00], # 'h'
[0x00, 0x00, 0x00, 0x48, 0x7A, 0x40, 0x00, 0x00], # 'i'
[0x00, 0x00, 0x40, 0x80, 0x80, 0x7A, 0x00, 0x00], # 'j'
[0x00, 0x7E, 0x18, 0x24, 0x40, 0x00, 0x00, 0x00], # 'k'
[0x00, 0x00, 0x00, 0x3E, 0x40, 0x40, 0x00, 0x00], # 'l'
[0x00, 0x7C, 0x04, 0x78, 0x04, 0x78, 0x00, 0x00], # 'm'
[0x00, 0x7C, 0x04, 0x04, 0x04, 0x78, 0x00, 0x00], # 'n'
[0x00, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00], # 'o'
[0x00, 0xFC, 0x24, 0x24, 0x24, 0x18, 0x00, 0x00], # 'p'
[0x00, 0x18, 0x24, 0x24, 0x24, 0xFC, 0x80, 0x00], # 'q'
[0x00, 0x00, 0x78, 0x04, 0x04, 0x04, 0x00, 0x00], # 'r'
[0x00, 0x48, 0x54, 0x54, 0x54, 0x20, 0x00, 0x00], # 's'
[0x00, 0x00, 0x04, 0x3E, 0x44, 0x40, 0x00, 0x00], # 't'
[0x00, 0x3C, 0x40, 0x40, 0x40, 0x3C, 0x00, 0x00], # 'u'
[0x00, 0x0C, 0x30, 0x40, 0x30, 0x0C, 0x00, 0x00], # 'v'
[0x00, 0x3C, 0x40, 0x38, 0x40, 0x3C, 0x00, 0x00], # 'w'
[0x00, 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, 0x00], # 'x'
[0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C, 0x00, 0x00], # 'y'
[0x00, 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, 0x00], # 'z'
[0x00, 0x08, 0x08, 0x76, 0x42, 0x42, 0x00, 0x00], # '{'
[0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00], # '|'
[0x00, 0x42, 0x42, 0x76, 0x08, 0x08, 0x00, 0x00], # '}'
[0x00, 0x00, 0x04, 0x02, 0x04, 0x02, 0x00, 0x00], # '~'
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x7F
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x80
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x81
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x82
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x83
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x84
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x85
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x86
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x87
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x88
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x89
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x8A
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x8B
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x8C
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x8D
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x8E
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x8F
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x90
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x91
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x92
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x93
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x94
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x95
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x96
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x97
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x98
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x99
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x9A
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x9B
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x9C
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x9D
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x9E
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x9F
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xA0
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xA1
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xA2
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xA3
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xA4
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xA5
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xA6
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xA7
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xA8
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xA9
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xAA
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xAB
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xAC
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xAD
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xAE
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xAF
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xB0
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xB1
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xB2
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xB3
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xB4
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xB5
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xB6
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xB7
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xB8
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xB9
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xBA
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xBB
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xBC
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xBD
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xBE
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xBF
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xC0
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xC1
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xC2
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xC3
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xC4
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xC5
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xC6
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xC7
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xC8
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xC9
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xCA
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xCB
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xCC
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xCD
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xCE
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xCF
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xD0
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xD1
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xD2
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xD3
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xD4
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xD5
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xD6
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xD7
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xD8
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xD9
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xDA
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xDB
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xDC
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xDD
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xDE
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xDF
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xE0
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xE1
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xE2
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xE3
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xE4
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xE5
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xE6
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xE7
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xE8
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xE9
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xEA
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xEB
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xEC
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xED
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xEE
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xEF
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xF0
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xF1
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xF2
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xF3
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xF4
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xF5
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xF6
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xF7
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xF8
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xF9
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xFA
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xFB
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xFC
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xFD
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xFE
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0xFF
]

13
clocky-font.txt Normal file
View File

@@ -0,0 +1,13 @@
to use the 6x8 font,
cat clocky-font.py >>/home/pi/.local/lib/python3.5/site-packages/luma/core/legacy/font.py
or wherever the luma-core font.py is. This can be found by running python manually:
python3
>>> import luma.core.legacy.font
>>> luma.core.legacy.font
<module 'luma.core.legacy.font' from '/home/pi/.local/lib/python3.5/site-packages/luma/core/legacy/font.py'>

378
clocky.py Normal file → Executable file
View File

@@ -1,109 +1,79 @@
#!/usr/bin/python
#!/usr/bin/python3
import pickle
import os.path
import os
import time
import sys
import tm1637
import max7219
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
import pygame
from time import sleep,strftime
import RPi.GPIO as GPIO
import button
import signal
import clockyconfig
import clockytracklist
VERBOSE=True
settings= {}
looptype=0
quit=0
print "\n +----------+\n | Clocky |\n | v0.0.5 |\n +----------+\n"
print("\n +----------+\n | Clocky |\n | v0.3.0 |\n +----------+\n")
o_configfilename = "clocky.conf"
o_defaultalarmtime = 60*7+45 # hh*60+mm
o_showalarmtime=3 # time that the alarmtime shows after short press
o_showtracktime=2 # note that this is per track, so total time is 10 times longer
o_editdelaytime=3 # time it takes to qualify as longpress
o_showtimeout=6 # timeout to exit edit modus
o_snoozetime = 9 # time to snooze
o_timetomaxvol = 150 # seconds it takes to go from 0% to 100% volume
o_maxplaytime = 1800 # seconds it to play
o_soundpreviewtime=5
o_defaultbrightness=1
#o_defaultalarmtime = 60*14+10 # hh*60+mm
#config.settings['showalarmtime']=3 # time that the alarmtime shows after short press
#config.settings['showtracktime']=2 # note that this is per track, so total time is 10 times longer
#config.settings['editdelaytime']=3 # time it takes to qualify as longpress
#config.settings['edittimeout']=6 # timeout to exit edit modus
#config.settings['snoozetime'] = 9 # time to snooze
#config.settings['timetomaxvolume'] = 150# seconds it takes to go from 0% to 100% volume
#config.settings['maxalarmtime'] = 900 # seconds it to play
#config.settings['soundpreviewtime']=5
#config.settings['defaultbrightness']=0
o_loopdelay=0.25
track=0
stopprogram=0
reload=False
#GPIO.setmode(GPIO.BCM) # set up BCM GPIO numbering
#GPIO.setup(16, GPIO.IN, pull_up_down = GPIO.PUD_UP)
def signal_handler(signal,frame):
global quit
print ""
quit=1
#def signal_handler(signal,frame):
# global quit
# print("")
# quit=1
def stamp():
sys.stdout.write(strftime("[%Y%m%d %H%M%S] "))
def showclock(tstr):
"Show da clock"
# sys.stdout.write( "%s [%d]\r" % (tstr,looptype))
# sys.stdout.flush()
d=0
if tstr[2]==':':
display.ShowDoublepoint(True)
def receive_signal(signum, stack):
global stopprogram
global reload
if VERBOSE:
print('Received signal: %d' %signum)
else:
display.ShowDoublepoint(False)
if tstr[0]==' ':
display.Show1(0,0x7f)
else:
display.Show1(0,int(tstr[0]))
if tstr[1]==' ':
display.Show1(1,0x7f)
elif tstr[1]=='=':
display.Show1(1,16)
else:
display.Show1(1,int(tstr[1]))
if tstr[3]==' ':
display.Show1(2,0x7f)
else:
display.Show1(2,int(tstr[3]))
if tstr[4]==' ':
display.Show1(3,0x7f)
else:
display.Show1(3,int(tstr[4]))
print("")
if signum == signal.SIGHUP:
reload=True
if signum == signal.SIGINT:
stopprogram=1
def writesettings():
"write settings to conf file"
with open(o_configfilename, 'wb') as handle:
pickle.dump(settings, handle)
handle.close()
def stamp(str):
sys.stdout.write(strftime("[%Y%m%d %H%M%S] ")+str+"\n")
sys.stdout.flush()
def readmp3list():
c=0
mp3s=[]
dirs=os.listdir('.')
for ent in os.listdir('.'):
if ent.lower().endswith(".mp3") and os.access(ent,os.R_OK):
mp3s.append(ent)
mp3s.sort()
for m in mp3s:
c+=1
if c>99: break
def timetoval(str):
return (str.split(":")[0]*60)+str.split(":")[1]
if c:
return(mp3s)
else:
return(0)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
looptype=0
colon=0
count=0
digit=1
showtime=0
playtime=0
@@ -112,91 +82,106 @@ alarmstarted=0
silencedalarm=0
tvol=0
volume=0.0
brightness=0.0
brightness=0
snooze=0
count=0
if VERBOSE:
print('My PID is %d' %os.getpid())
signal.signal(signal.SIGHUP, receive_signal)
signal.signal(signal.SIGINT, receive_signal)
but1=button.Button(21,verbose=VERBOSE)
but2=button.Button(20,verbose=VERBOSE)
but3=button.Button(26,verbose=VERBOSE)
config=clockyconfig.ClockyConfig(verbose=VERBOSE)
tracks=clockytracklist.ClockyTracklist("mp3",recursive=True,verbose=VERBOSE)
#------------------------------------------------------------------
#------------------------------------------------------------------
while not stopprogram:
if VERBOSE:
print("Load config...")
reload=False
display=tm1637.TM1637(CLK=14, DIO=4, brightness=1)
# display=max7219.MAX7219(brightness=1)
signal.signal(signal.SIGINT,signal_handler)
display=tm1637.TM1637(CLK=14, DIO=4, brightness=1.0)
display.Clear()
display.SetBrightnessRaw(o_defaultbrightness)
display.SetBrightnessRaw(config.settings['defaultbrightness'])
print ""
print "reading mp3s from directory:"
allmp3s=readmp3list()
if allmp3s==0:
print "ERROR: No mp3's found!"
display.ShowDoublepoint(False)
display.Show1(0,0x7f);
display.Show1(1,14);
display.Show1(2,17);
display.Show1(3,17);
GPIO.cleanup()
sys.exit()
if VERBOSE:
print("Reading mp3s from directory:")
allmp3s=tracks.tracklist
c=0
if True: # VERBOSE:
print("\nTracks:")
for m in allmp3s:
print " %2d : %s"%(c+1,m)
print("%2d : %s"%(c+1,m))
c+=1
print ""
but1=button.Button(21)
but2=button.Button(20)
but3=button.Button(26)
print ""
stamp("Started")
# .................................................................
if not os.path.isfile(o_configfilename):
print "Createconf: \""+o_configfilename+"\":"
print("Createconf: \""+o_configfilename+"\":")
settings = {'track0':1, 'track1':2, 'track2':3, 'track3':4, 'track4':5, 'track5':6, 'track6':7, 'track7':8, 'track8':9, 'track9':10 }
settings['alarmtime']=o_defaultalarmtime;
settings['starttrack']=0;
settings['alarmdisabled']=0;
config.starttrack=0;
config.settings['alarmdisabled']=0;
with open(o_configfilename, 'wb') as handle:
pickle.dump(settings, handle)
handle.close()
else:
print "Configfile: \""+o_configfilename+"\":"
if VERBOSE:
print("Configfile: \""+o_configfilename+"\":")
with open(o_configfilename, 'rb') as handle:
settings = pickle.load(handle)
handle.close()
a_mins=settings['alarmtime']%60
a_hour=(settings['alarmtime']-a_mins)/60
print "Alarmtime : %02d:%02d"%(a_hour,a_mins)
print "Alarmdisable: %d"%(settings['alarmdisabled'])
print "Starttrack : %d"%(settings['starttrack'])
a_hour=int(config.settings['alarmtime'].split(":")[0])
a_mins=int(config.settings['alarmtime'].split(":")[1])
if VERBOSE:
print("Alarmtime : %02d:%02d"%(a_hour,a_mins))
print("Alarmdisable: %d"%(config.settings['alarmdisabled']))
print("Starttrack : %d"%(config.starttrack))
for i in range(0,10):
if i==settings['starttrack']:
print "=>",
if i==config.starttrack:
if VERBOSE:
print("=>",end='')
else:
print " ",
print "[T%02dM%02d]"%(i,settings["track%d"%i]),
if VERBOSE:
print(" ",end='')
if VERBOSE:
print(" [T%01dM%02d] "%(i,settings["track%d"%i]),end='')
if settings["track%d"%i] and (settings["track%d"%i]-1 < len(allmp3s)):
print "\""+allmp3s[settings["track%d"%i]-1]+"\""
if VERBOSE:
print("\""+allmp3s[settings["track%d"%i]-1]+"\"")
else:
print ""
if VERBOSE:
print("")
settings["track%d"%i]=0
writesettings()
print ""
stamp()
print "Started"
sys.stdout.flush()
#------------------------------------------------------------------
#------------------------------------------------------------------
while quit!=True:
# .................................................................
# Main loop without reload and stuff
#
while not reload and not stopprogram:
count+=1;
sleep(o_loopdelay)
mytime=time.localtime(time.time())
currenttime=mytime[3]*60 + mytime[4];
if not settings["alarmdisabled"]:
if currenttime == settings['alarmtime']:
if not config.settings["alarmdisabled"]:
if currenttime == timetoval(config.settings['alarmtime']):
if looptype==0 and not silencedalarm:
looptype=5
else:
@@ -211,16 +196,12 @@ while quit!=True:
if but1.WasLong():
if but2.WasPressed():
if but2.WasLong():
if settings["alarmdisabled"]==0:
settings["alarmdisabled"]=1
stamp()
print "Alarm disabled"
writesettings()
if config.settings["alarmdisabled"]==0:
config.settings["alarmdisabled"]=1
stamp("Alarm disabled")
else:
settings["alarmdisabled"]=0
stamp()
print "Alarm enabled"
writesettings()
config.settings["alarmdisabled"]=0
stamp("Alarm enabled")
looptype=1
else:
looptype=2
@@ -233,16 +214,12 @@ while quit!=True:
if but3.WasPressed():
if but3.WasLong():
if settings["alarmdisabled"]==0:
settings["alarmdisabled"]=1
stamp()
print "Alarm disabled"
writesettings()
if config.settings["alarmdisabled"]==0:
config.settings["alarmdisabled"]=1
stamp("Alarm disabled")
else:
settings["alarmdisabled"]=0
stamp()
print "Alarm enabled"
writesettings()
config.settings["alarmdisabled"]=0
stamp("Alarm enabled")
looptype=1
@@ -250,31 +227,27 @@ while quit!=True:
tim="%02d:%02d" % (mytime[3] , mytime[4])
else:
tim="%02d %02d" % (mytime[3] , mytime[4])
showclock(tim)
display.showclock(tim)
if count % 4 == 0:
colon=1-colon
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if looptype==1: # show alarmtime
if not settings["alarmdisabled"]==1:
a_mins=settings['alarmtime']%60
a_hour=(settings['alarmtime']-a_mins)/60
if not config.settings["alarmdisabled"]==1:
a_hour=int(config.settings['alarmtime'].split(":")[1])
a_mins=int(config.settings['alarmtime'].split(":")[1])
if colon:
tim="%02d:%02d" % (a_hour, a_mins)
else:
tim="%02d %02d" % (a_hour, a_mins)
showclock(tim)
display.showclock(tim)
colon=1-colon
else:
display.ShowDoublepoint(False)
display.Show1(0,0x7f);
display.Show1(1,0);
display.Show1(2,15);
display.Show1(3,15);
display.showclock(" O FF")
if showtime > o_showalarmtime:
if showtime > config.settings['showalarmtime']:
if but1.WasPressed(): # drop intermediate presses
{}
if but2.WasPressed():
@@ -290,11 +263,12 @@ while quit!=True:
if looptype==2: # edit alarmtime
delta=0
sm=settings['alarmtime']%10
dm=((settings['alarmtime']-sm)/10)%6
sh=(settings['alarmtime']-dm)/60%10
dh=(settings['alarmtime']-sh)/600
dh=int(config.settings['alarmtime'][0])
sh=int(config.settings['alarmtime'][1])
dm=int(config.settings['alarmtime'][3])
sm=int(config.settings['alarmtime'][4])
if colon:
tim="%0d%0d:%0d%0d" % (dh,sh,dm,sm)
@@ -342,31 +316,28 @@ while quit!=True:
tim="%0d%0d:%0d " % (dh,sh,dm )
delta=0
showclock(tim)
display.showclock(tim)
colon=1-colon
if showtime > o_showtimeout:
if showtime > config.settings['edittimeout']:
showtime=0
if dh==2 and sh>3:
sh=3
looptype=1
else:
looptype=0
if settings["alarmdisabled"]==1:
settings["alarmdisabled"]=0
stamp()
print "Alarm enabled"
settings['alarmtime']=dh*600+sh*60+dm*10+sm
writesettings()
stamp()
print "Set alarmtime = %d%d:%d%d"%(dh,sh,dm,sm)
if config.settings["alarmdisabled"]==1:
config.settings["alarmdisabled"]=0
stamp("Alarm enabled")
config.settings['alarmtime']=("%d%d:%d%d" %(dh,sh,dm,sm))
stamp("Set alarmtime = %d%d:%d%d"%(dh,sh,dm,sm))
sys.stdout.flush()
digit=1
else:
showtime+=o_loopdelay
settings['alarmtime']=dh*600+sh*60+dm*10+sm
config.settings['alarmtime']=("%d%d:%d%d" %(dh,sh,dm,sm))
if but1.WasPressed():
showtime=0
@@ -402,8 +373,8 @@ while quit!=True:
soundpreview=1
tr=track
tl=settings["track%d"%tr]%10
th=(settings["track%d"%tr]-tl)/10
tl=int(settings["track%d"%tr]%10)
th=int((settings["track%d"%tr]-tl)/10)
if colon:
tim="%d=:%d%d" % (tr,th,tl)
@@ -413,11 +384,11 @@ while quit!=True:
tr+=1;
if tr>9:
looptype=0
showclock(tim)
display.showclock(tim)
colon=1-colon
if soundpreview:
if pygame.mixer.music.get_pos() >o_soundpreviewtime*1000:
if pygame.mixer.music.get_pos() >config.settings['soundpreviewtime']*1000:
if pygame.mixer.get_init():
pygame.mixer.music.set_volume(0)
pygame.mixer.music.stop()
@@ -429,7 +400,7 @@ while quit!=True:
looptype=0
else:
if showtime > o_showtracktime:
if showtime > config.settings['showtracktime']:
showtime=0
track+=1;
if track>9:
@@ -444,8 +415,8 @@ while quit!=True:
delta=0
tr=track
tl=settings["track%d"%tr]%10
th=(settings["track%d"%tr]-tl)/10
tl=int(settings["track%d"%tr]%10)
th=int((settings["track%d"%tr]-tl)/10)
if colon:
tim="%d=:%d%d" % (tr,th,tl)
@@ -482,16 +453,15 @@ while quit!=True:
tim="%d=:%d " % (tr,th )
delta=0
showclock(tim)
display.showclock(tim)
colon=1-colon
settings["track%d"%tr]=th*10+tl
track=tr
if showtime > o_showtimeout:
if showtime > config.settings['edittimeout']:
showtime=0
looptype=0
writesettings()
else:
showtime+=o_loopdelay
@@ -505,8 +475,8 @@ while quit!=True:
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if looptype==5: # Alarm!
#o_timetomaxvol = 60 # seconds it takes to go from 0% to 100% volume
if looptype==5: # Alarm loop!
#config.settings['timetomaxvolume'] = 60 # seconds it takes to go from 0% to 100% volume
if colon:
display.SetBrightnessRaw(0)
@@ -514,14 +484,13 @@ while quit!=True:
else:
display.SetBrightnessRaw(brightness)
tim="%02d:%02d" % (mytime[3] , mytime[4])
showclock(tim)
display.showclock(tim)
if count % 2 == 0:
colon=1-colon
if not alarmstarted:
track=settings['starttrack'];
stamp()
print "[T%02dM%02d] \"%s\""%(track,settings["track%d"%track],(allmp3s[settings["track%d"%track]-1]))
track=config.starttrack;
stamp("[T%02dM%02d] \"%s\""%(track,settings["track%d"%track],(allmp3s[settings["track%d"%track]-1])))
sys.stdout.flush()
if not pygame.mixer.get_init():
pygame.mixer.init()
@@ -534,15 +503,14 @@ while quit!=True:
track=0
if settings["track%d"%track]==0:
track=0
settings['starttrack']=track;
writesettings()
config.starttrack=track;
playtime=0
alarmstarted=1
else: # alarmstarted
if playtime < o_timetomaxvol:
brightness=(playtime / o_timetomaxvol)*6
volume = float(int((playtime*100) / o_timetomaxvol))/100
# print "------> %d / %d => %f - %f"%(playtime,o_timetomaxvol,tvol,volume)
if playtime < config.settings['timetomaxvolume']:
brightness=int((playtime / config.settings['timetomaxvolume'])*255)
volume = float(int((playtime*100) / config.settings['timetomaxvolume']))/100
# print("------> %d / %d => %f - %f [%d]"%(playtime,config.settings['timetomaxvolume'],tvol,volume,brightness))
else:
volume=1
@@ -553,9 +521,8 @@ while quit!=True:
if pygame.mixer.get_init():
if not pygame.mixer.music.get_busy():
track=settings['starttrack']
stamp()
print "[T%02dM%02d] \"%s\""%(track,settings["track%d"%track],(allmp3s[settings["track%d"%track]-1]))
track=config.starttrack
stamp("[T%02dM%02d] \"%s\""%(track,settings["track%d"%track],(allmp3s[settings["track%d"%track]-1])))
sys.stdout.flush()
pygame.mixer.music.load(allmp3s[settings["track%d"%track]-1])
pygame.mixer.music.play()
@@ -564,18 +531,18 @@ while quit!=True:
track=0
if settings["track%d"%track]==0:
track=0
settings['starttrack']=track;
writesettings()
config.starttrack=track;
if playtime > o_maxplaytime:
if playtime > config.settings['maxalarmtime']:
looptype=0
playtime=0
if pygame.mixer.get_init():
pygame.mixer.music.set_volume(0)
pygame.mixer.music.stop()
pygame.mixer.quit()
display.SetBrightnessRaw(o_defaultbrightness)
display.SetBrightnessRaw(config.settings['defaultbrightness'])
alarmstarted=0
stamp("Alarmtime expired")
if but1.WasPressed():
if but1.WasLong(): # Finished
@@ -583,7 +550,7 @@ while quit!=True:
pygame.mixer.music.set_volume(0)
pygame.mixer.music.stop()
pygame.mixer.quit()
display.SetBrightnessRaw(o_defaultbrightness)
display.SetBrightnessRaw(config.settings['defaultbrightness'])
playtime=0
if but1.WasPressed(): # flush intermediate presses
{}
@@ -594,8 +561,7 @@ while quit!=True:
looptype=0
alarmstarted=0
silencedalarm=1
stamp()
print "Silenced alarm"
stamp("Silenced alarm")
if but2.WasPressed():
@@ -604,9 +570,8 @@ while quit!=True:
if pygame.mixer.music.get_busy():
pygame.mixer.music.stop()
track=settings['starttrack']
stamp()
print "[T%02dM%02d] \"%s\""%(track,settings["track%d"%track],(allmp3s[settings["track%d"%track]-1]))
track=config.starttrack
stamp("[T%02dM%02d] \"%s\""%(track,settings["track%d"%track],(allmp3s[settings["track%d"%track]-1])))
sys.stdout.flush()
if pygame.mixer.get_init():
pygame.mixer.music.load(allmp3s[settings["track%d"%track]-1])
@@ -616,12 +581,19 @@ while quit!=True:
track=0
if settings["track%d"%track]==0:
track=0
settings['starttrack']=track;
writesettings()
config.starttrack=track;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if count % 40 == 0: # every 10 seconds
if tracks.CheckTrackList() or config.CheckConfig():
reload = True;
#------------------------------------------------------------------
stamp()
print "Shutdown!"
sys.stdout.flush()
if pygame.mixer.get_init():
pygame.mixer.music.set_volume(0)
pygame.mixer.music.stop()
pygame.mixer.quit()
display.cleanup()
sys.stdout.flush()
stamp("Shutdown!")

138
clockyconfig.py Normal file
View File

@@ -0,0 +1,138 @@
#!/usr/bin/python3
import json
import os
import time
import copy
CONFIGFILEVERSION="1.1"
class ClockyConfig:
"""Read/write clocky config files."""
def __init__(self,filename="clocky.json",verbose=0):
"""Open existing Clocky config file and read config data. If no file can be found create a new one with default values."""
self.filename=filename
self.__verbose=verbose
if os.access(self.filename,os.R_OK):
self.__Read()
else:
self.__data={}
self.__data["clocky"]={}
self.__data["clocky"]["version"]=CONFIGFILEVERSION
self.__data["clocky"]["settings"]={}
self.__data["clocky"]["settings"]["alarmtime"]="09:00"
self.__data["clocky"]["settings"]["alarmdisabled"]=0
self.__data["clocky"]["settings"]["maxalarmtime"]=30
self.__data["clocky"]["settings"]["snoozetime"]=9
self.__data["clocky"]["settings"]["showalarmtime"]=3
self.__data["clocky"]["settings"]["showtracktime"]=2
self.__data["clocky"]["settings"]["editdelaytime"]=3
self.__data["clocky"]["settings"]["edittimeout"]=5
self.__data["clocky"]["settings"]["timetomaxvolume"]=150
self.__data["clocky"]["settings"]["soundpreviewtime"]=5
self.__data["clocky"]["settings"]["defaultbrightness"]=0
self.__data["clocky"]["settings"]["playmode"]="random"
self.__data["clocky"]["tracks"]={}
self.__data["clocky"]["starttrack"]=0
self.__data["clocky"]["tracklist"]=[]
self.__data["clocky"]["tracksequence"]=[]
self.__Write()
if(self.__verbose):
print("Created new config file called \"%s\"" %self.filename)
def __Read(self):
"""Internal function to do the actual reading of file in to config"""
with open(self.filename) as json_data_file:
self.__data = json.load(json_data_file)
if(self.__data["clocky"]["version"] != CONFIGFILEVERSION):
print ("ERROR: configfile \""+self.filename+"\" version ("+self.__data["clocky"]["version"]+") does not match program version ("+CONFIGFILEVERSION+")!")
exit();
if(self.__data["clocky"]["settings"]["alarmtime"][1]==':'): # make sure time data is like "09:00", not "9:00"
self.__data["clocky"]["settings"]["alarmtime"]="0"+self.__data["clocky"]["settings"]["alarmtime"]
self.__readdata=copy.deepcopy(self.__data)
self.__timestamp=os.stat(self.filename).st_mtime
self.settings=self.__data["clocky"]["settings"]
self.starttrack=self.__data["clocky"]["starttrack"]
self.tracklist=self.__data["clocky"]["tracklist"]
self.sequence=self.__data["clocky"]["tracksequence"]
def __Write(self):
"""Internal function to do the actual writing of data into file"""
if(self.__data["clocky"]["settings"]["alarmtime"][1]==':'): # make sure time data is like "09:00", not "9:00"
self.__data["clocky"]["settings"]["alarmtime"]="0"+self.__data["clocky"]["settings"]["alarmtime"]
with open(self.filename,"w") as json_data_file:
json.dump(self.__data,json_data_file)
self.__readdata=copy.deepcopy(self.__data)
self.__timestamp=os.stat(self.filename).st_mtime
self.settings=self.__data["clocky"]["settings"]
self.starttrack=self.__data["clocky"]["starttrack"]
self.tracklist=self.__data["clocky"]["tracklist"]
self.sequence=self.__data["clocky"]["tracksequence"]
def Print(self):
"""Print current config data in human readable format"""
print("--ClockyConfig-------------")
print("filename =",self.filename)
print("version =",self.__data["clocky"]["version"])
for x in self.__data["clocky"]["settings"].keys():
print("%-14s= %s" %(x,self.__data["clocky"]["settings"][x]))
print("...........................")
print("starttrack =",self.__data["clocky"]["starttrack"])
nrtracks=len(self.__data["clocky"]["tracklist"])
print ("%d Tracks:" %nrtracks)
for str in self.__data["clocky"]["tracklist"]:
print(" "+str)
print("%d sequence items:" %(len(self.__data["clocky"]["tracksequence"])) )
for num in self.__data["clocky"]["tracksequence"]:
if num<nrtracks:
print(" %d -> %s" %(num,self.__data["clocky"]["tracklist"][num]) )
else:
print(" %d UNKNOWN TRACK" %num)
print("---------------------------")
def Dump(self):
"""Dump current config data in json format"""
print(self.__data)
def CheckConfig(self):
"""Check if config file has changed or removed since reading, or if the settings have changed.
Re-write or Re-read when necessary"""
if not os.access(self.filename,os.R_OK):
self.__Write()
if(self.__verbose):
print("Re-write settings because of config file removal!")
self.Print()
return True
elif(os.stat(self.filename).st_mtime != self.__timestamp):
self.__Read()
if(self.__verbose):
print("Re-read settings because of config file change!")
self.Print()
return True
if(self.__data != self.__readdata):
self.__Write()
if(self.__verbose):
print("Re-write settings because of settings change!")
self.Print()
return True
return False

92
clockytracklist.py Normal file
View File

@@ -0,0 +1,92 @@
#!/usr/bin/python3
from pathlib import Path
EXTENSIONS=(".mp3",".ogg",".wav",".mpa",".m4a",".flac")
class ClockyTracklist:
"""read and monitor directory with audio files"""
def __init__(self,path=".",recursive=False,sort=True,verbose=False):
"""Read (current or supplied) path for all audio files. Add recursive=True to check all subdirectories too"""
self.recursive=recursive
self.path=path
self.__verbose=verbose
self.__sort=sort
self.__reloaded=False
self.supportedformats=EXTENSIONS
p=Path(self.path)
if not p.exists():
print("ERROR: directory \""+path+"\" does not exist")
exit();
if not p.is_dir():
print("ERROR: \""+path+"\" is not an directory")
exit();
self.__ReadTrackList()
if self.count==0:
print("ERROR: no (supported) files found in directory \""+path+"\"")
exit();
if(self.__verbose):
self.ShowTrackList()
def __ReadTrackList(self):
"""do the actual reading"""
self.tracklist=[]
self.count=0
path=Path(self.path)
if(self.recursive):
selection='**/*'
else:
selection='*'
for entry in path.glob(selection):
if entry.suffix in EXTENSIONS:
self.tracklist.append(entry.as_posix())
self.count+=1
if self.__sort:
self.tracklist.sort()
def ShowTrackList(self):
"""Print the list"""
print("Tracklist:")
print(" path = %s" %self.path)
print(" recursive = %s" %self.recursive)
print(" count = %d" %self.count)
print(" tracks:")
for track in self.tracklist:
print(" "+track)
f=open(track,"r")
if(f):
f.close()
def CheckTrackList(self):
"""Check path for filechanges"""
newtracklist=[]
newcount=0
if self.__reloaded:
self.__reloaded=False
newpath=Path(self.path)
if(self.recursive):
selection='**/*'
else:
selection='*'
for newentry in newpath.glob(selection):
if newentry.suffix in EXTENSIONS:
newtracklist.append(newentry.as_posix())
newcount+=1
if self.__sort:
newtracklist.sort()
if(newcount != self.count) or (newtracklist != self.tracklist):
if(self.__verbose):
print("Changes in filenames or number of files detected! Re-read tracklist.")
self.__ReadTrackList()
self.__reloaded=True
return self.__reloaded

67
conftest.py Executable file
View File

@@ -0,0 +1,67 @@
#!/usr/bin/python3
import json
import os
import time
import copy
import clockyconfig
class Tracklist:
def __init__(self,path="."):
self.path=path
self.tracklist=[]
self.count=0
olddir=os.getcwd()
if(self.path != '.'):
if(not os.path.isdir(self.path)):
print("ERROR: \""+self.path+"\" is not an existing directory")
exit();
os.chdir(self.path)
for ent in os.listdir("."):
if ent.lower().endswith(".mp3") and os.access(ent,os.R_OK):
self.tracklist.append(ent)
self.count+=1
self.tracklist.sort()
os.chdir(olddir)
def Show(self):
print("Tracklist.path = %s" %self.path)
print("Tracklist.count= %d" %self.count)
print("Tracks:")
for track in self.tracklist:
print (" "+track)
config=clockyconfig.ClockyConfig()
config.Print()
tl=Tracklist("mp3")
tl.Show()
if (tl.tracklist == config.tracklist):
print("Same!")
else:
print("diff")
a=0
t=0
while True:
t+=1
config.CheckConfig()
time.sleep(1)
a+=1
if(a>5):
config.settings["alarmdisabled"]=1-config.settings["alarmdisabled"]
print(config.settings["alarmdisabled"])
a=0
if(t>30):
break
tracklist=Tracklist()
#tracklist.Read("old")
#tracklist.Show()

60
max7219.py Normal file
View File

@@ -0,0 +1,60 @@
#!/usr/bin/env python3
import re
import time
from luma.led_matrix.device import max7219
from luma.core.interface.serial import spi, noop
from luma.core.render import canvas
from luma.core.legacy import text
from luma.core.legacy.font import SIXBYEIGHT_FONT, SIXBYEIGHTTHIN_FONT
class MAX7219:
__doublePoint = False
__brightness = 1.0 # default to min brightness
def __init__(self, brightness):
self.__brightness = brightness
serial = spi(port=0, device=0, gpio=noop())
self.__device = max7219(serial, cascaded=4, block_orientation=-90, rotate=0) # last arg is rotate: 0,1,2 or 3)
def Clear(self):
with canvas(self.__device) as draw:
draw.point((15,2), fill=None)
def showclock(self,tstr):
with canvas(self.__device) as draw:
text(draw, (0 ,0), tstr[0] , fill="white", font=SIXBYEIGHTTHIN_FONT)
text(draw, (8 ,0), tstr[1] , fill="white", font=SIXBYEIGHTTHIN_FONT)
text(draw, (17,0), tstr[3] , fill="white", font=SIXBYEIGHTTHIN_FONT)
text(draw, (25,0), tstr[4] , fill="white", font=SIXBYEIGHTTHIN_FONT)
if tstr[2]==':':
draw.point((15,2), fill="white")
draw.point((15,5), fill="white")
def SetBrightnessRaw(self, brightness):
"""Accepts raw brightness from 0 - 255"""
self.__device.contrast(brightness)
def ShowDoublepoint(self, on):
"""Show or hide double point divider"""
if(self.__doublePoint != on):
self.__doublePoint = on
draw.point((15,2), fill="white")
draw.point((15,5), fill="white")
def cleanup(self):
self.__brightness=0
if __name__ == "__main__":
try:
# demo()
showclock("01:23")
wait=raw_input("enter")
except KeyboardInterrupt:
pass

181
tm1637.py
View File

@@ -2,22 +2,21 @@ import math
import RPi.GPIO as IO
import threading
from time import sleep, localtime
# from tqdm import tqdm
# IO.setwarnings(False)
IO.setmode(IO.BCM)
HexDigits = [0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d,
0x07, 0x7f, 0x6f, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71, 0x49, 0x50 ]
0x07, 0x7f, 0x6f, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71, 0x49, 0x50, 0x40]
# 0 1 2 3 4 5 6
# 7 8 9 A B C D E F = r
# 10 11 12 13 14 15 16 17
# 7 8 9 A B C D E F = r -
# 10 11 12 13 14 15 16 17 18
#
# 0
# ---
# | |
# 5 | 7 | 1
# 5 | 6 | 1
# ---
# | |
# 4 | | 2
@@ -31,6 +30,36 @@ STARTADDR = 0xC0
# DEBUG = False
# return array value of a certain character
def s2c(s):
if s>='0' and s<='9':
return(int(s))
elif s=='A':
return(10)
elif s=='B':
return(11)
elif s=='C':
return(12)
elif s=='D':
return(13)
elif s=='E':
return(14)
elif s=='F':
return(15)
elif s=='=':
return(16)
elif s=='r':
return(17)
elif s=='-':
return(18)
elif s=='O':
return(0)
else:
return(0x7f)
class TM1637:
__doublePoint = False
__Clkpin = 0
@@ -47,6 +76,7 @@ class TM1637:
def cleanup(self):
"""Stop updating clock, turn off display, and cleanup GPIO"""
self.showclock(" ")
IO.cleanup()
def Clear(self):
@@ -60,11 +90,18 @@ class TM1637:
self.__brightness = b
self.__doublePoint = point
def ShowInt(self, i):
s = str(i)
self.Clear()
for i in range(0, len(s)):
self.Show1(i, int(s[i]))
def showclock(self,tstr):
"Show da clock"
if tstr[2]==':':
self.ShowDoublepoint(True)
else:
self.ShowDoublepoint(False)
self.Show1(0,s2c(tstr[0]))
self.Show1(1,s2c(tstr[1]))
self.Show1(2,s2c(tstr[3]))
self.Show1(3,s2c(tstr[4]))
def Show(self, data):
for i in range(0, 4):
@@ -96,21 +133,13 @@ class TM1637:
self.writeByte(0x88 + int(self.__brightness))
self.stop()
def SetBrightness(self, percent):
"""Accepts percent brightness from 0 - 1"""
max_brightness = 7.0
brightness = math.ceil(max_brightness * percent)
if (brightness < 0):
brightness = 0
def SetBrightnessRaw(self, briteness):
"""Accepts raw brightness from 0 - 255"""
brightness=briteness>>5
# print("BR=%d",brightness)
if(self.__brightness != brightness):
self.__brightness = brightness
self.Show(self.__currentData)
def SetBrightnessRaw(self, brightness):
"""Accepts raw brightness from 0 - 7"""
if(self.__brightness != brightness):
self.__brightness = brightness
self.Show(self.__currentData)
# self.Show(self.__currentData)
def ShowDoublepoint(self, on):
"""Show or hide double point divider"""
@@ -171,109 +200,3 @@ class TM1637:
else:
data = HexDigits[data] + pointData
return data
def clock(self, military_time):
"""Clock script modified from:
https://github.com/johnlr/raspberrypi-tm1637"""
self.ShowDoublepoint(True)
while (not self.__stop_event.is_set()):
t = localtime()
hour = t.tm_hour
if not military_time:
hour = 12 if (t.tm_hour % 12) == 0 else t.tm_hour % 12
d0 = hour // 10 if hour // 10 else 0
d1 = hour % 10
d2 = t.tm_min // 10
d3 = t.tm_min % 10
digits = [d0, d1, d2, d3]
self.Show(digits)
# # Optional visual feedback of running alarm:
# print digits
# for i in tqdm(range(60 - t.tm_sec)):
for i in range(60 - t.tm_sec):
if (not self.__stop_event.is_set()):
sleep(1)
def StartClock(self, military_time=True):
# Stop event based on: http://stackoverflow.com/a/6524542/3219667
self.__stop_event = threading.Event()
self.__clock_thread = threading.Thread(
target=self.clock, args=(military_time,))
self.__clock_thread.start()
def StopClock(self):
try:
print 'Attempting to stop live clock'
self.__stop_event.set()
except:
print 'No clock to close'
if __name__ == "__main__":
"""Confirm the display operation"""
display = TM1637(CLK=14, DIO=4, brightness=1.0)
display.Clear()
digits = [1, 2, 3, 4]
display.Show(digits)
print "1234 - Working? (Press Key)"
scrap = raw_input()
print "Updating one digit at a time:"
display.Clear()
display.Show1(1, 3)
sleep(0.5)
display.Show1(2, 2)
sleep(0.5)
display.Show1(3, 1)
sleep(0.5)
display.Show1(0, 4)
print "4321 - (Press Key)"
scrap = raw_input()
print "Add double point\n"
display.ShowDoublepoint(True)
sleep(0.2)
print "Brightness Off"
display.SetBrightness(0)
sleep(0.5)
print "Full Brightness"
display.SetBrightness(1)
sleep(0.5)
print "30% Brightness"
display.SetBrightness(0.3)
sleep(0.3)
display.ShowDoublepoint(False)
display.Show1(0,0x7f);
display.Show1(1,14);
display.Show1(2,17);
display.Show1(3,17);
# See clock.py for how to use the clock functions!
display.SetBrightnessRaw(0)
print "level=0"
scrap=raw_input()
display.SetBrightnessRaw(1)
print "level=1"
scrap=raw_input()
display.SetBrightnessRaw(2)
print "level=2"
scrap=raw_input()
display.SetBrightnessRaw(3)
print "level=3"
scrap=raw_input()
display.SetBrightnessRaw(4)
print "level=4"
scrap=raw_input()
display.SetBrightnessRaw(5)
print "level=5"
scrap=raw_input()
display.SetBrightnessRaw(6)
print "level=6"
scrap=raw_input()
display.SetBrightnessRaw(7)
print "level=7"
scrap=raw_input()