map_switch.c - aalesv/2boost GitHub Wiki

map_switch.c

All functions related to map selection located here.

uint8 globalMapSwitch(void)

If P_SI_DRVIE_STATE symbol is undefined

Return value Meaning
0 ROM map
1 2Boost map 1
2 2Boost map 2
3 2Boost Overtake map

If P_SI_DRVIE_STATE symbol is defined

Return value Meaning
0 ROM map
1 2Boost Intelligent map
2 2Boost Sport map
3 2Boost Sport Sharp map
4 2Boost Overtake map

This function returns an 8-bit unsigned integer value representing the current state of the global map switch. It first calls the overtakeMapSwitch() function to obtain the current state of the overtake map switch. If the return value is greater than zero, the function exits and returns this value. If the return value is zero, the function then determines the source of the global map switch by calling the globalMapSwitchSource() function. Depending on the source, the function sets the return value accordingly:

Finally, the function sets the global map switch state in RAM and returns the calculated value. This function is used as array index and can produce array overrun.

uint8 overtakeMapConditionsMet(void)

Accelerator pedal \ Cruise Cansel switch Off On
<= 25% 0 0
> 25% 0 Result of overtakeMapNumber() function call

If the cruise cancel switch is pressed and the accelerator pedal value is above a certain threshold, overtake conditions are met and this function returns 1. otherwise it return 0.

uint8 overtakeMapNumber(void)

This function returns LUT_OVERTAKE_MAP_COLUMN_NUMBER constant representing number of map that is an Overtake map.

uint8 overtakeMapSwitch(void)

This function returns an 8-bit unsigned integer value representing the current state of the overtake map switch. It determines the source of the overtake map switch by checking the value of the CFG_OVERTAKE_BUTTON_SWITCH_SOURCE constant. Depending on the source, the function may call the overtakeMapConditionsMet() function to determine if overtake conditions are met. If the conditions are met, the function calls overtakeMapNumber() and returns a predefined column number. Otherwise, it returns zero. This function is used as array index and can produce array overrun.

uint8 cruiseCancelPressed(void)

This function returns an 8-bit unsigned integer value representing whether the cruise cancel switch is pressed. It checks the value of the P_CRUISE_CANCEL_SWITCH variable and returns 1 if the switch is on, and 0 otherwise.

uint8 brakePedalPressed(void)

This function returns an 8-bit unsigned integer value representing whether the brake pedal is pressed. It checks the value of the P_BRAKE_PEDAL_SWITCH variable and returns 1 if the pedal is pressed, and 0 otherwise.

uint8 cruiseStateEnabled (void)

Later ROMs, P_CRUISE_STATE_MASK_CRUISE_ENABLED symbol is defined

This function returns an 8-bit unsigned integer value representing whether the cruise state is enabled. It checks the value of the P_CRUISE_STATE_MASK_CRUISE_ENABLED constant and determines if the cruise control is active by performing a bitwise AND operation with the P_CRUISE_STATE variable. If the result is equal to P_CRUISE_STATE_MASK_CRUISE_ENABLED, the function returns 1, indicating that the cruise control is enabled. If the result is 0, the function returns 0, indicating that the cruise control is not enabled. If the result is neither P_CRUISE_STATE_MASK_CRUISE_ENABLED nor 0, the function returns 0.

Earlier ROMs, P_CRUISE_STATE_MASK_CRUISE_DISABLED symbol is defined

This function returns an 8-bit unsigned integer value representing whether the cruise state is enabled. It checks the value of the P_CRUISE_STATE_MASK_CRUISE_DISABLED constant and determines if the cruise control is disabled by performing a bitwise AND operation with the P_CRUISE_STATE variable. If the result is equal to P_CRUISE_STATE_MASK_CRUISE_DISABLED, the function returns 0, indicating that the cruise control is disabled. If the result is 0, the function returns 1, indicating that the cruise control is enabled. If the result is neither P_CRUISE_STATE_MASK_CRUISE_DISABLED nor 0, the function returns 0.

uint8 siDriveState (void)

ROM Si-Drive State Return value
1 SI_DRIVE_STATE_SPORT
2 SI_DRIVE_STATE_SPORT_SHARP
3 SI_DRIVE_STATE_INTELLIGENT
8 SI_DRIVE_STATE_SPORT_SHARP
16 SI_DRIVE_STATE_INTELLIGENT
Other SI_DRIVE_STATE_NONE

This function returns an 8-bit unsigned integer value representing the current state of the Si-Drive switch. It checks the value of the P_SI_DRVIE_STATE variable and returns a predefined value depending on the state. If the value is 3 or 16, the function returns SI_DRIVE_STATE_INTELLIGENT. If the value is 1, the function returns SI_DRIVE_STATE_SPORT(./types.h#si_drive_state). If the value is 2 or 8, the function returns SI_DRIVE_STATE_SPORT_SHARP. Otherwise, the function returns SI_DRIVE_STATE_NONE. This function is used as array index and can produce array overrun.

uint8 globalMapSwitchSource (void)

This function returns CFG_OVERTAKE_BUTTON_SWITCH_SOURCE constant representing how map switching is controlled. Currently Cruise Control switch and Si-Drive switch are supported.

This page was created with help of ChatGPT

⚠️ **GitHub.com Fallback** ⚠️