Skip to content

Commit 6ba3d50

Browse files
committed
add support for 88005 light
1 parent 7f182d9 commit 6ba3d50

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

buildhat/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from .colordistance import ColorDistanceSensor
66
from .matrix import Matrix
77
from .wedo import TiltSensor, MotionSensor
8+
from .light import Light
89
from .hat import Hat
910
from .serinterface import BuildHAT
1011
from .exc import *

buildhat/devices.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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",

buildhat/light.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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))

0 commit comments

Comments
 (0)