Skip to content

Commit

Permalink
Fixed #53.
Browse files Browse the repository at this point in the history
Signed-off-by: ATATC <[email protected]>
  • Loading branch information
ATATC committed Feb 15, 2024
1 parent 80e3200 commit 11db7c9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 23 deletions.
1 change: 0 additions & 1 deletion leads_gui/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from typing import Any as _Any

from leads.config import ConfigTemplate as _ConfigTemplate
from leads_gui.system import get_system_platform


class Config(_ConfigTemplate):
Expand Down
3 changes: 1 addition & 2 deletions leads_gui/prototype.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from math import lcm as _lcm
from time import sleep as _sleep
from typing import Callable as _Callable, Self as _Self, TypeVar as _TypeVar, Generic as _Generic

from customtkinter import CTk as _CTk, CTkBaseClass as _CTkBaseClass, CTkLabel as _CTkLabel
from customtkinter import CTk as _CTk, CTkBaseClass as _CTkBaseClass

from leads_gui.runtime import RuntimeData
from leads_gui.system import get_system_platform
Expand Down
33 changes: 15 additions & 18 deletions leads_vec/controller.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from leads import L, device, controller, MAIN_CONTROLLER, get_controller, WHEEL_SPEED_CONTROLLER, THROTTLE_PEDAL, \
SRWDataContainer, DRWDataContainer, BRAKE_PEDAL, DC_MOTOR_CONTROLLER_A
from leads.config import get_config
from leads_gui import Config
from leads import L, controller, MAIN_CONTROLLER, get_controller, WHEEL_SPEED_CONTROLLER, SRWDataContainer, \
DRWDataContainer
from leads.comm import Callback, Service, ConnectionBase
from leads.config import get_config
from leads_arduino import ArduinoMicro
from leads_raspberry_pi import RaspberryPi4B, Pedal, DCMotorController
from leads_gui import Config
from leads_raspberry_pi import RaspberryPi4B

config = get_config(Config)
BAUD_RATE: int = config.get("baud_rate", 9600)
Expand All @@ -17,11 +17,8 @@
@controller(MAIN_CONTROLLER)
class VeCController(RaspberryPi4B):
def read(self) -> SRWDataContainer | DRWDataContainer:
return SRWDataContainer(
*get_controller(WHEEL_SPEED_CONTROLLER).read()
) if config.srw_mode else DRWDataContainer(
*get_controller(WHEEL_SPEED_CONTROLLER).read()
)
r = get_controller(WHEEL_SPEED_CONTROLLER).read()
return SRWDataContainer(*r) if config.srw_mode else DRWDataContainer(*r)


class WheelSpeedControllerCallback(Callback):
Expand All @@ -48,16 +45,16 @@ def read(self) -> [float, float]:
return self._wheel_speed, self._wheel_speed


@device((THROTTLE_PEDAL, BRAKE_PEDAL), MAIN_CONTROLLER, [(THROTTLE_PEDAL_PIN, False), (BRAKE_PEDAL_PIN, True)])
class Pedals(Pedal):
def __init__(self, pin: int, brake: bool) -> None:
super().__init__(pin)
self._brake: bool = brake
# @device((THROTTLE_PEDAL, BRAKE_PEDAL), MAIN_CONTROLLER, [(THROTTLE_PEDAL_PIN, False), (BRAKE_PEDAL_PIN, True)])
# class Pedals(Pedal):
# def __init__(self, pin: int, brake: bool) -> None:
# super().__init__(pin)
# self._brake: bool = brake


@device(DC_MOTOR_CONTROLLER_A, MAIN_CONTROLLER)
class DriverMotorController(DCMotorController):
pass
# @device(DC_MOTOR_CONTROLLER_A, MAIN_CONTROLLER)
# class DriverMotorController(DCMotorController):
# pass


_ = None # null export
3 changes: 1 addition & 2 deletions leads_vec_rc/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

from leads import L
from leads.config import *
from leads.comm import *
from leads.config import *
from leads.data_persistence import *
from leads_gui import *

Expand Down

0 comments on commit 11db7c9

Please sign in to comment.