Skip to content

Add light sensor to peripherals #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 15, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions adafruit_magtag/peripherals.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def __init__(self):
self._speaker_enable.direction = Direction.OUTPUT
self._speaker_enable.value = False

# Battery Voltage
self._light = AnalogIn(board.LIGHT)

# Buttons
self.buttons = []
for pin in (board.BUTTON_A, board.BUTTON_B, board.BUTTON_C, board.BUTTON_D):
Expand Down Expand Up @@ -143,3 +146,11 @@ def any_button_pressed(self):
Return whether any button is pressed
"""
return False in [self.buttons[i].value for i in range(0, 4)]

@property
def light(self):
"""
Return the value of the light sensor. The neopixel_disable property
must be false to get a value.
"""
return self._light.value