lots of little fixes!
Haldean Brown
3 years ago
17 | 17 |
if len(bits) != 3:
|
18 | 18 |
return None
|
19 | 19 |
typ = all_anims.get(bits[1], None)
|
|
20 |
bright = int(bits[2], 16)
|
20 | 21 |
if type(current) == typ:
|
|
22 |
current.brightness = bright
|
21 | 23 |
return current
|
22 | |
return typ(brightness=int(bits[2], 16))
|
|
24 |
return typ(brightness=bright)
|
23 | 25 |
|
24 | 26 |
def encode(anim_name, brightness):
|
25 | 27 |
return "anim/{}/{:02x}".format(anim_name, brightness)
|
155 | 155 |
|
156 | 156 |
def loop(self):
|
157 | 157 |
time_check = (self.last_anim_check is None or
|
158 | |
datetime.now() - self.last_anim_check > timedelta(seconds=5))
|
|
158 |
datetime.now() - self.last_anim_check > timedelta(seconds=30))
|
159 | 159 |
if time_check or self.current_anim is None:
|
160 | 160 |
new_screen = self.load()
|
161 | 161 |
if new_screen is not None:
|
|
169 | 169 |
self.write_screen(self.current_screen)
|
170 | 170 |
time.sleep(5)
|
171 | 171 |
return
|
172 | |
# if we get here, we either didn't check for new data and are in an
|
173 | |
# animation, or we did check for new data and found out we're in
|
174 | |
# an animation.
|
175 | |
anim_screen = self.current_anim.get_screen()
|
176 | |
self.write_screen(anim_screen)
|
177 | |
time.sleep(self.current_anim.desired_frame_time)
|
|
172 |
if self.current_anim is not None:
|
|
173 |
# if we get here, we either didn't check for new data and are in an
|
|
174 |
# animation, or we did check for new data and found out we're in an
|
|
175 |
# animation.
|
|
176 |
anim_screen = self.current_anim.get_screen()
|
|
177 |
self.write_screen(anim_screen)
|
|
178 |
time.sleep(self.current_anim.desired_frame_time)
|
178 | 179 |
|
179 | 180 |
def main(self):
|
180 | 181 |
try:
|
0 | 0 |
DEFAULT_SID = "__default"
|
1 | |
HOST = "localhost:80"
|
|
1 |
HOST = "pic.so3.group"
|
2 | 2 |
|
3 | 3 |
class Screen:
|
4 | 4 |
DATA_VERSION = 0
|