-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathactions.c
1226 lines (1216 loc) · 37.1 KB
/
actions.c
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
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <gtk/gtk.h>
#include <math.h>
#include "main.h"
#include "discovery.h"
#include "receiver.h"
#include "sliders.h"
#include "band_menu.h"
#include "diversity_menu.h"
#include "vfo.h"
#include "radio.h"
#include "radio_menu.h"
#include "new_menu.h"
#include "new_protocol.h"
#ifdef PURESIGNAL
#include "ps_menu.h"
#endif
#include "agc.h"
#include "filter.h"
#include "mode.h"
#include "band.h"
#include "bandstack.h"
#include "noise_menu.h"
#include "wdsp.h"
#ifdef CLIENT_SERVER
#include "client_server.h"
#endif
#include "ext.h"
#include "zoompan.h"
#include "actions.h"
#include "gpio.h"
#include "toolbar.h"
#ifdef LOCALCW
#include "iambic.h"
#endif
ACTION_TABLE ActionTable[] = {
{NO_ACTION, "NONE", NULL, TYPE_NONE},
{A_SWAP_B, "A<>B", "A<>B", MIDI_KEY | CONTROLLER_SWITCH},
{A_TO_B, "A>B", "A>B", MIDI_KEY | CONTROLLER_SWITCH},
{AF_GAIN, "AF GAIN", NULL, MIDI_KNOB | MIDI_WHEEL | CONTROLLER_ENCODER},
{AF_GAIN_RX1, "AF GAIN\nRX1", NULL, MIDI_KNOB | MIDI_WHEEL | CONTROLLER_ENCODER},
{AF_GAIN_RX2, "AF GAIN\nRX2", NULL, MIDI_KNOB | MIDI_WHEEL | CONTROLLER_ENCODER},
{AGC, "AGC", "AGC", MIDI_KEY | CONTROLLER_SWITCH},
{AGC_GAIN, "AGC GAIN", NULL, MIDI_KNOB | MIDI_WHEEL | CONTROLLER_ENCODER},
{AGC_GAIN_RX1, "AGC GAIN\nRX1", NULL, MIDI_KNOB | MIDI_WHEEL | CONTROLLER_ENCODER},
{AGC_GAIN_RX2, "AGC GAIN\nRX2", NULL, MIDI_KNOB | MIDI_WHEEL | CONTROLLER_ENCODER},
{ANF, "ANF", "ANF", MIDI_KEY | CONTROLLER_SWITCH},
{ATTENUATION, "ATTEN", NULL, MIDI_KNOB | MIDI_WHEEL | CONTROLLER_ENCODER},
{B_TO_A, "A<B", "A<B", MIDI_KEY | CONTROLLER_SWITCH},
{BAND_10, "BAND 10", "10", MIDI_KEY},
{BAND_12, "BAND 12", "12", MIDI_KEY},
{BAND_1240, "BAND 1240", "1240", MIDI_KEY},
{BAND_144, "BAND 144", "144", MIDI_KEY},
{BAND_15, "BAND 15", "15", MIDI_KEY},
{BAND_160, "BAND 160", "160", MIDI_KEY},
{BAND_17, "BAND 17", "17", MIDI_KEY},
{BAND_20, "BAND 20", "20", MIDI_KEY},
{BAND_220, "BAND 220", "220", MIDI_KEY},
{BAND_2300, "BAND 2300", "2300", MIDI_KEY},
{BAND_30, "BAND 30", "30", MIDI_KEY},
{BAND_3400, "BAND 3400", "3400", MIDI_KEY},
{BAND_40, "BAND 40", "40", MIDI_KEY},
{BAND_430, "BAND 430", "430", MIDI_KEY},
{BAND_6, "BAND 6", "6", MIDI_KEY},
{BAND_60, "BAND 60", "60", MIDI_KEY},
{BAND_70, "BAND 70", "70", MIDI_KEY},
{BAND_80, "BAND 80", "80", MIDI_KEY},
{BAND_902, "BAND 902", "902", MIDI_KEY},
{BAND_AIR, "BAND AIR", "AIR", MIDI_KEY},
{BAND_GEN, "BAND GEN", "GEN", MIDI_KEY},
{BAND_MINUS, "BAND -", "BND-", MIDI_KEY | CONTROLLER_SWITCH},
{BAND_PLUS, "BAND +", "BND+", MIDI_KEY | CONTROLLER_SWITCH},
{BAND_WWV, "BAND WWV", "WWV", MIDI_KEY},
{BANDSTACK_MINUS, "BANDSTACK -", "BSTK-", MIDI_KEY | CONTROLLER_SWITCH},
{BANDSTACK_PLUS, "BANDSTACK +", "BSTK+", MIDI_KEY | CONTROLLER_SWITCH},
{COMP_ENABLE, "COMP ON/OFF", "COMP", MIDI_KEY | CONTROLLER_SWITCH},
{COMPRESSION, "COMPRESSION", NULL, MIDI_KNOB | MIDI_WHEEL | CONTROLLER_ENCODER},
{CTUN, "CTUN", "CTUN", MIDI_KEY | CONTROLLER_SWITCH},
{CW_FREQUENCY, "CW FREQUENCY", NULL, MIDI_KNOB | MIDI_WHEEL | CONTROLLER_ENCODER},
{CW_LEFT, "CW LEFT", "CWL", MIDI_KEY | CONTROLLER_SWITCH},
{CW_RIGHT, "CW RIGHT", "CWR", MIDI_KEY | CONTROLLER_SWITCH},
{CW_SPEED, "CW SPEED", NULL, MIDI_KNOB | MIDI_WHEEL | CONTROLLER_ENCODER},
{DIV, "DIV ON/OFF", "DIV", MIDI_KEY | CONTROLLER_SWITCH},
{DIV_GAIN, "DIV GAIN", NULL, MIDI_WHEEL | CONTROLLER_ENCODER},
{DIV_GAIN_COARSE, "DIV GAIN\nCOARSE", NULL, MIDI_WHEEL | CONTROLLER_ENCODER},
{DIV_GAIN_FINE, "DIV GAIN\nFINE", NULL, MIDI_WHEEL | CONTROLLER_ENCODER},
{DIV_PHASE, "DIV PHASE", NULL, MIDI_WHEEL | CONTROLLER_ENCODER},
{DIV_PHASE_COARSE, "DIV PHASE\nCOARSE", NULL, MIDI_WHEEL | CONTROLLER_ENCODER},
{DIV_PHASE_FINE, "DIV PHASE\nFINE", NULL, MIDI_WHEEL | CONTROLLER_ENCODER},
{DRIVE, "TX DRIVE", NULL, MIDI_KNOB | MIDI_WHEEL | CONTROLLER_ENCODER},
{DUPLEX, "DUPLEX", "DUP", MIDI_KEY | CONTROLLER_SWITCH},
{FILTER_MINUS, "FILTER -", "FL-", MIDI_KEY | CONTROLLER_SWITCH},
{FILTER_PLUS, "FILTER +", "FL+", MIDI_KEY | CONTROLLER_SWITCH},
{FUNCTION, "FUNC", "FUNC", CONTROLLER_SWITCH},
{IF_SHIFT, "IF SHIFT", NULL, MIDI_WHEEL | CONTROLLER_ENCODER},
{IF_SHIFT_RX1, "IF SHIFT\nRX1", NULL, MIDI_WHEEL | CONTROLLER_ENCODER},
{IF_SHIFT_RX2, "IF SHIFT\nRX2", NULL, MIDI_WHEEL | CONTROLLER_ENCODER},
{IF_WIDTH, "IF WIDTH", NULL, MIDI_WHEEL | CONTROLLER_ENCODER},
{IF_WIDTH_RX1, "IF WIDTH\nRX1", NULL, MIDI_WHEEL | CONTROLLER_ENCODER},
{IF_WIDTH_RX2, "IF WIDTH\nRX2", NULL, MIDI_WHEEL | CONTROLLER_ENCODER},
{LINEIN_GAIN, "LINEIN\nGAIN", NULL, MIDI_KNOB | MIDI_WHEEL | CONTROLLER_ENCODER},
{LOCK, "LOCK", "LOCK", MIDI_KEY | CONTROLLER_SWITCH},
{MENU_AGC, "AGC\nMENU", "AGC", MIDI_KEY | CONTROLLER_SWITCH},
{MENU_BAND, "BAND\nMENU", "BAND", MIDI_KEY | CONTROLLER_SWITCH},
{MENU_BANDSTACK, "BSTK\nMENU", "BSTK", MIDI_KEY | CONTROLLER_SWITCH},
{MENU_DIVERSITY, "DIV\nMENU", "DIV", MIDI_KEY | CONTROLLER_SWITCH},
{MENU_FILTER, "FILT\nMENU", "FILT", MIDI_KEY | CONTROLLER_SWITCH},
{MENU_FREQUENCY, "FREQ\nMENU", "FREQ", MIDI_KEY | CONTROLLER_SWITCH},
{MENU_MEMORY, "MEM\nMENU", "MEM", MIDI_KEY | CONTROLLER_SWITCH},
{MENU_MODE, "MODE\nMENU", "MODE", MIDI_KEY | CONTROLLER_SWITCH},
{MENU_NOISE, "NOISE\nMENU", "NOISE", MIDI_KEY | CONTROLLER_SWITCH},
{MENU_PS, "PS MENU", "PS", MIDI_KEY | CONTROLLER_SWITCH},
{MIC_GAIN, "MIC GAIN", NULL, MIDI_KNOB | MIDI_WHEEL | CONTROLLER_ENCODER},
{MODE_MINUS, "MODE -", "MD-", MIDI_KEY | CONTROLLER_SWITCH},
{MODE_PLUS, "MODE +", "MD+", MIDI_KEY | CONTROLLER_SWITCH},
{MOX, "MOX", "MOX", MIDI_KEY | CONTROLLER_SWITCH},
{MUTE, "MUTE", "MUTE", MIDI_KEY | CONTROLLER_SWITCH},
{NB, "NB", "NB", MIDI_KEY | CONTROLLER_SWITCH},
{NR, "NR", "NR", MIDI_KEY | CONTROLLER_SWITCH},
{NUMPAD_0, "NUMPAD 0", "0", MIDI_KEY},
{NUMPAD_1, "NUMPAD 1", "1", MIDI_KEY},
{NUMPAD_2, "NUMPAD 2", "2", MIDI_KEY},
{NUMPAD_3, "NUMPAD 3", "3", MIDI_KEY},
{NUMPAD_4, "NUMPAD 4", "4", MIDI_KEY},
{NUMPAD_5, "NUMPAD 5", "5", MIDI_KEY},
{NUMPAD_6, "NUMPAD 6", "6", MIDI_KEY},
{NUMPAD_7, "NUMPAD 7", "7", MIDI_KEY},
{NUMPAD_8, "NUMPAD 8", "8", MIDI_KEY},
{NUMPAD_9, "NUMPAD 9", "9", MIDI_KEY},
{NUMPAD_CL, "NUMPAD\nCL", "CL", MIDI_KEY},
{NUMPAD_ENTER, "NUMPAD\nENTER", "EN", MIDI_KEY},
{PAN, "PAN", NULL, MIDI_WHEEL | CONTROLLER_ENCODER},
{PAN_MINUS, "PAN -", "PAN-", MIDI_KEY | CONTROLLER_SWITCH},
{PAN_PLUS, "PAN +", "PAN+", MIDI_KEY | CONTROLLER_SWITCH},
{PANADAPTER_HIGH, "PAN HIGH", NULL, MIDI_KNOB | MIDI_WHEEL | CONTROLLER_ENCODER},
{PANADAPTER_LOW, "PAN LOW", NULL, MIDI_KNOB | MIDI_WHEEL | CONTROLLER_ENCODER},
{PANADAPTER_STEP, "PAN STEP", NULL, MIDI_KNOB | MIDI_WHEEL | CONTROLLER_ENCODER},
{PREAMP, "PREAMP\nON/OFF", "PRE", MIDI_KEY | CONTROLLER_SWITCH},
{PS, "PS ON/OFF", "PS", MIDI_KEY | CONTROLLER_SWITCH},
{PTT, "PTT", "PTT", MIDI_KEY | CONTROLLER_SWITCH},
{RF_GAIN, "RF GAIN", NULL, MIDI_KNOB | MIDI_WHEEL | CONTROLLER_ENCODER},
{RF_GAIN_RX1, "RF GAIN\nRX1", NULL, MIDI_KNOB | MIDI_WHEEL | CONTROLLER_ENCODER},
{RF_GAIN_RX2, "RF GAIN\nRX2", NULL, MIDI_KNOB | MIDI_WHEEL | CONTROLLER_ENCODER},
{RIT, "RIT", NULL, MIDI_WHEEL | CONTROLLER_ENCODER},
{RIT_CLEAR, "RIT\nCLEAR", "RITCL", MIDI_KEY | CONTROLLER_SWITCH},
{RIT_ENABLE, "RIT\nON/OFF", "RIT", MIDI_KEY | CONTROLLER_SWITCH},
{RIT_MINUS, "RIT +", "RIT-", MIDI_KEY | CONTROLLER_SWITCH},
{RIT_PLUS, "RIT -", "RIT+", MIDI_KEY | CONTROLLER_SWITCH},
{RIT_RX1, "RIT\nRX1", NULL, MIDI_WHEEL | CONTROLLER_ENCODER},
{RIT_RX2, "RIT\nRX2", NULL, MIDI_WHEEL | CONTROLLER_ENCODER},
{RIT_STEP, "RIT\nSTEP", "RITST", MIDI_KEY | CONTROLLER_SWITCH},
{RSAT, "RSAT", "RSAT", MIDI_KEY | CONTROLLER_SWITCH},
{SAT, "SAT", "SAT", MIDI_KEY | CONTROLLER_SWITCH},
{SNB, "SNB", "SNB", MIDI_KEY | CONTROLLER_SWITCH},
{SPLIT, "SPLIT", "SPLIT", MIDI_KEY | CONTROLLER_SWITCH},
{SQUELCH, "SQUELCH", NULL, MIDI_KNOB | MIDI_WHEEL | CONTROLLER_ENCODER},
{SQUELCH_RX1, "SQUELCH\nRX1", NULL, MIDI_KNOB | MIDI_WHEEL | CONTROLLER_ENCODER},
{SQUELCH_RX2, "SQUELCH\nRX1", NULL, MIDI_KNOB | MIDI_WHEEL | CONTROLLER_ENCODER},
{SWAP_RX, "SWAP RX", "SWAPRX", MIDI_KEY | CONTROLLER_SWITCH},
{TUNE, "TUNE", "TUNE", MIDI_KEY | CONTROLLER_SWITCH},
{TUNE_DRIVE, "TUNE\nDRV", NULL, MIDI_KNOB | MIDI_WHEEL | CONTROLLER_ENCODER},
{TUNE_FULL, "TUNE\nFUL", "TUNF", MIDI_KEY | CONTROLLER_SWITCH},
{TUNE_MEMORY, "TUNE\nMEM", "TUNM", MIDI_KEY | CONTROLLER_SWITCH},
{TWO_TONE, "TWO TONE", "2TONE", MIDI_KEY | CONTROLLER_SWITCH},
{VFO, "VFO", NULL, MIDI_WHEEL | CONTROLLER_ENCODER},
{VFO_STEP_MINUS, "VFO STEP -", "STEP-", MIDI_KEY | CONTROLLER_SWITCH},
{VFO_STEP_PLUS, "VFO STEP +", "STEP+", MIDI_KEY | CONTROLLER_SWITCH},
{VFOA, "VFO A", NULL, MIDI_WHEEL | CONTROLLER_ENCODER},
{VFOB, "VFO B", NULL, MIDI_WHEEL | CONTROLLER_ENCODER},
{VOX, "VOX\nON/OFF", "VOX", MIDI_KEY | CONTROLLER_SWITCH},
{VOXLEVEL, "VOX\nLEVEL", NULL, MIDI_WHEEL | CONTROLLER_ENCODER},
{WATERFALL_HIGH, "WFALL\nHIGH", NULL, MIDI_WHEEL | CONTROLLER_ENCODER},
{WATERFALL_LOW, "WFALL\nLOW", NULL, MIDI_WHEEL | CONTROLLER_ENCODER},
{XIT , "XIT", NULL, MIDI_WHEEL | CONTROLLER_ENCODER},
{XIT_CLEAR, "XIT\nCLEAR", "XITCL", MIDI_KEY | CONTROLLER_SWITCH},
{XIT_ENABLE, "XIT\nON/OFF", "XIT", MIDI_KEY | CONTROLLER_SWITCH},
{XIT_MINUS, "XIT -", "XIT-", MIDI_KEY | CONTROLLER_SWITCH},
{XIT_PLUS, "XIT +", "XIT+", MIDI_KEY | CONTROLLER_SWITCH},
{ZOOM, "ZOOM", NULL, MIDI_WHEEL | CONTROLLER_ENCODER},
{ZOOM_MINUS, "ZOOM -", "ZOOM-", MIDI_KEY | CONTROLLER_SWITCH},
{ZOOM_PLUS, "ZOOM +", "ZOOM+", MIDI_KEY | CONTROLLER_SWITCH},
{ACTIONS, "", NULL, TYPE_NONE}
};
static gint timer=0;
static gboolean timer_released;
static int timeout_cb(gpointer data) {
if(timer_released) {
g_free(data);
timer=0;
return FALSE;
}
// process the action;
process_action(data);
return TRUE;
}
static inline double KnobOrWheel(PROCESS_ACTION *a, double oldval, double minval, double maxval, double inc) {
//
// Knob ("Potentiometer"): set value
// Wheel("Rotary Encoder"): increment/decrement the value (by "inc" per tick)
//
// In both cases, the returned value is
// - in the range minval...maxval
// - rounded to a multiple of inc
//
switch (a->mode) {
case RELATIVE:
oldval += a->val * inc;
break;
case ABSOLUTE:
oldval = minval + a->val*(maxval-minval)*0.01;
break;
default:
// do nothing
break;
}
//
// Round and check range
//
oldval=inc*round(oldval/inc);
if (oldval > maxval) oldval=maxval;
if (oldval < minval) oldval=minval;
return oldval;
}
int process_action(void *data) {
PROCESS_ACTION *a=(PROCESS_ACTION *)data;
double value;
int mode;
int id;
FILTER * band_filters=filters[vfo[active_receiver->id].mode];
FILTER *band_filter;
FILTER *filter;
int new_val;
int i;
gboolean free_action=TRUE;
//g_print("%s: action=%d mode=%d value=%d\n",__FUNCTION__,a->action,a->mode,a->val);
switch(a->action) {
case A_SWAP_B:
if(a->mode==PRESSED) {
vfo_a_swap_b();
}
break;
case A_TO_B:
if(a->mode==PRESSED) {
vfo_a_to_b();
}
break;
case AF_GAIN:
value=KnobOrWheel(a, active_receiver->volume, 0.0, 1.0, 0.01);
set_af_gain(active_receiver->id,value);
break;
case AF_GAIN_RX1:
value=KnobOrWheel(a, receiver[0]->volume, 0.0, 1.0, 0.01);
set_af_gain(0,value);
break;
case AF_GAIN_RX2:
value=KnobOrWheel(a, receiver[1]->volume, 0.0, 1.0, 0.01);
set_af_gain(1,value);
break;
case AGC:
if(a->mode==PRESSED) {
active_receiver->agc++;
if(active_receiver->agc>+AGC_LAST) {
active_receiver->agc=0;
}
set_agc(active_receiver, active_receiver->agc);
g_idle_add(ext_vfo_update, NULL);
}
break;
case AGC_GAIN:
value=KnobOrWheel(a, active_receiver->agc_gain, -20.0, 120.0, 1.0);
set_agc_gain(active_receiver->id,value);
break;
case AGC_GAIN_RX1:
value=KnobOrWheel(a, receiver[0]->agc_gain, -20.0, 120.0, 1.0);
set_agc_gain(0,value);
break;
case AGC_GAIN_RX2:
value=KnobOrWheel(a, receiver[1]->agc_gain, -20.0, 120.0, 1.0);
set_agc_gain(1,value);
break;
case ANF:
if(a->mode==PRESSED) {
if(active_receiver->anf==0) {
active_receiver->anf=1;
mode_settings[vfo[active_receiver->id].mode].anf=1;
} else {
active_receiver->anf=0;
mode_settings[vfo[active_receiver->id].mode].anf=0;
}
SetRXAANFRun(active_receiver->id, active_receiver->anf);
g_idle_add(ext_vfo_update, NULL);
}
break;
case ATTENUATION:
value=KnobOrWheel(a, adc[active_receiver->adc].attenuation, 0.0, 31.0, 1.0);
set_attenuation_value(value);
break;
case B_TO_A:
if(a->mode==PRESSED) {
vfo_b_to_a();
}
break;
case BAND_10:
if(a->mode==PRESSED) {
vfo_band_changed(active_receiver->id,band160);
}
break;
case BAND_12:
if(a->mode==PRESSED) {
vfo_band_changed(active_receiver->id,band12);
}
break;
#ifdef SOAPYSDR
case BAND_1240:
if(a->mode==PRESSED) {
vfo_band_changed(active_receiver->id,band1240);
}
break;
case BAND_144:
if(a->mode==PRESSED) {
vfo_band_changed(active_receiver->id,band144);
}
break;
#endif
case BAND_15:
if(a->mode==PRESSED) {
vfo_band_changed(active_receiver->id,band15);
}
break;
case BAND_160:
if(a->mode==PRESSED) {
vfo_band_changed(active_receiver->id,band160);
}
break;
case BAND_17:
if(a->mode==PRESSED) {
vfo_band_changed(active_receiver->id,band17);
}
break;
case BAND_20:
if(a->mode==PRESSED) {
vfo_band_changed(active_receiver->id,band20);
}
break;
#ifdef SOAPYSDR
case BAND_220:
if(a->mode==PRESSED) {
vfo_band_changed(active_receiver->id,band220);
}
break;
case BAND_2300:
if(a->mode==PRESSED) {
vfo_band_changed(active_receiver->id,band2300);
}
break;
#endif
case BAND_30:
if(a->mode==PRESSED) {
vfo_band_changed(active_receiver->id,band30);
}
break;
#ifdef SOAPYSDR
case BAND_3400:
if(a->mode==PRESSED) {
vfo_band_changed(active_receiver->id,band3400);
}
break;
#endif
case BAND_40:
if(a->mode==PRESSED) {
vfo_band_changed(active_receiver->id,band40);
}
break;
#ifdef SOAPYSDR
case BAND_430:
if(a->mode==PRESSED) {
vfo_band_changed(active_receiver->id,band430);
}
break;
#endif
case BAND_6:
if(a->mode==PRESSED) {
vfo_band_changed(active_receiver->id,band6);
}
break;
case BAND_60:
if(a->mode==PRESSED) {
vfo_band_changed(active_receiver->id,band60);
}
break;
#ifdef SOAPYSDR
case BAND_70:
if(a->mode==PRESSED) {
vfo_band_changed(active_receiver->id,band70);
}
break;
#endif
case BAND_80:
if(a->mode==PRESSED) {
vfo_band_changed(active_receiver->id,band80);
}
break;
#ifdef SOAPYSDR
case BAND_902:
if(a->mode==PRESSED) {
vfo_band_changed(active_receiver->id,band902);
}
break;
case BAND_AIR:
if(a->mode==PRESSED) {
vfo_band_changed(active_receiver->id,bandAIR);
}
break;
#endif
case BAND_GEN:
if(a->mode==PRESSED) {
vfo_band_changed(active_receiver->id,bandGen);
}
break;
case BAND_MINUS:
if(a->mode==PRESSED) {
long long frequency_min=radio->frequency_min;
long long frequency_max=radio->frequency_max;
int b=vfo[active_receiver->id].band;
BAND *band;
int found=0;
while(!found) {
b--;
if(b<0) b=BANDS+XVTRS-1;
band=(BAND*)band_get_band(b);
if(strlen(band->title)>0) {
if(b<BANDS) {
if(band->frequencyMin<frequency_min || band->frequencyMax>frequency_max) {
continue;
}
}
vfo_band_changed(active_receiver->id,b);
found=1;
}
}
}
break;
case BAND_PLUS:
if(a->mode==PRESSED) {
long long frequency_min=radio->frequency_min;
long long frequency_max=radio->frequency_max;
int b=vfo[active_receiver->id].band;
BAND *band;
int found=0;
while(!found) {
b++;
if(b>=BANDS+XVTRS) b=0;
band=(BAND*)band_get_band(b);
if(strlen(band->title)>0) {
if(b<BANDS) {
if(!(band->frequencyMin==0.0 && band->frequencyMax==0.0)) {
if(band->frequencyMin<frequency_min || band->frequencyMax>frequency_max) {
continue;
}
}
}
vfo_band_changed(active_receiver->id,b);
found=1;
}
}
}
break;
case BAND_WWV:
if(a->mode==PRESSED) {
vfo_band_changed(active_receiver->id,bandWWV);
}
break;
case BANDSTACK_MINUS:
if(a->mode==PRESSED) {
BAND *band=band_get_band(vfo[active_receiver->id].band);
BANDSTACK *bandstack=band->bandstack;
int b=vfo[active_receiver->id].bandstack-1;
if(b<0) b=bandstack->entries-1;;
vfo_bandstack_changed(b);
}
break;
case BANDSTACK_PLUS:
if(a->mode==PRESSED) {
BAND *band=band_get_band(vfo[active_receiver->id].band);
BANDSTACK *bandstack=band->bandstack;
int b=vfo[active_receiver->id].bandstack+1;
if(b>=bandstack->entries) b=0;
vfo_bandstack_changed(b);
}
break;
case COMP_ENABLE:
if(can_transmit && a->mode==PRESSED) {
transmitter_set_compressor(transmitter,transmitter->compressor?FALSE:TRUE);
}
break;
case COMPRESSION:
if(can_transmit) {
value=KnobOrWheel(a, transmitter->compressor_level, 0.0, 20.0, 1.0);
transmitter_set_compressor_level(transmitter,value);
transmitter_set_compressor(transmitter, value > 0.5);
g_idle_add(ext_vfo_update, NULL);
}
break;
case CTUN:
if(a->mode==PRESSED) {
vfo[active_receiver->id].ctun=!vfo[active_receiver->id].ctun;
if(!vfo[active_receiver->id].ctun) {
vfo[active_receiver->id].offset=0;
}
vfo[active_receiver->id].ctun_frequency=vfo[active_receiver->id].frequency;
set_offset(receiver[active_receiver->id],vfo[active_receiver->id].offset);
g_idle_add(ext_vfo_update, NULL);
}
break;
case CW_FREQUENCY:
#ifdef LOCALCW
value=KnobOrWheel(a, (double)cw_keyer_sidetone_frequency, 300.0, 1000.0, 10.0);
cw_keyer_sidetone_frequency=(int)value;
g_idle_add(ext_vfo_update,NULL);
#endif
break;
case CW_LEFT:
case CW_RIGHT:
if(a->mode==PRESSED || a->mode==RELEASED) {
#ifdef LOCALCW
keyer_event(a->action==CW_LEFT,a->mode==PRESSED);
#endif
}
break;
case CW_SPEED:
#ifdef LOCALCW
value=KnobOrWheel(a, (double)cw_keyer_speed, 1.0, 60.0, 1.0);
cw_keyer_speed=(int)value;
g_idle_add(ext_vfo_update,NULL);
#endif
break;
case DIV:
if(a->mode==PRESSED) {
diversity_enabled=diversity_enabled==1?0:1;
if (protocol == NEW_PROTOCOL) {
schedule_high_priority();
schedule_receive_specific();
}
g_idle_add(ext_vfo_update, NULL);
}
break;
case DIV_GAIN:
update_diversity_gain((double)a->val * 0.5);
break;
case DIV_GAIN_COARSE:
update_diversity_gain((double)a->val * 2.5);
break;
case DIV_GAIN_FINE:
update_diversity_gain((double)a->val * 0.1);
break;
case DIV_PHASE:
update_diversity_phase((double)a->val* 0.5);
break;
case DIV_PHASE_COARSE:
update_diversity_phase((double)a->val*2.5);
break;
case DIV_PHASE_FINE:
update_diversity_phase((double)a->val*0.1);
break;
case DRIVE:
value=KnobOrWheel(a, getDrive(), 0.0, drive_max, 1.0);
set_drive(value);
break;
case DUPLEX:
if(can_transmit && !isTransmitting() && a->mode == PRESSED) {
duplex=duplex==1?0:1;
g_idle_add(ext_set_duplex, NULL);
}
break;
case FILTER_MINUS:
if(a->mode==PRESSED) {
int f=vfo[active_receiver->id].filter+1;
if(f>=FILTERS) f=0;
vfo_filter_changed(f);
}
break;
case FILTER_PLUS:
if(a->mode==PRESSED) {
int f=vfo[active_receiver->id].filter-1;
if(f<0) f=FILTERS-1;
vfo_filter_changed(f);
}
break;
case FUNCTION:
if(a->mode==PRESSED) {
switch(controller) {
case NO_CONTROLLER:
case CONTROLLER1:
function++;
if(function>=MAX_FUNCTIONS) {
function=0;
}
toolbar_switches=switches_controller1[function];
switches=switches_controller1[function];
update_toolbar_labels();
break;
case CONTROLLER2_V1:
case CONTROLLER2_V2:
function++;
if(function>=MAX_FUNCTIONS) {
function=0;
}
toolbar_switches=switches_controller1[function];
update_toolbar_labels();
break;
}
}
break;
case IF_SHIFT:
filter_shift_changed(active_receiver->id,a->val);
break;
case IF_SHIFT_RX1:
filter_shift_changed(0,a->val);
break;
case IF_SHIFT_RX2:
filter_shift_changed(1,a->val);
break;
case IF_WIDTH:
filter_width_changed(active_receiver->id,a->val);
break;
case IF_WIDTH_RX1:
filter_width_changed(0,a->val);
break;
case IF_WIDTH_RX2:
filter_width_changed(1,a->val);
break;
//case LINEIN_GAIN:
case LOCK:
if(a->mode==PRESSED) {
#ifdef CLIENT_SERVER
if(radio_is_remote) {
send_lock(client_socket,locked==1?0:1);
} else {
#endif
locked=locked==1?0:1;
g_idle_add(ext_vfo_update, NULL);
#ifdef CLIENT_SERVER
}
#endif
}
break;
case MENU_AGC:
if(a->mode==PRESSED) {
start_agc();
}
break;
case MENU_BAND:
if(a->mode==PRESSED) {
start_band();
}
break;
case MENU_BANDSTACK:
if(a->mode==PRESSED) {
start_bandstack();
}
break;
case MENU_DIVERSITY:
if(a->mode==PRESSED) {
start_diversity();
}
break;
case MENU_FILTER:
if(a->mode==PRESSED) {
start_filter();
}
break;
case MENU_FREQUENCY:
if(a->mode==PRESSED) {
start_vfo(active_receiver->id);
}
break;
case MENU_MEMORY:
if(a->mode==PRESSED) {
start_store();
}
break;
case MENU_MODE:
if(a->mode==PRESSED) {
start_mode();
}
break;
case MENU_NOISE:
if(a->mode==PRESSED) {
start_noise();
}
break;
#ifdef PURESIGNAL
case MENU_PS:
if(a->mode==PRESSED) {
start_ps();
}
break;
#endif
case MIC_GAIN:
value=KnobOrWheel(a, mic_gain, -12.0, 50.0, 1.0);
set_mic_gain(value);
break;
case MODE_MINUS:
if(a->mode==PRESSED) {
int mode=vfo[active_receiver->id].mode;
mode--;
if(mode<0) mode=MODES-1;
vfo_mode_changed(mode);
}
break;
case MODE_PLUS:
if(a->mode==PRESSED) {
int mode=vfo[active_receiver->id].mode;
mode++;
if(mode>=MODES) mode=0;
vfo_mode_changed(mode);
}
break;
case MOX:
if(a->mode==PRESSED) {
if(getTune()==1) {
setTune(0);
}
if(getMox()==0) {
if(canTransmit() || tx_out_of_band) {
setMox(1);
} else {
transmitter_set_out_of_band(transmitter);
}
} else {
setMox(0);
}
g_idle_add(ext_vfo_update,NULL);
}
break;
case MUTE:
if(a->mode==PRESSED) {
active_receiver->mute_radio=!active_receiver->mute_radio;
}
break;
case NB:
if(a->mode==PRESSED) {
if(active_receiver->nb==0 && active_receiver->nb2==0) {
active_receiver->nb=1;
active_receiver->nb2=0;
mode_settings[vfo[active_receiver->id].mode].nb=1;
mode_settings[vfo[active_receiver->id].mode].nb2=0;
} else if(active_receiver->nb==1 && active_receiver->nb2==0) {
active_receiver->nb=0;
active_receiver->nb2=1;
mode_settings[vfo[active_receiver->id].mode].nb=0;
mode_settings[vfo[active_receiver->id].mode].nb2=1;
} else if(active_receiver->nb==0 && active_receiver->nb2==1) {
active_receiver->nb=0;
active_receiver->nb2=0;
mode_settings[vfo[active_receiver->id].mode].nb=0;
mode_settings[vfo[active_receiver->id].mode].nb2=0;
}
update_noise();
}
break;
case NR:
if(a->mode==PRESSED) {
if(active_receiver->nr==0 && active_receiver->nr2==0) {
active_receiver->nr=1;
active_receiver->nr2=0;
mode_settings[vfo[active_receiver->id].mode].nr=1;
mode_settings[vfo[active_receiver->id].mode].nr2=0;
} else if(active_receiver->nr==1 && active_receiver->nr2==0) {
active_receiver->nr=0;
active_receiver->nr2=1;
mode_settings[vfo[active_receiver->id].mode].nr=0;
mode_settings[vfo[active_receiver->id].mode].nr2=1;
} else if(active_receiver->nr==0 && active_receiver->nr2==1) {
active_receiver->nr=0;
active_receiver->nr2=0;
mode_settings[vfo[active_receiver->id].mode].nr=0;
mode_settings[vfo[active_receiver->id].mode].nr2=0;
}
update_noise();
}
break;
case NUMPAD_0:
if(a->mode==PRESSED) {
g_idle_add(ext_num_pad,GINT_TO_POINTER(0));
}
break;
case NUMPAD_1:
if(a->mode==PRESSED) {
g_idle_add(ext_num_pad,GINT_TO_POINTER(1));
}
break;
case NUMPAD_2:
if(a->mode==PRESSED) {
g_idle_add(ext_num_pad,GINT_TO_POINTER(2));
}
break;
case NUMPAD_3:
if(a->mode==PRESSED) {
g_idle_add(ext_num_pad,GINT_TO_POINTER(3));
}
break;
case NUMPAD_4:
if(a->mode==PRESSED) {
g_idle_add(ext_num_pad,GINT_TO_POINTER(4));
}
break;
case NUMPAD_5:
if(a->mode==PRESSED) {
g_idle_add(ext_num_pad,GINT_TO_POINTER(5));
}
break;
case NUMPAD_6:
if(a->mode==PRESSED) {
g_idle_add(ext_num_pad,GINT_TO_POINTER(6));
}
break;
case NUMPAD_7:
if(a->mode==PRESSED) {
g_idle_add(ext_num_pad,GINT_TO_POINTER(7));
}
break;
case NUMPAD_8:
if(a->mode==PRESSED) {
g_idle_add(ext_num_pad,GINT_TO_POINTER(8));
}
break;
case NUMPAD_9:
if(a->mode==PRESSED) {
g_idle_add(ext_num_pad,GINT_TO_POINTER(9));
}
break;
case NUMPAD_CL:
if(a->mode==PRESSED) {
g_idle_add(ext_num_pad,GINT_TO_POINTER(-1));
}
break;
case NUMPAD_ENTER:
if(a->mode==PRESSED) {
g_idle_add(ext_num_pad,GINT_TO_POINTER(-2));
}
break;
case PAN:
update_pan((double)a->val*100);
break;
case PAN_MINUS:
if(a->mode==PRESSED) {
update_pan(-100.0);
}
break;
case PAN_PLUS:
if(a->mode==PRESSED) {
update_pan(+100.0);
}
break;
case PANADAPTER_HIGH:
value=KnobOrWheel(a, active_receiver->panadapter_high, -60.0, 20.0, 1.0);
active_receiver->panadapter_high=(int)value;
break;
case PANADAPTER_LOW:
value=KnobOrWheel(a, active_receiver->panadapter_low, -160.0, -60.0, 1.0);
active_receiver->panadapter_low=(int)value;
break;
case PANADAPTER_STEP:
value=KnobOrWheel(a, active_receiver->panadapter_step, 5.0, 30.0, 1.0);
active_receiver->panadapter_step=(int)value;
break;
case PREAMP:
break;
case PS:
#ifdef PURESIGNAL
if(a->mode==PRESSED) {
if(can_transmit) {
if(transmitter->puresignal==0) {
tx_set_ps(transmitter,1);
} else {
tx_set_ps(transmitter,0);
}
}
}
#endif
break;
case PTT:
if(a->mode==PRESSED || a->mode==RELEASED) {
mox_update(a->mode==PRESSED);
}
break;
case RF_GAIN:
value=KnobOrWheel(a, adc[active_receiver->adc].gain, adc[active_receiver->adc].min_gain, adc[active_receiver->adc].max_gain, 1.0);
set_rf_gain(active_receiver->id,value);
break;
case RF_GAIN_RX1:
value=KnobOrWheel(a, adc[receiver[0]->adc].gain, adc[receiver[0]->adc].min_gain, adc[receiver[0]->adc].max_gain, 1.0);
set_rf_gain(0,value);
break;
case RF_GAIN_RX2:
value=KnobOrWheel(a, adc[receiver[1]->adc].gain, adc[receiver[1]->adc].min_gain, adc[receiver[1]->adc].max_gain, 1.0);
set_rf_gain(1,value);
break;
case RIT:
vfo_rit(active_receiver->id,a->val);
break;
case RIT_CLEAR:
if(a->mode==PRESSED) {
vfo_rit_clear(active_receiver->id);
}
break;
case RIT_ENABLE:
if(a->mode==PRESSED) {
vfo_rit_update(active_receiver->id);
}
break;
case RIT_MINUS:
if(a->mode==PRESSED) {
vfo_rit(active_receiver->id,-1);
if(timer==0) {
timer=g_timeout_add(250,timeout_cb,a);
timer_released=FALSE;
}
free_action=FALSE;
} else {
timer_released=TRUE;
}
break;
case RIT_PLUS:
if(a->mode==PRESSED) {
vfo_rit(active_receiver->id,1);
if(timer==0) {
timer=g_timeout_add(250,timeout_cb,a);
timer_released=FALSE;
}
free_action=FALSE;
} else {
timer_released=TRUE;
}
break;
case RIT_RX1:
vfo_rit(receiver[0]->id,a->val);
break;
case RIT_RX2:
vfo_rit(receiver[1]->id,a->val);
break;
case RIT_STEP:
switch(a->mode) {
case PRESSED:
a->val=1;
// fall through
case RELATIVE:
if(a->val>0) {
rit_increment=10*rit_increment;
} else {
rit_increment=rit_increment/10;
}
if(rit_increment<1) rit_increment=100;
if(rit_increment>100) rit_increment=1;
break;
default:
// ignore other types
break;
}
g_idle_add(ext_vfo_update,NULL);
break;
case RSAT:
if(a->mode==PRESSED) {
if(sat_mode==RSAT_MODE) {
sat_mode=SAT_NONE;
} else {
sat_mode=RSAT_MODE;
}
g_idle_add(ext_vfo_update, NULL);
}
break;
case SAT:
if(a->mode==PRESSED) {
if(sat_mode==SAT_MODE) {
sat_mode=SAT_NONE;
} else {
sat_mode=SAT_MODE;
}
g_idle_add(ext_vfo_update, NULL);
}
break;
case SNB:
if(a->mode==PRESSED) {
if(active_receiver->snb==0) {
active_receiver->snb=1;
mode_settings[vfo[active_receiver->id].mode].snb=1;
} else {
active_receiver->snb=0;
mode_settings[vfo[active_receiver->id].mode].snb=0;
}
update_noise();
}