1
|
|
|
import logging |
2
|
|
|
from itertools import cycle |
3
|
|
|
from curio import sleep |
4
|
|
|
from bricknil import attach, start |
5
|
|
|
from bricknil.hub import PoweredUpRemote |
6
|
|
|
from bricknil.sensor import TrainMotor, VisionSensor, Button, LED, InternalTiltSensor, InternalMotor, RemoteButtons |
7
|
|
|
from bricknil.process import Process |
8
|
|
|
from bricknil.const import Color |
9
|
|
|
|
10
|
|
|
@attach(Button, name='hub_btn', capabilities=['sense_press']) |
11
|
|
|
@attach(RemoteButtons, name='btn_r', capabilities=['sense_press']) |
12
|
|
|
@attach(RemoteButtons, name='btn_l', capabilities=['sense_press']) |
13
|
|
|
class Remote(PoweredUpRemote): |
14
|
|
|
|
15
|
|
|
async def hub_btn_change(self): |
16
|
|
|
self.message_info(f'Hub Btn change {self.hub_btn.value}') |
17
|
|
|
async def btn_r_change(self): |
18
|
|
|
self.message_info(f'Btn r change {self.btn_r.value}') |
19
|
|
|
async def btn_l_change(self): |
20
|
|
|
self.message_info(f'Btn l change {self.btn_l.value}') |
21
|
|
|
|
22
|
|
|
async def run(self): |
23
|
|
|
self.message_info("Running") |
24
|
|
|
await sleep(20) # Give it enough time to gather data |
25
|
|
|
|
26
|
|
|
async def system(): |
27
|
|
|
remote = Remote('remote', True) |
28
|
|
|
|
29
|
|
|
if __name__ == '__main__': |
30
|
|
|
logging.basicConfig(level=logging.INFO) |
31
|
|
|
start(system) |
32
|
|
|
|