MCU
Loading...
Searching...
No Matches
DashboardInterface.h
Go to the documentation of this file.
1#ifndef __DASHBOARDINTERFACE_H__
2#define __DASHBOARDINTERFACE_H__
3
5#include "FlexCAN_T4.h"
6#include "hytech.h"
7#include "MCUInterface.h"
8#include "InverterInterface.h"
9#include "SharedDataTypes.h"
10
11
12
13/* Enum for defined LED colors. ON will be LED's default color on dashboard*/
14enum class LEDColors_e
15{
16 OFF,
17 ON,
18 YELLOW,
19 RED,
20};
21
22/* Enum to index the LED array. Each LED in the CAN message is represented in no particular order. */
23enum class DashLED_e
24{
31 GLV_LED,
33 START_LED,
35 IMD_LED,
36 AMS_LED,
37};
38
39/* Struct holding the state of Dashboard buttons */
41{
42 bool start;
43 bool mark;
44 bool mode; // torque mode
45 bool mc_cycle; // clears encoder error codes
47 bool torque_mode; // torque loading
51};
52
53
54/* Struct holding all data for the DashboardInterface (inputs and outputs) */
56{
57 /* READ DATA */
58 // enum for dial position read by controller mux
62 // Buttons struct for better naming
64 bool ssok; // safety system OK (IMD?) RENAME
67
68 /* WRITTEN DATA */
70 //making it an array of ints to support enumerated LEDs as well as
71 //gradient/value based LEDs
72 uint8_t LED[12] = {};
73};
74
75/*
76 The DashboardInterface is an interface that handles all data to and from the dashboard.
77 Through a set of setters and getters (not explicitly named set/get) the state machine,
78 other interfaces, and systems can update the information on the dashboard.
79 Currently this is written to be a 1 to 1 representation of the current state of the dashboard,
80 almost no display logic for the below basic components is handled by the dash.
81*/
83{
84private:
85 /* Pointer to the circular buffer to write new messages */
87 /* The instantiated data struct used to access data by member functions */
90 void update_torque_mode_(bool button_pressed);
91
92public:
100 {
101 _data.torque_limit_mode = TorqueLimit_e::TCMUX_FULL_TORQUE;
103 msg_queue_ = msg_output_queue;
104 };
105
111 void read(const CAN_message_t &can_msg);
112
113 /* write function will Pack a message based on the current data in the interface and push it to the tx buffer */
114 CAN_message_t write();
115
116 /*
117 Tick DashboardInterface at 10hz to gather data and send CAN message
118 */
119 void tick10(MCUInterface* mcu,
120 int car_state,
121 bool buzzer,
122 bool drivetrain_error,
123 TorqueLimit_e torque,
124 float min_cell_voltage,
125 AnalogConversion_s glv_voltage,
126 int launch_state,
127 ControllerMode_e dial_mode);
128
135 /* gets whether the safety system is ok (wtf is a safety system - rename this)*/
136 bool safetySystemOK();
137
138 /* getter for the start button */
139 bool startButtonPressed();
140 /* getter for the mark button */
142 /* getter for the torque button (does not currently exist on dash ) */
144 /* getter for the inverter reset button (clears error codes ) */
146 /* getter for the launch control button */
148 /* getter for the torque mode/level button */
150 /* getter for the dimmer button (this logic handled on dash ) */
154 /* getter for the current shutdown threshold on the dashboard*/
156 /* setter for the buzzer */
157 void soundBuzzer(bool s);
158 /* getter for the buzzer */
159 bool checkBuzzer();
160
161 // LEDs in same order as dash rev. 7 placement
162
168 void setLED(DashLED_e led, LEDColors_e color);
169};
170
171#endif /* __DASHBOARDINTERFACE_H__ */
Circular_Buffer< uint8_t,(uint32_t) 128, sizeof(CAN_message_t)> CANBufferType
TorqueLimit_e
Defines modes of torque limit to be processed in torque limit map for exact values.
ControllerMode_e
ControllerMode_e getDialMode()
void read(const CAN_message_t &can_msg)
void update_torque_mode_(bool button_pressed)
void setLED(DashLED_e led, LEDColors_e color)
TorqueLimit_e getTorqueLimitMode()
DashComponentInterface_s _data
bool torqueLoadingButtonPressed()
void tick10(MCUInterface *mcu, int car_state, bool buzzer, bool drivetrain_error, TorqueLimit_e torque, float min_cell_voltage, AnalogConversion_s glv_voltage, int launch_state, ControllerMode_e dial_mode)
CANBufferType * msg_queue_
DashboardInterface(CANBufferType *msg_output_queue)
LEDColors_e
@ MC_ERROR_LED
from state machine. When READY_TO_DRIVE, set START_LED to true. See what else uses READY_TO_DRIVE so ...
@ LAUNCH_CONTROL_LED
@ IMD_LED
from DrivetrainSystem.cpp, get drivetrain_error_occurred()
LEDColors_e
ControllerMode_e cur_dial_mode