SendTritium Task#

The SendTritium task currently houses our velocity control code. It utilizes a FSM to coordinate what messages should be sent to the motor controller depending on a certain set of input variables. This FSM depends on data from across the system, such as: - The Pedals - The switches - The CAN messages from BPS (indicates whether we can regen brake or not)

group SendTritium

Defines

MOTOR_MSG_PERIOD 100#
FSM_PERIOD 100#
DEBOUNCE_PERIOD 2#
MOTOR_MSG_COUNTER_THRESHOLD (MOTOR_MSG_PERIOD)/(FSM_PERIOD)#
FOREACH_Gear(GEAR)

GEAR(FORWARD_GEAR),   \

GEAR(NEUTRAL_GEAR),  \

GEAR(REVERSE_GEAR),   \

#

Typedefs

typedef enum GEAR_ENUM Gear_t#
typedef struct TritiumState TritiumState_t#

Enums

enum GEAR_ENUM#

Values:

enumerator FOREACH_Gear#
enum TritiumStateName_t#

Values:

enumerator FORWARD_DRIVE#
enumerator NEUTRAL_DRIVE#
enumerator REVERSE_DRIVE#
enumerator RECORD_VELOCITY#
enumerator POWERED_CRUISE#
enumerator COASTING_CRUISE#
enumerator BRAKE_STATE#
enumerator ONEPEDAL#
enumerator ACCELERATE_CRUISE#

Functions

float mapToPercent(uint8_t input, uint8_t in_min, uint8_t in_max, uint8_t out_min, uint8_t out_max)#

Linearly map range of integers to another range of integers, and provide the pecentage result. in_min to in_max is mapped to out_min to out_max.

Parameters:
  • input – input integer value

  • in_min – minimum value of input range

  • in_max – maximum value of input range

  • out_min – minimum value of output range

  • out_max – maximum value of output range

Returns:

float value from (out_min / 100.0) to (out_max / 100.0)

Variables

TritiumStateName_t name#
void (*stateHandler)(void)#
void (*stateDecider)(void)#
struct TritiumState#