Skip to content

Commit

Permalink
Added buttons for indicators. (#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
ATATC committed Dec 12, 2024
1 parent 4c8572e commit 900f1e7
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions leads_vec/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
Controller, CENTER_REAR_WHEEL_SPEED_SENSOR, require_config, mark_device, ODOMETER, GPS_RECEIVER, \
ConcurrentOdometer, LEFT_INDICATOR, RIGHT_INDICATOR, VOLTAGE_SENSOR, DataContainer, has_device, \
FRONT_VIEW_CAMERA, LEFT_VIEW_CAMERA, RIGHT_VIEW_CAMERA, REAR_VIEW_CAMERA, VisualDataContainer, BRAKE_INDICATOR, \
SFT, read_device_marker, has_controller, POWER_CONTROLLER, WHEEL_SPEED_CONTROLLER, ACCELEROMETER
SFT, read_device_marker, has_controller, POWER_CONTROLLER, WHEEL_SPEED_CONTROLLER, ACCELEROMETER, require_context
from leads_arduino import ArduinoMicro, WheelSpeedSensor, VoltageSensor, Accelerometer, Acceleration
from leads_comm_serial import SOBD
from leads_gpio import NMEAGPSReceiver, LEDGroup, LED, LEDGroupCommand, LEDCommand, Entire, Transition
from leads_gpio import NMEAGPSReceiver, LEDGroup, LED, LEDGroupCommand, LEDCommand, Entire, Transition, Button, \
ButtonCallback
from leads_vec.config import Config
from leads_video import Base64Camera, get_camera

Expand Down Expand Up @@ -213,4 +214,30 @@ def write(self, payload: bool) -> None:
) if payload else LEDGroupCommand(LEDCommand.OFF, Entire()))


@device("lib", MAIN_CONTROLLER)
class LeftIndicatorButton(Button, ButtonCallback):
@override
def on_pressed(self) -> None:
ctx = require_context()
ctx.left_indicator(not ctx.left_indicator())

@override
def initialize(self, *parent_tags: str) -> None:
super().initialize(*parent_tags)
self.write(self)


@device("rib", MAIN_CONTROLLER)
class RightIndicatorButton(Button, ButtonCallback):
@override
def on_pressed(self) -> None:
ctx = require_context()
ctx.right_indicator(not ctx.right_indicator())

@override
def initialize(self, *parent_tags: str) -> None:
super().initialize(*parent_tags)
self.write(self)


_: None = None

0 comments on commit 900f1e7

Please sign in to comment.