import uasyncio as asyncio import machine import Hardware as HW class HousingCapButton(): def __init__(self, pin): self.tp = machine.TouchPad(machine.Pin(15)) reading = self.tp.read() self.value_avrg = [reading]*3 self.value_avrg2 = [reading]*4 loop = asyncio.get_event_loop() #loop.create_task(self._update_async()) async def _update_async(self): while True: await asyncio.sleep_ms(100) reading = self.tp.read() self.value_avrg = [reading*(10**-i) + (1-(10**-i))*v for i,v in enumerate(self.value_avrg)] #self.value_avrg2 = [max(v,max(self.value_avrg[1:i])) for i,v in enumerate(self.value_avrg[1:])] print("\t".join([str(v) for v in self.value_avrg])) if self.value_avrg[1] <= 80: #and not HW.buzzer.isPlaying() HW.buzzer.playSound(HW.Buzzer.BEEP)