File tree Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Original file line number Diff line number Diff line change 5
5
from .colordistance import ColorDistanceSensor
6
6
from .matrix import Matrix
7
7
from .wedo import TiltSensor , MotionSensor
8
+ from .light import Light
8
9
from .hat import Hat
9
10
from .serinterface import BuildHAT
10
11
from .exc import *
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ class Device:
11
11
_instance = None
12
12
_started = 0
13
13
_device_names = { 2 : "PassiveMotor" ,
14
+ 8 : "Light" ,
14
15
34 : "TiltSensor" ,
15
16
35 : "MotionSensor" ,
16
17
37 : "ColorDistanceSensor" ,
Original file line number Diff line number Diff line change
1
+ from .devices import Device
2
+ from .exc import DeviceInvalid
3
+
4
+ class Light (Device ):
5
+ """Light
6
+
7
+ Use on()/off() functions to turn lights on/off
8
+
9
+ :param port: Port of device
10
+ :raises DeviceInvalid: Occurs if there is no light attached to port
11
+ """
12
+ def __init__ (self , port ):
13
+ super ().__init__ (port )
14
+ if self .typeid != 8 :
15
+ raise DeviceInvalid ('There is not a light connected to port %s (Found %s)' % (port , self .name ))
You can’t perform that action at this time.
0 commit comments