-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathsettings.h
More file actions
141 lines (111 loc) · 3.16 KB
/
Copy pathsettings.h
File metadata and controls
141 lines (111 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#ifndef __SETTINGS_H
#define __SETTINGS_H
#include "display.h"
#include "esp_system.h"
#include "nvs_flash.h"
#include <core/lv_obj.h>
#include <esp_now.h>
#include <remote/receiver.h>
// Function to initialize settings (and NVS)
esp_err_t settings_init();
// Function to write an integer to NVS
esp_err_t nvs_write_int(const char *key, uint32_t value);
// Function to read an integer from NVS
esp_err_t nvs_read_int(const char *key, uint32_t *value);
// Function to write a string to NVS
esp_err_t nvs_write_str(const char *key, const char *value);
// Function to read a string from NVS
esp_err_t nvs_read_str(const char *key, char *out_value, size_t *length);
// Function to write a byte array to NVS
esp_err_t nvs_write_blob(const char *key, void *value, size_t length);
// Function to read a byte array from NVS
esp_err_t nvs_read_blob(const char *key, void *value, size_t length);
void save_device_settings();
void save_calibration();
esp_err_t save_pairing_data();
esp_err_t reset_all_settings();
esp_err_t save_wifi_ssid(const char *ssid);
esp_err_t save_wifi_password(const char *password);
char *get_wifi_ssid();
char *get_wifi_password();
typedef enum {
AUTO_OFF_DISABLED,
AUTO_OFF_2_MINUTES,
AUTO_OFF_5_MINUTES,
AUTO_OFF_10_MINUTES,
AUTO_OFF_20_MINUTES,
AUTO_OFF_30_MINUTES,
} AutoOffOptions;
typedef enum {
TEMP_UNITS_CELSIUS,
TEMP_UNITS_FAHRENHEIT,
} TempUnits;
typedef enum {
DISTANCE_UNITS_METRIC,
DISTANCE_UNITS_IMPERIAL,
} DistanceUnits;
typedef enum {
STARTUP_SOUND_DISABLED,
STARTUP_SOUND_BEEP,
STARTUP_SOUND_MELODY,
} StartupSoundOptions;
typedef enum {
DARK_TEXT_DISABLED,
DARK_TEXT_ENABLED,
} DarkTextOptions;
typedef enum {
BATTERY_DISPLAY_PERCENT,
BATTERY_DISPLAY_VOLTAGE,
BATTERY_DISPLAY_ALL,
} BoardBatteryDisplayOption;
typedef enum {
POCKET_MODE_DISABLED,
POCKET_MODE_ENABLED,
} PocketModeOptions;
typedef enum {
BUTTON_PRESS_ACTION_NONE,
BUTTON_PRESS_ACTION_SHUTDOWN,
BUTTON_PRESS_ACTION_OPEN_MENU,
BUTTON_PRESS_ACTION_TOGGLE_DISPLAY,
BUTTON_PRESS_ACTION_TOGGLE_POCKET_MODE,
BUTTON_PRESS_ACTION_CYCLE_SECONDARY_STAT,
BUTTON_PRESS_ACTION_CYCLE_BOARD_BATTERY_DISPLAY,
} StatsButtonPressAction;
#define DEFAULT_PAIRING_SECRET_CODE -1
typedef struct {
uint32_t secret_code;
uint8_t remote_addr[ESP_NOW_ETH_ALEN];
uint8_t channel;
} PairingSettings;
typedef struct {
uint16_t x_min;
uint16_t x_max;
uint16_t y_min;
uint16_t y_max;
uint16_t x_center;
uint16_t y_center;
uint16_t deadband;
float expo;
bool invert_y;
} CalibrationSettings;
typedef struct {
uint8_t bl_level;
ScreenRotation screen_rotation;
AutoOffOptions auto_off_time;
TempUnits temp_units;
DistanceUnits distance_units;
StartupSoundOptions startup_sound;
uint32_t theme_color;
bool dark_text;
BoardBatteryDisplayOption battery_display;
PocketModeOptions pocket_mode;
StatsButtonPressAction single_press_action;
StatsButtonPressAction double_press_action;
StatsButtonPressAction long_press_action;
} DeviceSettings;
uint64_t get_auto_off_ms();
bool is_pocket_mode_enabled();
extern CalibrationSettings calibration_settings;
extern DeviceSettings device_settings;
extern PairingSettings pairing_settings;
#endif