forked from afarhan/ubitxv6
-
Notifications
You must be signed in to change notification settings - Fork 11
/
settings.h
116 lines (94 loc) · 2 KB
/
settings.h
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
/*
* This class deals with all of the radio settings,
* so that other areas of the code doesn't have to
*
* Example usage:
* LoadSettingsFromEeprom();
* Serial.println(globalSettings.vfoAFreq);
* globalSettings.vfoAFreq = 12345678;
* SaveSettingsToEeprom();
* Serial.println(globalSettings.vfoAFreq);
*/
#pragma once
#include <stdint.h>//uint8_t etc.
static const uint8_t NUM_QUICKLIST_SETTINGS = 4;
/*
* Loads default values for all settings
*/
void LoadDefaultSettings();
/*
* Loads all persistent settings from the EEPROM
*/
void LoadSettingsFromEeprom();
/*
* Saves all persistent settings to the EEPROM
*
* It's a little CPU-cycle-wasteful to save EVERYTHING
* each time, but keeps things simple
*/
void SaveSettingsToEeprom();
/*
* These are all of the settings
* Note that not all settings are saved to the EEPROM
*/
enum Vfo_e : uint8_t
{
VFO_A,
VFO_B
};
enum VfoMode_e : uint8_t
{
VFO_MODE_LSB = 2,
VFO_MODE_USB = 3
};
struct VfoSettings_t
{
uint32_t frequency;
VfoMode_e mode;
};
enum TuningMode_e : uint8_t
{
TUNE_SSB,
TUNE_CW
};
enum KeyerMode_e : uint8_t
{
KEYER_STRAIGHT,
KEYER_IAMBIC_A,
KEYER_IAMBIC_B
};
/*
* This is the definition of the settings/state variables
*/
struct SettingsRam
{
uint32_t oscillatorCal;
uint32_t usbCarrierFreq;
Vfo_e activeVfo;
VfoSettings_t vfoA;
VfoSettings_t vfoB;
VfoSettings_t quickList[4];
KeyerMode_e keyerMode;
uint32_t cwSideToneFreq;
uint16_t cwDitDurationMs;
uint16_t cwActiveTimeoutMs;
int16_t touchSlopeX;
int16_t touchSlopeY;
int16_t touchOffsetX;
int16_t touchOffsetY;
bool ritOn;
uint32_t ritFrequency;
TuningMode_e tuningMode;
bool splitOn;
bool txActive;
bool txCatActive;
uint32_t cwExpirationTimeMs;
bool morseMenuOn;
};
//This is the shared declaration
extern SettingsRam globalSettings;
//Some convenience functions
uint32_t GetActiveVfoFreq();
void SetActiveVfoFreq(uint32_t frequency);
VfoMode_e GetActiveVfoMode();
void SetActiveVfoMode(VfoMode_e mode);