Skip to content

Commit e72ef10

Browse files
committed
Add light sensor to peripherals
1 parent c62f549 commit e72ef10

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

adafruit_magtag/peripherals.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ def __init__(self):
5656
self._speaker_enable.direction = Direction.OUTPUT
5757
self._speaker_enable.value = False
5858

59+
# Battery Voltage
60+
self._light = AnalogIn(board.LIGHT)
61+
5962
# Buttons
6063
self.buttons = []
6164
for pin in (board.BUTTON_A, board.BUTTON_B, board.BUTTON_C, board.BUTTON_D):
@@ -143,3 +146,11 @@ def any_button_pressed(self):
143146
Return whether any button is pressed
144147
"""
145148
return False in [self.buttons[i].value for i in range(0, 4)]
149+
150+
@property
151+
def light(self):
152+
"""
153+
Return the value of the light sensor. The neopixel_disable property
154+
must be false to get a value.
155+
"""
156+
return self._light.value

0 commit comments

Comments
 (0)