-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButtonProc.cpp
More file actions
795 lines (718 loc) · 22.1 KB
/
ButtonProc.cpp
File metadata and controls
795 lines (718 loc) · 22.1 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
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
#ifndef BEENHERE
#include "SDT.h"
#endif
/*****
Purpose: To process a menu increase button push
Parameter list:
void
Return value:
void
*****/
void ButtonMenuIncrease() {
if (menuStatus == PRIMARY_MENU_ACTIVE) {
mainMenuIndex++;
if (mainMenuIndex == TOP_MENU_COUNT) { // At last menu option, so...
mainMenuIndex = 0; // ...wrap around to first menu option
}
} else {
if (menuStatus == SECONDARY_MENU_ACTIVE) {
secondaryMenuIndex++;
if (secondaryMenuIndex == subMenuMaxOptions) { // Same here...
secondaryMenuIndex = 0;
}
}
}
}
/*****
Purpose: To process a menu decrease button push
Parameter list:
void
Return value:
void
*****/
void ButtonMenuDecrease() {
if (menuStatus == PRIMARY_MENU_ACTIVE) {
mainMenuIndex--;
if (mainMenuIndex < 0) { // At last menu option, so...
mainMenuIndex = TOP_MENU_COUNT - 1; // ...wrap around to first menu option
}
} else {
if (menuStatus == SECONDARY_MENU_ACTIVE) {
secondaryMenuIndex--;
if (secondaryMenuIndex < 0) { // Same here...
secondaryMenuIndex = subMenuMaxOptions - 1;
}
}
}
}
//================== AFP 09-27-22
/*****
Purpose: To process a band increase button push
Parameter list:
void
Return value:
void
*****/
void ButtonBandIncrease() {
int tempIndex;
tempIndex = currentBandA;
if (currentBand == NUMBER_OF_BANDS) { // Incremented too far?
currentBand = 0; // Yep. Roll to list front.
}
NCOFreq = 0L;
switch (activeVFO) {
case VFO_A:
tempIndex = currentBandA;
if (save_last_frequency == 1) {
lastFrequencies[tempIndex][VFO_A] = TxRxFreq;
} else {
if (save_last_frequency == 0) {
if (directFreqFlag == 1) {
lastFrequencies[tempIndex][VFO_A] = TxRxFreqOld;
} else {
if (directFreqFlag == 0) {
lastFrequencies[tempIndex][VFO_A] = TxRxFreq;
}
}
TxRxFreqOld = TxRxFreq;
}
}
currentBandA++;
if (currentBandA == NUMBER_OF_BANDS) { // Incremented too far?
currentBandA = 0; // Yep. Roll to list front.
}
currentBand = currentBandA;
centerFreq = TxRxFreq = currentFreqA = lastFrequencies[currentBandA][VFO_A] + NCOFreq;
break;
case VFO_B:
tempIndex = currentBandB;
if (save_last_frequency == 1) {
lastFrequencies[tempIndex][VFO_B] = TxRxFreq;
} else {
if (save_last_frequency == 0) {
if (directFreqFlag == 1) {
lastFrequencies[tempIndex][VFO_B] = TxRxFreqOld;
} else {
if (directFreqFlag == 0) {
lastFrequencies[tempIndex][VFO_B] = TxRxFreq;
}
}
TxRxFreqOld = TxRxFreq;
}
}
currentBandB++;
if (currentBandB == NUMBER_OF_BANDS) { // Incremented too far?
currentBandB = 0; // Yep. Roll to list front.
}
currentBand = currentBandB;
centerFreq = TxRxFreq = currentFreqB = lastFrequencies[currentBandB][VFO_B] + NCOFreq;
break;
case VFO_SPLIT:
DoSplitVFO();
break;
}
directFreqFlag = 0;
EraseSpectrumDisplayContainer();
DrawSpectrumDisplayContainer();
SetBand();
SetFreq();
ShowFrequency();
ShowSpectrumdBScale();
MyDelay(1L);
AudioInterrupts();
EEPROMWrite();
// Draw or not draw CW filter graphics to audio spectrum area. KF5N July 30, 2023
tft.writeTo(L2);
tft.clearMemory();
tft.writeTo(L1);
if(xmtMode == CW_MODE) BandInformation();
DrawBandWidthIndicatorBar();
DrawFrequencyBarValue();
}
/*****
Purpose: To process a band decrease button push
Parameter list:
void
Return value:
void
*****/
void ButtonBandDecrease() {
int tempIndex = currentBand;
;
// NCOFreq = 0L;
currentBand--; // decrement band index
if (currentBand < 0) { // decremented too far?
currentBand = NUMBER_OF_BANDS - 1; // Yep. Roll to list end.
}
switch (activeVFO) {
case VFO_A:
if (save_last_frequency == 1) {
lastFrequencies[tempIndex][VFO_A] = TxRxFreq;
} else {
if (save_last_frequency == 0) {
if (directFreqFlag == 1) {
lastFrequencies[tempIndex][VFO_A] = TxRxFreqOld;
} else {
if (directFreqFlag == 0) {
lastFrequencies[tempIndex][VFO_A] = TxRxFreq;
}
}
TxRxFreqOld = TxRxFreq;
}
}
currentBandA--;
if (currentBandA == NUMBER_OF_BANDS) { // decremented too far?
currentBandA = 0; // Yep. Roll to list front.
}
if (currentBandA < 0) { // Incremented too far?
currentBandA = NUMBER_OF_BANDS - 1; // Yep. Roll to list front.
}
currentBand = currentBandA;
centerFreq = TxRxFreq = currentFreqA = lastFrequencies[currentBandA][VFO_A] + NCOFreq;
break;
case VFO_B:
if (save_last_frequency == 1) {
lastFrequencies[tempIndex][VFO_B] = TxRxFreq;
} else {
if (save_last_frequency == 0) {
if (directFreqFlag == 1) {
lastFrequencies[tempIndex][VFO_B] = TxRxFreqOld;
} else {
if (directFreqFlag == 0) {
lastFrequencies[tempIndex][VFO_B] = TxRxFreq;
}
}
TxRxFreqOld = TxRxFreq;
}
}
currentBandB--;
if (currentBandB == NUMBER_OF_BANDS) { // Incremented too far?
currentBandB = 0; // Yep. Roll to list front.
}
if (currentBandB < 0) { // Incremented too far?
currentBandB = NUMBER_OF_BANDS - 1; // Yep. Roll to list front.
}
currentBand = currentBandB;
centerFreq = TxRxFreq = currentFreqB = lastFrequencies[currentBandB][VFO_B] + NCOFreq;
break;
case VFO_SPLIT:
DoSplitVFO();
break;
}
directFreqFlag = 0;
EraseSpectrumDisplayContainer();
DrawSpectrumDisplayContainer();
SetBand();
SetFreq();
ShowFrequency();
MyDelay(1L);
ShowSpectrumdBScale();
AudioInterrupts();
EEPROMWrite();
// Draw or not draw CW filter graphics to audio spectrum area. KF5N July 30, 2023
tft.writeTo(L2);
tft.clearMemory();
tft.writeTo(L1);
if(xmtMode == CW_MODE) BandInformation();
DrawBandWidthIndicatorBar();
DrawFrequencyBarValue();
}
//================ AFP 09-27-22
/*****
Purpose: Chnage the horizontal scale of the frequency display
Parameter list:
void
Return value:
int index of the option selected
*****/
void ButtonZoom() {
zoomIndex++;
if (zoomIndex == MAX_ZOOM_ENTRIES) {
zoomIndex = 0;
}
if (zoomIndex <= 0)
spectrum_zoom = 0;
else
spectrum_zoom = zoomIndex;
ZoomFFTPrep();
UpdateZoomField();
tft.writeTo(L2); // Clear layer 2. KF5N July 31, 2023
tft.clearMemory();
tft.writeTo(L1); // Always exit function in L1. KF5N August 15, 2023
DrawBandWidthIndicatorBar();
ShowSpectrumdBScale();
DrawFrequencyBarValue();
ShowFrequency();
ShowBandwidth();
ResetTuning(); // AFP 10-11-22
}
/*****
Purpose: To process a filter button push
Parameter list:
void
Return value:
void
*****/
void ButtonFilter() {
switchFilterSideband = !switchFilterSideband;
ControlFilterF();
FilterBandwidth();
//SetFreq();
ShowFrequency();
}
/*****
Purpose: Process demodulation mode
Parameter list:
void
Return value:
void
*****/
void ButtonDemodMode() {
bands[currentBand].mode++;
if (bands[currentBand].mode > DEMOD_MAX) {
bands[currentBand].mode = DEMOD_MIN; // cycle thru demod modes
}
//AudioNoInterrupts();
BandInformation();
SetupMode(bands[currentBand].mode);
ShowFrequency();
ControlFilterF();
tft.writeTo(L2); // Destroy the bandwidth indicator bar. KF5N July 30, 2023
tft.clearMemory();
if(xmtMode == CW_MODE) BandInformation();
DrawBandWidthIndicatorBar(); // Restory the bandwidth indicator bar. KF5N July 30, 2023
FilterBandwidth();
DrawSMeterContainer();
ShowAnalogGain();
AudioInterrupts();
SetFreq(); // Must update frequency, for example moving from SSB to CW, the RX LO is shifted. KF5N
}
/*****
Purpose: Set transmission mode for SSB or CW
Parameter list:
void
Return value:
void
*****/
void ButtonMode() //====== Changed AFP 10-05-22 =================
{
if (xmtMode == CW_MODE) { // Toggle the current mode
xmtMode = SSB_MODE;
} else {
xmtMode = CW_MODE;
}
//fLoCutOld = bands[currentBand].FLoCut;
//fHiCutOld = bands[currentBand].FHiCut;
SetFreq(); // Required due to RX LO shift from CW to SSB modes. KF5N
//tft.fillWindow(); // This was erasing the waterfall when switching modes. Removed by KF5N.
DrawSpectrumDisplayContainer();
DrawFrequencyBarValue();
DrawInfoWindowFrame();
DisplayIncrementField();
AGCPrep();
UpdateAGCField();
#ifndef G0ORX_FRONTPANEL_2
EncoderVolume();
#endif
UpdateInfoWindow();
ControlFilterF();
BandInformation();
FilterBandwidth();
DrawSMeterContainer();
DrawAudioSpectContainer();
SpectralNoiseReductionInit();
UpdateNoiseField();
ShowName();
ShowSpectrumdBScale();
ShowTransmitReceiveStatus();
ShowFrequency();
// Draw or not draw CW filter graphics to audio spectrum area. KF5N July 30, 2023
if(xmtMode == SSB_MODE) {
tft.writeTo(L2);
tft.clearMemory();
} else BandInformation();
DrawBandWidthIndicatorBar();
}
/*****
Purpose: To process select noise reduction
Parameter list:
void
Return value:
void
*****/
void ButtonNR() //AFP 09-19-22 update
{
nrOptionSelect++;
if (nrOptionSelect > 3) {
nrOptionSelect = 0;
}
NROptions(); //AFP 09-19-22
UpdateNoiseField();
}
/*****
Purpose: To set the notch filter
Parameter list:
void
Return value:
void
*****/
void ButtonNotchFilter() {
ANR_notchOn = !ANR_notchOn;
MyDelay(100L);
}
/*****
Purpose: Allows quick setting of noise floor in spectrum display
Parameter list:
void
Return value;
int the current noise floor value
*****/
int ButtonSetNoiseFloor() {
int floor = currentNoiseFloor[currentBand]; // KF5N
int val;
tft.setFontScale((enum RA8875tsize)1);
ErasePrimaryMenu();
tft.fillRect(SECONDARY_MENU_X - 100, MENUS_Y, EACH_MENU_WIDTH + 120, CHAR_HEIGHT, RA8875_MAGENTA);
//tft.setTextColor(RA8875_WHITE);
tft.setTextColor(RA8875_BLACK); // JJP 7/17/23
tft.setCursor(SECONDARY_MENU_X - 98, MENUS_Y + 1);
tft.print("Pixels above axis:");
tft.setCursor(SECONDARY_MENU_X + 200, MENUS_Y + 1);
tft.print(currentNoiseFloor[currentBand]);
MyDelay(150L);
#ifdef G0ORX_FRONTPANEL_2
calibrateFlag=1;
#endif
while (true) {
if (filterEncoderMove != 0) {
floor += filterEncoderMove; // It moves the display
if (floor < 0) { // G0ORX was 50?
floor = 0;
}
tft.fillRect(SECONDARY_MENU_X + 190, MENUS_Y, 80, CHAR_HEIGHT, RA8875_MAGENTA);
tft.setCursor(SECONDARY_MENU_X + 200, MENUS_Y + 1);
tft.print(floor);
filterEncoderMove = 0;
}
val = ReadSelectedPushButton(); // Get ADC value
MyDelay(100L);
val = ProcessButtonPress(val);
if (val == MENU_OPTION_SELECT) // If they made a choice...
{
currentNoiseFloor[currentBand] = floor;
EEPROMData.spectrumNoiseFloor = floor;
EEPROMData.currentNoiseFloor[currentBand] = floor;
EEPROMWrite();
#ifdef G0ORX_FRONTPANEL_2
calibrateFlag=0;
#endif
break;
}
}
EraseMenus();
EraseSpectrumDisplayContainer();
DrawSpectrumDisplayContainer();
tft.setTextColor(RA8875_WHITE);
DrawSpectrumDisplayContainer();
ShowSpectrumdBScale();
ShowSpectrum();
tft.writeTo(L2);
DrawFrequencyBarValue();
tft.writeTo(L1);
return spectrumNoiseFloor;
}
/*****
Purpose: Draw in a red line at the new floor position
Parameter list:
int floor the pixel position for the new floor
Return value;
int the current noise floor value
*****/
int DrawNewFloor(int floor)
{
static int oldY = SPECTRUM_BOTTOM;
if (floor < 0) {
floor = 0;
oldY = SPECTRUM_BOTTOM - floor;
return floor;
}
return floor;
}
/*****
Purpose: The next 3 functions are "empty" user-defined function stubs that can be filled in by the user with
"real" code.
Parameter list:
void
Return value;
int the current noise floor value
*****/
int Unused1() {
return -1;
}
int Unused2() {
return -1;
}
int Unused3() {
return -1;
}
/*****
Purpose: Reset Zoom to zoomIndex
Parameter list:
void
Return value;
int the current noise floor value
*****/
void ResetZoom(int zoomIndex1) {
if (zoomIndex1 == MAX_ZOOM_ENTRIES) {
zoomIndex1 = 0;
}
if (zoomIndex1 <= 0)
spectrum_zoom = 0;
else
spectrum_zoom = zoomIndex1;
ZoomFFTPrep();
UpdateZoomField();
DrawBandWidthIndicatorBar();
//ShowSpectrumdBScale();
DrawFrequencyBarValue();
ShowFrequency();
ShowBandwidth();
//ResetTuning();
RedrawDisplayScreen();
}
/*****
Purpose: Direct Frequrncy Entry
Parameter list:
void
Return value;
void
Base Code courtesy of Harry GM3RVL
*****/
/*****
Purpose: Direct Frequency Entry
Parameter list:
void
Return value;
void
Base Code courtesy of Harry GM3RVL
*****/
void ButtonFrequencyEntry() {
TxRxFreqOld = TxRxFreq;
#define show_FEHelp
bool doneFE = false; // set to true when a valid frequency is entered
long enteredF = 0L; // desired frequency
char strF[6] = { ' ', ' ', ' ', ' ', ' ' }; // container for frequency string during entry
String stringF;
int valPin;
int key;
int numdigits = 0; // number of digits entered
int pushButtonSwitchIndex;
lastFrequencies[currentBand][activeVFO] = TxRxFreq;
//save_last_frequency = false; // prevents crazy frequencies when you change bands/save_last_frequency = true;
// Arrays for allocating values associated with keys and switches - choose whether USB keypad or analogue switch matrix
// USB keypad and analogue switch matrix
const char *DE_Band[] = {"80m","40m","20m","17m","15m","12m","10m"};
const char *DE_Flimit[] = {"4.5","9","16","26","26","30","30"};
int numKeys[] = { 0x0D, 0x7F, 0x58, // values to be allocated to each key push
0x37, 0x38, 0x39,
0x34, 0x35, 0x36,
0x31, 0x32, 0x33,
0x30, 0x7F, 0x7F,
0x7F, 0x7F, 0x99 };
EraseMenus();
#ifdef show_FEHelp
int keyCol[] = { YELLOW, RED, RED,
RA8875_BLUE, RA8875_GREEN, RA8875_GREEN,
RA8875_BLUE, RA8875_BLUE, RA8875_BLUE,
RED, RED, RED,
RED, RA8875_BLACK, RA8875_BLACK,
YELLOW, YELLOW, RA8875_BLACK };
int textCol[] = { RA8875_BLACK, RA8875_WHITE, RA8875_WHITE,
RA8875_WHITE, RA8875_BLACK, RA8875_BLACK,
RA8875_WHITE, RA8875_WHITE, RA8875_WHITE,
RA8875_WHITE, RA8875_WHITE, RA8875_WHITE,
RA8875_WHITE, RA8875_WHITE, RA8875_WHITE,
RA8875_BLACK, RA8875_BLACK, RA8875_WHITE };
const char *key_labels[] = { "<", "", "X",
"7", "8", "9",
"4", "5", "6",
"1", "2", "3",
"0", "D", "",
"", "", "S" };
#define KEYPAD_LEFT 350
#define KEYPAD_TOP SPECTRUM_TOP_Y + 35
#define KEYPAD_WIDTH 150
#define KEYPAD_HEIGHT 300
#define BUTTONS_LEFT KEYPAD_LEFT + 30
#define BUTTONS_TOP KEYPAD_TOP + 30
#define BUTTONS_SPACE 45
#define BUTTONS_RADIUS 15
#define TEXT_OFFSET -8
tft.writeTo(L1);
tft.fillRect(WATERFALL_LEFT_X, SPECTRUM_TOP_Y + 1, MAX_WATERFALL_WIDTH, WATERFALL_BOTTOM - SPECTRUM_TOP_Y, RA8875_BLACK); // Make space for FEInfo
tft.fillRect(MAX_WATERFALL_WIDTH, WATERFALL_TOP_Y - 10, 15, 30, RA8875_BLACK);
tft.writeTo(L2);
tft.fillRect(WATERFALL_LEFT_X, SPECTRUM_TOP_Y + 1, MAX_WATERFALL_WIDTH, WATERFALL_BOTTOM - SPECTRUM_TOP_Y, RA8875_BLACK);
tft.setCursor(centerLine - 140, WATERFALL_TOP_Y);
tft.drawRect(SPECTRUM_LEFT_X - 1, SPECTRUM_TOP_Y, MAX_WATERFALL_WIDTH + 2, 360, RA8875_YELLOW); // Spectrum box
// Draw keypad box
tft.fillRect(KEYPAD_LEFT, KEYPAD_TOP, KEYPAD_WIDTH, KEYPAD_HEIGHT, DARKGREY);
// put some circles
tft.setFontScale((enum RA8875tsize)1);
for (unsigned i = 0; i < 6; i++) {
for (unsigned j = 0; j < 3; j++) {
tft.fillCircle(BUTTONS_LEFT + j * BUTTONS_SPACE, BUTTONS_TOP + i * BUTTONS_SPACE, BUTTONS_RADIUS, keyCol[j + 3 * i]);
tft.setCursor(BUTTONS_LEFT + j * BUTTONS_SPACE + TEXT_OFFSET, BUTTONS_TOP + i * BUTTONS_SPACE - 18);
tft.setTextColor(textCol[j + 3 * i]);
tft.print(key_labels[j + 3 * i]);
}
}
tft.setFontScale((enum RA8875tsize)0);
tft.setCursor(WATERFALL_LEFT_X + 20, SPECTRUM_TOP_Y + 50);
tft.setTextColor(RA8875_WHITE);
tft.print("Direct Frequency Entry");
tft.setCursor(WATERFALL_LEFT_X + 20, SPECTRUM_TOP_Y + 100);
tft.print("< Apply entered frequency");
tft.setCursor(WATERFALL_LEFT_X + 20, SPECTRUM_TOP_Y + 130);
tft.print("X Exit without changing frequency");
tft.setCursor(WATERFALL_LEFT_X + 20, SPECTRUM_TOP_Y + 160);
tft.print("D Delete last digit");
tft.setCursor(WATERFALL_LEFT_X + 20, SPECTRUM_TOP_Y + 190);
tft.print("S Save Direct to Last Freq. ");
tft.setCursor(WATERFALL_LEFT_X + 20, SPECTRUM_TOP_Y + 240);
tft.print("Direct Entry was called from ");
tft.print(DE_Band[currentBand]);
tft.print(" band");
tft.setCursor(WATERFALL_LEFT_X + 20, SPECTRUM_TOP_Y + 270);
tft.print("Frequency response limited above ");
tft.print(DE_Flimit[currentBand]);
tft.print("MHz");
tft.setCursor(WATERFALL_LEFT_X + 20, SPECTRUM_TOP_Y + 300);
tft.print("For widest direct entry frequency range");
tft.setCursor(WATERFALL_LEFT_X + 20, SPECTRUM_TOP_Y + 330);
tft.print("call from 12m or 10m band");
#endif
tft.writeTo(L2);
tft.setFontScale((enum RA8875tsize)1);
tft.setTextColor(RA8875_WHITE);
tft.setCursor(10, 0);
tft.print("Enter Frequency");
tft.fillRect(SECONDARY_MENU_X + 20, MENUS_Y, EACH_MENU_WIDTH + 10, CHAR_HEIGHT, RA8875_MAGENTA);
//tft.setTextColor(RA8875_WHITE);
tft.setTextColor(RA8875_BLACK); // JJP 7/17/23
tft.setCursor(SECONDARY_MENU_X + 21, MENUS_Y + 1);
tft.print("kHz or MHz:");
tft.setFontScale((enum RA8875tsize)0);
tft.setCursor(WATERFALL_LEFT_X + 50, SPECTRUM_TOP_Y + 260);
tft.print("Save Direct to Last Freq.= ");
tft.setCursor(WATERFALL_LEFT_X + 270, SPECTRUM_TOP_Y + 190);
if (save_last_frequency == 0) {
tft.setTextColor(RA8875_MAGENTA);
tft.print("Off");
} else {
if (save_last_frequency == 1) {
tft.setTextColor(RA8875_GREEN);
tft.print("On");
}
}
while (doneFE == false) {
valPin = ReadSelectedPushButton(); // Poll UI push buttons
if (valPin != BOGUS_PIN_READ) { // If a button was pushed...
pushButtonSwitchIndex = ProcessButtonPress(valPin); // Winner, winner...chicken dinner!
key = numKeys[pushButtonSwitchIndex];
switch (key) {
case 0x7F: // erase last digit =127
if (numdigits != 0) {
numdigits--;
strF[numdigits] = ' ';
}
break;
case 0x58: // Exit without updating frequency =88
doneFE = true;
break;
case 0x0D: // Apply the entered frequency (if valid) =13
stringF = String(strF);
enteredF = stringF.toInt();
if ((numdigits == 1) || (numdigits == 2)) {
enteredF = enteredF * 1000000;
}
if ((numdigits == 4) || (numdigits == 5)) {
enteredF = enteredF * 1000;
}
if ((enteredF > 30000000) || (enteredF < 1250000)) {
stringF = " "; // 5 spaces
stringF.toCharArray(strF, stringF.length());
numdigits = 0;
} else {
doneFE = true;
}
break;
case 0x99:
save_last_frequency = !save_last_frequency;
tft.setFontScale((enum RA8875tsize)0);
tft.fillRect(WATERFALL_LEFT_X + 269, SPECTRUM_TOP_Y + 190, 50, CHAR_HEIGHT, RA8875_BLACK);
tft.setCursor(WATERFALL_LEFT_X + 260, SPECTRUM_TOP_Y + 190);
if (save_last_frequency == 0) {
tft.setTextColor(RA8875_MAGENTA);
tft.print("Off");
save_last_frequency = 0;
break;
} else {
if (save_last_frequency == 1) {
tft.setTextColor(RA8875_GREEN);
tft.print("On");
save_last_frequency = 1;
}
}
break;
default:
if ((numdigits == 5) || ((key == 0x30) & (numdigits == 0))) {
} else {
strF[numdigits] = char(key);
numdigits++;
}
break;
}
tft.setTextColor(RA8875_WHITE);
tft.setFontScale((enum RA8875tsize)1);
tft.fillRect(SECONDARY_MENU_X + 195, MENUS_Y + 1, 85, CHAR_HEIGHT, RA8875_MAGENTA);
tft.setCursor(SECONDARY_MENU_X + 200, MENUS_Y + 1);
tft.print(strF);
MyDelay(250); // only for analogue switch matrix
}
}
if (key != 0x58) {
TxRxFreq = enteredF;
}
NCOFreq = 0L;
directFreqFlag = 1;
centerFreq = TxRxFreq;
centerTuneFlag = 1; // Put back in so tuning bar is refreshed. KF5N July 31, 2023
SetFreq(); // Used here instead of centerTuneFlag. KF5N July 22, 2023
//}
if (save_last_frequency == 1) {
lastFrequencies[currentBand][activeVFO] = enteredF;
} else {
if (save_last_frequency == 0) {
lastFrequencies[currentBand][activeVFO] = TxRxFreqOld;
}
}
tft.fillRect(0, 0, 799, 479, RA8875_BLACK); // Clear layer 2 JJP 7/23/23
tft.writeTo(L1);
EraseSpectrumDisplayContainer();
DrawSpectrumDisplayContainer();
DrawFrequencyBarValue();
SetBand();
SetFreq();
ShowFrequency();
MyDelay(1L);
ShowSpectrumdBScale();
AudioInterrupts();
EEPROMWrite();
// Draw or not draw CW filter graphics to audio spectrum area. KF5N July 30, 2023
tft.writeTo(L2);
tft.clearMemory();
if(xmtMode == CW_MODE) BandInformation();
DrawBandWidthIndicatorBar();
RedrawDisplayScreen(); // KD0RC
}