2 Commits

Author SHA1 Message Date
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
10 changed files with 844 additions and 454 deletions

48
README.md Normal file
View File

@@ -0,0 +1,48 @@
# 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
```
### 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

@@ -9,54 +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 button stuff' """Handle clocky 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): def __init__(self, gpio):
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

28
changes.txt Normal file
View File

@@ -0,0 +1,28 @@
0.1.0:
* Added additional logging messages for end of alarm
* implemented SIGINT (Ctrl-C) handling to exit gracefully
0.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
----
add SIGHUP handling for reload config
changes config file format to json

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'>

160
clocky.py Normal file → Executable file
View File

@@ -1,10 +1,11 @@
#!/usr/bin/python #!/usr/bin/python3
import pickle import pickle
import os.path import os.path
import time import time
import sys import sys
import tm1637 import tm1637
import max7219
import pygame import pygame
from time import sleep,strftime from time import sleep,strftime
import RPi.GPIO as GPIO import RPi.GPIO as GPIO
@@ -16,19 +17,19 @@ looptype=0
quit=0 quit=0
print "\n +----------+\n | Clocky |\n | v0.0.5 |\n +----------+\n" print("\n +----------+\n | Clocky |\n | v0.2.0 |\n +----------+\n")
o_configfilename = "clocky.conf" o_configfilename = "clocky.conf"
o_defaultalarmtime = 60*7+45 # hh*60+mm o_defaultalarmtime = 60*13+24 # 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 = 1800 # seconds it to play o_maxplaytime = 900 # seconds it to play
o_soundpreviewtime=5 o_soundpreviewtime=5
o_defaultbrightness=1 o_defaultbrightness=0
o_loopdelay=0.25 o_loopdelay=0.25
track=0 track=0
@@ -38,43 +39,12 @@ track=0
def signal_handler(signal,frame): def signal_handler(signal,frame):
global quit global quit
print "" print("")
quit=1 quit=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:
@@ -112,40 +82,38 @@ alarmstarted=0
silencedalarm=0 silencedalarm=0
tvol=0 tvol=0
volume=0.0 volume=0.0
brightness=0.0 brightness=0
snooze=0 snooze=0
signal.signal(signal.SIGINT,signal_handler) signal.signal(signal.SIGINT,signal_handler)
display=tm1637.TM1637(CLK=14, DIO=4, brightness=1.0) #display=tm1637.TM1637(CLK=14, DIO=4, brightness=1)
display=max7219.MAX7219(brightness=1)
display.Clear() display.Clear()
display.SetBrightnessRaw(o_defaultbrightness) display.SetBrightnessRaw(o_defaultbrightness)
print "" print("")
print "reading mp3s from directory:" print("reading mp3s from directory:")
allmp3s=readmp3list() allmp3s=readmp3list()
if allmp3s==0: if allmp3s==0:
print "ERROR: No mp3's found!" print("ERROR: No mp3's found!")
display.ShowDoublepoint(False) display.showclock(" E rr")
display.Show1(0,0x7f); sleep(30)
display.Show1(1,14);
display.Show1(2,17);
display.Show1(3,17);
GPIO.cleanup()
sys.exit() sys.exit()
c=0 c=0
for m in allmp3s: for m in allmp3s:
print " %2d : %s"%(c+1,m) print(" %2d : %s"%(c+1,m))
c+=1 c+=1
print "" print("")
but1=button.Button(21) but1=button.Button(21)
but2=button.Button(20) but2=button.Button(20)
but3=button.Button(26) but3=button.Button(26)
print "" print("")
if not os.path.isfile(o_configfilename): 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 = {'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;
@@ -157,7 +125,7 @@ if not os.path.isfile(o_configfilename):
handle.close() handle.close()
else: else:
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)
@@ -165,26 +133,26 @@ else:
a_mins=settings['alarmtime']%60 a_mins=settings['alarmtime']%60
a_hour=(settings['alarmtime']-a_mins)/60 a_hour=(settings['alarmtime']-a_mins)/60
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']:
print "=>", print("=>",end='')
else: else:
print " ", print(" ",end='')
print "[T%02dM%02d]"%(i,settings["track%d"%i]), 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)):
print "\""+allmp3s[settings["track%d"%i]-1]+"\"" print("\""+allmp3s[settings["track%d"%i]-1]+"\"")
else: else:
print "" print("")
settings["track%d"%i]=0 settings["track%d"%i]=0
writesettings() writesettings()
print "" print("")
stamp() stamp()
print "Started" print("Started")
sys.stdout.flush() sys.stdout.flush()
#------------------------------------------------------------------ #------------------------------------------------------------------
#------------------------------------------------------------------ #------------------------------------------------------------------
@@ -214,12 +182,12 @@ while quit!=True:
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:
@@ -236,12 +204,12 @@ while quit!=True:
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
@@ -250,7 +218,7 @@ while quit!=True:
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])
showclock(tim) display.showclock(tim)
if count % 4 == 0: if count % 4 == 0:
colon=1-colon colon=1-colon
@@ -265,14 +233,10 @@ while quit!=True:
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)
showclock(tim) display.showclock(tim)
colon=1-colon colon=1-colon
else: else:
display.ShowDoublepoint(False) display.showclock(" O FF")
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
@@ -342,7 +306,7 @@ while quit!=True:
tim="%0d%0d:%0d " % (dh,sh,dm ) tim="%0d%0d:%0d " % (dh,sh,dm )
delta=0 delta=0
showclock(tim) display.showclock(tim)
colon=1-colon colon=1-colon
@@ -356,11 +320,11 @@ while quit!=True:
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:
@@ -413,7 +377,7 @@ while quit!=True:
tr+=1; tr+=1;
if tr>9: if tr>9:
looptype=0 looptype=0
showclock(tim) display.showclock(tim)
colon=1-colon colon=1-colon
if soundpreview: if soundpreview:
@@ -482,7 +446,7 @@ while quit!=True:
tim="%d=:%d " % (tr,th ) tim="%d=:%d " % (tr,th )
delta=0 delta=0
showclock(tim) display.showclock(tim)
colon=1-colon colon=1-colon
settings["track%d"%tr]=th*10+tl settings["track%d"%tr]=th*10+tl
@@ -514,14 +478,14 @@ while quit!=True:
else: else:
display.SetBrightnessRaw(brightness) display.SetBrightnessRaw(brightness)
tim="%02d:%02d" % (mytime[3] , mytime[4]) tim="%02d:%02d" % (mytime[3] , mytime[4])
showclock(tim) display.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()
@@ -540,9 +504,9 @@ while quit!=True:
alarmstarted=1 alarmstarted=1
else: # alarmstarted else: # alarmstarted
if playtime < o_timetomaxvol: if playtime < o_timetomaxvol:
brightness=(playtime / o_timetomaxvol)*6 brightness=int((playtime / o_timetomaxvol)*255)
volume = float(int((playtime*100) / o_timetomaxvol))/100 volume = float(int((playtime*100) / o_timetomaxvol))/100
# print "------> %d / %d => %f - %f"%(playtime,o_timetomaxvol,tvol,volume) # print("------> %d / %d => %f - %f [%d]"%(playtime,o_timetomaxvol,tvol,volume,brightness))
else: else:
volume=1 volume=1
@@ -555,7 +519,7 @@ while quit!=True:
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()
@@ -576,6 +540,8 @@ while quit!=True:
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
@@ -595,7 +561,7 @@ while quit!=True:
alarmstarted=0 alarmstarted=0
silencedalarm=1 silencedalarm=1
stamp() stamp()
print "Silenced alarm" print("Silenced alarm")
if but2.WasPressed(): if but2.WasPressed():
@@ -606,7 +572,7 @@ while quit!=True:
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])
@@ -621,7 +587,11 @@ while quit!=True:
#------------------------------------------------------------------ #------------------------------------------------------------------
stamp() if pygame.mixer.get_init():
print "Shutdown!" pygame.mixer.music.set_volume(0)
sys.stdout.flush() pygame.mixer.music.stop()
pygame.mixer.quit()
display.cleanup() display.cleanup()
sys.stdout.flush()
stamp()
print("Shutdown!")

View File

@@ -1,116 +0,0 @@
#!/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,67 +0,0 @@
#!/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()

64
max7219.py Normal file
View File

@@ -0,0 +1,64 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2017-18 Richard Hull and contributors
# See LICENSE.rst for details.
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 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 ] 0x07, 0x7f, 0x6f, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71, 0x49, 0x50, 0x40]
# 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 # 10 11 12 13 14 15 16 17 18
# #
# 0 # 0
# --- # ---
# | | # | |
# 5 | 7 | 1 # 5 | 6 | 1
# --- # ---
# | | # | |
# 4 | | 2 # 4 | | 2
@@ -31,6 +30,36 @@ 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
@@ -47,6 +76,7 @@ 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):
@@ -60,11 +90,18 @@ class TM1637:
self.__brightness = b self.__brightness = b
self.__doublePoint = point self.__doublePoint = point
def ShowInt(self, i): def showclock(self,tstr):
s = str(i) "Show da clock"
self.Clear()
for i in range(0, len(s)): if tstr[2]==':':
self.Show1(i, int(s[i])) 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): def Show(self, data):
for i in range(0, 4): for i in range(0, 4):
@@ -96,21 +133,13 @@ class TM1637:
self.writeByte(0x88 + int(self.__brightness)) self.writeByte(0x88 + int(self.__brightness))
self.stop() self.stop()
def SetBrightness(self, percent): def SetBrightnessRaw(self, briteness):
"""Accepts percent brightness from 0 - 1""" """Accepts raw brightness from 0 - 255"""
max_brightness = 7.0 brightness=briteness>>5
brightness = math.ceil(max_brightness * percent) # print("BR=%d",brightness)
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"""
@@ -171,109 +200,3 @@ 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()