Skip to content

Commit

Permalink
created PowerCANInterface handler for the DashboardCommands struct
Browse files Browse the repository at this point in the history
  • Loading branch information
TamerTimraz committed Oct 27, 2024
1 parent e89d123 commit 40d342f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions PowerBoard/lib/include/PowerCANInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
#include "CANInterface.h"
#include "ECUCANStructs.h"
#include "MotorControllerCANStructs.h"
#include "DashboardCommandsCANStruct.h"

class PowerCANInterface : public CANInterface {
public:
PowerCANInterface(PinName rd, PinName td, PinName standby_pin);
void handle(DashboardCommands *can_struct);
int send(CANStruct *can_struct);

private:
Expand Down
14 changes: 13 additions & 1 deletion PowerBoard/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ I2C regen(NC, NC);
MotorInterface motor_interface(throttle, regen);

// Need to update powercaninterface
// PowerCANInterface vehicle_can_interface(UART5_RX, UART5_TX, DEBUG_SWITCH);
PowerCANInterface vehicle_can_interface(NC, NC, NC);

// Placeholders for DigitalIn pins
bool flashLeftTurnSignal = false;
Expand All @@ -60,6 +60,8 @@ bool contact_12_error = false;
bool has_faulted = false;
bool regen_enabled = false;
bool cruise_control_enabled = false;
bool cruise_control_increase = false;
bool cruise_control_decrease = false;

/**
* Function that handles the flashing of the turn signals and hazard lights.
Expand Down Expand Up @@ -172,4 +174,14 @@ int main() {
drl.write(PIN_ON);
queue.call_every(MOTOR_STATUS_LOOP_PERIOD, set_motor_status);
queue.dispatch_forever();
}

void PowerCANInterface::handle(DashboardCommands *can_struct){
flashHazards = can_struct->hazards;
flashLeftTurnSignal = can_struct->left_turn_signal;
flashRightTurnSignal = can_struct->right_turn_signal;
regen_enabled = can_struct->regen_en;
cruise_control_enabled = can_struct->cruise_en;
cruise_control_increase = can_struct->cruise_inc;
cruise_control_decrease = can_struct->cruise_dec;
}

0 comments on commit 40d342f

Please sign in to comment.