def run(self):
trash_counter = 10
trash = None
while True:
gc.collect()
gc.threshold(gc.mem_free() // 4 + gc.mem_alloc())
self.handle_duty_cycle()
trash_counter -= 1
if trash_counter == 0:
self.handle_year_changed()
trash = self.get_trash_tomorrow()
trash_counter = 10
print(trash)
if not self.wlan.isconnected():
print("Reconnecting to {0}...".format(self.essid))
self.wlan.connect(self.essid, self.password)
if trash != None:
if "b" in self.types:
self.set_red("b" in trash)
p = False
if "p" in self.types:
p = p or ("p" in trash)
if "p4" in self.types:
p = p or ("p4" in trash)
self.set_blue(p)
r = False
if "r" in self.types:
r = r or ("r" in trash)
if "r2" in self.types:
r = r or ("r2" in trash)
if "r4" in self.types:
r = r or ("r4" in trash)
self.set_white(r)
if "g" in self.types:
self.set_yellow("g" in trash)
time.sleep(1)
评论列表
文章目录