Compare commits

1 Commits

11 changed files with 514 additions and 1028 deletions

View File

@@ -1,58 +0,0 @@
# 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 python3 #!/usr/bin/env python2.7
import time import time
import RPi.GPIO as GPIO import RPi.GPIO as GPIO
@@ -9,55 +9,54 @@ GPIO.setmode(GPIO.BCM) # set up BCM GPIO numbering
#GPIO.setup(20, GPIO.IN, pull_up_down = GPIO.PUD_UP) #GPIO.setup(20, GPIO.IN, pull_up_down = GPIO.PUD_UP)
class Button: class Button:
"""Handle clocky button stuff""" 'Handle button stuff'
starttime=0 starttime=0
ispushed=0 ispushed=0
waspushed=0 waspushed=0
presstime=0 presstime=0
ignore=0 ignore=0
def __init__(self, gpio,verbose=False): def __init__(self, gpio):
if verbose: print "initialize button on gpio %d"%gpio
print("initialize button on gpio %d" %gpio) self.gpio = gpio
self.gpio = gpio GPIO.setup(self.gpio, GPIO.IN, pull_up_down = GPIO.PUD_UP)
GPIO.setup(self.gpio, GPIO.IN, pull_up_down = GPIO.PUD_UP) GPIO.add_event_detect(self.gpio, GPIO.BOTH, callback=self.my_callback)
GPIO.add_event_detect(self.gpio, GPIO.BOTH, callback=self.my_callback) self.presstime=0
self.presstime=0 self.starttime=0
self.starttime=0 self.presstime=0
self.presstime=0 self.waslong=0
self.waslong=0
def my_callback(self,channel): def my_callback(self,channel):
if not GPIO.input(channel): # button is pressed if not GPIO.input(channel): # button is pressed
# print "[press] on %d"%self.gpio # print "[press] on %d"%self.gpio
self.starttime=time.time() self.starttime=time.time()
self.ispushed=1 self.ispushed=1
else: # button released else: # button released
self.presstime=time.time()-self.starttime self.presstime=time.time()-self.starttime
# print "[release] on %d / <pressed> for=%f sconds"%(self.gpio,self.presstime) # print "[release] on %d / <pressed> for=%f sconds"%(self.gpio,self.presstime)
if self.ispushed: if self.ispushed:
self.waspushed=1 self.waspushed=1
self.ispushed=0 self.ispushed=0
def WasPressed(self): def WasPressed(self):
if self.waspushed: if self.waspushed:
self.waspushed=0 self.waspushed=0
return 1 return 1
elif self.ispushed: elif self.ispushed:
self.presstime=time.time()-self.starttime self.presstime=time.time()-self.starttime
if self.presstime > 2: if self.presstime > 2:
self.ispushed=0 self.ispushed=0
self.waspushed=1 self.waspushed=1
self.waslong=1 self.waslong=1
else: else:
return 0 return 0
def WasLong(self): def WasLong(self):
if self.presstime > 2: if self.presstime > 2:
self.waslong=0 self.waslong=0
self.ignore=1 self.ignore=1
return 1 return 1
else: else:
return 0 return 0

View File

@@ -1,28 +0,0 @@
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

View File

@@ -1,527 +0,0 @@
#: 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
]

View File

@@ -1,13 +0,0 @@
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'>

303
clocky.py Executable file → Normal file
View File

@@ -1,79 +1,109 @@
#!/usr/bin/python3 #!/usr/bin/python
import pickle import pickle
import os import os.path
import time import time
import sys import sys
import tm1637 import tm1637
import max7219
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
import pygame import pygame
from time import sleep,strftime from time import sleep,strftime
import RPi.GPIO as GPIO import RPi.GPIO as GPIO
import button import button
import signal import signal
import clockytracklist
VERBOSE=False
settings= {} settings= {}
looptype=0 looptype=0
quit=0 quit=0
print("\n +----------+\n | Clocky |\n | v0.2.5 |\n +----------+\n") print "\n +----------+\n | Clocky |\n | v0.0.5 |\n +----------+\n"
o_configfilename = "clocky.conf" o_configfilename = "clocky.conf"
o_defaultalarmtime = 60*14+10 # hh*60+mm o_defaultalarmtime = 60*7+45 # hh*60+mm
o_showalarmtime=3 # time that the alarmtime shows after short press 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_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_editdelaytime=3 # time it takes to qualify as longpress
o_showtimeout=6 # timeout to exit edit modus o_showtimeout=6 # timeout to exit edit modus
o_snoozetime = 9 # time to snooze o_snoozetime = 9 # time to snooze
o_timetomaxvol = 150# seconds it takes to go from 0% to 100% volume o_timetomaxvol = 150 # seconds it takes to go from 0% to 100% volume
o_maxplaytime = 900 # seconds it to play o_maxplaytime = 1800 # seconds it to play
o_soundpreviewtime=5 o_soundpreviewtime=5
o_defaultbrightness=0 o_defaultbrightness=1
o_loopdelay=0.25 o_loopdelay=0.25
track=0 track=0
stopprogram=0
reload=False
#GPIO.setmode(GPIO.BCM) # set up BCM GPIO numbering #GPIO.setmode(GPIO.BCM) # set up BCM GPIO numbering
#GPIO.setup(16, GPIO.IN, pull_up_down = GPIO.PUD_UP) #GPIO.setup(16, GPIO.IN, pull_up_down = GPIO.PUD_UP)
#def signal_handler(signal,frame): def signal_handler(signal,frame):
# global quit global quit
# print("") print ""
# quit=1 quit=1
def receive_signal(signum, stack):
global stopprogram
global reload
if VERBOSE:
print('Received signal: %d' %signum)
else:
print("")
if signum == signal.SIGHUP:
reload=True
if signum == signal.SIGINT:
stopprogram=1
def stamp(): def stamp():
sys.stdout.write(strftime("[%Y%m%d %H%M%S] ")) 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)
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]))
def writesettings(): def writesettings():
"write settings to conf file" "write settings to conf file"
with open(o_configfilename, 'wb') as handle: with open(o_configfilename, 'wb') as handle:
pickle.dump(settings, handle) pickle.dump(settings, handle)
handle.close() handle.close()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 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
if c:
return(mp3s)
else:
return(0)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
looptype=0 looptype=0
colon=0 colon=0
count=0
digit=1 digit=1
showtime=0 showtime=0
playtime=0 playtime=0
@@ -82,52 +112,40 @@ alarmstarted=0
silencedalarm=0 silencedalarm=0
tvol=0 tvol=0
volume=0.0 volume=0.0
brightness=0 brightness=0.0
snooze=0 snooze=0
count=0
if VERBOSE: signal.signal(signal.SIGINT,signal_handler)
print('My PID is %d' %os.getpid()) display=tm1637.TM1637(CLK=14, DIO=4, brightness=1.0)
signal.signal(signal.SIGHUP, receive_signal) display.Clear()
signal.signal(signal.SIGINT, receive_signal) display.SetBrightnessRaw(o_defaultbrightness)
but1=button.Button(21,verbose=VERBOSE) print ""
but2=button.Button(20,verbose=VERBOSE) print "reading mp3s from directory:"
but3=button.Button(26,verbose=VERBOSE) 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()
#------------------------------------------------------------------ c=0
#------------------------------------------------------------------ for m in allmp3s:
print " %2d : %s"%(c+1,m)
c+=1
while not stopprogram: print ""
if VERBOSE: but1=button.Button(21)
print("Load config...") but2=button.Button(20)
reload=False but3=button.Button(26)
print ""
display=tm1637.TM1637(CLK=14, DIO=4, brightness=1) if not os.path.isfile(o_configfilename):
# display=max7219.MAX7219(brightness=1) print "Createconf: \""+o_configfilename+"\":"
display.Clear()
display.SetBrightnessRaw(o_defaultbrightness)
if VERBOSE:
print("Reading mp3s from directory:")
tracks=clockytracklist.ClockyTracklist("mp3",recursive=True,verbose=VERBOSE)
allmp3s=tracks.tracklist
c=0
if VERBOSE:
print("\nTracks:")
for m in allmp3s:
print("%2d : %s"%(c+1,m))
c+=1
stamp()
print("Started")
sys.stdout.flush()
# .................................................................
if not os.path.isfile(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 = {'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['alarmtime']=o_defaultalarmtime;
@@ -138,44 +156,39 @@ while not stopprogram:
pickle.dump(settings, handle) pickle.dump(settings, handle)
handle.close() handle.close()
else: else:
if VERBOSE: print "Configfile: \""+o_configfilename+"\":"
print("Configfile: \""+o_configfilename+"\":")
with open(o_configfilename, 'rb') as handle: with open(o_configfilename, 'rb') as handle:
settings = pickle.load(handle) settings = pickle.load(handle)
handle.close() handle.close()
a_mins=int(settings['alarmtime']%60) a_mins=settings['alarmtime']%60
a_hour=int((settings['alarmtime']-a_mins)/60) a_hour=(settings['alarmtime']-a_mins)/60
if VERBOSE: print "Alarmtime : %02d:%02d"%(a_hour,a_mins)
print("Alarmtime : %02d:%02d"%(a_hour,a_mins)) print "Alarmdisable: %d"%(settings['alarmdisabled'])
print("Alarmdisable: %d"%(settings['alarmdisabled'])) print "Starttrack : %d"%(settings['starttrack'])
print("Starttrack : %d"%(settings['starttrack']))
for i in range(0,10): for i in range(0,10):
if i==settings['starttrack']: if i==settings['starttrack']:
if VERBOSE: print "=>",
print("=>",end='')
else: else:
if VERBOSE: print " ",
print(" ",end='') print "[T%02dM%02d]"%(i,settings["track%d"%i]),
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)): if settings["track%d"%i] and (settings["track%d"%i]-1 < len(allmp3s)):
if VERBOSE: print "\""+allmp3s[settings["track%d"%i]-1]+"\""
print("\""+allmp3s[settings["track%d"%i]-1]+"\"")
else: else:
if VERBOSE: print ""
print("") settings["track%d"%i]=0
settings["track%d"%i]=0 writesettings()
writesettings()
print ""
stamp()
# ................................................................. print "Started"
sys.stdout.flush()
while not reload and not stopprogram: #------------------------------------------------------------------
#------------------------------------------------------------------
while quit!=True:
count+=1; count+=1;
sleep(o_loopdelay) sleep(o_loopdelay)
@@ -201,12 +214,12 @@ while not stopprogram:
if settings["alarmdisabled"]==0: if settings["alarmdisabled"]==0:
settings["alarmdisabled"]=1 settings["alarmdisabled"]=1
stamp() stamp()
print("Alarm disabled") print "Alarm disabled"
writesettings() writesettings()
else: else:
settings["alarmdisabled"]=0 settings["alarmdisabled"]=0
stamp() stamp()
print("Alarm enabled") print "Alarm enabled"
writesettings() writesettings()
looptype=1 looptype=1
else: else:
@@ -223,12 +236,12 @@ while not stopprogram:
if settings["alarmdisabled"]==0: if settings["alarmdisabled"]==0:
settings["alarmdisabled"]=1 settings["alarmdisabled"]=1
stamp() stamp()
print("Alarm disabled") print "Alarm disabled"
writesettings() writesettings()
else: else:
settings["alarmdisabled"]=0 settings["alarmdisabled"]=0
stamp() stamp()
print("Alarm enabled") print "Alarm enabled"
writesettings() writesettings()
looptype=1 looptype=1
@@ -237,7 +250,7 @@ while not stopprogram:
tim="%02d:%02d" % (mytime[3] , mytime[4]) tim="%02d:%02d" % (mytime[3] , mytime[4])
else: else:
tim="%02d %02d" % (mytime[3] , mytime[4]) tim="%02d %02d" % (mytime[3] , mytime[4])
display.showclock(tim) showclock(tim)
if count % 4 == 0: if count % 4 == 0:
colon=1-colon colon=1-colon
@@ -245,17 +258,21 @@ while not stopprogram:
if looptype==1: # show alarmtime if looptype==1: # show alarmtime
if not settings["alarmdisabled"]==1: if not settings["alarmdisabled"]==1:
a_mins=int(settings['alarmtime']%60) a_mins=settings['alarmtime']%60
a_hour=int((settings['alarmtime']-a_mins)/60) a_hour=(settings['alarmtime']-a_mins)/60
if colon: if colon:
tim="%02d:%02d" % (a_hour, a_mins) tim="%02d:%02d" % (a_hour, a_mins)
else: else:
tim="%02d %02d" % (a_hour, a_mins) tim="%02d %02d" % (a_hour, a_mins)
display.showclock(tim) showclock(tim)
colon=1-colon colon=1-colon
else: else:
display.showclock(" O FF") display.ShowDoublepoint(False)
display.Show1(0,0x7f);
display.Show1(1,0);
display.Show1(2,15);
display.Show1(3,15);
if showtime > o_showalarmtime: if showtime > o_showalarmtime:
if but1.WasPressed(): # drop intermediate presses if but1.WasPressed(): # drop intermediate presses
@@ -273,12 +290,11 @@ while not stopprogram:
if looptype==2: # edit alarmtime if looptype==2: # edit alarmtime
delta=0 delta=0
sm=int(settings['alarmtime']%10) sm=settings['alarmtime']%10
dm=int(((settings['alarmtime']-sm)/10)%6) dm=((settings['alarmtime']-sm)/10)%6
sh=int((settings['alarmtime']-dm)/60%10) sh=(settings['alarmtime']-dm)/60%10
dh=int((settings['alarmtime']-sh)/600) dh=(settings['alarmtime']-sh)/600
if colon: if colon:
tim="%0d%0d:%0d%0d" % (dh,sh,dm,sm) tim="%0d%0d:%0d%0d" % (dh,sh,dm,sm)
@@ -326,7 +342,7 @@ while not stopprogram:
tim="%0d%0d:%0d " % (dh,sh,dm ) tim="%0d%0d:%0d " % (dh,sh,dm )
delta=0 delta=0
display.showclock(tim) showclock(tim)
colon=1-colon colon=1-colon
@@ -340,11 +356,11 @@ while not stopprogram:
if settings["alarmdisabled"]==1: if settings["alarmdisabled"]==1:
settings["alarmdisabled"]=0 settings["alarmdisabled"]=0
stamp() stamp()
print("Alarm enabled") print "Alarm enabled"
settings['alarmtime']=dh*600+sh*60+dm*10+sm settings['alarmtime']=dh*600+sh*60+dm*10+sm
writesettings() writesettings()
stamp() stamp()
print("Set alarmtime = %d%d:%d%d"%(dh,sh,dm,sm)) print "Set alarmtime = %d%d:%d%d"%(dh,sh,dm,sm)
sys.stdout.flush() sys.stdout.flush()
digit=1 digit=1
else: else:
@@ -386,8 +402,8 @@ while not stopprogram:
soundpreview=1 soundpreview=1
tr=track tr=track
tl=int(settings["track%d"%tr]%10) tl=settings["track%d"%tr]%10
th=int((settings["track%d"%tr]-tl)/10) th=(settings["track%d"%tr]-tl)/10
if colon: if colon:
tim="%d=:%d%d" % (tr,th,tl) tim="%d=:%d%d" % (tr,th,tl)
@@ -397,7 +413,7 @@ while not stopprogram:
tr+=1; tr+=1;
if tr>9: if tr>9:
looptype=0 looptype=0
display.showclock(tim) showclock(tim)
colon=1-colon colon=1-colon
if soundpreview: if soundpreview:
@@ -428,8 +444,8 @@ while not stopprogram:
delta=0 delta=0
tr=track tr=track
tl=int(settings["track%d"%tr]%10) tl=settings["track%d"%tr]%10
th=int((settings["track%d"%tr]-tl)/10) th=(settings["track%d"%tr]-tl)/10
if colon: if colon:
tim="%d=:%d%d" % (tr,th,tl) tim="%d=:%d%d" % (tr,th,tl)
@@ -466,7 +482,7 @@ while not stopprogram:
tim="%d=:%d " % (tr,th ) tim="%d=:%d " % (tr,th )
delta=0 delta=0
display.showclock(tim) showclock(tim)
colon=1-colon colon=1-colon
settings["track%d"%tr]=th*10+tl settings["track%d"%tr]=th*10+tl
@@ -489,7 +505,7 @@ while not stopprogram:
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if looptype==5: # Alarm loop! if looptype==5: # Alarm!
#o_timetomaxvol = 60 # seconds it takes to go from 0% to 100% volume #o_timetomaxvol = 60 # seconds it takes to go from 0% to 100% volume
if colon: if colon:
@@ -498,14 +514,14 @@ while not stopprogram:
else: else:
display.SetBrightnessRaw(brightness) display.SetBrightnessRaw(brightness)
tim="%02d:%02d" % (mytime[3] , mytime[4]) tim="%02d:%02d" % (mytime[3] , mytime[4])
display.showclock(tim) showclock(tim)
if count % 2 == 0: if count % 2 == 0:
colon=1-colon colon=1-colon
if not alarmstarted: if not alarmstarted:
track=settings['starttrack']; track=settings['starttrack'];
stamp() stamp()
print("[T%02dM%02d] \"%s\""%(track,settings["track%d"%track],(allmp3s[settings["track%d"%track]-1]))) print "[T%02dM%02d] \"%s\""%(track,settings["track%d"%track],(allmp3s[settings["track%d"%track]-1]))
sys.stdout.flush() sys.stdout.flush()
if not pygame.mixer.get_init(): if not pygame.mixer.get_init():
pygame.mixer.init() pygame.mixer.init()
@@ -524,9 +540,9 @@ while not stopprogram:
alarmstarted=1 alarmstarted=1
else: # alarmstarted else: # alarmstarted
if playtime < o_timetomaxvol: if playtime < o_timetomaxvol:
brightness=int((playtime / o_timetomaxvol)*255) brightness=(playtime / o_timetomaxvol)*6
volume = float(int((playtime*100) / o_timetomaxvol))/100 volume = float(int((playtime*100) / o_timetomaxvol))/100
# print("------> %d / %d => %f - %f [%d]"%(playtime,o_timetomaxvol,tvol,volume,brightness)) # print "------> %d / %d => %f - %f"%(playtime,o_timetomaxvol,tvol,volume)
else: else:
volume=1 volume=1
@@ -539,7 +555,7 @@ while not stopprogram:
if not pygame.mixer.music.get_busy(): if not pygame.mixer.music.get_busy():
track=settings['starttrack'] track=settings['starttrack']
stamp() stamp()
print("[T%02dM%02d] \"%s\""%(track,settings["track%d"%track],(allmp3s[settings["track%d"%track]-1]))) print "[T%02dM%02d] \"%s\""%(track,settings["track%d"%track],(allmp3s[settings["track%d"%track]-1]))
sys.stdout.flush() sys.stdout.flush()
pygame.mixer.music.load(allmp3s[settings["track%d"%track]-1]) pygame.mixer.music.load(allmp3s[settings["track%d"%track]-1])
pygame.mixer.music.play() pygame.mixer.music.play()
@@ -560,8 +576,6 @@ while not stopprogram:
pygame.mixer.quit() pygame.mixer.quit()
display.SetBrightnessRaw(o_defaultbrightness) display.SetBrightnessRaw(o_defaultbrightness)
alarmstarted=0 alarmstarted=0
stamp()
print("Alarmtime expired")
if but1.WasPressed(): if but1.WasPressed():
if but1.WasLong(): # Finished if but1.WasLong(): # Finished
@@ -581,7 +595,7 @@ while not stopprogram:
alarmstarted=0 alarmstarted=0
silencedalarm=1 silencedalarm=1
stamp() stamp()
print("Silenced alarm") print "Silenced alarm"
if but2.WasPressed(): if but2.WasPressed():
@@ -592,7 +606,7 @@ while not stopprogram:
track=settings['starttrack'] track=settings['starttrack']
stamp() stamp()
print("[T%02dM%02d] \"%s\""%(track,settings["track%d"%track],(allmp3s[settings["track%d"%track]-1]))) print "[T%02dM%02d] \"%s\""%(track,settings["track%d"%track],(allmp3s[settings["track%d"%track]-1]))
sys.stdout.flush() sys.stdout.flush()
if pygame.mixer.get_init(): if pygame.mixer.get_init():
pygame.mixer.music.load(allmp3s[settings["track%d"%track]-1]) pygame.mixer.music.load(allmp3s[settings["track%d"%track]-1])
@@ -605,18 +619,9 @@ while not stopprogram:
settings['starttrack']=track; settings['starttrack']=track;
writesettings() writesettings()
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if count % 40 == 0: # every 10 seconds
if tracks.CheckTrackList():
reload = True;
#------------------------------------------------------------------ #------------------------------------------------------------------
if pygame.mixer.get_init():
pygame.mixer.music.set_volume(0)
pygame.mixer.music.stop()
pygame.mixer.quit()
display.cleanup()
sys.stdout.flush()
stamp() stamp()
print("Shutdown!") print "Shutdown!"
sys.stdout.flush()
display.cleanup()

116
clockyconfig.py Normal file
View File

@@ -0,0 +1,116 @@
#!/usr/bin/python
import json
import os
import time
import copy
CONFIGFILEVERSION="1.0"
class ClockyConfig:
"""Read/write clocky config files."""
def __init__(self,filename,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"]["CONFIGFILEVERSION"]=CONFIGFILEVERSION
self.__data["clocky"]["settings"]={}
self.__data["clocky"]["settings"]["alarmtime"]="9:00"
self.__data["clocky"]["settings"]["alarmdisabled"]=0
self.__data["clocky"]["settings"]["maxalarmtime"]=30
self.__data["clocky"]["settings"]["snoozetime"]=9
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+"\" CONFIGFILEVERSION ("+self.__data["clocky"]["version"]+") does not match program CONFIGFILEVERSION ("+CONFIGFILEVERSION+")!")
exit();
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"""
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("CONFIGFILEVERSION =",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 file removal!")
self.Print()
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()
if(self.__data != self.__readdata):
self.__Write()
if(self.__verbose):
print("Re-write settings because of settings change!")
self.Print()

View File

@@ -1,92 +0,0 @@
#!/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 Normal file
View File

@@ -0,0 +1,67 @@
#!/usr/bin/python
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("clocky.jso")
config.Print()
tl=Tracklist("m")
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()

View File

@@ -1,60 +0,0 @@
#!/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,21 +2,22 @@ import math
import RPi.GPIO as IO import RPi.GPIO as IO
import threading import threading
from time import sleep, localtime from time import sleep, localtime
# from tqdm import tqdm
# IO.setwarnings(False) # IO.setwarnings(False)
IO.setmode(IO.BCM) IO.setmode(IO.BCM)
HexDigits = [0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, HexDigits = [0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d,
0x07, 0x7f, 0x6f, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71, 0x49, 0x50, 0x40] 0x07, 0x7f, 0x6f, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71, 0x49, 0x50 ]
# 0 1 2 3 4 5 6 # 0 1 2 3 4 5 6
# 7 8 9 A B C D E F = r - # 7 8 9 A B C D E F = r
# 10 11 12 13 14 15 16 17 18 # 10 11 12 13 14 15 16 17
# #
# 0 # 0
# --- # ---
# | | # | |
# 5 | 6 | 1 # 5 | 7 | 1
# --- # ---
# | | # | |
# 4 | | 2 # 4 | | 2
@@ -30,36 +31,6 @@ STARTADDR = 0xC0
# DEBUG = False # 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: class TM1637:
__doublePoint = False __doublePoint = False
__Clkpin = 0 __Clkpin = 0
@@ -76,7 +47,6 @@ class TM1637:
def cleanup(self): def cleanup(self):
"""Stop updating clock, turn off display, and cleanup GPIO""" """Stop updating clock, turn off display, and cleanup GPIO"""
self.showclock(" ")
IO.cleanup() IO.cleanup()
def Clear(self): def Clear(self):
@@ -90,18 +60,11 @@ class TM1637:
self.__brightness = b self.__brightness = b
self.__doublePoint = point self.__doublePoint = point
def showclock(self,tstr): def ShowInt(self, i):
"Show da clock" s = str(i)
self.Clear()
if tstr[2]==':': for i in range(0, len(s)):
self.ShowDoublepoint(True) self.Show1(i, int(s[i]))
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): def Show(self, data):
for i in range(0, 4): for i in range(0, 4):
@@ -133,13 +96,21 @@ class TM1637:
self.writeByte(0x88 + int(self.__brightness)) self.writeByte(0x88 + int(self.__brightness))
self.stop() self.stop()
def SetBrightnessRaw(self, briteness): def SetBrightness(self, percent):
"""Accepts raw brightness from 0 - 255""" """Accepts percent brightness from 0 - 1"""
brightness=briteness>>5 max_brightness = 7.0
# print("BR=%d",brightness) brightness = math.ceil(max_brightness * percent)
if (brightness < 0):
brightness = 0
if(self.__brightness != brightness): if(self.__brightness != brightness):
self.__brightness = brightness self.__brightness = brightness
# self.Show(self.__currentData) 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)
def ShowDoublepoint(self, on): def ShowDoublepoint(self, on):
"""Show or hide double point divider""" """Show or hide double point divider"""
@@ -200,3 +171,109 @@ class TM1637:
else: else:
data = HexDigits[data] + pointData data = HexDigits[data] + pointData
return data 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()