Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/newDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class HTX_Display
void draw_popup(String title);
void send_display_buffer(SPI_HandleTypeDef *hspi);
void display_min_cell(float min_cell_voltage);
void display_all_temps(veh_vec<int> temps);
void display_max_temps(int inverter_temp, int motor_temp);

uint8_t current_page = 0;

private:
Expand Down
29 changes: 27 additions & 2 deletions lib/interfaces/include/VCRInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ struct MotorMechanics_s
float actual_speed; //rpm
};

struct Temperature_s
{
veh_vec<int> inverter_temps;
veh_vec<int> motor_temps;
};

struct InverterStatus_s
{
veh_vec<bool> error;
veh_vec<float> dc_bus_voltage;
veh_vec<int> error_id;
};

class VCRInterface
{
Expand All @@ -24,22 +36,35 @@ class VCRInterface
bool is_in_pedals_calibration_state() {return _is_in_pedals_calibration_state;}

void receive_inv_dynamics(const CAN_message_t &can_msg, unsigned long curr_millis);

MotorMechanics_s get_curr_wheel_data() {return _wheel_data;}

void receive_vehicle_state(const CAN_message_t &can_msg);

VehicleState_e get_curr_car_state() {return _vehicle_state_value;}

bool get_drivebrain_in_control() {return _is_db_in_ctrl;}


void receive_inverter_status_1(const CAN_message_t &can_msg);
void receive_inverter_status_2(const CAN_message_t &can_msg);
void receive_inverter_status_3(const CAN_message_t &can_msg);
void receive_inverter_status_4(const CAN_message_t &can_msg);

void receive_inverter_temperature_1(const CAN_message_t &can_msg);
void receive_inverter_temperature_2(const CAN_message_t &can_msg);
void receive_inverter_temperature_3(const CAN_message_t &can_msg);
void receive_inverter_temperature_4(const CAN_message_t &can_msg);
int get_inverter_max_temp() {return std::max({_temps.inverter_temps.FL, _temps.inverter_temps.FR, _temps.inverter_temps.RL, _temps.inverter_temps.RR});}
int get_motor_max_temp() {return std::max({_temps.motor_temps.FL, _temps.motor_temps.FR, _temps.motor_temps.RL, _temps.motor_temps.RR});}

private:
TorqueLimit_e _torque_limit = TorqueLimit_e::TCMUX_LOW_TORQUE;
bool _is_in_pedals_calibration_state = false;
MotorMechanics_s _wheel_data;
VehicleState_e _vehicle_state_value;
DrivetrainState_e _drivetrain_state_value;
bool _is_db_in_ctrl;
InverterStatus_s _inverter_status;
Temperature_s _temps;
};


Expand Down
46 changes: 40 additions & 6 deletions lib/interfaces/src/DashCANInterfaceImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
void DashCAN::dash_read_switch(CANInterfaces &interfaces, const CAN_message_t &msg, unsigned long millis)
{
switch (msg.id) {
// case DASHBOARD_BUZZER_CONTROL_CANID:
// {
// interfaces.vcr_interface.receive_dash_control_data(_msg);
// break;
// }
case BMS_VOLTAGES_CANID:
{
interfaces.acu_interface.receive_acu_voltages(msg);
Expand Down Expand Up @@ -40,7 +35,46 @@ void DashCAN::dash_read_switch(CANInterfaces &interfaces, const CAN_message_t &m
interfaces.vcf_interface.receive_dashboard_message(msg, millis);
break;
}

case INV1_STATUS_CANID:
{
interfaces.vcr_interface.receive_inverter_status_1(msg);
break;
}
case INV2_STATUS_CANID:
{
interfaces.vcr_interface.receive_inverter_status_2(msg);
break;
}
case INV3_STATUS_CANID:
{
interfaces.vcr_interface.receive_inverter_status_3(msg);
break;
}
case INV4_STATUS_CANID:
{
interfaces.vcr_interface.receive_inverter_status_4(msg);
break;
}
case INV1_TEMPS_CANID:
{
interfaces.vcr_interface.receive_inverter_temperature_1(msg);
break;
}
case INV2_TEMPS_CANID:
{
interfaces.vcr_interface.receive_inverter_temperature_2(msg);
break;
}
case INV3_TEMPS_CANID:
{
interfaces.vcr_interface.receive_inverter_temperature_3(msg);
break;
}
case INV4_TEMPS_CANID:
{
interfaces.vcr_interface.receive_inverter_temperature_4(msg);
break;
}
default:
break;
}
Expand Down
65 changes: 65 additions & 0 deletions lib/interfaces/src/VCRInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,69 @@ void VCRInterface::receive_vehicle_state(const CAN_message_t &can_msg)
_vehicle_state_value = static_cast<VehicleState_e>(unpacked_msg.vehicle_state);
_drivetrain_state_value = static_cast<DrivetrainState_e>(unpacked_msg.drivetrain_state);
_is_db_in_ctrl = unpacked_msg.drivebrain_in_control;
}

void VCRInterface::receive_inverter_status_1(const CAN_message_t &can_msg)
{
INV1_STATUS_t unpacked_msg;
Unpack_INV1_STATUS_hytech(&unpacked_msg, can_msg.buf, can_msg.len); //NOLINT
_inverter_status.error.FL = unpacked_msg.error;
_inverter_status.dc_bus_voltage.FL = unpacked_msg.dc_bus_voltage;
}

void VCRInterface::receive_inverter_status_2(const CAN_message_t &can_msg)
{
INV2_STATUS_t unpacked_msg;
Unpack_INV2_STATUS_hytech(&unpacked_msg, can_msg.buf, can_msg.len); //NOLINT
_inverter_status.error.FR = unpacked_msg.error;
_inverter_status.dc_bus_voltage.FR = unpacked_msg.dc_bus_voltage;

}

void VCRInterface::receive_inverter_status_3(const CAN_message_t &can_msg)
{
INV3_STATUS_t unpacked_msg;
Unpack_INV3_STATUS_hytech(&unpacked_msg, can_msg.buf, can_msg.len); //NOLINT
_inverter_status.error.RL = unpacked_msg.error;
_inverter_status.dc_bus_voltage.RL = unpacked_msg.dc_bus_voltage;
}

void VCRInterface::receive_inverter_status_4(const CAN_message_t &can_msg)
{
INV4_STATUS_t unpacked_msg;
Unpack_INV4_STATUS_hytech(&unpacked_msg, can_msg.buf, can_msg.len); //NOLINT
_inverter_status.error.RR = unpacked_msg.error;
_inverter_status.dc_bus_voltage.RR = unpacked_msg.dc_bus_voltage;
}

void VCRInterface::receive_inverter_temperature_1(const CAN_message_t &can_msg)
{
INV1_TEMPS_t unpacked_msg;
Unpack_INV1_TEMPS_hytech(&unpacked_msg, can_msg.buf, can_msg.len); //NOLINT
_temps.motor_temps.FL = HYTECH_motor_temp_ro_fromS(unpacked_msg.motor_temp_ro);
_temps.inverter_temps.FL = HYTECH_inverter_temp_ro_fromS(unpacked_msg.inverter_temp_ro);
}

void VCRInterface::receive_inverter_temperature_2(const CAN_message_t &can_msg)
{
INV2_TEMPS_t unpacked_msg;
Unpack_INV2_TEMPS_hytech(&unpacked_msg, can_msg.buf, can_msg.len); //NOLINT
_temps.motor_temps.FR = HYTECH_motor_temp_ro_fromS(unpacked_msg.motor_temp_ro);
_temps.inverter_temps.FR = HYTECH_inverter_temp_ro_fromS(unpacked_msg.inverter_temp_ro);
}

void VCRInterface::receive_inverter_temperature_3(const CAN_message_t &can_msg)
{
INV3_TEMPS_t unpacked_msg;
Unpack_INV3_TEMPS_hytech(&unpacked_msg, can_msg.buf, can_msg.len); //NOLINT
_temps.motor_temps.RL = HYTECH_motor_temp_ro_fromS(unpacked_msg.motor_temp_ro);
_temps.inverter_temps.RL = HYTECH_inverter_temp_ro_fromS(unpacked_msg.inverter_temp_ro);
}

void VCRInterface::receive_inverter_temperature_4(const CAN_message_t &can_msg)
{
INV4_TEMPS_t unpacked_msg;
Unpack_INV4_TEMPS_hytech(&unpacked_msg, can_msg.buf, can_msg.len); //NOLINT
_temps.motor_temps.RR = HYTECH_motor_temp_ro_fromS(unpacked_msg.motor_temp_ro);
_temps.inverter_temps.RR = HYTECH_inverter_temp_ro_fromS(unpacked_msg.inverter_temp_ro);
}
6 changes: 3 additions & 3 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ build_src_filter =
build_flags =
-std=c++17
-D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
-D USBCON
#-D USBCON
-D USBD_VID=0x0483
-D USBD_PID=0x0003
-D USE_HAL_DRIVER
-D HAL_PCD_MODULE_ENABLED
-D HAL_FDCAN_MODULE_ENABLED
-D USBCON
-D USBD_USE_CDC
#-D USBCON
#-D USBD_USE_CDC
-D HSE_VALUE=25000000
check_src_filters =
+<include/*>
Expand Down
7 changes: 6 additions & 1 deletion src/Dash_Tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
#define SHARP_CS PB4
#define SHARP_CLK PB10
#define SHARP_MOSI PB15

veh_vec<int> fake_temps = {30, 32, 28, 31};


HT_TASK::TaskResponse init_heartbeat(const unsigned long& sys_micros, const HT_TASK::TaskInfo& task_info)
{
SerialUSB.begin(115200);
//SerialUSB.begin(115200);

// Create Interfaces
ACUInterfaceInstance::create();
Expand Down Expand Up @@ -58,10 +60,13 @@ HT_TASK::TaskResponse screen_refresh(const unsigned long& sys_micros, const HT_T
HTXDisplayInstance::instance().draw_background();
HTXDisplayInstance::instance().invert_display(VCFInterfaceInstance::instance().is_mech_brake_pressed());
HTXDisplayInstance::instance().draw_vertical_pedal_bar(VCFInterfaceInstance::instance().get_curr_data().stamped_pedals.pedals_data.brake_percent * 100, 17);
HTXDisplayInstance::instance().draw_vertical_pedal_bar(VCFInterfaceInstance::instance().get_curr_data().stamped_pedals.pedals_data.accel_percent * 100, 46);

HTXDisplayInstance::instance().draw_battery_bar((ACUInterfaceInstance::instance().get_curr_data().pack_voltage - 460) / 70 * 100.0 + 1);
HTXDisplayInstance::instance().draw_icons(1, VCRInterfaceInstance::instance().get_curr_car_state(), VCRInterfaceInstance::instance().get_drivebrain_in_control());
HTXDisplayInstance::instance().display_mode(VCFInterfaceInstance::instance().get_control_mode());
HTXDisplayInstance::instance().display_min_cell(ACUInterfaceInstance::instance().get_curr_data().min_cell_voltage);
HTXDisplayInstance::instance().display_max_temps(VCRInterfaceInstance::instance().get_inverter_max_temp(), VCRInterfaceInstance::instance().get_motor_max_temp());
//HTXDisplayInstance::instance().display_speeds(VCRInterfaceInstance::instance().get_curr_wheel_data().actual_speed);

if (ACUInterfaceInstance::instance().get_curr_data().imd_ok == false || ACUInterfaceInstance::instance().get_curr_data().bms_ok == false)
Expand Down
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void setup() {
void loop() {
scheduler.run();

Serial.println(ACUInterfaceInstance::instance().get_curr_data().pack_voltage);
Serial.println(VCFInterfaceInstance::instance().get_curr_data().stamped_pedals.pedals_data.brake_percent);
//Serial.println(ACUInterfaceInstance::instance().get_curr_data().pack_voltage);
//Serial.println(VCFInterfaceInstance::instance().get_curr_data().stamped_pedals.pedals_data.brake_percent);
}

45 changes: 42 additions & 3 deletions src/newDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ void HTX_Display::draw_background()
{
_display.clearDisplayBuffer();
_display.fillRect(0, 0, 320, 240, _white);
_display.drawBitmap(0, 0, epd_bitmap_hytech_dashboard, 320, 240, _black);
_display.fillRect(15, 33, 22, 179, _black);
_display.fillRect(44, 33, 22, 179, _black);
//_display.drawBitmap(0, 0, epd_bitmap_hytech_dashboard, 320, 240, _black);
_display.fillRect(320 - 40, 30, 40, 200, _white);
//_display.fillRect(283, 36, 305 - 283, 210 - 36, _black);
_display.fillRect(283 - 3, (36 + 210 - 36) / 2 + 15, 25, 7, _white);
Expand Down Expand Up @@ -136,16 +138,53 @@ void HTX_Display::display_mode(int mode)

void HTX_Display::display_min_cell(float min_cell_voltage)
{
_display.setFont(&FreeSans12pt7b);
_display.setFont(&FreeSans9pt7b);
_display.setTextSize(1);
_display.setTextColor(_black);

_display.setCursor(220, 100);
_display.setCursor(230, 100);
_display.print("CEL:");
_display.setCursor(270, 100);

// SerialUSB.println(mph);
_display.print(min_cell_voltage);
}



void HTX_Display::display_max_temps(int inverter_temp, int motor_temp)
{
_display.setFont(&FreeSans9pt7b);
_display.setTextSize(1);
_display.setTextColor(_black);
_display.setCursor(235, 130);
_display.print("TEMPS");
_display.setCursor(230, 150);
_display.print("INV:");
_display.setCursor(265, 150);
_display.print(inverter_temp);
_display.setCursor(230, 170);
_display.print("MTR:");
_display.setCursor(275, 170);
_display.print(motor_temp);
}

void HTX_Display::display_all_temps(veh_vec<int> temps)
{
_display.setFont(&FreeSans9pt7b);
_display.setTextSize(1);
_display.setTextColor(_black);

_display.setCursor(220, 120);
_display.print(temps.FL);
_display.setCursor(250, 120);
_display.print(temps.FR);
_display.setCursor(220, 140);
_display.print(temps.RL);
_display.setCursor(250, 140);
_display.print(temps.RR);
}

void HTX_Display::draw_icons(uint8_t vn_status, VehicleState_e car_state, bool db_in_ctrl)
{

Expand Down
Loading