git.haldean.org bitpic / cef3ea4
lots of little fixes! Haldean Brown 2 years ago
3 changed file(s) with 12 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
1717 if len(bits) != 3:
1818 return None
1919 typ = all_anims.get(bits[1], None)
20 bright = int(bits[2], 16)
2021 if type(current) == typ:
22 current.brightness = bright
2123 return current
22 return typ(brightness=int(bits[2], 16))
24 return typ(brightness=bright)
2325
2426 def encode(anim_name, brightness):
2527 return "anim/{}/{:02x}".format(anim_name, brightness)
155155
156156 def loop(self):
157157 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))
159159 if time_check or self.current_anim is None:
160160 new_screen = self.load()
161161 if new_screen is not None:
169169 self.write_screen(self.current_screen)
170170 time.sleep(5)
171171 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)
178179
179180 def main(self):
180181 try:
00 DEFAULT_SID = "__default"
1 HOST = "localhost:80"
1 HOST = "pic.so3.group"
22
33 class Screen:
44 DATA_VERSION = 0