Total Complexity | 3 |
Total Lines | 28 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import logging |
||
2 | |||
3 | from curio import sleep |
||
4 | from bricknil import attach, start |
||
5 | from bricknil.hub import PoweredUpHub |
||
6 | from bricknil.sensor import TrainMotor |
||
7 | from bricknil.process import Process |
||
8 | |||
9 | @attach(TrainMotor, name='motor') |
||
10 | class Train(PoweredUpHub): |
||
11 | |||
12 | async def run(self): |
||
13 | self.message_info("Running") |
||
14 | for i in range(2): |
||
15 | self.message_info('Increasing speed') |
||
16 | await self.motor.ramp_speed(80,5000) |
||
17 | await sleep(6) |
||
18 | self.message_info('Coming to a stop') |
||
19 | await self.motor.ramp_speed(0,1000) |
||
20 | await sleep(2) |
||
21 | |||
22 | async def system(): |
||
23 | train = Train('My train') |
||
24 | |||
25 | if __name__ == '__main__': |
||
26 | logging.basicConfig(level=logging.INFO) |
||
27 | start(system) |
||
28 |