Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added more granular swatch time, small refactoring

  • Loading branch information...
commit 37ca7e9fa0b225d442a6b02dfeddbded2e51b100 1 parent 6b8d1a1
@mhenstell mhenstell authored
Showing with 23 additions and 13 deletions.
  1. +23 −13 hexaservice/service.py
View
36 hexaservice/service.py
@@ -10,8 +10,6 @@
debug = False
-
-
def internet_time():
"Swatch Internet Time. Biel meridian."
h, m, s = time.gmtime()[3:6]
@@ -21,6 +19,25 @@ def internet_time():
beats = beats % 1000.0
return beats
+def internet_time2():
+ "More granular Swatch time. Courtesy https://github.com/gcohen55/pebble-beapoch"
+ return (((time.time() + 3600) % 86400) * 1000) / 86400
+
+def render_time_bitmap():
+ "Render local time + Swatch beats into a 2-panel bitmap"
+ beats = internet_time2()
+ msg = time.strftime("%H:%M:%S")
+ txtimg = base_font.strImg(msg)
+ img = Image.new("1",(120,7))
+ img.paste(txtimg,(15,0))
+ bmsg = "{0:03.2f}".format(beats)
+ txt2img = base_font.strImg(bmsg)
+ img.paste(txt2img,(62,0))
+ img.paste(base_font.strImg(".beats"),(93,0))
+ bitmap = compile_image(img,0,0)
+
+ return bitmap
+
class PanelThread(threading.Thread):
def __init__(self, panel):
pass
@@ -45,20 +62,13 @@ def sigint_handler(signal,frame):
signal.signal(signal.SIGINT,sigint_handler)
while True:
- beats = internet_time()
- msg = time.strftime("%H:%M:%S")
- txtimg = base_font.strImg(msg)
- img = Image.new("1",(120,7))
- img.paste(txtimg,(15,0))
- bmsg = "{0:03.2f}".format(beats)
- txt2img = base_font.strImg(bmsg)
- img.paste(txt2img,(62,0))
- img.paste(base_font.strImg(".beats"),(93,0))
- bitmap = compile_image(img,0,0)
+
+ bitmap = render_time_bitmap()
for j in range(3):
panels[j].setCompiledImage(bitmap)
- time.sleep(0.1)
+
+ time.sleep(0.10)
panels[0].setRelay(False)
Please sign in to comment.
Something went wrong with that request. Please try again.