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 55from .colordistance import ColorDistanceSensor
66from .matrix import Matrix
77from .wedo import TiltSensor , MotionSensor
8+ from .light import Light
89from .hat import Hat
910from .serinterface import BuildHAT
1011from .exc import *
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ class Device:
1111 _instance = None
1212 _started = 0
1313 _device_names = { 2 : "PassiveMotor" ,
14+ 8 : "Light" ,
1415 34 : "TiltSensor" ,
1516 35 : "MotionSensor" ,
1617 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