-
Notifications
You must be signed in to change notification settings - Fork 5
/
ff-abuttons.ino
248 lines (199 loc) · 6.24 KB
/
ff-abuttons.ino
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
/******************************************************************************
*
* This file is part of the Arduino-Arcs project, see
* https://github.com/pavelmc/arduino-arcs
*
* Copyright (C) 2016...2017 Pavel Milanes (CO7WT) <[email protected]>
*
* This program is free software under the GNU GPL v3.0
*
* ***************************************************************************/
#ifdef ABUT
// VFO A/B button click >>>> (OK/SAVE click)
void btnVFOABClick() {
// beep
beep();
// normal mode
if (runMode) {
#ifdef MEMORIES
// is the scanning feature turned on?
#ifdef MEM_SCAN
if (!vfoMode) {
mscan != mscan;
return;
}
#endif
#endif
// we force to deactivate the RIT on VFO change, as it will confuse
// the users and have a non logical use, only if activated and
// BEFORE we change the active VFO
if (ritActive) toggleRit();
// now we swap the VFO.
swapVFO();
// update VFO/BFO and instruct to update the LCD
updateAllFreq();
// force a memory save
saveEEPROM();
// set the LCD update flag
update = true;
} else {
// SETUP mode
if (!inSetup) {
// I'm going to setup a element
inSetup = true;
// change the mode to follow VFO A
if (config == CONFIG_USB) u.aMode = MODE_USB;
else if (config == CONFIG_CW) u.aMode = MODE_CW;
else u.aMode = MODE_LSB;
#ifdef LCD
// config update on the LCD
showModConfig();
#endif // nolcd
} else {
// get out of the setup change
inSetup = false;
// save to the eeprom
saveEEPROM();
#ifdef LCD
// lcd delay to show it properly (user feedback)
lcd.setCursor(0, 0);
lcd.print(F("## SAVED ##"));
delay(1000);
// show setup
showConfig();
#endif // nolcd
// reset the minimum step if set (1hz > 10 hz)
if (step == 1) step = 2;
}
}
}
// MODE button click >>>> (CANCEL click)
void btnModeClick() {
// beep
beep();
// normal mode
if (runMode) {
changeMode();
update = true;
} else if (inSetup) {
// setup mode, just inside a value edit, then get out of here
inSetup = false;
#ifdef LCD
// user feedback
lcd.setCursor(0, 0);
lcd.print(F(" # Canceled # "));
delay(1000);
// show it
showConfig();
#endif // nolcd
}
}
// RIT button click >>>> (RESET values click)
void btnRITClick() {
// beep
beep();
// normal mode
if (runMode) {
#ifdef MEMORIES
// if we are in mem mode RIT has no sense
if (!vfoMode) return;
#endif
toggleRit();
update = true;
} else if (inSetup) {
// SETUP mode just inside a value edit.
// where we are to know what to reset?
if (config == CONFIG_USB) u.usb = 2400;
if (config == CONFIG_CW) u.cw = 600;
if (config == CONFIG_IF) u.ifreq = 0;
if (config == CONFIG_PPM) u.ppm = 0;
// update the freqs for
updateAllFreq();
#ifdef LCD
showModConfig();
#endif // nolcd
}
}
// SPLIT button click >>>> (Nothing yet)
void btnSPLITClick() {
// beep
beep();
// normal mode
if (runMode) {
#ifdef MEMORIES
// if we are in mem mode split has no sense
if (!vfoMode) return;
#endif
split = !split;
update = true;
}
}
// RIT toggle
void toggleRit() {
if (!ritActive) {
// going to activate it: store the active VFO
tvfo = *ptrVFO;
ritActive = true;
} else {
// going to deactivate: reset the stored VFO
*ptrVFO = tvfo;
ritActive = false;
#ifdef SMETER
// flag to redraw the bar graph
barReDraw = true;
#endif
}
}
#ifdef MEMORIES
// VFO/MEM mode change
void btnVFOMEM() {
// beep
beep();
// toggle the flag
vfoMode = !vfoMode;
// force the update of the mem
if (!vfoMode) loadMEM(mem);
// rise the update flag
update = true;
}
// mem > vfo | vfo > mem, taking into account in what mode we are
void btnVFOsMEM() {
// beep
beop();
// detect in which mode I'm, to decide what to do
if (vfoMode) {
// VFO > MEM
saveMEM(mem, true);
// swap to mem mode
vfoMode = false;
} else {
// MEM > VFO
loadMEM(mem);
// swap to the VFO mode
vfoMode = true;
}
// update flag for the LCD
update = true;
}
// erase the actual mem position
void btnEraseMEM() {
// beep
beop();
// erase the actual mem position
saveMEM(mem, false);
// now force an update of the LCD
update = true;
}
// erase the whole mem space
void btnEraseWholeMem() {
// sound signal
beep();
delay(50);
beop();
// sure?
wipeMEM();
// now force an update of the LCD
update = true;
}
#endif // memories
#endif