Midnight Sun Firmware
Loading...
Searching...
No Matches
opd.h
1#pragma once
2
3/************************************************************************************************
4 * @file opd.h
5 *
6 * @brief Header file for one pedal drive manager
7 *
8 * @date 2025-09-14
9 * @author Midnight Sun Team #24 - MSXVI
10 ************************************************************************************************/
11
12/* Standard library Headers */
13#include <stdint.h>
14
15/* Inter-component Headers */
16#include "status.h"
17
18/* Intra-component Headers */
19#include "front_controller.h"
20
27typedef struct {
28 uint16_t lower_value;
29 uint16_t upper_value;
31
32typedef enum { ACCEL_STATE_DRIVING, ACCEL_STATE_BRAKING } AccelState;
33
34typedef struct OpdStorage {
35 float accel_percentage;
36 float prev_accel_percentage;
37 AccelState accel_state;
38 float max_braking_percentage;
39 uint32_t max_vehicle_speed_kph;
40
41 OpdCalibrationStorage calibration_data;
43
44typedef enum { PTS_TYPE_LINEAR, PTS_TYPE_EXPONENTIAL, PTS_TYPE_QUADRATIC } PtsRelationType;
45
46typedef enum { CURVE_TYPE_LINEAR, CURVE_TYPE_EXPONENTIAL, CURVE_TYPE_QUADRATIC } curveType;
47
48StatusCode opd_run();
49
50StatusCode opd_init(FrontControllerStorage *storage);
51
52StatusCode opd_calculate_handler(float pedal_percentage, PtsRelationType relation_type, float *calculated_reading, curveType curve_type);
53
54StatusCode opd_linear_calculate(float pedal_percentage, PtsRelationType relation_type, float *calculated_reading);
55
56StatusCode opd_quadratic_calculate(float pedal_percentage, PtsRelationType relation_type, float *calculated_reading);
57
StatusCode
StatusCodes for various errors.
Definition: status.h:27
Front Controller storage.
Definition: front_controller.h:59
Definition: opd.h:27
uint16_t upper_value
Definition: opd.h:29
uint16_t lower_value
Definition: opd.h:28
Definition: opd.h:34