Skip to content
Snippets Groups Projects

imu: make it part of InputState

Merged schneider requested to merge schneider/imu-inputstate into main
All threads resolved!
+ 22
22
@@ -8,6 +8,26 @@ from st3m.power import Power
power = Power()
class IMUState:
"""
State of the Inertial Measurement Unit
Acceleration in m/s**2, roation rate in deg/s, pressure in Pascal
"""
__slots__ = ("acc", "gyro", "pressure")
def __init__(
self,
acc: Tuple[float, float, float],
gyro: Tuple[float, float, float],
pressure: float,
) -> None:
self.acc = acc
self.gyro = gyro
self.pressure = pressure
class InputState:
"""
Current state of inputs from badge user. Passed via think() to every
@@ -46,14 +66,14 @@ class InputState:
acc = imu.acc_read()
gyro = imu.gyro_read()
pressure, temperature = imu.pressure_read()
imu = IMUState(acc, gyro, pressure)
imu_state = IMUState(acc, gyro, pressure)
battery_voltage = power.battery_voltage
return InputState(
cts,
left_button,
right_button,
imu,
imu_state,
temperature,
battery_voltage,
)
@@ -463,26 +483,6 @@ class TriSwitchState:
self.right._ignore_pressed()
class IMUState:
"""
State of the Inertial Measurement Unit
Acceleration in m/s**2, roation rate in deg/s, pressure in Pascal
"""
__slots__ = ("acc", "gyro", "pressure")
def __init__(
self,
acc: Tuple[float, float, float],
gyro: Tuple[float, float, float],
pressure: float,
) -> None:
self.acc = acc
self.gyro = gyro
self.pressure = pressure
class InputController:
"""
A stateful input controller. It accepts InputState updates from the Reactor
Loading