Skip to content
This repository has been archived by the owner on Dec 23, 2021. It is now read-only.

Commit

Permalink
Merge branch 'users/t-vali/light-temp-accel-sensors' into users/t-anm…
Browse files Browse the repository at this point in the history
…ah/sensor-integration
  • Loading branch information
andreamah committed Feb 10, 2020
2 parents 9a9b1c1 + b5a523b commit fa0e7bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/microbit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from .__model.image import Image
from .__model.microbit_model import __mb

accelerometer = __mb.accelerometer
button_a = __mb.button_a
button_b = __mb.button_b
display = __mb.display
accelerometer = __mb.accelerometer


def sleep(n):
Expand Down
9 changes: 9 additions & 0 deletions src/microbit/__model/accelerometer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


class Accelerometer:
# The implementation is based off of https://microbit-micropython.readthedocs.io/en/v1.0.1/accelerometer.html.
def __init__(self):
self.__x = 0
self.__y = 0
Expand Down Expand Up @@ -108,6 +109,14 @@ def __get_accel(self, axis):
elif axis == "z":
return self.get_z()

def __set_accel(self, axis, accel):
if axis == "x":
self.__x = self.__get_valid_acceleration(accel)
elif axis == "y":
self.__y = self.__get_valid_acceleration(accel)
elif axis == "z":
self.__z = self.__get_valid_acceleration(accel)

def __set_gesture(self, gesture):
if gesture in CONSTANTS.GESTURES:
self.__current_gesture = gesture
Expand Down

0 comments on commit fa0e7bb

Please sign in to comment.