firmware
IEM Firmware Documentation
Loading...
Searching...
No Matches
constants.h
Go to the documentation of this file.
1
10
11#ifndef CONSTANTS_H
12#define CONSTANTS_H
13
14#include <stdint.h>
15#include <stdbool.h>
16
17#include "iem_utils.h"
18
19
20#define RAD_TO_DEG 57.295779F
21#define DEG_TO_RAD 0.0174532925F
22
23#define ADC_RAW16_TO_V (3.3F / 65535.0F)
24
25#define CAN_TIMEOUT_MS 100
26
27// 22 degrees
28// TODO: APPS calibration mode
29// #define APPS_DEG_TO_PERCENT (100.0F / 22.0F)
30
31#define APPS_LEFT_ZERO -118.0F
32#define APPS_RIGHT_ZERO -2.0F
33#define APPS_LEFT_DIR -1.0F
34#define APPS_RIGHT_DIR 1.0F
35#define APPS_RANGE 22.0F // deg
36
37static inline __attribute__((always_inline)) float apps_right_deg_to_per(float deg) {
38 return 100.0F * (((deg - APPS_RIGHT_ZERO) * APPS_RIGHT_DIR) / APPS_RANGE);
39}
40
41static inline __attribute__((always_inline)) float apps_left_deg_to_per(float deg) {
42 return 100.0F * ((deg - APPS_LEFT_ZERO) * APPS_LEFT_DIR) / APPS_RANGE;
43}
44
45#endif
#define APPS_LEFT_ZERO
Definition constants.h:31
#define APPS_LEFT_DIR
Definition constants.h:33
static float apps_left_deg_to_per(float deg)
Definition constants.h:41
#define APPS_RIGHT_ZERO
Definition constants.h:32
#define APPS_RIGHT_DIR
Definition constants.h:34
static float apps_right_deg_to_per(float deg)
Definition constants.h:37
#define APPS_RANGE
Definition constants.h:35