Fuel Gauge
This module provides a set of functionalities for managing the Fuel Gauge system, including initialization, bar state updates, low fuel warnings, and configuration management to ensure accurate representation of fuel levels.
Configuration Parameters
All API functions have the first argument as the module ID.
Name |
Description |
Range |
---|---|---|
enable |
Enables Fuel Gauge functionality. |
0 (disabled) or 1 (enabled) |
fuel_capacity |
Total fuel tank capacity (in liters). |
1 to 48 liters |
reserve_fuel_value |
Reserve fuel level threshold (in percentage). |
0 to 100% |
max_bar_count |
Maximum number of bars for fuel display. |
1 to 7 |
bar_thresholds |
ON/OFF thresholds for each bar in the fuel gauge. |
Array of thresholds (configurable values). |
APIs
The Fuel Gauge module provides the following APIs to initialize, process, and update the fuel gauge data:
Function |
Description |
---|---|
rs_am_fuelgauge_init |
Initializes the fuel gauge system with default configuration values. |
rs_am_fuelgauge_process |
Processes the fuel gauge system by updating the bar states and checking for warnings. |
Error Codes
Each API for the fuel gauge module returns success or failure codes. For detailed information on the error codes, please refer to the following section:
See also
:doc:/error_codes
Fuel Gauge Module Header Details
The header file for fuel gauge modules, rs_am_fuel_gauge.h, defines the required structures and APIs for initialization and processing.
Defines
-
RS_AM_FUEL_GAUGE_MAX_BAR_VALUE
Maximum number of bars for fuel gauge.
Typedefs
-
typedef struct tag_rs_fuel_bar_threshold rs_fuel_bar_threshold_t
Fuel Gauge threshold data structure.
-
typedef struct tag_rs_fuel_config rs_fuel_config_t
Fuel Gauge configuration data structure.
-
typedef struct tag_rs_fuel_runtime rs_fuel_runtime_t
Fuel Gauge runtime data structure.
-
typedef struct tag_rs_fuel_output rs_fuel_output_t
Fuel Gauge output data structure.
-
typedef struct tag_rs_am_fuelgauge rs_am_fuelgauge_t
Contains information about fuel gauge.
Functions
-
rs_ret_val_t rs_am_fuelgauge_init(rs_am_fuelgauge_t *ptr_fuelgauge)
Initializes the fuel gauge module.
This function Sets default values for configuration and runtime state, and registers the module with the dispatcher.
- Parameters:
ptr_fuelgauge – [in] Pointer to the fuel gauge structure to be initialized.
- Returns:
Returns success on successful initialization.
-
rs_ret_val_t rs_am_fuelgauge_process(rs_am_fuelgauge_t *ptr_fuelgauge)
Periodically updates the fuel gauge state.
Updates the bar states, writes fuel level data to memory, and dispatches the updated display fuel level to consumers.
- Parameters:
ptr_fuelgauge – [in] Pointer to the fuel gauge structure.
- Returns:
Returns success after processing the fuel state.
-
struct tag_rs_fuel_bar_threshold
- #include <rs_am_fuel_gauge.h>
Fuel Gauge threshold data structure.
-
struct tag_rs_fuel_config
- #include <rs_am_fuel_gauge.h>
Fuel Gauge configuration data structure.
Public Members
-
uint8_t enable
Enable or disable the fuel gauge functionality.
-
uint8_t fuel_capacity
Total fuel tank capacity (e.g., 48 liters)
-
uint8_t reserve_fuel_value
Reserve fuel threshold (in value)
-
uint8_t max_bar_count
Maximum number of bars for fuel display.
-
uint8_t fuel_threshold_value
Fuel gauge threshold value.
-
rs_fuel_bar_threshold_t fuel_bar_thresholds[RS_AM_FUEL_GAUGE_MAX_BAR_VALUE]
Thresholds for each bar’s on/off state.
-
uint8_t enable
-
struct tag_rs_fuel_runtime
- #include <rs_am_fuel_gauge.h>
Fuel Gauge runtime data structure.
-
struct tag_rs_fuel_output
- #include <rs_am_fuel_gauge.h>
Fuel Gauge output data structure.
-
struct tag_rs_am_fuelgauge
- #include <rs_am_fuel_gauge.h>
Contains information about fuel gauge.
Public Members
-
rs_fuel_config_t config
Configuration settings for the fuel gauge.
-
rs_fuel_runtime_t runtime
Runtime data of the fuel gauge system.
-
rs_fuel_output_t output
Output data to control the display of the fuel gauge.
-
rs_fuel_config_t config