Commit 24f95eef authored by doebi's avatar doebi
Browse files

added latest version from hatchery

parent cdbc0818
......@@ -4,7 +4,7 @@ import badge
import wifi
import appglue
from hashlib import sha1
import woezel
#import woezel
import uos
import ubinascii
......@@ -89,17 +89,23 @@ class WinkeKatze:
self.wink(colors)
if topic.endswith('/motd'):
self.motd = msg.decode("utf-8")
self.wink(''.join(['\0\0\50\0' for i in range(6)]))
if topic.endswith('/version'):
nv = int(msg.decode("utf-8"))
if nv > self.version:
woezel.install("Winkekatze")
appglue.start_app("Winkekatze")
self.draw_cat()
for i in range(2):
badge.leds_send_data(''.join(['\50\0\0\0' for i in range(6)]))
time.sleep(0.1)
badge.leds_send_data(''.join(['\0\0\0\0' for i in range(6)]))
time.sleep(0.1)
#if topic.endswith('/version'):
# nv = int(msg.decode("utf-8"))
# if nv > self.version:
# woezel.install("Winkekatze")
# appglue.start_app("Winkekatze")
if topic.endswith('/num_clients'):
self.clients = int(msg.decode("utf-8"))
self.draw_cat()
def wink(self, colors):
for count in [1,2,3]:
for count in range(2):
self.draw_cat(cat="down")
badge.leds_send_data(colors)
badge.vibrator_activate(127)
......@@ -143,7 +149,7 @@ class WinkeKatze:
self.server = server
self.topic = topic
self.clients = 0
self.version = 22
self.version = 32
self.nick = ''
self.nick1 = ''
self.nick2 = ''
......@@ -173,7 +179,9 @@ class WinkeKatze:
self.c.set_callback(self.sub_cb)
self.c.set_last_will(self.statustopic, 'OFFLINE')
self.c.connect()
self.c.subscribe("%s/#" % self.topic)
self.c.subscribe("%s/nick" % self.topic)
self.c.subscribe("%s/motd" % self.topic)
self.c.subscribe("%s/num_clients" % self.topic)
self.c.publish(self.statustopic, str(self.version), retain=True)
ugfx.clear(ugfx.BLACK)
......@@ -192,8 +200,13 @@ class WinkeKatze:
ugfx.input_attach(ugfx.BTN_B,lambda pressed: self.btn_b(pressed))
self.draw_cat()
last_status_update = time.time()
status_update_interval = 60
while True:
time.sleep(0.5)
self.c.check_msg()
if (time.time() > last_status_update + status_update_interval):
last_status_update = time.time()
self.c.publish(self.statustopic, str(self.version), retain=True)
wk = WinkeKatze()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment