GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( d74eb3...fdd290 )
by Virantha
01:35
created

boost_motor_position.Robot.run()   A

Complexity

Conditions 2

Size

Total Lines 32
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 20
nop 1
dl 0
loc 32
rs 9.4
c 0
b 0
f 0
1
import logging
2
3
from curio import sleep, Queue
4
from bricknil import attach, start
5
from bricknil.hub import PoweredUpRemote, BoostHub
6
from bricknil.sensor import InternalMotor, RemoteButtons, LED, Button, ExternalMotor
7
from bricknil.process import Process
8
from bricknil.const import Color
9
10
from random import randint
11
12
@attach(LED, name='led') 
13
@attach(ExternalMotor, name='motor')
14
class Robot(BoostHub):
15
    """ Rotate the external motor connected to a boost hub by degrees
16
17
        Demonstrate both the absolute positioning as well as relative rotation.
18
    """
19
20
    async def run(self):
21
        self.message("Running")
22
23
        # Set the robot LED to green to show we're ready
24
        await self.led.set_color(Color.green)
25
        await sleep(2)
26
27
        # The powered on position becomes the 12 o'clock reference point
28
29
        for i in range(5):
30
            # Turn to 11 o'clock position
31
            await self.led.set_color(Color.blue)
32
            await self.motor.set_pos(-30, speed=50)
33
            await sleep(2)
34
            await self.led.set_color(Color.red)
35
            # Turn to 1 o'clock position
36
            await self.motor.set_pos(30, speed=30)
37
            await sleep(2)
38
            await self.led.set_color(Color.yellow)
39
            # Turn to 3 o'clock position
40
            await self.motor.set_pos(90, speed=20)
41
            await sleep(2)
42
43
            # Rotate a random amount of degrees from 1 to 180
44
            await self.led.set_color(Color.purple)
45
            await self.motor.rotate(randint(1,180), speed=10)
46
            await sleep(3)
47
48
            # Then reset to 12 o'clock position
49
            await self.led.set_color(Color.green)
50
            await self.motor.set_pos(0)
51
            await sleep(2)
52
53
54
55
async def system():
56
    robot = Robot('Vernie')
57
    
58
if __name__ == '__main__':
59
    logging.basicConfig(level=logging.DEBUG)
60
    start(system)
61