1 // ----------------------------------------------------------------------------
2 // Copyright (C) 2014
3 // David Freese, W1HKJ
4 //
5 // This file is part of flrig.
6 //
7 // flrig is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // flrig is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 // ----------------------------------------------------------------------------
20
21 #include <stdlib.h>
22 #include <iostream>
23 #include <fstream>
24 #include <sstream>
25 #include <sys/types.h>
26 #include <sys/stat.h>
27 #include <stdlib.h>
28 #include <stdio.h>
29 #include <stdarg.h>
30 #include <fcntl.h>
31
32 #include <FL/Fl_Text_Display.H>
33 #include <FL/Fl_Text_Buffer.H>
34 #include <FL/Enumerations.H>
35
36 #include "icons.h"
37 #include "support.h"
38 #include "debug.h"
39 #include "gettext.h"
40 #include "rig_io.h"
41 #include "dialogs.h"
42 #include "rigbase.h"
43 #include "ptt.h"
44 #include "socket_io.h"
45 #include "ui.h"
46 #include "tod_clock.h"
47 #include "rig.h"
48 #include "rigs.h"
49 #include "K3_ui.h"
50 #include "KX3_ui.h"
51 #include "rigpanel.h"
52 #include "tod_clock.h"
53 #include "trace.h"
54 #include "cwio.h"
55 #include "xml_server.h"
56 #include "gpio_ptt.h"
57
58 void initTabs();
59
60 using namespace std;
61
62 rigbase *selrig = rigs[0];
63
64 extern bool test;
65 void init_notch_control();
66
67 bool flrig_abort = false;
68
69 int freqval = 0;
70
71 XCVR_STATE vfoA = XCVR_STATE(14070000, 0, 0, UI);
72 XCVR_STATE vfoB = XCVR_STATE(7070000, 0, 0, UI);
73 XCVR_STATE *vfo = &vfoA;
74
75 //XCVR_STATE xmlvfo = XCVR_STATE(14070000, 0, 0, UI);
76
77 XCVR_STATE xcvr_vfoA, xcvr_vfoB;
78
79 enum {VOL, MIC, PWR, SQL, IFSH, NOTCH, RFGAIN, NR, NB };
80
81 queue<VFOQUEUE> srvc_reqs;
82
83 bool useB = false;
84 bool changed_vfo = false;
85
86 const char **old_bws = NULL;
87
88 // Add alpha-tag to XCVR_STATE;
89 struct ATAG_XCVR_STATE {
90 long freq;
91 int imode;
92 int iBW;
93 int src;
94 char alpha_tag[ATAGSIZE];
95 };
96 ATAG_XCVR_STATE oplist[LISTSIZE];
97
98 int numinlist = 0;
99 vector<string> rigmodes_;
100 vector<string> rigbws_;
101
102 Cserial *RigSerial;
103 Cserial *AuxSerial;
104 Cserial *SepSerial;
105
106 bool using_buttons = false;
107
108 enum { SWR_IMAGE, ALC_IMAGE };
109 int meter_image = SWR_IMAGE;
110
111 bool xcvr_online = false;
112
113 //======================================================================
114 // slider change processing
115 //======================================================================
116 int inhibit_nb_level = 0;
117 int inhibit_volume = 0;
118 int inhibit_pbt = 0;
119 int inhibit_shift = 0;
120 int inhibit_nr = 0;
121 int inhibit_notch = 0;
122 int inhibit_power = 0;
123 int inhibit_mic = 0;
124 int inhibit_rfgain = 0;
125 int inhibit_squelch = 0;
126
127 struct SLIDER {
128 enum {NOTCH, SHIFT, INNER, OUTER, LOCK, VOLUME, MIC, POWER, SQUELCH, RFGAIN, NB_LEVEL, NR, NR_VAL};
129 int fnc;
130 int val;
131 };
132
133 //======================================================================
134 // loop for serial i/o thread
135 // runs continuously until program is closed
136 // only accesses the serial port if it has been successfully opened
137 //======================================================================
138
139 bool bypass_serial_thread_loop = true;
140 bool run_serial_thread = true;
141
142 bool PTT = false;
143
144 int powerlevel = 0;
145
printXCVR_STATE(XCVR_STATE & data)146 string printXCVR_STATE(XCVR_STATE &data)
147 {
148 stringstream str;
149 const char **bwt = selrig->bwtable(data.imode);
150 const char **dsplo = selrig->lotable(data.imode);
151 const char **dsphi = selrig->hitable(data.imode);
152 str << data.freq << ", ";
153 str <<
154 (selrig->modes_ ? selrig->modes_[data.imode] : "modes n/a");
155 if (data.iBW > 256 && selrig->has_dsp_controls) {
156 str << ", " <<
157 (dsplo ? dsplo[data.iBW & 0x7F] : "??");
158 } else if (bwt) {
159 str << ", " << bwt[data.iBW];
160 } else
161 str << ", n/a";
162
163 if (data.iBW > 256 && selrig->has_dsp_controls) {
164 str << ", " <<
165 (dsphi ? dsphi[(data.iBW >> 8) & 0x7F] : "??");
166 }
167
168 return str.str();
169 }
170
print_ab()171 string print_ab()
172 {
173 std::string s;
174 s.assign("VFO-A: ");
175 s.append(printXCVR_STATE(vfoA));
176 s.append("; VFO-B: ");
177 s.append(printXCVR_STATE(vfoB));
178 return s;
179 }
180
print(XCVR_STATE & data)181 char *print(XCVR_STATE &data)
182 {
183 static char str[1024];
184 const char **bwt = selrig->bwtable(data.imode);
185 const char **dsplo = selrig->lotable(data.imode);
186 const char **dsphi = selrig->hitable(data.imode);
187 snprintf(
188 str, sizeof(str),
189 "\
190 Data Source: %s\n\
191 freq ........... %ld\n\
192 mode ........... %d [%s]\n\
193 filter ......... %s\n\
194 bwt index ...... %2d, [%s] [%s]\n\
195 split .......... %4d, power_control . %4d, volume_control %4d\n\
196 attenuator ..... %4d, preamp ........ %4d, rf gain ....... %4d\n\
197 if_shift ....... %4d, shift val ..... %4d\n\
198 auto notch ..... %4d, notch ......... %4d, notch value ... %4d\n\
199 noise .......... %4d, nr ............ %4d, nr val ........ %4d\n\
200 mic gain ....... %4d, agc level ..... %4d, squelch ....... %4d\n\
201 compression .... %4d, compON ........ %4d",
202 data.src == XML ? "XML" : data.src == UI ? "UI" :
203 data.src == SRVR ? "SRVR" : "RIG",
204 data.freq,
205 data.imode,
206 selrig->modes_ ? selrig->modes_[data.imode] : "modes n/a",
207 selrig->has_FILTER ? selrig->FILT(selrig->get_FILT(data.imode)) : "n/a",
208 data.iBW,
209 (data.iBW > 256 && selrig->has_dsp_controls) ?
210 (dsplo ? dsplo[data.iBW & 0x7F] : "??") : (bwt ? bwt[data.iBW] : "n/a"),
211 (data.iBW > 256 && selrig->has_dsp_controls) ?
212 (dsphi ? dsphi[(data.iBW >> 8) & 0x7F] : "??") : "",
213 data.split,
214 data.power_control,
215 data.volume_control,
216 data.attenuator,
217 data.preamp,
218 data.rf_gain,
219 data.if_shift,
220 data.shift_val,
221 data.auto_notch,
222 data.notch,
223 data.notch_val,
224 data.noise,
225 data.nr,
226 data.nr_val,
227 data.mic_gain,
228 data.agc_level,
229 data.squelch,
230 data.compression,
231 data.compON
232 );
233 return str;
234 }
235
236 // the following functions are ONLY CALLED by the serial loop
237 // read any data stream sent by transceiver
238 // support for the K3 and KX3 read of VFO, MODE and BW are
239 // in the K3_ui and KX3_ui source files
240
read_info()241 void read_info()
242 {
243 trace(1,"read_info()");
244 selrig->get_info();
245 }
246
247 // read current vfo frequency
248
read_vfo()249 void read_vfo()
250 {
251 // transceiver changed ?
252 trace(1,"read_vfo()");
253 unsigned long int freq;
254 if (!useB) { // vfo-A
255 trace(2, "vfoA active", "get vfo A");
256 freq = selrig->get_vfoA();
257 if (freq != vfoA.freq) {
258 vfoA.freq = freq;
259 Fl::awake(setFreqDispA, (void *)vfoA.freq);
260 vfo = &vfoA;
261 }
262 if ( selrig->twovfos() ) {
263 trace(2, "vfoA active", "get vfo B");
264 freq = selrig->get_vfoB();
265 if (freq != vfoB.freq) {
266 vfoB.freq = freq;
267 Fl::awake(setFreqDispB, (void *)vfoB.freq);
268 }
269 }
270 } else { // vfo-B
271 trace(2, "vfoB active", "get vfo B");
272 freq = selrig->get_vfoB();
273 if (freq != vfoB.freq) {
274 vfoB.freq = freq;
275 Fl::awake(setFreqDispB, (void *)vfoB.freq);
276 vfo = &vfoB;
277 }
278 if ( selrig->twovfos() ) {
279 trace(2, "vfoB active", "get vfo A");
280 freq = selrig->get_vfoA();
281 if (freq != vfoA.freq) {
282 vfoA.freq = freq;
283 Fl::awake(setFreqDispA, (void *)vfoA.freq);
284 }
285 }
286 }
287 }
288
updateUI(void *)289 void updateUI(void *)
290 {
291 setModeControl(NULL);
292 setBWControl(NULL);
293 updateBandwidthControl(NULL);
294 highlight_vfo(NULL);
295 }
296
update_vfoAorB(void * d)297 void update_vfoAorB(void *d)
298 {
299 if (xcvr_name == rig_FT817.name_) {
300 trace(1,"FT817, update_vfoAorB()");
301 if (useB) {
302 vfoB.src = RIG;
303 vfoB.freq = selrig->get_vfoB();
304 vfoB.imode = selrig->get_modeB();
305 vfoB.iBW = selrig->get_bwB();
306 } else {
307 vfoA.src = RIG;
308 vfoA.freq = selrig->get_vfoA();
309 vfoA.imode = selrig->get_modeA();
310 vfoA.iBW = selrig->get_bwA();
311 }
312 return;
313 }
314 updateUI((void*)0);
315 }
316
read_vfoAorB()317 void read_vfoAorB()
318 {
319 int val;
320 if (selrig->has_getvfoAorB) {
321 {
322 trace(1,"read_vfoAorB()");
323 val = selrig->get_vfoAorB();
324 if (val == -1) val = 0;
325 }
326 if (val != useB) {
327 useB = val;
328 Fl::awake(update_vfoAorB, reinterpret_cast<void*>(val));
329 MilliSleep(50);
330 }
331 }
332 }
333
setModeControl(void *)334 void setModeControl(void *)
335 {
336 opMODE->index(vfo->imode);
337
338 // enables/disables the IF shift control, depending on the mode.
339 // the IF Shift function, is ONLY valid in CW modes, with the 870S.
340
341 if (xcvr_name == rig_TS870S.name_) {
342 if (vfo->imode == RIG_TS870S::tsCW || vfo->imode == RIG_TS870S::tsCWR) {
343 btnIFsh->activate();
344 if (sldrIFSHIFT) sldrIFSHIFT->activate();
345 if (spnrIFSHIFT) spnrIFSHIFT->activate();
346 } else {
347 btnIFsh->deactivate();
348 if (sldrIFSHIFT) sldrIFSHIFT->deactivate();
349 if (spnrIFSHIFT) spnrIFSHIFT->deactivate();
350 }
351 }
352 init_notch_control();
353 }
354
setFILTER(void *)355 void setFILTER(void *)
356 {
357 if (selrig->has_FILTER) {
358 if (useB)
359 btnFILT->label(selrig->FILT(vfoB.filter));
360 else
361 btnFILT->label(selrig->FILT(vfoA.filter));
362 btnFILT->redraw_label();
363 trace(3, "Filter", (useB ? "B" : "A"), btnFILT->label());
364 }
365 }
366
367 // mode and bandwidth
read_mode()368 void read_mode()
369 {
370 int nu_mode;
371 int nu_BW;
372 if (!useB) {
373 trace(2, "read_mode", "vfoA active");
374 nu_mode = selrig->get_modeA();
375 vfoA.filter = selrig->get_FILT(nu_mode);
376 if (nu_mode != vfoA.imode) {
377 {
378 vfoA.imode = vfo->imode = nu_mode;
379 selrig->adjust_bandwidth(vfo->imode);
380 nu_BW = selrig->get_bwA();
381 vfoA.iBW = vfo->iBW = nu_BW;
382 }
383 Fl::awake(setModeControl);
384 set_bandwidth_control();
385 }
386 Fl::awake(setFILTER);
387 if (selrig->can_change_alt_vfo) {
388 vfoB.imode = selrig->get_modeB();
389 vfoB.filter = selrig->get_FILT(vfoB.imode);
390 }
391 } else {
392 trace(2, "read_mode", "vfoB active");
393 nu_mode = selrig->get_modeB();
394 vfoB.filter = selrig->get_FILT(nu_mode);
395 if (nu_mode != vfoB.imode) {
396 {
397 vfoB.imode = vfo->imode = nu_mode;
398 selrig->adjust_bandwidth(vfo->imode);
399 nu_BW = selrig->get_bwB();
400 vfoB.iBW = vfo->iBW = nu_BW;
401 }
402 Fl::awake(setModeControl);
403 set_bandwidth_control();
404 }
405 Fl::awake(setFILTER);
406 if (selrig->can_change_alt_vfo) {
407 vfoA.imode = selrig->get_modeA();
408 vfoA.filter = selrig->get_FILT(vfoA.imode);
409 }
410 }
411 }
412
setBWControl(void *)413 void setBWControl(void *)
414 {
415 if (selrig->has_dsp_controls) {
416 if (opDSP_lo->isbusy() || opDSP_hi->isbusy())
417 return;
418 if (vfo->iBW > 256) {
419 opBW->index(0);
420 opBW->hide();
421 if (opDSP_lo->visible()) {
422 opDSP_hi->index((vfo->iBW >> 8) & 0x7F);
423 opDSP_hi->hide();
424 opDSP_lo->index(vfo->iBW & 0xFF);
425 opDSP_lo->show();
426 } else {
427 opDSP_hi->index((vfo->iBW >> 8) & 0x7F);
428 opDSP_lo->index(vfo->iBW & 0xFF);
429 opDSP_lo->hide();
430 opDSP_hi->show();
431 }
432 btnDSP->label(selrig->SL_label);
433 btnDSP->redraw_label();
434 btnDSP->show();
435 } else {
436 opDSP_lo->index(0);
437 opDSP_hi->index(0);
438 opDSP_lo->hide();
439 opDSP_hi->hide();
440 btnDSP->hide();
441 opBW->index(vfo->iBW);
442 opBW->show();
443 }
444 }
445 else {
446 if (opBW->isbusy())
447 return;
448 opDSP_lo->hide();
449 opDSP_hi->hide();
450 btnDSP->hide();
451 opBW->index(vfo->iBW);
452 opBW->show();
453 }
454 }
455
read_bandwidth()456 void read_bandwidth()
457 {
458 trace(1,"read_bandwidth()");
459 int nu_BW;
460 if (!useB) {
461 trace(2, "vfoA active", "get_bwA()");
462 nu_BW = selrig->get_bwA();
463 if (nu_BW != vfoA.iBW) {
464 stringstream s;
465 s << "Bandwidth A change. nu_BW=" << nu_BW << ", vfoA.iBW=" << vfoA.iBW << ", vfo->iBW=" << vfo->iBW;
466 trace(1, s.str().c_str());
467 vfoA.iBW = vfo->iBW = nu_BW;
468 }
469 } else {
470 trace(2, "vfoB active", "get_bwB()");
471 nu_BW = selrig->get_bwB();
472 if (nu_BW != vfoB.iBW) {
473 stringstream s;
474 s << "Bandwidth B change. nu_BW=" << nu_BW << ", vfoB.iBW=" << vfoB.iBW << ", vfo->iBW=" << vfo->iBW;
475 trace(1, s.str().c_str());
476 vfoB.iBW = vfo->iBW = nu_BW;
477 }
478 }
479 Fl::awake(setBWControl);
480 }
481
482 // read current signal level
483 int mval = 0;
read_smeter()484 void read_smeter()
485 {
486 if (!selrig->has_smeter) return;
487 int sig;
488 {
489 trace(1,"read_smeter()");
490 sig = selrig->get_smeter();
491 }
492 if (sig == -1) return;
493 mval = sig;
494 Fl::awake(updateSmeter, reinterpret_cast<void*>(sig));
495 }
496
497 int tunerval = 0;
update_UI_TUNER(void *)498 void update_UI_TUNER(void *)
499 {
500 btn_tune_on_off->value(tunerval);
501 btn_tune_on_off->redraw();
502 }
503
read_tuner()504 void read_tuner()
505 {
506 if (!selrig->has_tune_control) return;
507
508 tunerval = selrig->get_tune();
509 if (tunerval != btn_tune_on_off->value()) {
510 stringstream s;
511 s << "tuner state: " << tunerval;
512 trace(1, s.str().c_str());
513 Fl::awake(update_UI_TUNER);
514 }
515 }
516
517 // read power out
518 int pwrval = 0;
read_power_out()519 void read_power_out()
520 {
521 if (!selrig->has_power_out) return;
522 int sig;
523 {
524 trace(1,"read_power_out()");
525 sig = selrig->get_power_out();
526 }
527 if (sig == -1) return;
528 pwrval = sig;
529 Fl::awake(updateFwdPwr, reinterpret_cast<void*>(sig));
530 }
531
532 // read swr
533 int swrval = 0;
read_swr()534 void read_swr()
535 {
536 if ((meter_image != SWR_IMAGE) ||
537 !selrig->has_swr_control) return;
538 int sig;
539 {
540 trace(1,"read_swr()");
541 sig = selrig->get_swr();
542 }
543 if (sig == -1) return;
544 swrval = sig;
545 Fl::awake(updateSWR, reinterpret_cast<void*>(sig));
546 }
547
548 // alc
read_alc()549 void read_alc()
550 {
551 if ((meter_image != ALC_IMAGE) ||
552 !selrig->has_alc_control) return;
553 int sig;
554 {
555 trace(1,"read_alc()");
556 sig = selrig->get_alc();
557 }
558 if (sig > -1)
559 Fl::awake(updateALC, reinterpret_cast<void*>(sig));
560 }
561
562 // notch
update_auto_notch(void * d)563 void update_auto_notch(void *d)
564 {
565 btnAutoNotch->value(progStatus.auto_notch);
566 }
567
read_auto_notch()568 void read_auto_notch()
569 {
570 int val;
571 if (!selrig->has_auto_notch) return;
572 {
573 trace(1,"read_auto_notch()");
574 val = selrig->get_auto_notch();
575 }
576 if (val != progStatus.auto_notch) {
577 progStatus.auto_notch = vfo->auto_notch = val;
578 Fl::awake(update_auto_notch, (void*)0);
579 }
580 }
581
582 // NOISE blanker
update_noise(void * d)583 void update_noise(void *d)
584 {
585 btnNOISE->value(progStatus.noise);
586 btnNOISE->redraw();
587 sldr_nb_level->value(progStatus.nb_level);
588 sldr_nb_level->redraw();
589 }
590
read_noise()591 void read_noise()
592 {
593 int on = 0, val = 0;
594 if (inhibit_nb_level > 0) {
595 inhibit_nb_level--;
596 return;
597 }
598 {
599 trace(1,"read_noise()");
600 on = selrig->get_noise();
601 val = selrig->get_nb_level();
602 }
603 if ((on != progStatus.noise) || (val != progStatus.nb_level)) {
604 vfo->noise = progStatus.noise = on;
605 vfo->nb_level = progStatus.nb_level = val;
606 Fl::awake(update_noise, (void*)0);
607 }
608 }
609
610 // compression
update_compression(void * d)611 void update_compression(void *d)
612 {
613 if (btnCompON) btnCompON->value(progStatus.compON);
614 if (spnr_compression) spnr_compression->value(progStatus.compression);
615 }
616
read_compression()617 void read_compression()
618 {
619 int on = progStatus.compON;
620 int val = progStatus.compression;
621 if (selrig->has_compression || selrig->has_compON) {
622 {
623 trace(1,"read_compression()");
624 selrig->get_compression( on, val );
625 }
626 if (on != progStatus.compON || val != progStatus.compression) {
627 vfo->compression = progStatus.compression = val;
628 vfo->compON = progStatus.compON = on;
629 Fl::awake(update_compression, (void*)0);
630 }
631 }
632 }
633
634 // preamp - attenuator
update_preamp(void * d)635 void update_preamp(void *d)
636 {
637 btnPreamp->value(progStatus.preamp);
638 }
639
update_attenuator(void * d)640 void update_attenuator(void *d)
641 {
642 btnAttenuator->value(progStatus.attenuator);
643 btnAttenuator->redraw();
644 }
645
read_preamp_att()646 void read_preamp_att()
647 {
648 int val;
649 if (selrig->has_preamp_control) {
650 {
651 trace(1,"read_preamp_att() 1");
652 val = selrig->get_preamp();
653 }
654 if (val != progStatus.preamp || val != vfo->preamp || (btnPreamp && val != btnPreamp->value())) {
655 vfo->preamp = progStatus.preamp = val;
656 Fl::awake(update_preamp, (void*)0);
657 }
658 }
659 if (selrig->has_attenuator_control) {
660 {
661 trace(1,"read_preamp_att() 2");
662 val = selrig->get_attenuator();
663 }
664 if (val != progStatus.attenuator || val != vfo->attenuator || (btnAttenuator && val != btnAttenuator->value())) {
665 vfo->attenuator = progStatus.attenuator = val;
666 Fl::awake(update_attenuator, (void*)0);
667 }
668 }
669 }
670
671 // split
update_split(void * d)672 void update_split(void *d)
673 {
674 /*
675 if (xcvr_name == rig_yaesu.name_ || xcvr_name == rig_FTdx1200.name_ ||
676 xcvr_name == rig_TS480SAT.name_ || xcvr_name == rig_TS480HX.name_ ||
677 xcvr_name == rig_TS590S.name_ || xcvr_name == rig_TS590SG.name_ ||
678 xcvr_name == rig_TS890S.name_ ||
679 xcvr_name == rig_TS2000.name_ || xcvr_name == rig_TS990.name_) {
680 switch (progStatus.split) {
681 case 0: btnSplit->value(0);
682 useB = false;
683 highlight_vfo(NULL);
684 break;
685 case 1: btnSplit->value(1);
686 useB = true;
687 highlight_vfo(NULL);
688 break;
689 case 2: btnSplit->value(1);
690 useB = false;
691 highlight_vfo(NULL);
692 break;
693 case 3: btnSplit->value(0);
694 useB = true;
695 highlight_vfo(NULL);
696 break;
697 }
698 } else
699 */
700 btnSplit->value(progStatus.split);
701 btnSplit->redraw();
702 }
703
read_split()704 void read_split()
705 {
706 int val = progStatus.split;
707 if (selrig->has_split) {
708 val = selrig->get_split();
709 vfo->split = progStatus.split = val;
710 Fl::awake(update_split, (void*)0);
711 ostringstream s;
712 s << "read_split() " << (val ? "ON" : "OFF");
713 trace(1, s.str().c_str());
714 } else {
715 vfo->split = progStatus.split;
716 }
717 }
718
719 // volume
update_volume(void * d)720 void update_volume(void *d)
721 {
722 long *nr = (long *)d;
723 if (spnrVOLUME) {
724 spnrVOLUME->value(progStatus.volume);
725 spnrVOLUME->activate();
726 spnrVOLUME->redraw();
727 }
728
729 if (sldrVOLUME) {
730 sldrVOLUME->value(progStatus.volume); // Set slider to last known value
731 sldrVOLUME->activate(); // activate it
732 sldrVOLUME->redraw();
733 }
734
735 if (*nr) btnVol->value(1); // Button Lit
736 else btnVol->value(0); // Button Dark.
737 btnVol->redraw();
738 }
739
740 long nlzero = 0L;
741 long nlone = 1L;
742
read_volume()743 void read_volume()
744 {
745 if (inhibit_volume > 0) {
746 inhibit_volume--;
747 return;
748 }
749 if (!selrig->has_volume_control) return;
750 int vol;
751 {
752 trace(1,"read_volume()");
753 vol = selrig->get_volume_control();
754 }
755 if (vol != progStatus.volume) {
756 if (vol <= 1 && !btnVol->value()) return;
757 progStatus.volume = vol;
758 if (vol <= 1 && btnVol->value())
759 Fl::awake(update_volume, (void*)&nlzero);
760 else
761 Fl::awake(update_volume, (void*)&nlone);
762 }
763 }
764
765 // ifshift
update_ifshift(void * d)766 void update_ifshift(void *d)
767 {
768 btnIFsh->value(progStatus.shift);
769 btnIFsh->redraw();
770 if (sldrIFSHIFT) {
771 sldrIFSHIFT->value(progStatus.shift_val);
772 sldrIFSHIFT->redraw();
773 }
774 if (spnrIFSHIFT) {
775 spnrIFSHIFT->value(progStatus.shift_val);
776 spnrIFSHIFT->redraw();
777 }
778 }
779
update_pbt(void *)780 void update_pbt(void *)
781 {
782 if (sldrINNER) {
783 sldrINNER->value(progStatus.pbt_inner);
784 sldrINNER->redraw();
785 }
786 if (sldrOUTER) {
787 sldrOUTER->value(progStatus.pbt_outer);
788 sldrOUTER->redraw();
789 }
790 }
791
read_pbt()792 void read_pbt()
793 {
794 if (inhibit_pbt > 0) {
795 inhibit_pbt--;
796 return;
797 }
798 progStatus.pbt_inner = selrig->get_pbt_inner();
799 progStatus.pbt_outer = selrig->get_pbt_outer();
800 Fl::awake(update_pbt, (void*)0);
801 }
802
read_ifshift()803 void read_ifshift()
804 {
805 int on = 0;
806 int val = 0;
807 if (selrig->has_pbt_controls)
808 return read_pbt();
809
810 if (inhibit_shift > 0) {
811 inhibit_shift--;
812 return;
813 }
814 if (!selrig->has_ifshift_control) return;
815 {
816 trace(1,"read_if_shift()");
817 on = selrig->get_if_shift(val);
818 }
819 if ((on != progStatus.shift) || (val != progStatus.shift_val)) {
820 vfo->if_shift = progStatus.shift = on;
821 vfo->shift_val = progStatus.shift_val = val;
822 Fl::awake(update_ifshift, (void*)0);
823 }
824 }
825
826 // noise reduction
update_nr(void * d)827 void update_nr(void *d)
828 {
829 btnNR->value(progStatus.noise_reduction);
830 btnNR->redraw();
831 if (sldrNR) {
832 sldrNR->value(progStatus.noise_reduction_val);
833 sldrNR->redraw();
834 }
835 if (spnrNR) {
836 spnrNR->value(progStatus.noise_reduction_val);
837 spnrNR->redraw();
838 }
839 }
840
read_nr()841 void read_nr()
842 {
843 int on = 0;
844 int val = 0;
845 if (inhibit_nr > 0) {
846 inhibit_nr--;
847 return;
848 }
849 if (!selrig->has_noise_reduction) return;
850 {
851 trace(1,"read_nr()");
852 on = selrig->get_noise_reduction();
853 val = selrig->get_noise_reduction_val();
854 }
855 if ((on != progStatus.noise_reduction) || (val != progStatus.noise_reduction_val)) {
856 vfo->nr = progStatus.noise_reduction = on;
857 vfo->nr_val = progStatus.noise_reduction_val = val;
858 Fl::awake(update_nr, (void*)0);
859 }
860 }
861
862 // manual notch
update_notch(void * d)863 void update_notch(void *d)
864 {
865 btnNotch->value(progStatus.notch);
866 btnNotch->redraw();
867 if (sldrNOTCH) {
868 sldrNOTCH->value(progStatus.notch_val);
869 sldrNOTCH->redraw();
870 }
871 if (spnrNOTCH) {
872 spnrNOTCH->value(progStatus.notch_val);
873 spnrNOTCH->redraw();
874 }
875 }
876
read_notch()877 void read_notch()
878 {
879 int on = progStatus.notch;
880 int val = progStatus.notch_val;
881 if (inhibit_notch > 0) {
882 inhibit_notch--;
883 return;
884 }
885 if (!selrig->has_notch_control) return;
886 {
887 trace(1,"read_notch()");
888 on = selrig->get_notch(val);
889 }
890 if ((on != progStatus.notch) || (val != progStatus.notch_val)) {
891 vfo->notch_val = progStatus.notch_val = val;
892 vfo->notch = progStatus.notch = on;
893 Fl::awake(update_notch, (void*)0);
894 }
895 }
896
897 // power_control
update_power_control(void * d)898 void update_power_control(void *d)
899 {
900 set_power_controlImage(progStatus.power_level);
901 if (sldrPOWER) {
902 sldrPOWER->value(progStatus.power_level);
903 sldrPOWER->redraw();
904 }
905 if (spnrPOWER) {
906 spnrPOWER->value(progStatus.power_level);
907 spnrPOWER->redraw();
908 }
909 if (xcvr_name == rig_K2.name_) {
910 double min, max, step;
911 selrig->get_pc_min_max_step(min, max, step);
912 if (sldrPOWER) sldrPOWER->minimum(min);
913 if (sldrPOWER) sldrPOWER->maximum(max);
914 if (sldrPOWER) sldrPOWER->step(step);
915 if (sldrPOWER) sldrPOWER->redraw();
916 if (spnrPOWER) spnrPOWER->minimum(min);
917 if (spnrPOWER) spnrPOWER->maximum(max);
918 if (spnrPOWER) spnrPOWER->step(step);
919 if (spnrPOWER) spnrPOWER->redraw();
920 }
921 }
922
read_power_control()923 void read_power_control()
924 {
925 int val;
926 if (inhibit_power > 0) {
927 inhibit_power--;
928 return;
929 }
930 if (!selrig->has_power_control) return;
931 {
932 trace(1,"read_power_control()");
933 val = selrig->get_power_control();
934 }
935 if (val != progStatus.power_level || val != vfo->power_control || (sldrPOWER && val != sldrPOWER->value()) ) {
936 stringstream s;
937 s << "read_power_control(), UPDATE progStatus.power_level=" << progStatus.power_level << ", vfo->power_control=" << vfo->power_control << ", radio power=" << val << ", sldrPOWER->value()=" << (sldrPOWER ? sldrPOWER->value() : -1);
938 trace(1, s.str().c_str());
939
940 vfo->power_control = progStatus.power_level = val;
941 Fl::awake(update_power_control, (void*)0);
942 }
943 //else
944 //{
945 // stringstream s;
946 // s << "read_power_control(), CURRENT progStatus.power_level=" << progStatus.power_level << ", vfo->power_control=" << vfo->power_control << ", read power=" << val << ", sldrPOWER->value()=" << (sldrPOWER ? sldrPOWER->value() : -1);
947 // trace(1, s.str().c_str());
948 //}
949 }
950
951 // mic gain
update_mic_gain(void * d)952 void update_mic_gain(void *d)
953 {
954 if (sldrMICGAIN) {
955 sldrMICGAIN->value(progStatus.mic_gain);
956 sldrMICGAIN->redraw();
957 }
958 if (spnrMICGAIN) {
959 spnrMICGAIN->value(progStatus.mic_gain);
960 spnrMICGAIN->redraw();
961 }
962 }
963
read_mic_gain()964 void read_mic_gain()
965 {
966 int val;
967 if (inhibit_mic > 0) {
968 inhibit_mic--;
969 return;
970 }
971 if (!selrig->has_micgain_control) return;
972 {
973 trace(1,"read_mic_gain()");
974 val = selrig->get_mic_gain();
975 }
976 if (val != progStatus.mic_gain || val != vfo->mic_gain || (sldrMICGAIN && val != sldrMICGAIN->value())) {
977 vfo->mic_gain = progStatus.mic_gain = val;
978 Fl::awake(update_mic_gain, (void*)0);
979 }
980 }
981
read_agc()982 void read_agc()
983 {
984 int val;
985 if (!selrig->has_agc_control) return;
986 trace(1,"read_agc()");
987 val = selrig->get_agc();
988 if (val != progStatus.agc_level) {
989 vfo->agc_level = progStatus.agc_level = val;
990 Fl::awake(setAGC);
991 }
992 }
993
994 // rf gain
update_rfgain(void * d)995 void update_rfgain(void *d)
996 {
997 if (sldrRFGAIN) {
998 sldrRFGAIN->value(progStatus.rfgain);
999 sldrRFGAIN->redraw();
1000 }
1001 if (spnrRFGAIN) {
1002 spnrRFGAIN->value(progStatus.rfgain);
1003 spnrRFGAIN->redraw();
1004 }
1005 }
1006
read_rfgain()1007 void read_rfgain()
1008 {
1009 int val;
1010 if (inhibit_rfgain > 0) {
1011 inhibit_rfgain--;
1012 return;
1013 }
1014 if (selrig->has_rf_control) {
1015 trace(1,"read_rfgain");
1016 val = selrig->get_rf_gain();
1017 if (val != progStatus.rfgain) {
1018 progStatus.rfgain = val;
1019 Fl::awake(update_rfgain, (void*)0);
1020 }
1021 }
1022 read_agc();
1023 }
1024
1025 // squelch
update_squelch(void * d)1026 void update_squelch(void *d)
1027 {
1028 if (sldrSQUELCH) {
1029 sldrSQUELCH->value(progStatus.squelch);
1030 sldrSQUELCH->redraw();
1031 }
1032 if (spnrSQUELCH) {
1033 spnrSQUELCH->value(progStatus.squelch);
1034 spnrSQUELCH->redraw();
1035 }
1036 }
1037
read_squelch()1038 void read_squelch()
1039 {
1040 int val;
1041 if (inhibit_squelch > 0) {
1042 inhibit_squelch--;
1043 return;
1044 }
1045 if (!selrig->has_sql_control) return;
1046 {
1047 trace(1,"read_squelch()");
1048 val = selrig->get_squelch();
1049 }
1050
1051 if (val != progStatus.squelch || val != vfo->squelch || (sldrSQUELCH && val != sldrSQUELCH->value())) {
1052 vfo->squelch = progStatus.squelch = val;
1053 Fl::awake(update_squelch, (void*)0);
1054 }
1055 }
1056
1057 void set_ptt(void *);
1058
check_ptt()1059 void check_ptt()
1060 {
1061 int check = 0;
1062
1063 if (progStatus.comm_catptt) {
1064 check = selrig->get_PTT();
1065 } else if (progStatus.comm_dtrptt) {
1066 check = RigSerial->getPTT();
1067 } else if (progStatus.comm_rtsptt) {
1068 check = RigSerial->getPTT();
1069 } else if (SepSerial->IsOpen() && progStatus.sep_dtrptt) {
1070 check = SepSerial->getPTT();
1071 } else if (SepSerial->IsOpen() && progStatus.sep_rtsptt) {
1072 check = SepSerial->getPTT();
1073 } else if (progStatus.gpio_ptt) {
1074 check = get_gpio();
1075 }
1076
1077 if (check != PTT)
1078 PTT = check;
1079
1080 Fl::awake(set_ptt, (void *)PTT);
1081 }
1082
check_break_in()1083 void check_break_in()
1084 {
1085 if (selrig->has_cw_break_in)
1086 selrig->get_break_in();
1087 }
1088
1089 struct POLL_PAIR {
1090 int *poll;
1091 void (*pollfunc)();
1092 };
1093
1094 POLL_PAIR RX_poll_pairs[] = {
1095 {&progStatus.poll_vfoAorB, read_vfoAorB},
1096 {&progStatus.poll_frequency, read_vfo},
1097 {&progStatus.poll_mode, read_mode},
1098 {&progStatus.poll_bandwidth, read_bandwidth},
1099 {&progStatus.poll_smeter, read_smeter},
1100 {&progStatus.poll_tuner, read_tuner},
1101 {&progStatus.poll_volume, read_volume},
1102 {&progStatus.poll_auto_notch, read_auto_notch},
1103 {&progStatus.poll_notch, read_notch},
1104 {&progStatus.poll_ifshift, read_ifshift},
1105 {&progStatus.poll_power_control, read_power_control},
1106 {&progStatus.poll_pre_att, read_preamp_att},
1107 {&progStatus.poll_micgain, read_mic_gain},
1108 {&progStatus.poll_squelch, read_squelch},
1109 {&progStatus.poll_rfgain, read_rfgain},
1110 {&progStatus.poll_split, read_split},
1111 {&progStatus.poll_nr, read_nr},
1112 {&progStatus.poll_noise, read_noise},
1113 {&progStatus.poll_compression, read_compression},
1114 {&progStatus.poll_ptt, check_ptt},
1115 {&progStatus.poll_break_in, check_break_in},
1116 {NULL, NULL}
1117 };
1118
1119 POLL_PAIR TX_poll_pairs[] = {
1120 {&progStatus.poll_pout, read_power_out},
1121 {&progStatus.poll_swr, read_swr},
1122 {&progStatus.poll_alc, read_alc},
1123 {&progStatus.poll_split, read_split},
1124 {&progStatus.poll_ptt, check_ptt},
1125 {NULL, NULL}
1126 };
1127
1128 POLL_PAIR *poll_parameters;
1129
1130 static bool resetrcv = true;
1131 static bool resetxmt = true;
1132
1133 // On the Yaesu FT-891, the mode must be set before VFO, since mode
1134 // changes can shift frequency.
1135 //
1136 // For example, might set freq to 7123.000, but then change mode from USB
1137 // to DATA-U. This mode shift would change the VFO to 7123.700, instead
1138 // of the desired 7123.000.
1139 //
1140 // Setting VFO after the mode change will prevent this type of frequency
1141 // shifting.
yaesu891UpdateA(XCVR_STATE * newVfo)1142 void yaesu891UpdateA(XCVR_STATE * newVfo)
1143 {
1144 selrig->set_modeA(newVfo->imode);
1145 selrig->set_vfoA(newVfo->freq);
1146 selrig->set_bwA(newVfo->iBW);
1147 }
yaesu891UpdateB(XCVR_STATE * newVfo)1148 void yaesu891UpdateB(XCVR_STATE * newVfo)
1149 {
1150 selrig->set_modeB(newVfo->imode);
1151 selrig->set_vfoB(newVfo->freq);
1152 selrig->set_bwB(newVfo->iBW);
1153 }
1154
serviceQUE()1155 void serviceQUE()
1156 {
1157 guard_lock que_lock(&mutex_srvc_reqs, "serviceQUE");
1158 guard_lock serial(&mutex_serial);
1159
1160 queue<VFOQUEUE> pending; // creates an empty queue
1161
1162 VFOQUEUE nuvals;
1163
1164 while (!srvc_reqs.empty()) {
1165 {
1166 nuvals = srvc_reqs.front();
1167 srvc_reqs.pop();
1168 }
1169
1170 if (nuvals.change == ON || nuvals.change == OFF) { // PTT processing
1171
1172 if (selrig->ICOMmainsub && useB) { // disallowed operation
1173 Fl::awake(update_UI_PTT);
1174 return;
1175 }
1176
1177 PTT = (nuvals.change == ON);
1178 if (nuvals.change == ON) trace(1,"ptt ON");
1179 else trace(1,"ptt OFF");
1180 rigPTT(PTT);
1181 if (progStatus.comm_catptt) {
1182 int get = selrig->get_PTT();
1183 int cnt = 0;
1184 while ((get != PTT) && (cnt++ < 100)) {
1185 MilliSleep(10);
1186 get = selrig->get_PTT();
1187 }
1188 stringstream s;
1189 s << "ptt returned " << get << " in " << cnt * 10 << " msec";
1190 trace(1, s.str().c_str());
1191 Fl::awake(update_UI_PTT);
1192 }
1193 continue;
1194 }
1195
1196 if (PTT) {
1197 if ((nuvals.vfo.iBW != 255) ||
1198 (nuvals.vfo.imode != -1)) {
1199 pending.push(nuvals);
1200 continue; // while (!srvc_reqs.empty())
1201 }
1202 }
1203
1204 switch (nuvals.change) {
1205 case vX:
1206 if (useB)
1207 serviceB(nuvals.vfo);
1208 else
1209 serviceA(nuvals.vfo);
1210 break;
1211 case vA:
1212 serviceA(nuvals.vfo);
1213 break;
1214 case vB:
1215 serviceB(nuvals.vfo);
1216 break;
1217 case sA: // select A
1218 {
1219 useB = false;
1220 selrig->selectA();
1221 vfo = &vfoA;
1222 if (selrig->name_ == rig_FT891.name_) {
1223 // Restore mode, then freq and bandwidth after select
1224 yaesu891UpdateA(&vfoA);
1225 }
1226 trace(2, "case sA ", printXCVR_STATE(vfoA).c_str());
1227 rig_trace(2, "case sA ", printXCVR_STATE(vfoA).c_str());
1228 Fl::awake(updateUI);
1229 }
1230 break;
1231 case sB: // select B
1232 {
1233 useB = true;
1234 selrig->selectB();
1235 vfo = &vfoB;
1236 if (selrig->name_ == rig_FT891.name_) {
1237 // Restore mode, then freq and bandwidth after select
1238 yaesu891UpdateB(&vfoB);
1239 }
1240 trace(2, "case sB ", printXCVR_STATE(vfoB).c_str());
1241 rig_trace(2, "case sB ", printXCVR_STATE(vfoB).c_str());
1242 Fl::awake(updateUI);
1243 }
1244 break;
1245 case sON: case sOFF:
1246 {
1247 int on = 0;
1248 if (nuvals.change == sON) on = 1;
1249 trace(1, (on ? "split ON" : "split OFF"));
1250 rig_trace(2, "case sB ", printXCVR_STATE(vfoB).c_str());
1251 if (selrig->can_split() || selrig->has_split_AB) {
1252 selrig->set_split(on);
1253 progStatus.split = on;
1254 Fl::awake(update_split, (void *)0);
1255 if (selrig->ICOMmainsub) {
1256 useB = false;
1257 selrig->selectA();
1258 vfo = &vfoA;
1259 }
1260 }
1261 }
1262 break;
1263 case SWAP:
1264 trace(1, "execute swapab()");
1265 rig_trace(1, "execute swapab()");
1266 execute_swapAB();
1267 break;
1268 case A2B:
1269 trace(1, "execute A2B()");
1270 rig_trace(1, "execute A2B()");
1271 execute_A2B();
1272 break;
1273 default:
1274 trace(2, "default ", printXCVR_STATE(nuvals.vfo).c_str());
1275 if (useB) serviceB(nuvals.vfo);
1276 else serviceA(nuvals.vfo);
1277 break;
1278 }
1279 }
1280
1281 {
1282 while (!srvc_reqs.empty()) {
1283 pending.push(srvc_reqs.front());
1284 srvc_reqs.pop();
1285 }
1286 while (!pending.empty()) {
1287 srvc_reqs.push(pending.front());
1288 pending.pop();
1289 }
1290 }
1291 Fl::awake(updateUI);
1292 }
1293
find_bandwidth(XCVR_STATE & nuvals)1294 void find_bandwidth(XCVR_STATE &nuvals)
1295 {
1296 if (nuvals.iBW == 255) return;
1297 if (!selrig->has_bandwidth_control) {
1298 nuvals.iBW = 255;
1299 return;
1300 }
1301 if (nuvals.iBW > 65536) {
1302 nuvals.iBW /= 256;
1303 nuvals.iBW /= 256;
1304 int i = 0;
1305 while ( selrig->bandwidths_[i] &&
1306 atol(selrig->bandwidths_[i]) < nuvals.iBW) {
1307 i++;
1308 }
1309 if (!selrig->bandwidths_[i]) i--;
1310 nuvals.iBW = i;
1311 }
1312 }
1313
serviceA(XCVR_STATE nuvals)1314 void serviceA(XCVR_STATE nuvals)
1315 {
1316 if (nuvals.freq == 0) nuvals.freq = vfoA.freq;
1317 if (nuvals.imode == -1) nuvals.imode = vfoA.imode;
1318 // find_bandwidth(nuvals);
1319 if (nuvals.iBW == 255) nuvals.iBW = vfoA.iBW;
1320
1321 if (useB) {
1322 if (selrig->can_change_alt_vfo) {
1323 trace(2, "B active, set alt vfo A", printXCVR_STATE(nuvals).c_str());
1324 rig_trace(2, "B active, set alt vfo A", printXCVR_STATE(nuvals).c_str());
1325 if (vfoA.imode != nuvals.imode) {
1326 if (selrig->name_ == rig_FT891.name_) {
1327 // Mode change on ft891 requires mode first, so set all values
1328 yaesu891UpdateA(&nuvals);
1329 vfoA = nuvals;
1330 } else {
1331 selrig->set_modeA(nuvals.imode);
1332 }
1333 }
1334 if (vfoA.iBW != nuvals.iBW)
1335 selrig->set_bwA(nuvals.iBW);
1336 if (vfoA.freq != nuvals.freq)
1337 selrig->set_vfoA(nuvals.freq);
1338 vfoA = nuvals;
1339 } else if (xcvr_name != rig_TT550.name_) {
1340 trace(2, "B active, set vfo A", printXCVR_STATE(nuvals).c_str());
1341 rig_trace(2, "B active, set vfo A", printXCVR_STATE(nuvals).c_str());
1342 useB = false;
1343 selrig->selectA();
1344 if (vfoA.imode != nuvals.imode)
1345 selrig->set_modeA(nuvals.imode);
1346 if (vfoA.iBW != nuvals.iBW)
1347 selrig->set_bwA(nuvals.iBW);
1348 if (vfoA.freq != nuvals.freq)
1349 selrig->set_vfoA(nuvals.freq);
1350 useB = true;
1351 selrig->selectB();
1352 vfoA = nuvals;
1353 }
1354 Fl::awake(setFreqDispA, (void *)nuvals.freq);
1355 return;
1356 }
1357
1358 trace(2, "service VFO A", printXCVR_STATE(nuvals).c_str());
1359
1360 if ((nuvals.imode != -1) && (vfoA.imode != nuvals.imode)) {
1361 if (selrig->name_ == rig_FT891.name_) {
1362 // Mode change on ft891 can change frequency, so set all values
1363 yaesu891UpdateA(&nuvals);
1364 vfoA = nuvals;
1365 set_bandwidth_control();
1366 } else {
1367 std::string m1, m2;
1368 m1 = selrig->modes_[nuvals.imode];
1369 m2 = selrig->modes_[vfoA.imode];
1370 selrig->set_modeA(vfoA.imode = nuvals.imode);
1371 set_bandwidth_control();
1372 selrig->set_bwA(vfoA.iBW);
1373 if (m1.find("CW") != std::string::npos ||
1374 m2.find("CW") != std::string::npos)
1375 vfoA.freq = nuvals.freq = selrig->get_vfoA();
1376 }
1377
1378 }
1379 if (vfoA.iBW != nuvals.iBW) {
1380 selrig->set_bwA(vfoA.iBW = nuvals.iBW);
1381 }
1382 if (vfoA.freq != nuvals.freq) {
1383 trace(1, "change vfoA frequency");
1384 selrig->set_vfoA(vfoA.freq = nuvals.freq);
1385 }
1386 vfo = &vfoA;
1387
1388 Fl::awake(setFreqDispA, (void *)vfoA.freq);
1389 // Fl::awake(updateUI); // may be redundant
1390 }
1391
serviceB(XCVR_STATE nuvals)1392 void serviceB(XCVR_STATE nuvals)
1393 {
1394 if (nuvals.freq == 0) nuvals.freq = vfoB.freq;
1395 if (nuvals.imode == -1) nuvals.imode = vfoB.imode;
1396 if (nuvals.iBW == 255) nuvals.iBW = vfoB.iBW;
1397
1398 if (!useB) {
1399 if (selrig->can_change_alt_vfo) {
1400 trace(2, "A active, set alt vfo B", printXCVR_STATE(nuvals).c_str());
1401 if (vfoB.imode != nuvals.imode) {
1402 if (selrig->name_ == rig_FT891.name_) {
1403 // Mode change on ft891 requires mode first, so set all values
1404 yaesu891UpdateB(&nuvals);
1405 vfoB = nuvals;
1406 } else {
1407 selrig->set_modeB(nuvals.imode);
1408 }
1409 }
1410 if (vfoB.iBW != nuvals.iBW)
1411 selrig->set_bwB(nuvals.iBW);
1412 if (vfoB.freq != nuvals.freq)
1413 selrig->set_vfoB(nuvals.freq);
1414 vfoB = nuvals;
1415 } else if (xcvr_name != rig_TT550.name_) {
1416 trace(2, "A active, set vfo B", printXCVR_STATE(nuvals).c_str());
1417 useB = true;
1418 selrig->selectB();
1419 if (vfoB.imode != nuvals.imode)
1420 selrig->set_modeB(nuvals.imode);
1421 if (vfoB.iBW != nuvals.iBW)
1422 selrig->set_bwB(nuvals.iBW);
1423 if (vfoB.freq != nuvals.freq)
1424 selrig->set_vfoB(nuvals.freq);
1425 useB = false;
1426 selrig->selectA();
1427 vfoB = nuvals;
1428 }
1429 Fl::awake(setFreqDispB, (void *)nuvals.freq);
1430 return;
1431 }
1432
1433 trace(2, "service VFO B", printXCVR_STATE(nuvals).c_str());
1434
1435 if ((nuvals.imode != -1) && (vfoB.imode != nuvals.imode)) {
1436 std::string m1, m2;
1437 m1 = selrig->modes_[nuvals.imode];
1438 m2 = selrig->modes_[vfoB.imode];
1439 selrig->set_modeB(vfoB.imode = nuvals.imode);
1440 set_bandwidth_control();
1441 selrig->set_bwB(vfoB.iBW);
1442 if (m1.find("CW") != std::string::npos ||
1443 m2.find("CW") != std::string::npos)
1444 vfoB.freq = nuvals.freq = selrig->get_vfoB();
1445 }
1446 if (vfoB.iBW != nuvals.iBW) {
1447 selrig->set_bwB(vfoB.iBW = nuvals.iBW);
1448 }
1449 if (vfoB.freq != nuvals.freq)
1450 selrig->set_vfoB(vfoB.freq = nuvals.freq);
1451
1452 vfo = &vfoB;
1453
1454 Fl::awake(setFreqDispB, (void *)vfoB.freq);
1455
1456 }
1457
set_ptt(void * d)1458 void set_ptt(void *d)
1459 {
1460 if (d == (void*)0) {
1461 btnPTT->value(0);
1462 sldrSWR->hide();
1463 sldrSWR->redraw();
1464 sldrRcvSignal->show();
1465 sldrRcvSignal->redraw();
1466 btnALC_SWR->hide();
1467 scaleSmeter->show();
1468 } else {
1469 btnPTT->value(1);
1470 sldrRcvSignal->hide();
1471 sldrRcvSignal->redraw();
1472 scaleSmeter->hide();
1473 sldrSWR->show();
1474 sldrSWR->redraw();
1475 btnALC_SWR->image(meter_image == SWR_IMAGE ? image_swr : image_alc);
1476 btnALC_SWR->redraw();
1477 btnALC_SWR->show();
1478 }
1479 }
1480
serial_thread_loop(void * d)1481 void * serial_thread_loop(void *d)
1482 {
1483 static int loopcount = progStatus.serloop_timing / 10;
1484 static int poll_nbr = 0;
1485
1486 for(;;) {
1487
1488 if (!run_serial_thread) {
1489 break;
1490 }
1491
1492 MilliSleep(10);
1493
1494 if (bypass_serial_thread_loop) {
1495 goto serial_bypass_loop;
1496 }
1497
1498 //send any freq/mode/bw changes in the queu
1499 if (!srvc_reqs.empty())
1500 serviceQUE();
1501
1502 if (!PTT) {
1503 if (resetrcv) {
1504 Fl::awake(zeroXmtMeters, 0);
1505 resetrcv = false;
1506 loopcount = progStatus.serloop_timing / 10;
1507 poll_nbr = 0;
1508 }
1509 resetxmt = true;
1510
1511 if (--loopcount <= 0) {
1512 loopcount = progStatus.serloop_timing / 10;
1513 poll_nbr++;
1514
1515 if (xcvr_name == rig_K3.name_) {
1516 read_K3();
1517 }
1518 else if (xcvr_name == rig_KX3.name_) {
1519 read_KX3();
1520 }
1521 if ((xcvr_name == rig_K2.name_) ||
1522 (selrig->has_get_info &&
1523 (progStatus.poll_frequency ||
1524 progStatus.poll_mode ||
1525 progStatus.poll_bandwidth) ) )
1526 read_info();
1527 if (bypass_serial_thread_loop) {
1528 trace(1, "bypass serial thread loop");
1529 goto serial_bypass_loop;// continue;
1530 }
1531 poll_parameters = &RX_poll_pairs[0];
1532 while (poll_parameters->poll) {
1533 // need to put thread asleep to allow other threads
1534 // access to serial mutex
1535 MilliSleep(1);
1536
1537 if (!srvc_reqs.empty()) goto serial_bypass_loop;//break;
1538
1539 if (PTT) {
1540 trace(1, "PTT detected");
1541 goto serial_bypass_loop;//break;
1542 }
1543 if (bypass_serial_thread_loop) {
1544 trace(1, "bypass_serial_thread_loop");
1545 goto serial_bypass_loop;//break;
1546 }
1547 if (*(poll_parameters->poll) && !(poll_nbr % *(poll_parameters->poll))) {
1548 guard_lock serial_lock(&mutex_serial);
1549 (poll_parameters->pollfunc)();
1550 }
1551 poll_parameters++;
1552 }
1553 }
1554 } else {
1555 if (resetxmt) {
1556 Fl::awake(updateSmeter, (void *)(0));
1557 resetxmt = false;
1558 loopcount = progStatus.serloop_timing / 10;
1559 poll_nbr = 0;
1560 }
1561 resetrcv = true;
1562 if (!srvc_reqs.empty()) goto serial_bypass_loop;
1563 if (--loopcount <= 0) {
1564 loopcount = progStatus.serloop_timing / 10;
1565 poll_nbr++;
1566 poll_parameters = &TX_poll_pairs[0];
1567 while (poll_parameters->poll) {
1568 MilliSleep(1);
1569 if (!srvc_reqs.empty()) goto serial_bypass_loop;
1570
1571 if (!PTT) {
1572 trace(1, "!PTT detected");
1573 goto serial_bypass_loop;
1574 }
1575 if (*(poll_parameters->poll) && !(poll_nbr % *(poll_parameters->poll))) {
1576 guard_lock serial_lock(&mutex_serial);
1577 (poll_parameters->pollfunc)();
1578 }
1579 poll_parameters++;
1580 }
1581 }
1582 }
1583 serial_bypass_loop: ;
1584 }
1585 return NULL;
1586 }
1587
1588 //=============================================================================
1589
setBW()1590 void setBW()
1591 {
1592 XCVR_STATE fm = *vfo;
1593 fm.src = UI;
1594 fm.iBW = opBW->index();
1595 guard_lock que_lock( &mutex_srvc_reqs, "setBW" );
1596 srvc_reqs.push( VFOQUEUE((useB ? vB : vA), fm));
1597 }
1598
setDSP()1599 void setDSP()
1600 {
1601 XCVR_STATE fm = *vfo;
1602 fm.src = UI;
1603 fm.iBW = ((opDSP_hi->index() << 8) | 0x8000) | (opDSP_lo->index() & 0xFF) ;
1604 guard_lock que_lock( & mutex_srvc_reqs, "setDSP" );
1605 srvc_reqs.push ( VFOQUEUE((useB ? vB : vA), fm));
1606 }
1607
selectDSP()1608 void selectDSP()
1609 {
1610 if (btnDSP->label()[0] == selrig->SL_label[0]) {
1611 btnDSP->label(selrig->SH_label);
1612 btnDSP->redraw_label();
1613 opDSP_hi->show();
1614 opDSP_lo->hide();
1615 } else {
1616 btnDSP->label(selrig->SL_label);
1617 btnDSP->redraw_label();
1618 opDSP_lo->show();
1619 opDSP_hi->hide();
1620 }
1621 }
1622
selectFILT()1623 void selectFILT()
1624 {
1625 guard_lock lock(&mutex_serial);
1626 btnFILT->label(selrig->nextFILT());
1627 btnFILT->redraw_label();
1628 }
1629
1630 // set_bandwidth_control updates iBW and then posts the call for
1631 // the UI thread to updateBandwidthControl
1632 // changes to the UI cannot come from any thread other than the
1633 // main FL thread! Doing otherwise can cause what appears to be
1634 // random program crashes.
1635
set_bandwidth_control()1636 void set_bandwidth_control()
1637 {
1638 if (!selrig->has_bandwidth_control) return;
1639
1640 vfo->iBW = selrig->def_bandwidth(vfo->imode);
1641
1642 if (vfo->iBW < 256) {
1643 int i = 0;
1644 while (selrig->bandwidths_[i]) i++;
1645 i--;
1646 if (vfo->iBW > i) vfo->iBW = selrig->def_bandwidth(vfo->imode);
1647 }
1648 useB ? vfoB.iBW = vfo->iBW : vfoA.iBW = vfo->iBW;
1649 Fl::awake(updateBandwidthControl);
1650 }
1651
updateBandwidthControl(void * d)1652 void updateBandwidthControl(void *d)
1653 {
1654 if (selrig->has_bandwidth_control) {
1655 if (selrig->adjust_bandwidth(vfo->imode) != -1) {
1656 opBW->clear();
1657 rigbws_.clear();
1658 for (int i = 0; selrig->bandwidths_[i] != NULL; i++) {
1659 rigbws_.push_back(selrig->bandwidths_[i]);
1660 opBW->add(selrig->bandwidths_[i]);
1661 }
1662
1663 if (selrig->has_dsp_controls) {
1664 opDSP_lo->clear();
1665 opDSP_hi->clear();
1666 for (int i = 0; selrig->dsp_SL[i] != NULL; i++)
1667 opDSP_lo->add(selrig->dsp_SL[i]);
1668 for (int i = 0; selrig->dsp_SH[i] != NULL; i++)
1669 opDSP_hi->add(selrig->dsp_SH[i]);
1670 if (vfo->iBW > 256) {
1671 opBW->index(0);
1672 opBW->hide();
1673 opBW->hide();
1674 opDSP_lo->index(vfo->iBW & 0xFF);
1675 opDSP_lo->hide();
1676 opDSP_hi->index((vfo->iBW >> 8) & 0x7F);
1677 btnDSP->label(selrig->SL_label);
1678 opDSP_lo->show();
1679 btnDSP->show();
1680 btnFILT->hide();
1681 } else {
1682 opDSP_lo->hide();
1683 opDSP_hi->hide();
1684 btnDSP->hide();
1685 btnFILT->hide();
1686 opBW->index(vfo->iBW);
1687 opBW->show();
1688 }
1689 } else { // no DSP control so update BW control, hide DSP
1690 opDSP_lo->hide();
1691 opDSP_hi->hide();
1692 btnDSP->hide();
1693 opBW->index(vfo->iBW);
1694 if (selrig->has_FILTER) {
1695 btnFILT->show();
1696 btnFILT->label(
1697 selrig->FILT(
1698 useB ? vfoB.filter : vfoA.filter));
1699 btnFILT->redraw_label();
1700 opBW->resize(opDSP_lo->x(), opDSP_lo->y(), opDSP_lo->w(), opDSP_lo->h());
1701 opBW->redraw();
1702 }
1703 opBW->show();
1704 }
1705 // Allow BW to receive rig updates as value is changed there, without needing
1706 // to click the dropdown first
1707 opBW->isbusy(false);
1708 }
1709 } else { // no BW, no DSP controls
1710 opBW->index(0);
1711 opBW->hide();
1712 btnFILT->hide();
1713 opDSP_lo->index(0);
1714 opDSP_hi->index(0);
1715 btnDSP->hide();
1716 opDSP_lo->hide();
1717 opDSP_hi->hide();
1718 }
1719 }
1720
setMode()1721 void setMode()
1722 {
1723 XCVR_STATE fm = *vfo;
1724 fm.imode = opMODE->index();
1725 fm.iBW = selrig->def_bandwidth(fm.imode);
1726 fm.src = UI;
1727 if (selrig->has_FILTER) {
1728 fm.filter = selrig->get_FILT(fm.imode);
1729 if (useB) fm.filter = selrig->get_FILT(fm.imode);
1730 }
1731
1732 guard_lock que_lock( &mutex_srvc_reqs, "setMode" );
1733 srvc_reqs.push(VFOQUEUE( (useB ? vB : vA), fm));
1734 }
1735
sortList()1736 void sortList() {
1737 if (!numinlist) return;
1738 ATAG_XCVR_STATE temp;
1739 for (int i = 0; i < numinlist - 1; i++)
1740 for (int j = i + 1; j < numinlist; j++)
1741 if (oplist[i].freq > oplist[j].freq) {
1742 temp = oplist[i];
1743 oplist[i] = oplist[j];
1744 oplist[j] = temp;
1745 }
1746 }
1747
clearList()1748 void clearList() {
1749 if (!numinlist) return;
1750 for (int i = 0; i < LISTSIZE; i++) {
1751 oplist[i].freq = 0;
1752 oplist[i].imode = USB;
1753 oplist[i].iBW = 0;
1754 memset(oplist[i].alpha_tag, 0, ATAGSIZE);
1755 }
1756 FreqSelect->clear();
1757 numinlist = 0;
1758 inAlphaTag->value("");
1759 }
1760
updateSelect()1761 void updateSelect() {
1762 char szline[1000];
1763 char szatag[ATAGSIZE];
1764 int i;
1765 FreqSelect->clear();
1766 if (!numinlist) return;
1767 sortList();
1768 // stripe lines
1769 int bg1, bg2, bg_clr;
1770 bg1 = FL_WHITE; bg2 = FL_LIGHT2;
1771
1772 for (int n = 0; n < numinlist; n++) {
1773 memset(szline, 0, sizeof(szline));
1774 memset(szatag, 0, sizeof(szatag));
1775 for (i = 0; i < ATAGSIZE; i++) {
1776 szatag[i] = oplist[n].alpha_tag[i];
1777 if (szatag[i] == '\n') szatag[i] = ' ';
1778 }
1779 bg_clr = (n % 2) ? bg1 : bg2;
1780 snprintf(szline, sizeof(szline), "\
1781 @F%d@S%d@B%d@r%.3f\t\
1782 @F%d@S%d@B%d@.|\t\
1783 @F%d@S%d@B%d@r%s\t\
1784 @F%d@S%d@B%d@.|\t\
1785 @F%d@S%d@B%d@r%s\t\
1786 @F%d@S%d@B%d@.|\t\
1787 @F%d@S%d@B%d@.%s",
1788 progStatus.memfontnbr, progStatus.memfontsize, bg_clr, oplist[n].freq / 1000.0,
1789 progStatus.memfontnbr, progStatus.memfontsize, bg_clr,
1790 progStatus.memfontnbr, progStatus.memfontsize, bg_clr, selrig->get_bwname_(oplist[n].iBW, oplist[n].imode),
1791 progStatus.memfontnbr, progStatus.memfontsize, bg_clr,
1792 progStatus.memfontnbr, progStatus.memfontsize, bg_clr, selrig->get_modename_(oplist[n].imode),
1793 progStatus.memfontnbr, progStatus.memfontsize, bg_clr,
1794 progStatus.memfontnbr, progStatus.memfontsize, bg_clr, szatag );
1795 FreqSelect->add (szline);
1796 }
1797 inAlphaTag->value("");
1798 }
1799
addtoList(int val,int imode,int iBW)1800 void addtoList(int val, int imode, int iBW) {
1801 if (numinlist < LISTSIZE) {
1802 oplist[numinlist].imode = imode;
1803 oplist[numinlist].freq = val;
1804 oplist[numinlist].iBW = iBW;
1805 memset(oplist[numinlist].alpha_tag, 0, ATAGSIZE);
1806 numinlist++;
1807 }
1808 }
1809
readFile()1810 void readFile() {
1811 ifstream iList(defFileName.c_str());
1812 if (!iList) {
1813 fl_message ("Could not open %s", defFileName.c_str());
1814 return;
1815 }
1816 clearList();
1817 int i = 0, mode, bw;
1818 long freq;
1819 while (!iList.eof()) {
1820 freq = 0L; mode = -1;
1821 iList >> freq >> mode >> bw;
1822 if (freq && (mode > -1)) {
1823 oplist[i].freq = freq;
1824 oplist[i].imode = mode;
1825 oplist[i].iBW = (bw == -1 ? 0 : bw);
1826 memset(oplist[i].alpha_tag, 0, ATAGSIZE);
1827 i++;
1828 }
1829 }
1830 iList.close();
1831 numinlist = i;
1832 updateSelect();
1833 }
1834
readTagFile()1835 void readTagFile() {
1836 ifstream iList(defFileName.c_str());
1837 if (!iList) {
1838 fl_message ("Could not open %s", defFileName.c_str());
1839 return;
1840 }
1841 clearList();
1842 int i = 0, mode, bw;
1843 long freq;
1844 string atag;
1845 char ca[ATAGSIZE + 60];
1846 while (!iList.eof()) {
1847 freq = 0L; mode = -1;
1848 atag.clear();
1849 memset(ca, 0, sizeof(ca));
1850 iList >> freq >> mode >> bw;
1851 iList.getline(ca, sizeof(ca) - 1);
1852 atag = ca;
1853 if (freq && (mode > -1)) {
1854 oplist[i].freq = freq;
1855 oplist[i].imode = mode;
1856 oplist[i].iBW = (bw == -1 ? 0 : bw);
1857 // trim leading, trailing spaces and double quotes
1858 atag = lt_trim(atag);
1859 snprintf(oplist[i].alpha_tag, ATAGSIZE, "%s", atag.c_str());
1860 i++;
1861 }
1862 }
1863 iList.close();
1864 numinlist = i;
1865 updateSelect();
1866 }
1867
buildlist()1868 void buildlist() {
1869 string tmpFN, orgFN;
1870 // check for new Memory-Alpha-Tag file
1871 defFileName = RigHomeDir;
1872 defFileName.append(selrig->name_);
1873 defFileName.append(".mat");
1874 FILE *fh = fopen(defFileName.c_str(), "r");
1875 if (fh != NULL) {
1876 fclose (fh);
1877 readTagFile();
1878 return;
1879 }
1880 // else only read original file to make new MAT file
1881 orgFN = RigHomeDir;
1882 orgFN.append(selrig->name_);
1883 orgFN.append(".arv");
1884 fh = fopen(orgFN.c_str(), "r");
1885 if (fh != NULL) {
1886 fclose (fh);
1887 tmpFN = defFileName;
1888 defFileName = orgFN;
1889 readFile();
1890 defFileName = tmpFN;
1891 return;
1892 }
1893 clearList();
1894 }
1895
1896 // flrig front panel changed
1897
movFreqA()1898 int movFreqA() {
1899 XCVR_STATE nuvfo = vfoA;
1900 nuvfo.freq = FreqDispA->value();
1901 nuvfo.src = UI;
1902 guard_lock que_lock(&mutex_srvc_reqs, "movFreqA");
1903 srvc_reqs.push(VFOQUEUE(vA, nuvfo));
1904 return 1;
1905 }
1906
movFreqB()1907 int movFreqB() {
1908 XCVR_STATE nuvfo = vfoB;
1909 nuvfo.freq = FreqDispB->value();
1910 nuvfo.src = UI;
1911 guard_lock que_lock(&mutex_srvc_reqs, "movFreqB");
1912 srvc_reqs.push(VFOQUEUE(vB, nuvfo));
1913 return 1;
1914 }
1915
execute_swapAB()1916 void execute_swapAB()
1917 {
1918 if (selrig->canswap()) {
1919 selrig->swapAB();
1920 if (selrig->ICOMmainsub) {
1921 XCVR_STATE temp = vfoA;
1922 vfoA = vfoB;
1923 vfoB = temp;
1924 selrig->selectA();
1925 vfo = &vfoA;
1926 useB = false;
1927 } else if (selrig->ICOMrig) {
1928 if (useB) {
1929 useB = false;
1930 selrig->selectA();
1931 vfo = &vfoA;
1932 } else {
1933 useB = true;
1934 selrig->selectB();
1935 vfo = &vfoB;
1936 }
1937 } else if (selrig->name_ == rig_FT891.name_) {
1938 // No need for extra select, as swapAB accomplishes this
1939 if (useB) {
1940 useB = false;
1941 vfo = &vfoA;
1942 // Restore mode, then frequency and bandwidth after swap.
1943 yaesu891UpdateA(&vfoA);
1944 }
1945 else {
1946 useB = true;
1947 vfo = &vfoB;
1948 // Restore mode, then frequency and bandwidth after swap.
1949 yaesu891UpdateB(&vfoB);
1950 }
1951 } else {
1952 XCVR_STATE temp = vfoB;
1953 vfoB = vfoA;
1954 vfoA = temp;
1955 if (useB) {
1956 selrig->selectB();
1957 vfo = &vfoB;
1958 } else {
1959 selrig->selectA();
1960 vfo = &vfoA;
1961 }
1962 }
1963 } else {
1964 if (useB) {
1965 XCVR_STATE vfotemp = vfoA;
1966 selrig->selectA();
1967 vfoA = vfoB;
1968 selrig->set_vfoA(vfoA.freq);
1969 selrig->set_modeA(vfoA.imode);
1970 selrig->set_bwA(vfoA.iBW);
1971
1972 selrig->selectB();
1973 vfoB = vfotemp;
1974 selrig->set_vfoB(vfoB.freq);
1975 selrig->set_modeB(vfoB.imode);
1976 selrig->set_bwB(vfoB.iBW);
1977 vfo = &vfoB;
1978 } else {
1979 XCVR_STATE vfotemp = vfoB;
1980 selrig->selectB();
1981 vfoB = vfoA;
1982 selrig->set_vfoB(vfoB.freq);
1983 selrig->set_modeB(vfoB.imode);
1984 selrig->set_bwB(vfoB.iBW);
1985
1986 selrig->selectA();
1987 vfoA = vfotemp;
1988 selrig->set_vfoA(vfoA.freq);
1989 selrig->set_modeA(vfoA.imode);
1990 selrig->set_bwA(vfoA.iBW);
1991 vfo = &vfoA;
1992 }
1993 }
1994 Fl::awake(updateUI);
1995 }
1996
cbAswapB()1997 void cbAswapB()
1998 {
1999 guard_lock lock(&mutex_srvc_reqs, "cbAswapB");
2000 if (Fl::event_button() == FL_RIGHT_MOUSE) {
2001 VFOQUEUE xcvr;
2002 xcvr.change = A2B;
2003 trace(1, "cb Active->Inactive vfo");
2004 srvc_reqs.push(xcvr);
2005 } else {
2006 VFOQUEUE xcvr;
2007 xcvr.change = SWAP;
2008 trace(1, "cb SWAP");
2009 srvc_reqs.push(xcvr);
2010 }
2011 }
2012
execute_A2B()2013 void execute_A2B()
2014 {
2015 if (xcvr_name == rig_K3.name_) {
2016 K3_A2B();
2017 } else if (xcvr_name == rig_KX3.name_) {
2018 KX3_A2B();
2019 } else if (xcvr_name == rig_K2.name_) {
2020 trace(1,"cbA2B() 1");
2021 vfoB = vfoA;
2022 selrig->set_vfoB(vfoB.freq);
2023 FreqDispB->value(vfoB.freq);
2024 }
2025 if (selrig->ICOMmainsub) {
2026 useB = false;
2027 selrig->selectA();
2028 selrig->A2B();
2029 vfoB = vfoA;
2030 vfo = &vfoA;
2031 } else if (selrig->has_a2b) {
2032 trace(1,"cbA2B() 2");
2033 selrig->A2B();
2034 if (useB) {
2035 vfoA = vfoB;
2036 FreqDispA->value(vfoA.freq);
2037 } else {
2038 vfoB = vfoA;
2039 FreqDispB->value(vfoB.freq);
2040 }
2041 } else {
2042 if (useB) {
2043 vfoA = vfoB;
2044 if (selrig->name_ == rig_FT891.name_) {
2045 yaesu891UpdateA(&vfoA);
2046 } else {
2047 selrig->set_vfoA(vfoA.freq);
2048 selrig->set_modeA(vfoA.imode);
2049 selrig->set_bwA(vfoA.iBW);
2050 }
2051 FreqDispA->value(vfoA.freq);
2052 } else {
2053 vfoB = vfoA;
2054 if (selrig->name_ == rig_FT891.name_) {
2055 yaesu891UpdateB(&vfoB);
2056 } else {
2057 selrig->set_vfoB(vfoB.freq);
2058 selrig->set_modeB(vfoB.imode);
2059 selrig->set_bwB(vfoB.iBW);
2060 }
2061 FreqDispB->value(vfoB.freq);
2062 }
2063 }
2064 Fl::awake(updateUI);
2065 }
2066
highlight_vfo(void * d)2067 void highlight_vfo(void *d)
2068 {
2069 Fl_Color norm_fg = fl_rgb_color(progStatus.fg_red, progStatus.fg_green, progStatus.fg_blue);
2070 Fl_Color norm_bg = fl_rgb_color(progStatus.bg_red, progStatus.bg_green, progStatus.bg_blue);
2071 Fl_Color dim_bg = fl_color_average( norm_bg, FL_BLACK, 0.75);
2072 FreqDispA->value(vfoA.freq);
2073 FreqDispB->value(vfoB.freq);
2074 if (useB) {
2075 FreqDispA->SetONOFFCOLOR( norm_fg, dim_bg );
2076 FreqDispB->SetONOFFCOLOR( norm_fg, norm_bg );
2077 btnA->value(0);
2078 btnB->value(1);
2079 } else {
2080 FreqDispA->SetONOFFCOLOR( norm_fg, norm_bg );
2081 FreqDispB->SetONOFFCOLOR( norm_fg, dim_bg);
2082 btnA->value(1);
2083 btnB->value(0);
2084 }
2085 FreqDispA->redraw();
2086 FreqDispB->redraw();
2087 btnA->redraw();
2088 btnB->redraw();
2089 Fl::check();
2090 }
2091
cb_set_split(int val)2092 void cb_set_split(int val)
2093 {
2094 progStatus.split = val;
2095 VFOQUEUE xcvr_split;
2096 if (val) xcvr_split.change = sON;
2097 else xcvr_split.change = sOFF;
2098 trace(1, (val ? "cb_set_split(ON)" : "cb_set_split(OFF)"));
2099 srvc_reqs.push(xcvr_split);
2100 }
2101
cb_selectA()2102 void cb_selectA()
2103 {
2104 guard_lock que_lock( &mutex_srvc_reqs, "cb_selectA");
2105 srvc_reqs.push (VFOQUEUE(sA, vfoA));
2106 return;
2107 }
2108
cb_selectB()2109 void cb_selectB()
2110 {
2111 guard_lock que_lock( &mutex_srvc_reqs, "cb_selectB");
2112 srvc_reqs.push (VFOQUEUE(sB, vfoB));
2113 return;
2114 }
2115
setLower()2116 void setLower()
2117 {
2118 }
2119
setUpper()2120 void setUpper()
2121 {
2122 }
2123
selectFreq()2124 void selectFreq() {
2125 long n = FreqSelect->value();
2126 if (!n) return;
2127
2128 n--;
2129 XCVR_STATE fm;
2130 fm.freq = oplist[n].freq;
2131 fm.imode = oplist[n].imode;
2132 fm.iBW = oplist[n].iBW;
2133 fm.src = UI;
2134 if (!useB) {
2135 FreqDispA->value(fm.freq);
2136 guard_lock que_lock(&mutex_srvc_reqs, "selectFreq on A");
2137 srvc_reqs.push(VFOQUEUE(vA, fm));
2138 } else {
2139 FreqDispB->value(fm.freq);
2140 guard_lock que_lock(&mutex_srvc_reqs, "selectFreq on B");
2141 srvc_reqs.push(VFOQUEUE(vB, fm));
2142 }
2143 }
2144
2145 #include <FL/names.h>
select_and_close()2146 void select_and_close()
2147 {
2148 int key = Fl::event_key();
2149 int btn = Fl::event_button();
2150
2151 if (FreqSelect->value() <= 0) return;
2152
2153 if ((btn == FL_LEFT_MOUSE && Fl::event_clicks()) ||
2154 btn == FL_RIGHT_MOUSE ||
2155 key == FL_Enter ||
2156 key == FL_Left) {
2157 inAlphaTag->value(oplist[FreqSelect->value() - 1].alpha_tag);
2158 selectFreq();
2159 Fl::focus(FreqSelect);
2160 return;
2161 }
2162
2163 if (btn == FL_LEFT_MOUSE || key == FL_Up || key == FL_Down) {
2164 inAlphaTag->value(oplist[FreqSelect->value() - 1].alpha_tag);
2165 Fl::focus(FreqSelect);
2166 return;
2167 }
2168
2169 if (key == FL_Right) {
2170 addFreq();
2171 FreqSelect->select(1, 1);
2172 inAlphaTag->value(oplist[0].alpha_tag);
2173 Fl::focus(FreqSelect);
2174 return;
2175 }
2176
2177 if (key == FL_Delete) {
2178 long n = FreqSelect->value();
2179 delFreq();
2180 FreqSelect->select(n, 1);
2181 inAlphaTag->value(oplist[n-1].alpha_tag);
2182 Fl::focus(FreqSelect);
2183 return;
2184 }
2185 }
2186
delFreq()2187 void delFreq() {
2188 if (FreqSelect->value()) {
2189 long n = FreqSelect->value() - 1;
2190 for (int i = n; i < numinlist; i ++)
2191 oplist[i] = oplist[i+1];
2192 if (numinlist) {
2193 oplist[numinlist - 1].imode = USB;
2194 oplist[numinlist - 1].freq = 0;
2195 oplist[numinlist - 1].iBW = 0;
2196 memset(oplist[numinlist - 1].alpha_tag, 0, ATAGSIZE);
2197 numinlist--;
2198 }
2199 updateSelect();
2200 }
2201 }
2202
addFreq()2203 void addFreq() {
2204 if (useB) {
2205 long freq = FreqDispB->value();
2206 if (!freq) return;
2207 int mode = opMODE->index();
2208 int bw;
2209 if (btnDSP->visible())
2210 bw = ((opDSP_hi->index() << 8) | 0x8000) | (opDSP_lo->index() & 0xFF) ;
2211 else
2212 bw = opBW->index();
2213 for (int n = 0; n < numinlist; n++)
2214 if (freq == oplist[n].freq && mode == oplist[n].imode) {
2215 oplist[n].iBW = bw;
2216 updateSelect(); // update list
2217 return;
2218 }
2219 addtoList(freq, mode, bw);
2220 updateSelect();
2221 FreqDispB->visual_beep();
2222 } else {
2223 long freq = FreqDispA->value();
2224 if (!freq) return;
2225 int mode = opMODE->index();
2226 int bw;
2227 if (btnDSP->visible())
2228 bw = ((opDSP_hi->index() << 8) | 0x8000) | (opDSP_lo->index() & 0xFF) ;
2229 else
2230 bw = opBW->index();
2231 for (int n = 0; n < numinlist; n++)
2232 if (freq == oplist[n].freq && mode == oplist[n].imode) {
2233 oplist[n].iBW = bw;
2234 updateSelect(); // update list
2235 return;
2236 }
2237 addtoList(freq, mode, bw);
2238 updateSelect();
2239 FreqDispA->visual_beep();
2240 }
2241 }
2242
cbRIT()2243 void cbRIT()
2244 {
2245 guard_lock serial_lock(&mutex_serial);
2246 trace(1, "cbRIT()");
2247 if (selrig->has_rit && cntRIT)
2248 selrig->setRit((int)cntRIT->value());
2249 }
2250
cbXIT()2251 void cbXIT()
2252 {
2253 guard_lock serial_lock(&mutex_serial);
2254 trace(1, "cbXIT()");
2255 selrig->setXit((int)cntXIT->value());
2256 }
2257
cbBFO()2258 void cbBFO()
2259 {
2260 if (selrig->has_bfo) {
2261 guard_lock serial_lock(&mutex_serial);
2262 trace(1, "cbBFO()");
2263 selrig->setBfo((int)cntBFO->value());
2264 }
2265 }
2266
cbAttenuator()2267 void cbAttenuator()
2268 {
2269 guard_lock serial_lock(&mutex_serial);
2270 trace(1, "cbAttenuator()");
2271 progStatus.attenuator = selrig->next_attenuator();
2272 selrig->set_attenuator(progStatus.attenuator);
2273 }
2274
setAttControl(void * d)2275 void setAttControl(void *d)
2276 {
2277 int val = (long)d;
2278 btnAttenuator->value(val);
2279 }
2280
cbPreamp()2281 void cbPreamp()
2282 {
2283 guard_lock serial_lock(&mutex_serial);
2284 trace(1, "cbPreamp()");
2285 progStatus.preamp = selrig->next_preamp();
2286 selrig->set_preamp(progStatus.preamp);
2287 }
2288
setPreampControl(void * d)2289 void setPreampControl(void *d)
2290 {
2291 int val = (long)d;
2292 btnPreamp->value(val);
2293 }
2294
cbAN()2295 void cbAN()
2296 {
2297 progStatus.auto_notch = btnAutoNotch->value();
2298 guard_lock serial_lock(&mutex_serial);
2299 trace(1, "cbAN()");
2300 selrig->set_auto_notch(progStatus.auto_notch);
2301 }
2302
cbbtnNotch()2303 void cbbtnNotch()
2304 {
2305 if (!selrig->has_notch_control) return;
2306 guard_lock serial_lock(&mutex_serial);
2307 trace(1, "cbbtnNotch()");
2308
2309 int btn, cnt = 0;
2310
2311 btn = btnNotch->value();
2312 progStatus.notch = btn;
2313
2314 selrig->set_notch(btn, progStatus.notch_val);
2315
2316 MilliSleep(progStatus.comm_wait);
2317 int on, val = progStatus.notch_val;
2318 on = selrig->get_notch(val);
2319 while ((on != btn) && (cnt++ < 10)) {
2320 MilliSleep(progStatus.comm_wait);
2321 on = selrig->get_notch(val);
2322 Fl::awake();
2323 }
2324 }
2325
setNotch()2326 void setNotch()
2327 {
2328 if (!selrig->has_notch_control) return;
2329
2330 trace(1, "setNotch()");
2331
2332 int ev = Fl::event();
2333 if (ev == FL_LEAVE || ev == FL_ENTER) return;
2334 if (ev == FL_DRAG || ev == FL_PUSH) {
2335 inhibit_notch = 1;
2336 return;
2337 }
2338
2339 int set = 0;
2340 if (sldrNOTCH) {
2341 set = sldrNOTCH->value();
2342 } else {
2343 set = spnrNOTCH->value();
2344 }
2345
2346 progStatus.notch_val = set;
2347 guard_lock lock( &mutex_serial);
2348 selrig->set_notch(progStatus.notch, progStatus.notch_val);
2349 }
2350
2351 // called from xml_io thread
2352 // xcvr updated in xml_io / xml_server code
2353 // this only updates the dialog controls
2354
setNotchControl(void * d)2355 void setNotchControl(void *d)
2356 {
2357 if (sldrNOTCH) sldrNOTCH->value(progStatus.notch_val);
2358 if (spnrNOTCH) spnrNOTCH->value(progStatus.notch_val);
2359 btnNotch->value(progStatus.notch);
2360 }
2361
adjust_if_shift_control(void * d)2362 void adjust_if_shift_control(void *d)
2363 {
2364 if (sldrIFSHIFT) sldrIFSHIFT->minimum(selrig->if_shift_min);
2365 if (sldrIFSHIFT) sldrIFSHIFT->maximum(selrig->if_shift_max);
2366 if (sldrIFSHIFT) sldrIFSHIFT->step(selrig->if_shift_step);
2367 if (sldrIFSHIFT) sldrIFSHIFT->value(selrig->if_shift_mid);
2368 if (sldrIFSHIFT) sldrIFSHIFT->redraw();
2369 if (spnrIFSHIFT) spnrIFSHIFT->minimum(selrig->if_shift_min);
2370 if (spnrIFSHIFT) spnrIFSHIFT->maximum(selrig->if_shift_max);
2371 if (spnrIFSHIFT) spnrIFSHIFT->step(selrig->if_shift_step);
2372 if (spnrIFSHIFT) spnrIFSHIFT->value(selrig->if_shift_mid);
2373 if (spnrIFSHIFT) spnrIFSHIFT->redraw();
2374 btnIFsh->value(0);
2375 btnIFsh->redraw();
2376 }
2377
setIFshiftButton(void * d)2378 void setIFshiftButton(void *d)
2379 {
2380 bool b = (bool)d;
2381 if (b && !btnIFsh->value()) {
2382 btnIFsh->value(1);
2383 }
2384 else if (!b && btnIFsh->value()) {
2385 btnIFsh->value(0);
2386 if (sldrIFSHIFT) sldrIFSHIFT->value( selrig->if_shift_mid );
2387 if (spnrIFSHIFT) spnrIFSHIFT->value( selrig->if_shift_mid );
2388 }
2389 }
2390
setIFshiftControl(void * d)2391 void setIFshiftControl(void *d)
2392 {
2393 int val = (long)d;
2394 if (sldrIFSHIFT) {
2395 if (sldrIFSHIFT->value() != val)
2396 sldrIFSHIFT->value(val);
2397 }
2398 if (spnrIFSHIFT) {
2399 if (spnrIFSHIFT->value() != val)
2400 spnrIFSHIFT->value(val);
2401 }
2402 btnIFsh->value( val != selrig->if_shift_mid );
2403 }
2404
setIFshift()2405 void setIFshift()
2406 {
2407 trace(1, "setIFshift()");
2408
2409 int ev = Fl::event();
2410 if (ev == FL_LEAVE || ev == FL_ENTER) return;
2411 if (ev == FL_DRAG || ev == FL_PUSH) {
2412 inhibit_shift = 1;
2413 return;
2414 }
2415
2416 int btn = 0, set = 0;
2417
2418 btn = btnIFsh->value();
2419 progStatus.shift = btn;
2420
2421 if (sldrIFSHIFT) {
2422 set = sldrIFSHIFT->value();
2423 } else if (spnrIFSHIFT) {
2424 set = spnrIFSHIFT->value();
2425 }
2426 progStatus.shift_val = set;
2427
2428
2429 guard_lock lock(&mutex_serial);
2430 if (xcvr_name == rig_TS990.name_) {
2431 if (progStatus.shift)
2432 selrig->set_monitor(1);
2433 else
2434 selrig->set_monitor(0);
2435 }
2436 selrig->set_if_shift(progStatus.shift_val);
2437 }
2438
cbIFsh()2439 void cbIFsh()
2440 {
2441 guard_lock serial_lock(&mutex_serial);
2442 trace(1, "setIFsh()");
2443
2444 int btn, set, cnt = 0;
2445 if (sldrIFSHIFT) {
2446 set = sldrIFSHIFT->value();
2447 btn = btnIFsh->value();
2448 } else {
2449 set = spnrIFSHIFT->value();
2450 btn = btnIFsh->value();
2451 }
2452 if (btn == 0) set = 0;
2453
2454 selrig->set_if_shift(set);
2455 MilliSleep(progStatus.comm_wait);
2456 int val, on;
2457 on = selrig->get_if_shift(val);
2458 while ((on != btn) && (cnt++ < 10)) {
2459 MilliSleep(progStatus.comm_wait);
2460 on = selrig->get_if_shift(val);
2461 Fl::awake();
2462 }
2463 }
2464
setLOCK()2465 void setLOCK()
2466 {
2467 progStatus.pbt_lock = btnLOCK->value();
2468 if (progStatus.pbt_lock) {
2469 guard_lock serial_lock(&mutex_serial);
2470 progStatus.pbt_outer = progStatus.pbt_inner;
2471 sldrOUTER->value(progStatus.pbt_outer);
2472 selrig->set_pbt_outer(progStatus.pbt_outer);
2473 sldrOUTER->redraw();
2474 }
2475 }
2476
setINNER()2477 void setINNER()
2478 {
2479 if (progStatus.pbt_lock) {
2480 sldrOUTER->value(sldrINNER->value());
2481 sldrOUTER->redraw();
2482 }
2483
2484 int ev = Fl::event();
2485 if (ev == FL_LEAVE || ev == FL_ENTER) return;
2486 if (ev == FL_DRAG || ev == FL_PUSH) {
2487 inhibit_pbt = 1;
2488 return;
2489 }
2490 progStatus.pbt_inner = sldrINNER->value();
2491 guard_lock lock(&mutex_serial);
2492 selrig->set_pbt_inner(progStatus.pbt_inner);
2493 selrig->set_pbt_outer(progStatus.pbt_outer);
2494 }
2495
setOUTER()2496 void setOUTER()
2497 {
2498 if (progStatus.pbt_lock) {
2499 sldrINNER->value(sldrOUTER->value());
2500 sldrINNER->redraw();
2501 }
2502
2503 int ev = Fl::event();
2504 if (ev == FL_LEAVE || ev == FL_ENTER) return;
2505 if (ev == FL_DRAG || ev == FL_PUSH) {
2506 inhibit_pbt = 1;
2507 return;
2508 }
2509
2510 progStatus.pbt_outer = sldrOUTER->value();
2511 if (progStatus.pbt_lock) {
2512 progStatus.pbt_inner = progStatus.pbt_outer;
2513 sldrINNER->value(progStatus.pbt_outer);
2514 sldrINNER->redraw();
2515 }
2516 guard_lock lock(&mutex_serial);
2517 selrig->set_pbt_outer(progStatus.pbt_outer);
2518 selrig->set_pbt_inner(progStatus.pbt_inner);
2519 }
2520
setCLRPBT()2521 void setCLRPBT()
2522 {
2523 progStatus.pbt_inner = progStatus.pbt_outer = 0;
2524
2525 sldrOUTER->value(0);
2526 sldrOUTER->redraw();
2527
2528 sldrINNER->value(0);
2529 sldrINNER->redraw();
2530
2531 guard_lock lock(&mutex_serial);
2532 selrig->set_pbt_outer(progStatus.pbt_outer);
2533 selrig->set_pbt_inner(progStatus.pbt_inner);
2534 }
2535
2536 //----------------------------------------------------------------------
2537 // these only apply to the IC7610
2538 //----------------------------------------------------------------------
2539
digi_sel_on_off()2540 void digi_sel_on_off()
2541 {
2542 selrig->set_digi_sel(progStatus.digi_sel_on_off);
2543 }
2544
set_ic7610_digi_sel_on_off(void *)2545 void set_ic7610_digi_sel_on_off(void *)
2546 {
2547 ic7610digi_sel_on_off->value(progStatus.digi_sel_on_off);
2548 }
2549
digi_sel_val()2550 void digi_sel_val()
2551 {
2552 selrig->set_digi_val(progStatus.digi_sel_val);
2553 }
2554
set_ic7610_digi_sel_val(void *)2555 void set_ic7610_digi_sel_val(void *)
2556 {
2557 ic7610_digi_sel_val->value(progStatus.digi_sel_val);
2558 }
2559
dual_watch()2560 void dual_watch()
2561 {
2562 selrig->set_dual_watch(progStatus.dual_watch);
2563 }
2564
set_ic7610_dual_watch(void *)2565 void set_ic7610_dual_watch(void *)
2566 {
2567 }
2568
index_att()2569 void index_att()
2570 {
2571 selrig->set_index_att(progStatus.index_ic7610att);
2572 }
2573
set_ic7610_index_att(void *)2574 void set_ic7610_index_att(void *)
2575 {
2576 ic7610att->index(progStatus.index_ic7610att);
2577 }
2578
2579 //----------------------------------------------------------------------
2580
cbEventLog()2581 void cbEventLog()
2582 {
2583 debug::show();
2584 }
2585
setVolume()2586 void setVolume() // UI call
2587 {
2588 trace(1, "setVolume()");
2589 int ev = Fl::event();
2590 if (ev == FL_LEAVE || ev == FL_ENTER) return;
2591 if (ev == FL_DRAG || ev == FL_PUSH) {
2592 inhibit_volume = 1;
2593 return;
2594 }
2595 int set;
2596 if (spnrVOLUME) set = spnrVOLUME->value();
2597 else set = sldrVOLUME->value();
2598 progStatus.volume = set;
2599
2600 if (btnVol->value() == 0) return;
2601
2602 guard_lock serial_lock(&mutex_serial);
2603 selrig->set_volume_control(progStatus.volume);
2604 }
2605
setVolumeControl(void * d)2606 void setVolumeControl(void* d) // called by xml_server
2607 {
2608 guard_lock serial_lock(&mutex_serial);
2609 trace(1, "setVolumeControl()");
2610 if (sldrVOLUME) sldrVOLUME->value(progStatus.volume);
2611 if (spnrVOLUME) spnrVOLUME->value(progStatus.volume);
2612 selrig->set_volume_control(progStatus.volume);
2613 }
2614
cbMute()2615 void cbMute()
2616 {
2617 guard_lock serial_lock(&mutex_serial);
2618 trace(1, "cbMute()");
2619
2620 int set = 0, get, cnt = 0;
2621 if (btnVol->value() == 0) {
2622 if (spnrVOLUME) spnrVOLUME->deactivate();
2623 if (sldrVOLUME) sldrVOLUME->deactivate();
2624 } else {
2625 if (spnrVOLUME) {
2626 spnrVOLUME->activate();
2627 set = spnrVOLUME->value();
2628 }
2629 if (sldrVOLUME) {
2630 sldrVOLUME->activate();
2631 set = sldrVOLUME->value();
2632 }
2633 }
2634 selrig->set_volume_control(set);
2635 MilliSleep(progStatus.comm_wait);
2636 get = selrig->get_volume_control();
2637 while (get != set && cnt++ < 10) {
2638 MilliSleep(progStatus.comm_wait);
2639 get = selrig->get_volume_control();
2640 Fl::awake();
2641 }
2642 progStatus.volume = set;
2643 }
2644
setMicGain()2645 void setMicGain()
2646 {
2647 int ev = Fl::event();
2648 if (ev == FL_LEAVE || ev == FL_ENTER) return;
2649 if (ev == FL_DRAG || ev == FL_PUSH) {
2650 inhibit_mic = 1;
2651 return;
2652 }
2653 stringstream str;
2654 str << "setMicGain(), ev=" << ev << ", inhibit_mic=" << inhibit_mic;
2655 trace(1, str.str().c_str());
2656
2657
2658 int set = 0;
2659
2660 if (sldrMICGAIN) set = sldrMICGAIN->value();
2661 if (spnrMICGAIN) set = spnrMICGAIN->value();
2662
2663 progStatus.mic_gain = set;
2664
2665 guard_lock lock(&mutex_serial);
2666 selrig->set_mic_gain(set);
2667 }
2668
setMicGainControl(void * d)2669 void setMicGainControl(void* d)
2670 {
2671 guard_lock serial_lock(&mutex_serial);
2672 trace(1, "setMicGainControl()");
2673 if (sldrMICGAIN) sldrMICGAIN->value(progStatus.mic_gain);
2674 if (spnrMICGAIN) spnrMICGAIN->value(progStatus.mic_gain);
2675 }
2676
2677 static int img = -1;
2678
set_power_controlImage(double pwr)2679 void set_power_controlImage(double pwr)
2680 {
2681 if (progStatus.pwr_scale == 0 || (progStatus.pwr_scale == 5 && pwr <= 5.0)) {
2682 if (img != 1) {
2683 img = 1;
2684 scalePower->image(image_p5);
2685 sldrFwdPwr->maximum(5.0);
2686 sldrFwdPwr->minimum(0.0);
2687 scalePower->redraw();
2688 }
2689 }
2690 else if (progStatus.pwr_scale == 1 || (progStatus.pwr_scale == 5 && pwr <= 25.0)) {
2691 if (img != 2) {
2692 img = 2;
2693 scalePower->image(image_p25);
2694 sldrFwdPwr->maximum(25.0);
2695 sldrFwdPwr->minimum(0.0);
2696 scalePower->redraw();
2697 }
2698 }
2699 else if (progStatus.pwr_scale == 2 || (progStatus.pwr_scale == 5 && pwr <= 50.0)) {
2700 if (img != 3) {
2701 img = 3;
2702 scalePower->image(image_p50);
2703 sldrFwdPwr->maximum(50.0);
2704 sldrFwdPwr->minimum(0.0);
2705 scalePower->redraw();
2706 }
2707 }
2708 else if (progStatus.pwr_scale == 3 || (progStatus.pwr_scale == 5 && pwr <= 100.0)) {
2709 if (img != 4) {
2710 img = 4;
2711 scalePower->image(image_p100);
2712 sldrFwdPwr->maximum(100.0);
2713 sldrFwdPwr->minimum(0.0);
2714 scalePower->redraw();
2715 }
2716 }
2717 else if (progStatus.pwr_scale == 4 || (pwr > 100.0)) {
2718 if (img != 5) {
2719 img = 5;
2720 scalePower->image(image_p200);
2721 sldrFwdPwr->maximum(200.0);
2722 sldrFwdPwr->minimum(0.0);
2723 scalePower->redraw();
2724 }
2725 }
2726 return;
2727 }
2728
setPower()2729 void setPower()
2730 {
2731 int ev = Fl::event();
2732 if (ev == FL_LEAVE || ev == FL_ENTER) return;
2733 if (ev == FL_DRAG || ev == FL_PUSH) {
2734 inhibit_power = 1;
2735 return;
2736 }
2737 stringstream str;
2738 str << "setPower(), ev=" << ev << ", inhibit_power=" << inhibit_power;
2739 trace(1, str.str().c_str());
2740
2741 int set = 0;
2742
2743 if (spnrPOWER) set = progStatus.power_level = spnrPOWER->value();
2744 if (sldrPOWER) set = progStatus.power_level = sldrPOWER->value();
2745
2746 if (xcvr_name == rig_K2.name_) {
2747 double min, max, step;
2748 selrig->get_pc_min_max_step(min, max, step);
2749 if (spnrPOWER) spnrPOWER->minimum(min);
2750 if (spnrPOWER) spnrPOWER->maximum(max);
2751 if (spnrPOWER) spnrPOWER->step(step);
2752 if (spnrPOWER) spnrPOWER->value(progStatus.power_level);
2753 if (spnrPOWER) spnrPOWER->redraw();
2754 if (sldrPOWER) sldrPOWER->minimum(min);
2755 if (sldrPOWER) sldrPOWER->maximum(max);
2756 if (sldrPOWER) sldrPOWER->step(step);
2757 if (sldrPOWER) sldrPOWER->value(progStatus.power_level);
2758 if (sldrPOWER) sldrPOWER->redraw();
2759 }
2760
2761 guard_lock lock(&mutex_serial);
2762 selrig->set_power_control(set);
2763 }
2764
cbTune()2765 void cbTune()
2766 {
2767 guard_lock serial_lock(&mutex_serial);
2768 trace(1, "cbTune()");
2769 selrig->tune_rig(2);
2770 }
2771
cb_tune_on_off()2772 void cb_tune_on_off()
2773 {
2774 guard_lock serial_lock(&mutex_serial);
2775 trace(1, "cb_tune_on_off()");
2776 selrig->tune_rig(btn_tune_on_off->value());
2777 }
2778
2779
cbPTT()2780 void cbPTT()
2781 {
2782 setPTT(reinterpret_cast<void *>(btnPTT->value()));
2783 }
2784
setSQUELCH()2785 void setSQUELCH()
2786 {
2787 trace(1, "setSQUELCH()");
2788
2789 int ev = Fl::event();
2790 if (ev == FL_LEAVE || ev == FL_ENTER) return;
2791 if (ev == FL_DRAG || ev == FL_PUSH) {
2792 inhibit_squelch = 1;
2793 return;
2794 }
2795 int set = 0;
2796 if (sldrSQUELCH) set = sldrSQUELCH->value();
2797 if (spnrSQUELCH) set = spnrSQUELCH->value();
2798
2799 progStatus.squelch = set;
2800 guard_lock lock(&mutex_serial);
2801 selrig->set_squelch(set);
2802 }
2803
2804 int agcwas = 0;
redrawAGC()2805 void redrawAGC()
2806 {
2807 const char *lbl = selrig->agc_label();
2808 int val = progStatus.agc_level;
2809
2810 if (!selrig->has_rf_control) {
2811 sldrSQUELCH->label("");
2812 sldrSQUELCH->redraw_label();
2813 }
2814 btnAGC->label(lbl);
2815 btnAGC->redraw_label();
2816
2817 if (xcvr_name == rig_FT450D.name_) {
2818 switch (val) {
2819 case 0 : btnAGC->selection_color(FL_BACKGROUND_COLOR); // off
2820 break;
2821 case 1 : btnAGC->selection_color(FL_RED); // fast
2822 break;
2823 case 2 : btnAGC->selection_color(FL_YELLOW); // slow
2824 break;
2825 case 3 : btnAGC->selection_color(FL_GREEN); // auto
2826 break;
2827 }
2828 btnAGC->redraw();
2829 }
2830
2831 int rignbr = 0;
2832 if (xcvr_name == rig_IC7200.name_) rignbr = 1;
2833 if (xcvr_name == rig_IC7300.name_) rignbr = 2;
2834 if (rignbr) {
2835 if (val == 0) btnAGC->selection_color(FL_BACKGROUND_COLOR); // off
2836 if (val == 1) btnAGC->selection_color(
2837 rignbr == 1 ? FL_GREEN : FL_RED); // fast
2838 if (val == 2) btnAGC->selection_color(
2839 rignbr == 1 ? FL_RED : FL_YELLOW); // med / slow
2840 if (val == 3) btnAGC->selection_color(FL_GREEN); // slow
2841 btnAGC->value(val > 0);
2842 } else {
2843 if (val == 0)
2844 btnAGC->value(0);
2845 else
2846 btnAGC->value(1);
2847 }
2848
2849 if (agcwas != val) {
2850 agcwas = val;
2851 }
2852
2853 btnAGC->redraw();
2854 }
2855
setAGC(void *)2856 void setAGC(void *)
2857 {
2858 if (!selrig->has_agc_control) return;
2859 redrawAGC();
2860 }
2861
cbAGC()2862 void cbAGC()
2863 {
2864 if (!selrig->has_agc_control) return;
2865 guard_lock serial_lock(&mutex_serial);
2866 trace(1, "cbAGC()");
2867 progStatus.agc_level = selrig->incr_agc();
2868 redrawAGC();
2869 }
2870
setRFGAIN()2871 void setRFGAIN()
2872 {
2873 trace(1, "setRFGAIN()");
2874
2875 int ev = Fl::event();
2876 if (ev == FL_LEAVE || ev == FL_ENTER) return;
2877 if (ev == FL_DRAG || ev == FL_PUSH) {
2878 inhibit_rfgain = 1;
2879 return;
2880 }
2881
2882 int set = 0;
2883
2884 if (spnrRFGAIN) set = spnrRFGAIN->value();
2885 if (sldrRFGAIN) set = sldrRFGAIN->value();
2886
2887 progStatus.rfgain = set;
2888
2889 guard_lock lock(&mutex_serial);
2890 selrig->set_rf_gain(set);
2891 }
2892
setRFGAINControl(void * d)2893 void setRFGAINControl(void* d)
2894 {
2895 guard_lock serial_lock(&mutex_serial);
2896 trace(1, "setRFGAINControl()");
2897 if (sldrRFGAIN) sldrRFGAIN->value(progStatus.rfgain);
2898 if (spnrRFGAIN) spnrRFGAIN->value(progStatus.rfgain);
2899 }
2900
updateALC(void * d)2901 void updateALC(void * d)
2902 {
2903 if (meter_image != ALC_IMAGE) return;
2904 double data = (long)d;
2905 sldrRcvSignal->hide();
2906 sldrSWR->hide();
2907 sldrALC->show();
2908 sldrALC->value(data);
2909 sldrALC->redraw();
2910 }
2911
updateSWR(void * d)2912 void updateSWR(void * d)
2913 {
2914 if (meter_image != SWR_IMAGE) return;
2915 double data = (long)d;
2916 if (selrig->has_swr_control) {
2917 sldrRcvSignal->hide();
2918 sldrALC->hide();
2919 sldrSWR->show();
2920 }
2921 sldrSWR->value(data);
2922 sldrSWR->redraw();
2923 }
2924
updateFwdPwr(void * d)2925 void updateFwdPwr(void *d)
2926 {
2927 double power = (long)d;
2928 if (!sldrFwdPwr->visible()) {
2929 sldrFwdPwr->show();
2930 }
2931 power /= selrig->power_scale();
2932 sldrFwdPwr->value(power);
2933
2934 sldrFwdPwr->redraw();
2935 if (selrig->has_power_control)
2936 set_power_controlImage(power);
2937 }
2938
updateSquelch(void * d)2939 void updateSquelch(void *d)
2940 {
2941 if (sldrSQUELCH) sldrSQUELCH->value((long)d);
2942 if (sldrSQUELCH) sldrSQUELCH->redraw();
2943 if (spnrSQUELCH) spnrSQUELCH->value((long)d);
2944 if (spnrSQUELCH) spnrSQUELCH->redraw();
2945 }
2946
updateRFgain(void * d)2947 void updateRFgain(void *d)
2948 {
2949 if (spnrRFGAIN) {
2950 spnrRFGAIN->value((long)d);
2951 spnrRFGAIN->redraw();
2952 }
2953 if (sldrRFGAIN) {
2954 sldrRFGAIN->value((long)d);
2955 sldrRFGAIN->redraw();
2956 }
2957 }
2958
zeroXmtMeters(void * d)2959 void zeroXmtMeters(void *d)
2960 {
2961 sldrFwdPwr->clear();
2962 sldrALC->clear();
2963 sldrSWR->clear();
2964 updateFwdPwr(0);
2965 updateALC(0);
2966 updateSWR(0);
2967 }
2968
setFreqDispA(void * d)2969 void setFreqDispA(void *d)
2970 {
2971 long f = (long)d;
2972 FreqDispA->value(f);
2973 FreqDispA->redraw();
2974 }
2975
setFreqDispB(void * d)2976 void setFreqDispB(void *d)
2977 {
2978 long f = (long)d;
2979 FreqDispB->value(f);
2980 FreqDispB->redraw();
2981 }
2982
updateSmeter(void * d)2983 void updateSmeter(void *d) // 0 to 100;
2984 {
2985 double smeter = (long)d;
2986 if (!sldrRcvSignal->visible()) {
2987 sldrRcvSignal->show();
2988 sldrFwdPwr->hide();
2989 sldrALC->hide();
2990 sldrSWR->hide();
2991 }
2992 sldrRcvSignal->value(smeter);
2993 sldrRcvSignal->redraw();
2994 }
2995
saveFreqList()2996 void saveFreqList()
2997 {
2998 string atag;
2999
3000 if (!numinlist) return;
3001
3002 rotate_log(defFileName);
3003
3004 ofstream oList(defFileName.c_str());
3005 if (!oList) {
3006 fl_message ("Could not write to %s", defFileName.c_str());
3007 return;
3008 }
3009 for (int i = 0; i < numinlist; i++) {
3010 atag = oplist[i].alpha_tag;
3011 oList << oplist[i].freq << " " << oplist[i].imode << " " << oplist[i].iBW << " \"" << atag.c_str() << "\"" << endl;
3012
3013 }
3014 oList.close();
3015 }
3016
setPTT(void * d)3017 void setPTT( void *d)
3018 {
3019 guard_lock que_lock(&mutex_srvc_reqs, "setPTT");
3020
3021 int set = (long)d;
3022
3023 VFOQUEUE xcvrptt;
3024 if (set) xcvrptt.change = ON;
3025 else xcvrptt.change = OFF;
3026 srvc_reqs.push(xcvrptt);
3027 }
3028
update_progress(int val)3029 void update_progress(int val)
3030 {
3031 progress->value(val);
3032 Fl::check();
3033 }
3034
restore_rig_vals_(XCVR_STATE & xcvrvfo)3035 void restore_rig_vals_(XCVR_STATE &xcvrvfo)
3036 {
3037 if (progStatus.restore_pre_att) {
3038 selrig->set_attenuator(xcvrvfo.attenuator);
3039 selrig->set_preamp(xcvrvfo.preamp);
3040 }
3041 update_progress(progress->value() + 5);
3042
3043 if (progStatus.restore_auto_notch)
3044 selrig->set_auto_notch(xcvrvfo.auto_notch);
3045 if (progStatus.restore_split)
3046 selrig->set_split(xcvrvfo.split);
3047 update_progress(progress->value() + 5);
3048
3049 if (progStatus.restore_power_control)
3050 selrig->set_power_control(xcvrvfo.power_control);
3051 if (progStatus.restore_volume)
3052 selrig->set_volume_control(xcvrvfo.volume_control);
3053 update_progress(progress->value() + 5);
3054
3055 if (progStatus.restore_if_shift)
3056 selrig->set_if_shift(xcvrvfo.if_shift);
3057 update_progress(progress->value() + 5);
3058
3059 if (progStatus.restore_notch)
3060 selrig->set_notch(xcvrvfo.notch, xcvrvfo.notch_val);
3061 if (progStatus.restore_noise)
3062 selrig->set_noise(xcvrvfo.noise);
3063 update_progress(progress->value() + 5);
3064
3065 if (progStatus.restore_nr) {
3066 selrig->set_noise_reduction(xcvrvfo.nr);
3067 selrig->set_noise_reduction_val(xcvrvfo.nr_val);
3068 }
3069 update_progress(progress->value() + 5);
3070
3071 if (progStatus.restore_mic_gain)
3072 selrig->set_mic_gain(xcvrvfo.mic_gain);
3073 update_progress(progress->value() + 5);
3074
3075 if (progStatus.restore_squelch)
3076 selrig->set_squelch(xcvrvfo.squelch);
3077 update_progress(progress->value() + 5);
3078
3079 if (progStatus.restore_rf_gain)
3080 selrig->set_rf_gain(xcvrvfo.rf_gain);
3081 update_progress(progress->value() + 5);
3082
3083 if (progStatus.restore_comp_on_off && progStatus.restore_comp_level)
3084 selrig->set_compression(xcvrvfo.compON, xcvrvfo.compression);
3085 else if (progStatus.restore_comp_on_off)
3086 selrig->set_compression(xcvrvfo.compON, progStatus.compression);
3087 else if (progStatus.restore_comp_level)
3088 selrig->set_compression(progStatus.compON, xcvrvfo.compression);
3089 update_progress(progress->value() + 5);
3090
3091 }
3092
restore_rig_vals()3093 void restore_rig_vals()
3094 {
3095 if (progStatus.start_stop_trace) ss_trace(true);
3096
3097 update_progress(0);
3098
3099 guard_lock serial_lock(&mutex_serial);
3100 trace(1, "restore_rig_vals()");
3101
3102 if (!useB) {
3103 useB = true;
3104 selrig->selectB();
3105 }
3106
3107 if (progStatus.restore_mode) {
3108 selrig->set_modeB(xcvr_vfoB.imode);
3109 selrig->set_FILT(xcvr_vfoB.filter);
3110 }
3111
3112 if (progStatus.restore_frequency)
3113 selrig->set_vfoB(xcvr_vfoB.freq);
3114
3115 if (progStatus.restore_bandwidth)
3116 selrig->set_bwB(xcvr_vfoB.iBW);
3117
3118 restore_rig_vals_(xcvr_vfoB);
3119
3120 trace(2, "Restored xcvr B:\n", print(xcvr_vfoB));
3121
3122 useB = false;
3123 selrig->selectA();
3124
3125 if (progStatus.restore_mode) {
3126 selrig->set_modeA(xcvr_vfoA.imode);
3127 selrig->set_FILT(xcvr_vfoA.filter);
3128 }
3129
3130 if (progStatus.restore_frequency)
3131 selrig->set_vfoA(xcvr_vfoA.freq);
3132
3133 if (progStatus.restore_bandwidth)
3134 selrig->set_bwA(xcvr_vfoA.iBW);
3135
3136 restore_rig_vals_(xcvr_vfoA);
3137
3138 trace(2, "Restored xcvr A:\n", print(xcvr_vfoA));
3139
3140 if (progStatus.start_stop_trace) ss_trace(false);
3141
3142 }
3143
read_rig_vals_(XCVR_STATE & xcvrvfo)3144 void read_rig_vals_(XCVR_STATE &xcvrvfo)
3145 {
3146 if (selrig->has_preamp_control)
3147 xcvrvfo.preamp = selrig->get_preamp();
3148 if (selrig->has_attenuator_control)
3149 xcvrvfo.attenuator = selrig->get_attenuator();
3150
3151 if (selrig->has_preamp_control || selrig->has_attenuator_control)
3152 btnRestorePreAtt->activate();
3153 else
3154 btnRestorePreAtt->deactivate();
3155
3156 if (selrig->has_auto_notch) {
3157 btnRestoreAutoNotch->activate();
3158 if (progStatus.restore_auto_notch && selrig->has_auto_notch)
3159 xcvrvfo.auto_notch = selrig->get_auto_notch();
3160 } else btnRestoreAutoNotch->deactivate();
3161
3162 if (selrig->has_split) {
3163 btnRestoreSplit->activate();
3164 if (progStatus.restore_split && selrig->has_split)
3165 xcvrvfo.split = selrig->get_split();
3166 } else
3167 btnRestoreSplit->deactivate();
3168
3169 update_progress(progress->value() + 4);
3170
3171 if (selrig->has_power_control) {
3172 btnRestorePowerControl->activate();
3173 if (progStatus.restore_power_control)
3174 xcvrvfo.power_control = selrig->get_power_control();
3175 } else
3176 btnRestorePowerControl->deactivate();
3177
3178 if (selrig->has_volume_control) {
3179 btnRestoreVolume->activate();
3180 if (progStatus.restore_volume)
3181 xcvrvfo.volume_control = selrig->get_volume_control();
3182 } else
3183 btnRestoreVolume->deactivate();
3184
3185 if (selrig->has_ifshift_control) {
3186 btnRestoreIFshift->activate();
3187 if (progStatus.restore_if_shift)
3188 selrig->get_if_shift(xcvrvfo.if_shift);
3189 } else
3190 btnRestoreIFshift->deactivate();
3191
3192 update_progress(progress->value() + 4);
3193
3194 if (selrig->has_notch_control) {
3195 btnRestoreNotch->activate();
3196 if (progStatus.restore_notch)
3197 xcvrvfo.notch = selrig->get_notch(xcvrvfo.notch_val);
3198 } else
3199 btnRestoreNotch->deactivate();
3200
3201 if (selrig->has_noise_control) {
3202 btnRestoreNoise->activate();
3203 if (progStatus.restore_noise)
3204 xcvrvfo.noise = selrig->get_noise();
3205 } else
3206 btnRestoreNoise->deactivate();
3207
3208
3209 update_progress(progress->value() + 4);
3210
3211 if (selrig->has_noise_reduction_control) {
3212 btnRestoreNR->activate();
3213 if (progStatus.restore_nr) {
3214 xcvrvfo.nr = selrig->get_noise_reduction();
3215 xcvrvfo.nr_val = selrig->get_noise_reduction_val();
3216 }
3217 } else
3218 btnRestoreNR->deactivate();
3219
3220 if (selrig->has_micgain_control) {
3221 btnRestoreMicGain->activate();
3222 if (progStatus.restore_mic_gain)
3223 xcvrvfo.mic_gain = selrig->get_mic_gain();
3224 } else
3225 btnRestoreMicGain->deactivate();
3226
3227 if (selrig->has_sql_control) {
3228 btnRestoreSquelch->activate();
3229 if (progStatus.restore_squelch)
3230 xcvrvfo.squelch = selrig->get_squelch();
3231 } else
3232 btnRestoreSquelch->deactivate();
3233
3234
3235 update_progress(progress->value() + 4);
3236
3237 if (selrig->has_rf_control) {
3238 btnRestoreRfGain->activate();
3239 if (progStatus.restore_rf_gain)
3240 xcvrvfo.rf_gain = selrig->get_rf_gain();
3241 } else
3242 btnRestoreRfGain->deactivate();
3243
3244 if (selrig->has_compression || selrig->has_compON) {
3245
3246 selrig->get_compression( xcvrvfo.compON, xcvrvfo.compression );
3247
3248 if (selrig->has_compON)
3249 btnRestoreCompOnOff->activate();
3250 else
3251 btnRestoreCompOnOff->deactivate();
3252
3253 if (selrig->has_compression)
3254 btnRestoreCompLevel->activate();
3255 else
3256 btnRestoreCompLevel->deactivate();
3257
3258 } else {
3259 btnRestoreCompOnOff->deactivate();
3260 btnRestoreCompLevel->deactivate();
3261 }
3262
3263 update_progress(progress->value() + 4);
3264
3265 }
3266
read_vfoA_vals()3267 void read_vfoA_vals()
3268 {
3269 trace(1, "read_vfoA_vals()");
3270 update_progress(progress->value() + 4);
3271
3272 if (selrig->has_get_info)
3273 selrig->get_info();
3274
3275 trace(1, "read vfoA()");
3276 xcvr_vfoA.freq = selrig->get_vfoA();
3277 update_progress(progress->value() + 4);
3278
3279 trace(1, "read modeA()");
3280 xcvr_vfoA.imode = selrig->get_modeA();
3281 update_progress(progress->value() + 4);
3282
3283 trace(1, "get bwA()");
3284 xcvr_vfoA.iBW = selrig->get_bwA();
3285 update_progress(progress->value() + 4);
3286
3287 trace(1, "get FILT(A)");
3288 xcvr_vfoA.filter = selrig->get_FILT(xcvr_vfoA.imode);
3289
3290 trace(1, "read_rig_vals()");
3291 read_rig_vals_(xcvr_vfoA);
3292
3293 trace(2, "Read xcvr A:\n", print(xcvr_vfoA));
3294 }
3295
read_vfoB_vals()3296 void read_vfoB_vals()
3297 {
3298 trace(1, "read_vfoB_vals()");
3299 update_progress(progress->value() + 4);
3300
3301 if (selrig->has_get_info)
3302 selrig->get_info();
3303
3304 trace(1, "read vfoB()");
3305 xcvr_vfoB.freq = selrig->get_vfoB();
3306 update_progress(progress->value() + 4);
3307
3308 trace(1, "read modeB()");
3309 xcvr_vfoB.imode = selrig->get_modeB();
3310 update_progress(progress->value() + 4);
3311
3312 trace(1, "get bwB()");
3313 xcvr_vfoB.iBW = selrig->get_bwB();
3314 update_progress(progress->value() + 4);
3315
3316 trace(1, "get FILT(B)");
3317 xcvr_vfoB.filter = selrig->get_FILT(xcvr_vfoB.imode);
3318
3319 trace(1, "read_rig_vals()");
3320 read_rig_vals_(xcvr_vfoB);
3321
3322 trace(2, "Read xcvr B:\n", print(xcvr_vfoB));
3323 }
3324
read_rig_vals()3325 void read_rig_vals()
3326 {
3327 if (progStatus.start_stop_trace) ss_trace(true);
3328
3329 if (selrig->has_mode_control)
3330 btnRestoreMode->activate();
3331 else
3332 btnRestoreMode->deactivate();
3333
3334 if (selrig->has_bandwidth_control)
3335 btnRestoreBandwidth->activate();
3336 else
3337 btnRestoreBandwidth->deactivate();
3338
3339 // no guard_lock ... this function called from within a guard_lock block
3340 trace(1, "read_rig_vals()");
3341 update_progress(0);
3342
3343 if (selrig->name_ == rig_FT891.name_) {
3344 // The FT-891 loses width WDH on A/B changes. It also starts
3345 // with VFOA active, so no selectA() before reading VFOA values.
3346 useB = false;
3347 read_vfoA_vals();
3348 useB = true;
3349 selrig->selectB(); // first select call
3350 read_vfoB_vals();
3351
3352 // Restore VFOA mode, then freq and bandwidth
3353 useB = false;
3354 selrig->selectA(); // second select call
3355 yaesu891UpdateA(&xcvr_vfoA);
3356 } else {
3357 useB = true;
3358 selrig->selectB(); // first select call to FT897D
3359 read_vfoB_vals();
3360 useB = false;
3361 selrig->selectA(); // second select call
3362 read_vfoA_vals();
3363 }
3364 if (selrig->has_agc_control) {
3365 progStatus.agc_level = selrig->get_agc();
3366 redrawAGC();
3367 }
3368
3369 if (selrig->has_FILTER)
3370 selrig->set_FILTERS(progStatus.filters);
3371
3372 selrig->set_BANDWIDTHS(progStatus.bandwidths);
3373
3374 if (progStatus.start_stop_trace) ss_trace(false);
3375 }
3376
close_UI()3377 void close_UI()
3378 {
3379 {
3380 guard_lock serial_lock(&mutex_serial);
3381 trace(1, "close_UI()");
3382 run_serial_thread = false;
3383 }
3384 //std::cout << "close_UI()" << std::endl;
3385 //std::cout << "pthread_join(*serial_thread, NULL)" << std::endl;
3386 pthread_join(*serial_thread, NULL);
3387
3388 // xcvr auto off
3389 if (selrig->has_xcvr_auto_on_off && progStatus.xcvr_auto_off)
3390 selrig->set_xcvr_auto_off();
3391
3392 // close down the serial port
3393 RigSerial->ClosePort();
3394
3395 if (dlgDisplayConfig && dlgDisplayConfig->visible())
3396 dlgDisplayConfig->hide();
3397 if (dlgXcvrConfig && dlgXcvrConfig->visible())
3398 dlgXcvrConfig->hide();
3399 if (dlgMemoryDialog && dlgMemoryDialog->visible())
3400 dlgMemoryDialog->hide();
3401
3402 debug::stop();
3403
3404 mainwindow->hide();
3405 }
3406
closeRig()3407 void closeRig()
3408 {
3409 trace(1, "closeRig()");
3410 if (xcvr_online) {
3411 restore_rig_vals();
3412 selrig->shutdown();
3413 }
3414 xcvr_online = false;
3415 }
3416
cbExit()3417 void cbExit()
3418 {
3419 main_group->hide();
3420 main_group->redraw();
3421
3422 grpInitializing->size(mainwindow->w(), mainwindow->h() - grpInitializing->y());
3423 grpInitializing->show();
3424 grpInitializing->redraw();
3425
3426 progress->label("Closing");
3427 progress->redraw_label();
3428
3429 progress->position(grpInitializing->w()/4, grpInitializing->y() + grpInitializing->h()/2);
3430
3431 update_progress(0);
3432
3433 progStatus.freq_A = vfoA.freq;
3434 progStatus.imode_A = vfoA.imode;
3435 progStatus.iBW_A = vfoA.iBW;
3436
3437 progStatus.freq_B = vfoB.freq;
3438 progStatus.imode_B = vfoB.imode;
3439 progStatus.iBW_B = vfoB.iBW;
3440
3441 if (selrig->has_FILTER)
3442 progStatus.filters = selrig->get_FILTERS();
3443
3444 progStatus.spkr_on = btnVol->value();
3445
3446 saveFreqList();
3447
3448 if (spnrPOWER) progStatus.power_level = spnrPOWER->value();
3449 if (spnrVOLUME) progStatus.volume = spnrVOLUME->value();
3450 if (spnrRFGAIN) progStatus.rfgain = spnrRFGAIN->value();
3451 if (spnrMICGAIN) progStatus.mic_gain = spnrMICGAIN->value();
3452 if (spnrNOTCH) progStatus.notch_val = spnrNOTCH->value();
3453 if (spnrIFSHIFT) progStatus.shift_val = spnrIFSHIFT->value();
3454 if (spnrNR) progStatus.noise_reduction_val = spnrNR->value();
3455
3456 if (sldrPOWER) progStatus.power_level = sldrPOWER->value();
3457 if (sldrVOLUME) progStatus.volume = sldrVOLUME->value();
3458 if (sldrRFGAIN) progStatus.rfgain = sldrRFGAIN->value();
3459 if (sldrMICGAIN) progStatus.mic_gain = sldrMICGAIN->value();
3460 if (sldrNOTCH) progStatus.notch_val = sldrNOTCH->value();
3461 if (sldrIFSHIFT) progStatus.shift_val = sldrIFSHIFT->value();
3462 if (sldrNR) progStatus.noise_reduction_val = sldrNR->value();
3463
3464 progStatus.notch = btnNotch->value();
3465 progStatus.shift = btnIFsh->value();
3466 progStatus.noise_reduction = btnNR->value();
3467 progStatus.noise = btnNOISE->value();
3468 progStatus.attenuator = btnAttenuator->value();
3469 progStatus.preamp = btnPreamp->value();
3470 progStatus.auto_notch = btnAutoNotch->value();
3471
3472 progStatus.bandwidths = selrig->get_BANDWIDTHS();
3473
3474 progStatus.saveLastState();
3475 closeRig();
3476
3477 stop_cwio_thread();
3478
3479 exit_server();
3480
3481 close_UI();
3482
3483 if (tracewindow) tracewindow->hide();
3484 if (tabs_dialog) tabs_dialog->hide();
3485 if (cwio_keyer_dialog) cwio_keyer_dialog->hide();
3486 if (cwio_editor) cwio_editor->hide();
3487 if (cwio_configure) cwio_configure->hide();
3488 }
3489
cbALC_SWR()3490 void cbALC_SWR()
3491 {
3492 if (!selrig->has_alc_control) return;
3493 if (meter_image == SWR_IMAGE) {
3494 btnALC_SWR->image(image_alc);
3495 meter_image = ALC_IMAGE;
3496 sldrALC->show();
3497 {
3498 guard_lock serial_lock(&mutex_serial);
3499 trace(1, "cbALC_SWR() 1");
3500 selrig->select_alc();
3501 }
3502 } else {
3503 btnALC_SWR->image(image_swr);
3504 meter_image = SWR_IMAGE;
3505 sldrSWR->show();
3506 {
3507 guard_lock serial_lock(&mutex_serial);
3508 trace(1, "cbALC_SWR() 2");
3509 selrig->select_swr();
3510 }
3511 }
3512 btnALC_SWR->redraw();
3513 }
3514
update_UI_PTT(void * d)3515 void update_UI_PTT(void *d)
3516 {
3517 btnPTT->value(PTT);
3518 if (!PTT) {
3519 btnALC_SWR->hide();
3520 scaleSmeter->show();
3521 sldrRcvSignal->clear();
3522 } else {
3523 btnALC_SWR->show();
3524 scaleSmeter->hide();
3525 sldrFwdPwr->clear();
3526 sldrALC->clear();
3527 sldrSWR->clear();
3528 }
3529 }
3530
adjust_small_ui()3531 void adjust_small_ui()
3532 {
3533 int y = 0;
3534
3535 mainwindow->resize( mainwindow->x(), mainwindow->y(), SMALL_MAINW, SMALL_MAINH);
3536
3537 btnVol->hide();
3538 sldrVOLUME->hide();
3539 sldrRFGAIN->hide();
3540 btnIFsh->hide();
3541 sldrIFSHIFT->hide();
3542 btnLOCK->hide();
3543 btnCLRPBT->hide();
3544 sldrINNER->hide();
3545 btnCLRPBT->hide();
3546 sldrOUTER->hide();
3547 btnNotch->hide();
3548 sldrNOTCH->hide();
3549 sldrMICGAIN->hide();
3550 btnPOWER->hide();
3551 sldrPOWER->hide();
3552 btnPOWER->hide();
3553 sldrSQUELCH->hide();
3554 btnNR->hide();
3555 sldrNR->hide();
3556 btnNOISE->hide();
3557 btnAGC->hide();
3558 sldrRFGAIN->redraw_label();
3559
3560 if (progStatus.schema == 1 && selrig->widgets[0].W != NULL) {
3561 int i = 0;
3562 while (selrig->widgets[i].W != NULL) {
3563 selrig->widgets[i].W->resize(
3564 selrig->widgets[i].x, selrig->widgets[i].y,
3565 selrig->widgets[i].w, selrig->widgets[i].W->h() );
3566 selrig->widgets[i].W->show();
3567 selrig->widgets[i].W->redraw();
3568 if (selrig->widgets[i].y > y) y = selrig->widgets[i].y;
3569 i++;
3570 }
3571 if (selrig->has_data_port) {
3572 sldrMICGAIN->label("");
3573 sldrMICGAIN->redraw_label();
3574 }
3575 if (selrig->has_power_control) {
3576 btnPOWER->resize( sldrPOWER->x() - 52, sldrPOWER->y(), 50, 18 );
3577 btnPOWER->redraw();
3578 btnPOWER->show();
3579 }
3580 if (mnuSchema) mnuSchema->set();
3581 } else {
3582 if (mnuSchema) mnuSchema->clear();
3583 y = cntRIT->y() + 2;
3584 if (selrig->has_volume_control) {
3585 y += 20;
3586 btnVol->position( 2, y);
3587 btnVol->show();
3588 btnVol->redraw();
3589 sldrVOLUME->resize( 54, y, 368, 18 );
3590 sldrVOLUME->show();
3591 sldrVOLUME->redraw();
3592 }
3593 if (selrig->has_rf_control) {
3594 y += 20;
3595 sldrRFGAIN->resize( 54, y, 368, 18 );
3596 sldrRFGAIN->show();
3597 sldrRFGAIN->redraw();
3598 }
3599 if (selrig->has_sql_control) {
3600 y += 20;
3601 sldrSQUELCH->resize( 54, y, 368, 18 );
3602 sldrSQUELCH->show();
3603 sldrSQUELCH->redraw();
3604 }
3605 if (selrig->has_noise_reduction_control) {
3606 y += 20;
3607 btnNR->position( 2, y);
3608 btnNR->show();
3609 btnNR->redraw();
3610 sldrNR->resize( 54, y, 368, 18 );
3611 sldrNR->show();
3612 sldrNR->redraw();
3613 if (xcvr_name == rig_TT599.name_) btnNR->deactivate();
3614 }
3615 if (selrig->has_pbt_controls) {
3616 y += 20;
3617 btnLOCK->position( 2, y);
3618 btnLOCK->show();
3619 btnLOCK->redraw();
3620 sldrINNER->resize( 54, y, 368, 18 );
3621 sldrINNER->show();
3622 sldrINNER->redraw();
3623 y += 20;
3624 btnCLRPBT->position( 2, y);
3625 btnCLRPBT->show();
3626 btnCLRPBT->redraw();
3627 sldrOUTER->resize( 54, y, 368, 18);
3628 sldrOUTER->show();
3629 sldrOUTER->redraw();
3630 }
3631 if (selrig->has_ifshift_control) {
3632 y += 20;
3633 btnIFsh->position( 2, y);
3634 btnIFsh->show();
3635 btnIFsh->redraw();
3636 sldrIFSHIFT->resize( 54, y, 368, 18 );
3637 sldrIFSHIFT->show();
3638 sldrIFSHIFT->redraw();
3639 }
3640 if (selrig->has_notch_control) {
3641 y += 20;
3642 btnNotch->position( 2, y);
3643 btnNotch->show();
3644 btnNotch->redraw();
3645 sldrNOTCH->resize( 54, y, 368, 18 );
3646 sldrNOTCH->show();
3647 sldrNOTCH->redraw();
3648 }
3649 if (selrig->has_micgain_control || selrig->has_data_port) {
3650 if (selrig->has_micgain_control) {
3651 y += 20;
3652 sldrMICGAIN->resize( 54, y, 368, 18 );
3653 sldrMICGAIN->show();
3654 sldrMICGAIN->redraw();
3655 if (selrig->has_data_port) {
3656 sldrMICGAIN->label("");
3657 sldrMICGAIN->redraw_label();
3658 btnDataPort->position( 2, y);
3659 btnDataPort->show();
3660 btnDataPort->redraw();
3661 }
3662 } else if (selrig->has_data_port) {
3663 btnDataPort->position( 214, 105);
3664 btnDataPort->show();
3665 btnDataPort->redraw();
3666 }
3667 }
3668 if (selrig->has_power_control) {
3669 y += 20;
3670 sldrPOWER->resize( 54, y, 368, 18 );
3671 sldrPOWER->show();
3672 sldrPOWER->redraw();
3673 btnPOWER->resize( 2, y, 50, 18 );
3674 btnPOWER->show();
3675 }
3676 }
3677 y += 20;
3678 btn_show_controls->position( btn_show_controls->x(), y );
3679 btnAttenuator->position( btnAttenuator->x(), y);
3680 btnAttenuator->redraw();
3681 btnPreamp->position( btnPreamp->x(), y);
3682 btnPreamp->redraw();
3683 btnNOISE->position( btnNOISE->x(), y);
3684 btnAutoNotch->position( btnAutoNotch->x(), y);
3685 btnAutoNotch->redraw();
3686 btnTune->position( btnTune->x(), y);
3687 btnTune->redraw();
3688 btn_tune_on_off->position( btn_tune_on_off->x(), y);
3689 btn_tune_on_off->redraw();
3690
3691 if (selrig->has_noise_reduction) {
3692 btnNOISE->show();
3693 } else {
3694 btnNOISE->hide();
3695 }
3696 btnNOISE->redraw();
3697
3698 if (selrig->has_agc_control) {
3699 btnAGC->show();
3700 sldrRFGAIN->label("");
3701 sldrRFGAIN->redraw_label();
3702 } else {
3703 btnAGC->hide();
3704 sldrRFGAIN->label(_("RF"));
3705 sldrRFGAIN->redraw_label();
3706 }
3707
3708 if (xcvr_name == rig_FT1000MP.name_) {
3709 y -= 20;
3710 btnTune->position( btnTune->x(), y);
3711 btnTune->redraw();
3712 btn_tune_on_off->position( btn_tune_on_off->x(), y);
3713 btn_tune_on_off->redraw();
3714 btnAutoNotch->position( btnAutoNotch->x(), y);
3715 btnAutoNotch->redraw();
3716 btnPTT->position( btnPTT->x(), y);
3717 btnPTT->redraw();
3718 }
3719
3720 if (xcvr_name == rig_FT100D.name_ ||
3721 xcvr_name == rig_FT767.name_ ||
3722 xcvr_name == rig_FT817.name_ ||
3723 xcvr_name == rig_FT847.name_ ||
3724 xcvr_name == rig_FT857D.name_ ||
3725 xcvr_name == rig_FT890.name_ ||
3726 xcvr_name == rig_FT897D.name_ ||
3727 xcvr_name == rig_FT920.name_ ) {
3728 y -= 20;
3729 btnPTT->position( mainwindow->w() - btnPTT->w() - btn_show_controls->w() - 10, y);
3730 btnPTT->redraw();
3731 btn_show_controls->position( btnPTT->x() + btnPTT->w() + 5, y );
3732 btn_show_controls->redraw();
3733 }
3734
3735 int use_AuxPort = (progStatus.aux_serial_port != "NONE");
3736 if (use_AuxPort) {
3737 btnPTT->resize(btnPTT->x(), y, btnPTT->w(), 38);
3738 btnPTT->redraw();
3739 y += 20;
3740 boxControl->position(boxControl->x(), y);
3741 btnAuxRTS->position(btnAuxRTS->x(), y);
3742 btnAuxDTR->position(btnAuxDTR->x(), y);
3743 btnAuxRTS->value(progStatus.aux_rts);
3744 btnAuxDTR->value(progStatus.aux_dtr);
3745 boxControl->show();
3746 btnAuxRTS->show();
3747 btnAuxDTR->show();
3748 } else {
3749 boxControl->hide();
3750 btnAuxRTS->hide();
3751 btnAuxDTR->hide();
3752 btnPTT->resize(btnPTT->x(), y, btnPTT->w(), 18);
3753 btnPTT->redraw();
3754 }
3755
3756 btn_show_controls->label("@-22->");
3757 btn_show_controls->redraw_label();
3758
3759 y += 20;
3760
3761 btn_show_controls->show();
3762 mainwindow->init_sizes();
3763 mainwindow->size( mainwindow->w(), y);
3764
3765 if (progStatus.tooltips) {
3766 Fl_Tooltip::enable(1);
3767 if (mnuTooltips) mnuTooltips->set();
3768 } else {
3769 if (mnuTooltips) mnuTooltips->clear();
3770 Fl_Tooltip::enable(0);
3771 }
3772
3773 mainwindow->redraw();
3774
3775 if (tabs_dialog && tabs_dialog->visible())
3776 tabs_dialog->position(mainwindow->x(), mainwindow->y() + mainwindow->h() + 26);
3777
3778 }
3779
adjust_xig_wide()3780 void adjust_xig_wide()
3781 {
3782 btnPreamp->show();
3783 btnAttenuator->show();
3784 btnNOISE->show();
3785 btnAutoNotch->hide();
3786
3787 btnAGC->resize(btnAutoNotch->x(), btnAutoNotch->y(), btnAutoNotch->w(), btnAutoNotch->h());
3788 btnAGC->show();
3789 grp_row1b1b->add(btnAGC);
3790
3791 btnAswapB->show();
3792 btnSplit->show();
3793 btnPTT->show();
3794 btnTune->show();
3795
3796 int xig_y = grp_row2->y() + grp_row2->h() / 4;
3797 int xig_h = 5 * btnAGC->h() / 4;
3798
3799 Fl_Group *xig_group = new Fl_Group(
3800 2, xig_y,
3801 mainwindow->w() - 4, xig_h);
3802
3803 Fl_Group *xig_gp1 = new Fl_Group(
3804 xig_group->x(), xig_group->y(),
3805 (xig_group->w() - 4) / 3, xig_h);
3806
3807 btnVol->resize(
3808 xig_gp1->x(), xig_y,
3809 54, xig_gp1->h());
3810 xig_gp1->add(btnVol);
3811
3812 sldrVOLUME->resize(
3813 xig_gp1->x() + 54, xig_y,
3814 xig_gp1->w() - 54, xig_h);
3815 xig_gp1->add(sldrVOLUME);
3816
3817 btnVol->show();
3818 sldrVOLUME->show();
3819
3820 xig_gp1->end();
3821 xig_gp1->resizable(sldrVOLUME);
3822
3823 Fl_Group *xig_gp2 = new Fl_Group(
3824 xig_gp1->x() + xig_gp1->w() + 2, xig_y,
3825 xig_gp1->w(), xig_h);
3826
3827 btnPOWER->resize(
3828 xig_gp2->x(), xig_y,
3829 54, xig_h);
3830 xig_gp2->add(btnPOWER);
3831
3832 sldrPOWER->resize(
3833 xig_gp2->x() + 54, xig_y,
3834 xig_gp2->w() - 54, xig_h);
3835 xig_gp2->add(sldrPOWER);
3836
3837 btnPOWER->show();
3838 sldrPOWER->show();
3839
3840 xig_gp2->end();
3841 xig_gp2->resizable(sldrPOWER);
3842
3843 Fl_Group *xig_gp3 = new Fl_Group(
3844 xig_gp2->x() + xig_gp2->w() + 2, xig_y,
3845 xig_group->w() - 2 * xig_gp1->w() - 4, xig_h);
3846
3847 xig_gp3->add(sldrSQUELCH);
3848 sldrSQUELCH->resize(
3849 xig_gp3->x() + 54, xig_y,
3850 xig_gp3->w() - 54, xig_h);
3851 sldrSQUELCH->label("SQL");
3852 sldrSQUELCH->redraw_label();
3853 sldrSQUELCH->show();
3854
3855 xig_gp3->end();
3856 xig_gp3->resizable(sldrSQUELCH);
3857
3858 xig_group->end();
3859
3860 grp_row2a->remove(sldrMICGAIN);
3861 grp_row2a->resize(xig_group->x(), xig_group->y(), xig_group->w(), xig_group->h());
3862 grp_row2a->hide();
3863 grp_row2b->remove(btnIFsh);
3864 grp_row2b->remove(sldrIFSHIFT);
3865 grp_row2b->resize(xig_group->x(), xig_group->y(), xig_group->w(), xig_group->h());
3866 grp_row2b->hide();
3867 grp_row2c->remove(sldrRFGAIN);
3868 grp_row2c->resize(xig_group->x(), xig_group->y(), xig_group->w(), xig_group->h());
3869 grp_row2c->hide();
3870 grp_row2->resize(xig_group->x(), xig_group->y(), xig_group->w(), xig_group->h());
3871 grp_row2->hide();
3872 mainwindow->remove(grp_row2);
3873
3874 mainwindow->add(xig_group);
3875
3876 if (progStatus.tooltips) {
3877 Fl_Tooltip::enable(1);
3878 if (mnuTooltips) mnuTooltips->set();
3879 } else {
3880 if (mnuTooltips) mnuTooltips->clear();
3881 Fl_Tooltip::enable(0);
3882 }
3883
3884 mainwindow->redraw();
3885
3886 if (tabs_dialog && tabs_dialog->visible())
3887 tabs_dialog->position(mainwindow->x(), mainwindow->y() + mainwindow->h() + 26);
3888
3889 return;
3890 }
3891
adjust_wide_ui()3892 void adjust_wide_ui()
3893 {
3894 mainwindow->resize(
3895 progStatus.mainX, progStatus.mainY, progStatus.mainW, progStatus.mainH);
3896 mainwindow->redraw();
3897
3898 btnVol->show();
3899 sldrVOLUME->show();
3900 sldrRFGAIN->show();
3901 if (selrig->has_ifshift_control) {
3902 btnIFsh->show();
3903 sldrIFSHIFT->show();
3904 }
3905 if (selrig->has_pbt_controls) {
3906 btnLOCK->show();
3907 btnLOCK->value(progStatus.pbt_lock);
3908 btnCLRPBT->show();
3909 sldrINNER->show();
3910 sldrOUTER->show();
3911 sldrINNER->value(progStatus.pbt_inner);
3912 sldrOUTER->value(progStatus.pbt_outer);
3913 }
3914 btnNotch->show();
3915 sldrNOTCH->show();
3916 sldrMICGAIN->show();
3917 sldrPOWER->show();
3918 btnPOWER->hide();
3919 sldrSQUELCH->show();
3920 btnNR->show();
3921 sldrNR->show();
3922 btnAGC->hide();
3923 btnDataPort->hide();
3924 sldrRFGAIN->redraw_label();
3925
3926 if (!selrig->has_micgain_control)
3927 sldrMICGAIN->deactivate();
3928
3929 if (!selrig->has_noise_reduction)
3930 btnNR->deactivate();
3931
3932 if (!selrig->has_noise_reduction_control)
3933 sldrNR->deactivate();
3934
3935 if (xcvr_name == rig_TT550.name_) {
3936 tabs550->show();
3937 tabsGeneric->hide();
3938 } else {
3939 tabs550->hide();
3940
3941 tabsGeneric->remove(genericAux);
3942 if (progStatus.aux_serial_port != "NONE" || selrig->has_data_port) {
3943 if (progStatus.aux_serial_port != "NONE") {
3944 btnAuxRTS->activate();
3945 btnAuxDTR->activate();
3946 } else {
3947 btnAuxRTS->deactivate();
3948 btnAuxDTR->deactivate();
3949 }
3950 if (selrig->has_data_port)
3951 btnDataPort->show();
3952 else
3953 btnDataPort->hide();
3954 tabsGeneric->add(genericAux);
3955 }
3956 tabsGeneric->remove(genericRXB);
3957 if (selrig->has_rit || selrig->has_xit || selrig->has_bfo)
3958 tabsGeneric->add(genericRXB);
3959 tabsGeneric->show();
3960 if (selrig->has_agc_control) {
3961 btnAGC->show();
3962 sldrRFGAIN->label("");
3963 sldrRFGAIN->redraw_label();
3964 } else {
3965 btnAGC->hide();
3966 sldrRFGAIN->label(_("RF"));
3967 sldrRFGAIN->redraw_label();
3968 }
3969 if (selrig->has_power_control) {
3970 btnPOWER->resize(sldrPOWER->x() - 52, sldrPOWER->y(), 50, 18);
3971 btnPOWER->show();
3972 }
3973 else {
3974 sldrPOWER->deactivate();
3975 }
3976 }
3977
3978 if (progStatus.tooltips) {
3979 Fl_Tooltip::enable(1);
3980 if (mnuTooltips) mnuTooltips->set();
3981 } else {
3982 if (mnuTooltips) mnuTooltips->clear();
3983 Fl_Tooltip::enable(0);
3984 }
3985
3986 mainwindow->redraw();
3987 }
3988
adjust_touch_ui()3989 void adjust_touch_ui()
3990 {
3991 mainwindow->resize( mainwindow->x(), mainwindow->y(), mainwindow->w(), TOUCH_MAINH);
3992 mainwindow->redraw();
3993
3994 if (spnrPOWER) spnrPOWER->show();
3995 if (sldrPOWER) sldrPOWER->show();
3996 btnVol->show();
3997 if (spnrVOLUME) spnrVOLUME->show();
3998 if (sldrVOLUME) sldrVOLUME->show();
3999
4000 if (spnrRFGAIN) spnrRFGAIN->show();
4001 if (sldrRFGAIN) sldrRFGAIN->show();
4002
4003 btnIFsh->show();
4004 if (spnrIFSHIFT) spnrIFSHIFT->show();
4005 if (sldrIFSHIFT) sldrIFSHIFT->show();
4006
4007 btnNotch->show();
4008 if (spnrNOTCH) spnrNOTCH->show();
4009 if (sldrNOTCH) sldrNOTCH->show();
4010
4011 if (spnrMICGAIN) spnrMICGAIN->show();
4012 if (sldrMICGAIN) sldrMICGAIN->show();
4013
4014 if (spnrSQUELCH) spnrSQUELCH->show();
4015 if (sldrSQUELCH) sldrSQUELCH->show();
4016
4017 if (selrig->has_agc_control) {
4018 btnAGC->show();
4019 sldrRFGAIN->label("");
4020 sldrRFGAIN->redraw_label();
4021 } else {
4022 btnAGC->hide();
4023 sldrRFGAIN->label(_("RF"));
4024 sldrRFGAIN->redraw_label();
4025 }
4026
4027 btnNR->show();
4028 if (spnrNR) spnrNR->show();
4029 if (sldrNR) sldrNR->show();
4030
4031 if (xcvr_name == rig_TT550.name_) {
4032 tabs550->show();
4033 tabsGeneric->hide();
4034 } else {
4035 tabs550->hide();
4036 tabsGeneric->remove(genericAux);
4037 if (progStatus.aux_serial_port != "NONE" || selrig->has_data_port) {
4038 if (progStatus.aux_serial_port != "NONE") {
4039 btnAuxRTS->activate();
4040 btnAuxDTR->activate();
4041 } else {
4042 btnAuxRTS->deactivate();
4043 btnAuxDTR->deactivate();
4044 }
4045 if (selrig->has_data_port)
4046 btnDataPort->activate();
4047 else
4048 btnDataPort->deactivate();
4049 tabsGeneric->add(genericAux);
4050 }
4051 tabsGeneric->remove(genericRXB);
4052 if (selrig->has_rit || selrig->has_xit || selrig->has_bfo)
4053 tabsGeneric->add(genericRXB);
4054 tabsGeneric->show();
4055 }
4056
4057 if (progStatus.tooltips) {
4058 Fl_Tooltip::enable(1);
4059 if (mnuTooltips) mnuTooltips->set();
4060 } else {
4061 if (mnuTooltips) mnuTooltips->clear();
4062 Fl_Tooltip::enable(0);
4063 }
4064
4065 mainwindow->init_sizes();
4066 mainwindow->size_range(WIDE_MAINW, WIDE_MAINH, 0, WIDE_MAINH);
4067 mainwindow->redraw();
4068 }
4069
adjust_control_positions()4070 void adjust_control_positions()
4071 {
4072 switch (progStatus.UIsize) {
4073 case small_ui :
4074 adjust_small_ui();
4075 break;
4076 case wide_ui :
4077 if (xcvr_name == rig_XIG90.name_)
4078 adjust_xig_wide();
4079 else
4080 adjust_wide_ui();
4081 break;
4082 case touch_ui :
4083 default :
4084 adjust_touch_ui();
4085 break;
4086 }
4087 FreqDispA->set_hrd(progStatus.hrd_buttons);
4088 FreqDispB->set_hrd(progStatus.hrd_buttons);
4089 if (selrig->name_ == rig_FT891.name_) {
4090 // Default FT891 to only send slider updates to rig once slider
4091 // is released. This avoids a condition where once slider is
4092 // released, the slider value no longer tracks changes from
4093 // controls on the rig.
4094 progStatus.sliders_button = FL_WHEN_RELEASE;
4095 chk_sliders_button->value(false);
4096 }
4097 set_sliders_when();
4098 }
4099
initTabs()4100 void initTabs()
4101 {
4102 if (xcvr_name == rig_TT550.name_) {
4103 spnr_tt550_line_out->value(progStatus.tt550_line_out);
4104 cbo_tt550_agc_level->index(progStatus.tt550_agc_level);
4105 spnr_tt550_cw_wpm->value(progStatus.tt550_cw_wpm);
4106 spnr_tt550_cw_vol->value(progStatus.tt550_cw_vol);
4107 spnr_tt550_cw_spot->value(progStatus.tt550_cw_spot);
4108 spnr_tt550_cw_weight->value(progStatus.tt550_cw_weight);
4109 spnr_tt550_cw_qsk->value(progStatus.tt550_cw_qsk);
4110 btn_tt550_enable_keyer->value(progStatus.tt550_enable_keyer);
4111 btn_tt550_vox->value(progStatus.tt550_vox_onoff);
4112 spnr_tt550_vox_gain->value(progStatus.tt550_vox_gain);
4113 spnr_tt550_anti_vox->value(progStatus.tt550_vox_anti);
4114 spnr_tt550_vox_hang->value(progStatus.tt550_vox_hang);
4115 btn_tt550_CompON->value(progStatus.tt550_compON);
4116 spnr_tt550_compression->value(progStatus.tt550_compression);
4117 spnr_tt550_mon_vol->value(progStatus.tt550_mon_vol);
4118 btn_tt550_enable_xmtr->value(progStatus.tt550_enable_xmtr);
4119 btn_tt550_enable_tloop->value(progStatus.tt550_enable_tloop);
4120 btn_tt550_tuner_bypass->value(progStatus.tt550_tuner_bypass);
4121 btn_tt550_use_xmt_bw->value(progStatus.tt550_use_xmt_bw);
4122 sel_tt550_encoder_step->value(progStatus.tt550_encoder_step);
4123 spnr_tt550_encoder_sensitivity->value(progStatus.tt550_encoder_sensitivity);
4124 sel_tt550_F1_func->value(progStatus.tt550_F1_func);
4125 sel_tt550_F2_func->value(progStatus.tt550_F2_func);
4126 sel_tt550_F3_func->value(progStatus.tt550_F3_func);
4127 progStatus.use_rig_data = false;
4128 op_tt550_XmtBW->clear();
4129 for (int i = 0; TT550_xmt_widths[i] != NULL; i++) {
4130 op_tt550_XmtBW->add(TT550_xmt_widths[i]);
4131 }
4132 op_tt550_XmtBW->activate();
4133 op_tt550_XmtBW->index(progStatus.tt550_xmt_bw);
4134
4135 poll_smeter->activate(); poll_smeter->value(progStatus.poll_smeter);
4136 poll_pout->activate(); poll_pout->value(progStatus.poll_pout);
4137 poll_swr->activate(); poll_swr->value(progStatus.poll_swr);
4138 poll_alc->activate(); poll_alc->value(progStatus.poll_alc);
4139 poll_frequency->deactivate(); poll_frequency->value(0);
4140 poll_mode->deactivate(); poll_mode->value(0);
4141 poll_bandwidth->deactivate(); poll_bandwidth->value(0);
4142 poll_volume->deactivate(); poll_volume->value(0);
4143 poll_notch->deactivate(); poll_notch->value(0);
4144 poll_auto_notch->deactivate(); poll_auto_notch->value(0);
4145 poll_ifshift->deactivate(); poll_ifshift->value(0);
4146 poll_power_control->deactivate(); poll_power_control->value(0);
4147 poll_pre_att->deactivate(); poll_pre_att->value(0);
4148 poll_squelch->deactivate(); poll_squelch->value(0);
4149 poll_micgain->deactivate(); poll_micgain->value(0);
4150 poll_rfgain->deactivate(); poll_rfgain->value(0);
4151 poll_split->deactivate(); poll_split->value(0);
4152 poll_nr->deactivate(); poll_nr->value(0);
4153 poll_noise->deactivate(); poll_noise->value(0);
4154 poll_all->deactivate(); poll_all->value(0);
4155
4156 if (progStatus.tt550_at11_inline) {
4157 tt550_AT_inline->value(1);
4158 tt550_AT_inline->label("Inline");
4159 tt550_AT_inline->redraw_label();
4160 selrig->at11_autotune();
4161 } else {
4162 tt550_AT_inline->value(0);
4163 tt550_AT_inline->label("Bypassed");
4164 tt550_AT_inline->redraw_label();
4165 selrig->at11_bypass();
4166 }
4167 if (progStatus.tt550_at11_hiZ) {
4168 selrig->at11_hiZ();
4169 tt550_AT_Z->value(1);
4170 } else{
4171 selrig->at11_loZ();
4172 tt550_AT_Z->value(0);
4173 }
4174
4175 } else {
4176
4177 if (hidden_tabs) {
4178 hidden_tabs->add(tab_yaesu_bands);
4179 hidden_tabs->add(tab_ft991_bands);
4180 hidden_tabs->add(tab_FT8n_bands);
4181 hidden_tabs->add(tab_FT8n_CTCSS);
4182 hidden_tabs->add(tab_icom_bands);
4183 hidden_tabs->add(genericCW);
4184 hidden_tabs->add(genericQSK);
4185 hidden_tabs->add(genericVOX);
4186 hidden_tabs->add(genericSpeech);
4187 hidden_tabs->add(genericRx);
4188 hidden_tabs->add(genericMisc);
4189 hidden_tabs->add(genericUser_1);
4190 hidden_tabs->add(genericUser_2);
4191 hidden_tabs->add(genericUser_3);
4192 hidden_tabs->add(tab7610);
4193 } else {
4194 tabsGeneric->remove(tab_yaesu_bands);
4195 tabsGeneric->remove(tab_ft991_bands);
4196 tabsGeneric->remove(tab_FT8n_bands);
4197 tabsGeneric->remove(tab_FT8n_CTCSS);
4198 tabsGeneric->remove(tab_icom_bands);
4199 tabsGeneric->remove(genericCW);
4200 tabsGeneric->remove(genericQSK);
4201 tabsGeneric->remove(genericVOX);
4202 tabsGeneric->remove(genericSpeech);
4203 tabsGeneric->remove(genericRx);
4204 tabsGeneric->remove(genericMisc);
4205 tabsGeneric->remove(genericUser_1);
4206 tabsGeneric->remove(genericUser_2);
4207 tabsGeneric->remove(genericUser_3);
4208 tabsGeneric->remove(tab7610);
4209 }
4210
4211 if (selrig->has_band_selection) {
4212 if (selrig->ICOMrig || selrig->name_ == rig_XIG90.name_) {
4213 tabsGeneric->add(tab_icom_bands);
4214 tab_icom_bands->redraw();
4215 } else if (selrig->name_ == rig_FT857D.name_ || selrig->name_ == rig_FT897D.name_) {
4216 tabsGeneric->add(tab_FT8n_bands);
4217 tabsGeneric->add(tab_FT8n_CTCSS);
4218 tab_FT8n_bands->redraw();
4219 tab_FT8n_CTCSS->redraw();
4220 } else if (selrig->name_ == rig_FT991A.name_) {
4221 tabsGeneric->add(tab_ft991_bands);
4222 tab_ft991_bands->redraw();
4223 } else {
4224 tabsGeneric->add(tab_yaesu_bands);
4225 tab_yaesu_bands->redraw();
4226 }
4227 }
4228
4229 if (selrig->has_cw_wpm ||
4230 selrig->has_cw_weight ||
4231 selrig->has_cw_keyer ||
4232 selrig->has_cw_spot ||
4233 selrig->has_cw_spot_tone ) {
4234
4235 if (selrig->has_cw_wpm) {
4236 int min, max;
4237 selrig->get_cw_wpm_min_max(min, max);
4238 spnr_cw_wpm->minimum(min);
4239 spnr_cw_wpm->maximum(max);
4240 spnr_cw_wpm->value(progStatus.cw_wpm);
4241 spnr_cw_wpm->show();
4242 } else
4243 spnr_cw_wpm->hide();
4244
4245 if (selrig->has_cw_weight) {
4246 double min, max, step;
4247 selrig->get_cw_weight_min_max_step( min, max, step );
4248 spnr_cw_weight->minimum(min);
4249 spnr_cw_weight->maximum(max);
4250 spnr_cw_weight->step(step);
4251 spnr_cw_weight->value(progStatus.cw_weight);
4252 spnr_cw_weight->show();
4253 } else
4254 spnr_cw_weight->hide();
4255
4256 if (selrig->has_cw_keyer) {
4257 btn_enable_keyer->show();
4258 btn_enable_keyer->value(progStatus.enable_keyer);
4259 selrig->enable_keyer();
4260 }
4261 else
4262 btn_enable_keyer->hide();
4263
4264 if (selrig->has_cw_spot) {
4265 btnSpot->value(progStatus.cw_spot);
4266 selrig->set_cw_spot();
4267 btnSpot->show();
4268 } else
4269 btnSpot->hide();
4270
4271 if (selrig->has_cw_spot_tone) {
4272 spnr_cw_spot_tone->show();
4273 int min, max, step;
4274 selrig->get_cw_spot_tone_min_max_step(min, max, step);
4275 spnr_cw_spot_tone->minimum(min);
4276 spnr_cw_spot_tone->maximum(max);
4277 spnr_cw_spot_tone->step(step);
4278 spnr_cw_spot_tone->value(progStatus.cw_spot_tone);
4279 selrig->set_cw_spot_tone();
4280 } else
4281 spnr_cw_spot_tone->hide();
4282
4283 tabsGeneric->add(genericCW);
4284 genericCW->redraw();
4285 }
4286
4287 if (selrig->has_cw_qsk) {
4288
4289 tabsGeneric->add(genericQSK);
4290
4291 btnBreakIn->show();
4292 spnr_cw_delay->show();
4293
4294 if (selrig->has_cw_qsk) {
4295 double min, max, step;
4296 selrig->get_cw_qsk_min_max_step(min, max, step);
4297 spnr_cw_qsk->minimum(min);
4298 spnr_cw_qsk->maximum(max);
4299 spnr_cw_qsk->step(step);
4300 spnr_cw_qsk->value(progStatus.cw_qsk);
4301 spnr_cw_qsk->show();
4302 } else
4303 spnr_cw_qsk->hide();
4304 }
4305
4306 if (selrig->has_vox_onoff ||
4307 selrig->has_vox_gain ||
4308 selrig->has_vox_hang ||
4309 selrig->has_vox_on_dataport) {
4310
4311 if (selrig->has_vox_onoff) {
4312 btn_vox->value(progStatus.vox_onoff);
4313 btn_vox->show();
4314 selrig->set_vox_onoff();
4315 } else btn_vox->hide();
4316
4317 if (selrig->has_vox_gain) {
4318 int min, max, step;
4319 selrig->get_vox_gain_min_max_step(min, max, step);
4320 spnr_vox_gain->minimum(min);
4321 spnr_vox_gain->maximum(max);
4322 spnr_vox_gain->step(step);
4323 spnr_vox_gain->value(progStatus.vox_gain);
4324 spnr_vox_gain->show();
4325 selrig->set_vox_gain();
4326 } else spnr_vox_gain->hide();
4327
4328 if (selrig->has_vox_anti) {
4329 int min, max, step;
4330 selrig->get_vox_anti_min_max_step(min, max, step);
4331 spnr_anti_vox->minimum(min);
4332 spnr_anti_vox->maximum(max);
4333 spnr_anti_vox->step(step);
4334 spnr_anti_vox->value(progStatus.vox_anti);
4335 spnr_anti_vox->show();
4336 selrig->set_vox_anti();
4337 } else spnr_anti_vox->hide();
4338
4339 if (selrig->has_vox_hang) {
4340 int min, max, step;
4341 selrig->get_vox_hang_min_max_step(min, max, step);
4342 spnr_vox_hang->minimum(min);
4343 spnr_vox_hang->maximum(max);
4344 spnr_vox_hang->step(step);
4345 spnr_vox_hang->value(progStatus.vox_hang);
4346 spnr_vox_hang->show();
4347 selrig->set_vox_hang();
4348 } else spnr_vox_hang->hide();
4349
4350 if (selrig->has_vox_on_dataport) {
4351 btn_vox_on_dataport->value(progStatus.vox_on_dataport);
4352 btn_vox_on_dataport->show();
4353 selrig->set_vox_on_dataport();
4354 } else btn_vox_on_dataport->hide();
4355
4356 tabsGeneric->add(genericVOX);
4357 genericVOX->redraw();
4358 }
4359
4360 if (selrig->has_compON ||
4361 selrig->has_compression ) {
4362
4363 if (selrig->has_compON) {
4364 btnCompON->show();
4365 btnCompON->value(progStatus.compON);
4366 } else
4367 btnCompON->hide();
4368
4369 if (selrig->has_compression) {
4370 int min, max, step;
4371 selrig->get_comp_min_max_step(min, max, step);
4372 spnr_compression->minimum(min);
4373 spnr_compression->maximum(max);
4374 spnr_compression->step(step);
4375 spnr_compression->show();
4376 spnr_compression->value(progStatus.compression);
4377 selrig->set_compression(progStatus.compON, progStatus.compression);
4378 } else
4379 spnr_compression->hide();
4380
4381 tabsGeneric->add(genericSpeech);
4382 genericSpeech->redraw();
4383 }
4384
4385 if (selrig->has_nb_level ||
4386 selrig->has_bpf_center ) {
4387
4388 if (selrig->has_nb_level)
4389 sldr_nb_level->show();
4390 else
4391 sldr_nb_level->hide();
4392
4393 if (selrig->has_bpf_center) {
4394 spnr_bpf_center->value(progStatus.bpf_center);
4395 spnr_bpf_center->show();
4396 btn_use_bpf_center->show();
4397 } else {
4398 spnr_bpf_center->hide();
4399 btn_use_bpf_center->hide();
4400 }
4401 tabsGeneric->add(genericRx);
4402 genericRx->redraw();
4403 }
4404
4405 if (selrig->has_vfo_adj ||
4406 selrig->has_line_out ||
4407 selrig->has_xcvr_auto_on_off ) {
4408
4409 if (selrig->has_vfo_adj) {
4410 int min, max, step;
4411 selrig->get_vfoadj_min_max_step(min, max, step);
4412 spnr_vfo_adj->minimum(min);
4413 spnr_vfo_adj->maximum(max);
4414 spnr_vfo_adj->step(step);
4415 progStatus.vfo_adj = selrig->getVfoAdj();
4416 spnr_vfo_adj->value(progStatus.vfo_adj);
4417 spnr_vfo_adj->show();
4418 } else
4419 spnr_vfo_adj->hide();
4420
4421 if (selrig->has_line_out)
4422 spnr_line_out->show();
4423 else
4424 spnr_line_out->hide();
4425
4426 if (selrig->has_xcvr_auto_on_off) {
4427 btn_xcvr_auto_on->value(progStatus.xcvr_auto_on);
4428 btn_xcvr_auto_off->value(progStatus.xcvr_auto_off);
4429 btn_xcvr_auto_on->show();
4430 btn_xcvr_auto_off->show();
4431 } else {
4432 btn_xcvr_auto_on->hide();
4433 btn_xcvr_auto_off->hide();
4434 }
4435 tabsGeneric->add(genericMisc);
4436 genericMisc->redraw();
4437 }
4438
4439 tabsGeneric->add(genericUser_1);
4440 tabsGeneric->add(genericUser_2);
4441 tabsGeneric->add(genericUser_3);
4442 genericUser_1->redraw();
4443 genericUser_2->redraw();
4444 genericUser_3->redraw();
4445
4446 if (selrig->name_ == rig_IC7610.name_) {
4447 tabsGeneric->add(tab7610);
4448 tab7610->redraw();
4449 btnAttenuator->hide();
4450 }
4451
4452 tabsGeneric->redraw();
4453
4454 poll_frequency->activate(); poll_frequency->value(progStatus.poll_frequency);
4455 poll_mode->activate(); poll_mode->value(progStatus.poll_mode);
4456 poll_bandwidth->activate(); poll_bandwidth->value(progStatus.poll_bandwidth);
4457
4458 poll_smeter->activate(); poll_smeter->value(progStatus.poll_smeter);
4459 poll_pout->activate(); poll_pout->value(progStatus.poll_pout);
4460 poll_swr->activate(); poll_swr->value(progStatus.poll_swr);
4461 poll_alc->activate(); poll_alc->value(progStatus.poll_alc);
4462 poll_volume->activate(); poll_volume->value(progStatus.poll_volume);
4463 poll_notch->activate(); poll_notch->value(progStatus.poll_notch);
4464 poll_auto_notch->activate(); poll_auto_notch->value(progStatus.poll_auto_notch);
4465 poll_ifshift->activate(); poll_ifshift->value(progStatus.poll_ifshift);
4466 poll_power_control->activate(); poll_power_control->value(progStatus.poll_power_control);
4467 poll_pre_att->activate(); poll_pre_att->value(progStatus.poll_pre_att);
4468 poll_squelch->activate(); poll_squelch->value(progStatus.poll_squelch);
4469 poll_micgain->activate(); poll_micgain->value(progStatus.poll_micgain);
4470 poll_rfgain->activate(); poll_rfgain->value(progStatus.poll_rfgain);
4471 poll_split->activate(); poll_split->value(progStatus.poll_split);
4472 poll_noise->activate(); poll_noise->value(progStatus.poll_noise);
4473 poll_nr->activate(); poll_nr->value(progStatus.poll_nr);
4474 poll_compression->activate(); poll_compression->value(progStatus.poll_compression);
4475
4476 if (!selrig->has_bandwidth_control) { poll_bandwidth->deactivate(); poll_bandwidth->value(0); }
4477 if (!selrig->has_smeter) { poll_smeter->deactivate(); poll_smeter->value(0); }
4478 if (!selrig->has_power_out) { poll_pout->deactivate(); poll_pout->value(0); }
4479 if (!selrig->has_swr_control) { poll_swr->deactivate(); poll_swr->value(0); }
4480 if (!selrig->has_alc_control) { poll_alc->deactivate(); poll_alc->value(0); }
4481 if (!selrig->has_volume_control) { poll_volume->deactivate(); poll_volume->value(0); }
4482 if (!selrig->has_notch_control) { poll_notch->deactivate(); poll_notch->value(0); }
4483 if (!selrig->has_auto_notch ||
4484 xcvr_name == rig_FT1000MP.name_ )
4485 { poll_auto_notch->deactivate(); poll_auto_notch->value(0); }
4486 if (!selrig->has_ifshift_control &&
4487 !selrig->has_pbt_controls) { poll_ifshift->deactivate(); poll_ifshift->value(0); }
4488 if (selrig->has_pbt_controls) {
4489 poll_ifshift->label("pbt");
4490 poll_ifshift->redraw_label();
4491 }
4492 if (!selrig->has_power_control) { poll_power_control->deactivate(); poll_power_control->value(0); }
4493 if (!selrig->has_preamp_control && !selrig->has_attenuator_control)
4494 { poll_pre_att->deactivate(); poll_pre_att->value(0); }
4495 if (!selrig->has_sql_control) { poll_squelch->deactivate(); poll_squelch->value(0); }
4496 if (!selrig->has_micgain_control) { poll_micgain->deactivate(); poll_micgain->value(0); }
4497 if (!selrig->has_rf_control) { poll_rfgain->deactivate(); poll_rfgain->value(0); }
4498 if (!selrig->has_split) { poll_split->deactivate(); poll_split->value(0); }
4499 if (!selrig->has_noise_control) {poll_noise->deactivate(); poll_noise->value(0);}
4500 if (!selrig->has_noise_reduction) {poll_nr->deactivate(); poll_nr->value(0);}
4501 if (!selrig->has_compression) { poll_compression->deactivate(); poll_compression->value(0); }
4502
4503 }
4504
4505 }
4506
init_TT550()4507 void init_TT550()
4508 {
4509 useB = false;
4510 selrig->selectA();
4511
4512 vfoB.freq = progStatus.freq_B;
4513 vfoB.imode = progStatus.imode_B;
4514 vfoB.iBW = progStatus.iBW_B;
4515 FreqDispB->value(vfoB.freq);
4516 selrig->set_vfoB(vfoB.freq);
4517 selrig->set_modeB(vfoB.imode);
4518 selrig->set_bwB(vfoB.iBW);
4519
4520 vfoA.freq = progStatus.freq_A;
4521 vfoA.imode = progStatus.imode_A;
4522 vfoA.iBW = progStatus.iBW_A;
4523 FreqDispA->value( vfoA.freq );
4524 selrig->set_vfoA(vfoA.freq);
4525 selrig->set_modeA(vfoA.imode);
4526
4527 vfo = &vfoA;
4528
4529 if (vfoA.iBW == -1) vfoA.iBW = selrig->def_bandwidth(vfoA.imode);
4530 selrig->set_bwA(vfoA.iBW);
4531
4532 rigmodes_.clear();
4533 opMODE->clear();
4534 for (int i = 0; selrig->modes_[i] != NULL; i++) {
4535 rigmodes_.push_back(selrig->modes_[i]);
4536 opMODE->add(selrig->modes_[i]);
4537 }
4538 opMODE->activate();
4539 opMODE->index(vfoA.imode);
4540
4541 rigbws_.clear();
4542 opBW->show();
4543 opBW->clear();
4544 old_bws = selrig->bandwidths_;
4545 for (int i = 0; selrig->bandwidths_[i] != NULL; i++) {
4546 rigbws_.push_back(selrig->bandwidths_[i]);
4547 opBW->add(selrig->bandwidths_[i]);
4548 }
4549 opBW->activate();
4550 opBW->index(vfoA.iBW);
4551
4552 spnr_tt550_vfo_adj->value(progStatus.vfo_adj);
4553
4554 btnPreamp->label("Spot");
4555 btnPreamp->value(progStatus.tt550_spot_onoff);
4556 switch (progStatus.UIsize) {
4557 case small_ui :
4558 btnPreamp->show();
4559 break;
4560 case wide_ui : case touch_ui : default :
4561 btnPreamp->activate();
4562 }
4563 }
4564
init_generic_rig()4565 void init_generic_rig()
4566 {
4567 if (progStatus.CIV > 0)
4568 selrig->adjustCIV(progStatus.CIV);
4569
4570 if (selrig->has_getvfoAorB) {
4571
4572 int ret = selrig->get_vfoAorB();
4573 int retry = 10;
4574 while (ret == -1 && retry--) {
4575 MilliSleep(50);
4576 ret = selrig->get_vfoAorB();
4577 }
4578 if (ret == -1) ret = 0;
4579
4580 useB = ret;
4581
4582 read_rig_vals();
4583 if (progStatus.use_rig_data) {
4584 vfoA = xcvr_vfoA;
4585 vfoB = xcvr_vfoB;
4586 }
4587
4588 if (useB) {
4589 selrig->selectB();
4590 vfo = &vfoB;
4591 } else {
4592 vfo = &vfoA;
4593 }
4594 }
4595 else {
4596 read_rig_vals();
4597 if (progStatus.use_rig_data) {
4598 vfoA = xcvr_vfoA;
4599 vfoB = xcvr_vfoB;
4600 }
4601 }
4602 progStatus.compON = xcvr_vfoA.compON;
4603 progStatus.compression = xcvr_vfoA.compression;
4604
4605 vfo = &vfoA;
4606
4607 rigmodes_.clear();
4608 opMODE->clear();
4609 if (selrig->has_mode_control) {
4610 for (int i = 0; selrig->modes_[i] != NULL; i++) {
4611 rigmodes_.push_back(selrig->modes_[i]);
4612 opMODE->add(selrig->modes_[i]);
4613 }
4614 opMODE->activate();
4615 opMODE->index(progStatus.imode_A);
4616 } else {
4617 opMODE->add(" ");
4618 opMODE->index(0);
4619 opMODE->deactivate();
4620 }
4621
4622 rigbws_.clear();
4623 opBW->show();
4624 opBW->clear();
4625 if (selrig->has_bandwidth_control) {
4626 old_bws = selrig->bandwidths_;
4627 for (int i = 0; selrig->bandwidths_[i] != NULL; i++) {
4628 rigbws_.push_back(selrig->bandwidths_[i]);
4629 opBW->add(selrig->bandwidths_[i]);
4630 }
4631 opBW->activate();
4632 if (progStatus.iBW_A == -1) progStatus.iBW_A = selrig->def_bandwidth(vfoA.imode);
4633 if (progStatus.iBW_B == -1) progStatus.iBW_B = selrig->def_bandwidth(vfoB.imode);
4634 opBW->index(progStatus.iBW_A);
4635 } else {
4636 opBW->add(" ");
4637 opBW->index(0);
4638 opBW->deactivate();
4639 }
4640 }
4641
init_rit()4642 void init_rit()
4643 {
4644 if (!cntRIT) return;
4645 if (selrig->has_rit) {
4646 int min, max, step;
4647 selrig->get_RIT_min_max_step(min, max, step);
4648 cntRIT->minimum(min);
4649 cntRIT->maximum(max);
4650 cntRIT->step(step);
4651 switch (progStatus.UIsize) {
4652 case touch_ui :
4653 cntRIT->activate();
4654 break;
4655 case small_ui :
4656 case wide_ui :
4657 default :
4658 cntRIT->show();
4659 }
4660 cntRIT->value(progStatus.rit_freq);
4661 } else {
4662 switch (progStatus.UIsize) {
4663 case touch_ui :
4664 cntRIT->deactivate();
4665 break;
4666 case small_ui :
4667 case wide_ui :
4668 default :
4669 cntRIT->hide();
4670 }
4671 }
4672 }
4673
init_xit()4674 void init_xit()
4675 {
4676 if (!cntXIT) return;
4677 if (selrig->has_xit) {
4678 int min, max, step;
4679 selrig->get_XIT_min_max_step(min, max, step);
4680 cntXIT->minimum(min);
4681 cntXIT->maximum(max);
4682 cntXIT->step(step);
4683 cntXIT->value(progStatus.xit_freq);
4684 switch (progStatus.UIsize) {
4685 case small_ui :
4686 cntXIT->show();
4687 break;
4688 case wide_ui : case touch_ui : default :
4689 cntXIT->activate();
4690 }
4691 } else {
4692 switch (progStatus.UIsize) {
4693 case small_ui :
4694 cntXIT->hide();
4695 case wide_ui : case touch_ui : default :
4696 cntXIT->deactivate();
4697 }
4698 }
4699 }
4700
init_bfo()4701 void init_bfo()
4702 {
4703 if (!cntBFO) return;
4704 if (selrig->has_bfo) {
4705 int min, max, step;
4706 selrig->get_BFO_min_max_step(min, max, step);
4707 cntBFO->minimum(min);
4708 cntBFO->maximum(max);
4709 cntBFO->step(step);
4710 cntBFO->value(progStatus.bfo_freq);
4711 switch (progStatus.UIsize) {
4712 case small_ui :
4713 cntBFO->show();
4714 break;
4715 case wide_ui : case touch_ui : default :
4716 cntBFO->activate();
4717 }
4718 } else {
4719 switch (progStatus.UIsize) {
4720 case small_ui :
4721 cntBFO->hide();
4722 break;
4723 case wide_ui : case touch_ui : default :
4724 cntBFO->deactivate();
4725 }
4726 }
4727 }
4728
init_dsp_controls()4729 void init_dsp_controls()
4730 {
4731 if (selrig->has_dsp_controls) {
4732 opDSP_lo->clear();
4733 opDSP_hi->clear();
4734 btnDSP->label(selrig->SL_label);
4735 btnDSP->redraw_label();
4736 for (int i = 0; selrig->dsp_SL[i] != NULL; i++)
4737 opDSP_lo->add(selrig->dsp_SL[i]);
4738 opDSP_lo->tooltip(selrig->SL_tooltip);
4739 for (int i = 0; selrig->dsp_SH[i] != NULL; i++)
4740 opDSP_hi->add(selrig->dsp_SH[i]);
4741 opDSP_hi->tooltip(selrig->SH_tooltip);
4742 if (vfo->iBW > 256) {
4743 opDSP_lo->index(vfo->iBW & 0xFF);
4744 opDSP_hi->index((vfo->iBW >> 8) & 0x7F);
4745 btnDSP->show();
4746 opDSP_hi->show();
4747 opDSP_lo->hide();
4748 opBW->hide();
4749 opBW->index(0);
4750 btnFILT->hide();
4751 } else {
4752 opDSP_lo->index(0);
4753 opDSP_hi->index(0);
4754 btnDSP->hide();
4755 opDSP_lo->hide();
4756 opDSP_hi->hide();
4757 btnFILT->hide();
4758 opBW->show();
4759 }
4760 } else if (selrig->has_FILTER) {
4761 btnDSP->hide();
4762 opDSP_lo->hide();
4763 opDSP_hi->hide();
4764 btnFILT->show();
4765 opBW->resize(opDSP_lo->x(), opDSP_lo->y(), opDSP_lo->w(), opDSP_lo->h());
4766 opBW->redraw();
4767 opBW->show();
4768 } else {
4769 btnDSP->hide();
4770 opDSP_lo->hide();
4771 opDSP_hi->hide();
4772 btnFILT->hide();
4773 opBW->show();
4774 }
4775 }
4776
init_volume_control()4777 void init_volume_control()
4778 {
4779 if (selrig->has_volume_control) {
4780 int min, max, step;
4781 selrig->get_vol_min_max_step(min, max, step);
4782 if (spnrVOLUME) {
4783 spnrVOLUME->minimum(min);
4784 spnrVOLUME->maximum(max);
4785 spnrVOLUME->step(step);
4786 spnrVOLUME->redraw();
4787 spnrVOLUME->activate();
4788 }
4789 if (sldrVOLUME) {
4790 sldrVOLUME->minimum(min);
4791 sldrVOLUME->maximum(max);
4792 sldrVOLUME->step(step);
4793 sldrVOLUME->redraw();
4794 sldrVOLUME->activate();
4795 }
4796 switch (progStatus.UIsize) {
4797 case small_ui :
4798 btnVol->show();
4799 if (sldrVOLUME) sldrVOLUME->show();
4800 if (spnrVOLUME) spnrVOLUME->show();
4801 break;
4802 case wide_ui : case touch_ui : default :
4803 btnVol->activate();
4804 if (sldrVOLUME) sldrVOLUME->activate();
4805 if (spnrVOLUME) spnrVOLUME->activate();
4806 }
4807 } else {
4808 switch (progStatus.UIsize) {
4809 case small_ui :
4810 btnVol->hide();
4811 if (sldrVOLUME) sldrVOLUME->hide();
4812 if (spnrVOLUME) spnrVOLUME->hide();
4813 break;
4814 case wide_ui : case touch_ui : default :
4815 btnVol->deactivate();
4816 if (sldrVOLUME) sldrVOLUME->deactivate();
4817 if (spnrVOLUME) spnrVOLUME->deactivate();
4818 }
4819 }
4820 }
4821
set_init_volume_control()4822 void set_init_volume_control()
4823 {
4824 if (!selrig->has_volume_control)
4825 return;
4826
4827 if (progStatus.use_rig_data) {
4828 progStatus.volume = selrig->get_volume_control();
4829 if (sldrVOLUME) sldrVOLUME->value(progStatus.volume);
4830 if (sldrVOLUME) sldrVOLUME->activate();
4831 btnVol->value(1);
4832 if (spnrVOLUME) spnrVOLUME->value(progStatus.volume);
4833 if (spnrVOLUME) spnrVOLUME->activate();
4834 sldrVOLUME->activate();
4835 } else {
4836 if (sldrVOLUME) sldrVOLUME->value(progStatus.volume);
4837 if (spnrVOLUME) spnrVOLUME->value(progStatus.volume);
4838 if (progStatus.spkr_on == 0) {
4839 btnVol->value(0);
4840 if (sldrVOLUME) sldrVOLUME->deactivate();
4841 if (spnrVOLUME) spnrVOLUME->deactivate();
4842 selrig->set_volume_control(0);
4843 } else {
4844 btnVol->value(1);
4845 if (sldrVOLUME) sldrVOLUME->activate();
4846 if (spnrVOLUME) spnrVOLUME->activate();
4847 selrig->set_volume_control(progStatus.volume);
4848 }
4849 }
4850 }
4851
init_rf_control()4852 void init_rf_control()
4853 {
4854 if (selrig->has_rf_control) {
4855 int min, max, step;
4856 selrig->get_rf_min_max_step(min, max, step);
4857 if (sldrRFGAIN) sldrRFGAIN->minimum(min);
4858 if (sldrRFGAIN) sldrRFGAIN->maximum(max);
4859 if (sldrRFGAIN) sldrRFGAIN->step(step);
4860 if (sldrRFGAIN) sldrRFGAIN->redraw();
4861 if (spnrRFGAIN) spnrRFGAIN->minimum(min);
4862 if (spnrRFGAIN) spnrRFGAIN->maximum(max);
4863 if (spnrRFGAIN) spnrRFGAIN->step(step);
4864 if (spnrRFGAIN) spnrRFGAIN->redraw();
4865
4866 switch (progStatus.UIsize) {
4867 case small_ui :
4868 if (sldrRFGAIN) sldrRFGAIN->show();
4869 if (spnrRFGAIN) spnrRFGAIN->show();
4870 break;
4871 case wide_ui : case touch_ui : default :
4872 if (sldrRFGAIN) sldrRFGAIN->activate();
4873 if (spnrRFGAIN) spnrRFGAIN->activate();
4874 }
4875 } else {
4876 switch (progStatus.UIsize) {
4877 case small_ui :
4878 if (sldrRFGAIN) sldrRFGAIN->hide();
4879 if (spnrRFGAIN) spnrRFGAIN->hide();
4880 break;
4881 case wide_ui : case touch_ui : default :
4882 if (sldrRFGAIN) sldrRFGAIN->deactivate();
4883 if (spnrRFGAIN) spnrRFGAIN->deactivate();
4884 }
4885 }
4886 if (selrig->name_ == rig_ICF8101.name_) {
4887 if (sldrRFGAIN) sldrRFGAIN->deactivate();
4888 if (spnrRFGAIN) spnrRFGAIN->deactivate();
4889 }
4890 }
4891
set_init_rf_gain()4892 void set_init_rf_gain()
4893 {
4894 if (!selrig->has_rf_control)
4895 return;
4896
4897 if (progStatus.use_rig_data) {
4898 progStatus.rfgain = selrig->get_rf_gain();
4899 if (sldrRFGAIN) sldrRFGAIN->value(progStatus.rfgain);
4900 if (spnrRFGAIN) spnrRFGAIN->value(progStatus.rfgain);
4901 } else {
4902 if (sldrRFGAIN) sldrRFGAIN->value(progStatus.rfgain);
4903 if (spnrRFGAIN) spnrRFGAIN->value(progStatus.rfgain);
4904 selrig->set_rf_gain(progStatus.rfgain);
4905 }
4906 }
4907
init_sql_control()4908 void init_sql_control()
4909 {
4910 if (selrig->has_sql_control) {
4911 int min, max, step;
4912 selrig->get_squelch_min_max_step(min, max, step);
4913 if (sldrSQUELCH) sldrSQUELCH->minimum(min);
4914 if (sldrSQUELCH) sldrSQUELCH->maximum(max);
4915 if (sldrSQUELCH) sldrSQUELCH->step(step);
4916 if (sldrSQUELCH) sldrSQUELCH->redraw();
4917 if (spnrSQUELCH) spnrSQUELCH->minimum(min);
4918 if (spnrSQUELCH) spnrSQUELCH->maximum(max);
4919 if (spnrSQUELCH) spnrSQUELCH->step(step);
4920 if (spnrSQUELCH) spnrSQUELCH->redraw();
4921 switch (progStatus.UIsize) {
4922 case small_ui :
4923 if (sldrSQUELCH) sldrSQUELCH->show();
4924 if (spnrSQUELCH) spnrSQUELCH->show();
4925 break;
4926 case wide_ui : case touch_ui : default:
4927 if (sldrSQUELCH) sldrSQUELCH->activate();
4928 if (spnrSQUELCH) spnrSQUELCH->activate();
4929 }
4930
4931 } else {
4932 switch (progStatus.UIsize) {
4933 case small_ui :
4934 if (sldrSQUELCH) sldrSQUELCH->hide();
4935 if (spnrSQUELCH) spnrSQUELCH->hide();
4936 break;
4937 case wide_ui : case touch_ui : default :
4938 if (sldrSQUELCH) sldrSQUELCH->deactivate();
4939 if (spnrSQUELCH) spnrSQUELCH->deactivate();
4940 }
4941 }
4942 }
4943
set_init_sql_control()4944 void set_init_sql_control()
4945 {
4946 if (!selrig->has_sql_control)
4947 return;
4948
4949 if (progStatus.use_rig_data) {
4950 progStatus.squelch = selrig->get_squelch();
4951 if (sldrSQUELCH) sldrSQUELCH->value(progStatus.squelch);
4952 if (spnrSQUELCH) spnrSQUELCH->value(progStatus.squelch);
4953 } else {
4954 if (sldrSQUELCH) sldrSQUELCH->value(progStatus.squelch);
4955 if (spnrSQUELCH) spnrSQUELCH->value(progStatus.squelch);
4956 selrig->set_squelch(progStatus.squelch);
4957 }
4958 }
4959
set_init_noise_reduction_control()4960 void set_init_noise_reduction_control()
4961 {
4962 if (!selrig->has_noise_reduction_control)
4963 return;
4964
4965 if (progStatus.use_rig_data) {
4966 progStatus.noise_reduction = selrig->get_noise_reduction();
4967 progStatus.noise_reduction_val = selrig->get_noise_reduction_val();
4968 btnNR->value(progStatus.noise_reduction);
4969 if (sldrNR) sldrNR->value(progStatus.noise_reduction_val);
4970 if (spnrNR) spnrNR->value(progStatus.noise_reduction_val);
4971
4972 if (selrig->name_ == rig_FT891.name_) {
4973 // On the FT-891, the usual definitions of NB and NR buttons
4974 // as defined in FLRIG are reversed. Relabel them to match
4975 // what the user sees in the radio screens, and handle the
4976 // mapping to appropriate cat controls in the FT891.xx class.
4977 btnNR->label("NB");
4978 btnNR->tooltip(_("Noise Blanker On/Off"));
4979 }
4980
4981 } else {
4982 btnNR->value(progStatus.noise_reduction);
4983 if (sldrNR) sldrNR->value(progStatus.noise_reduction_val);
4984 if (spnrNR) spnrNR->value(progStatus.noise_reduction_val);
4985 selrig->set_noise_reduction(progStatus.noise_reduction);
4986 selrig->set_noise_reduction_val(progStatus.noise_reduction_val);
4987 }
4988 }
4989
init_noise_reduction_control()4990 void init_noise_reduction_control()
4991 {
4992 if (selrig->has_noise_reduction_control) {
4993 int min, max, step;
4994 selrig->get_nr_min_max_step(min, max, step);
4995
4996 if (sldrNR) sldrNR->minimum(min);
4997 if (sldrNR) sldrNR->maximum(max);
4998 if (sldrNR) sldrNR->step(step);
4999 if (sldrNR) sldrNR->redraw();
5000
5001 if (spnrNR) spnrNR->minimum(min);
5002 if (spnrNR) spnrNR->maximum(max);
5003 if (spnrNR) spnrNR->step(step);
5004 if (spnrNR) spnrNR->redraw();
5005
5006 if (selrig->name_ == rig_FT891.name_) {
5007 // On the FT-891, the usual definitions of NB and NR buttons
5008 // as defined in FLRIG are reversed. Relabel them to match
5009 // what the user sees in the radio screens, and handle the
5010 // mapping to appropriate cat controls in the FT891.xx class.
5011 sldrNR->tooltip(_("Adjust noise blanker"));
5012 }
5013
5014 switch (progStatus.UIsize) {
5015 case small_ui :
5016 btnNR->show();
5017 if (sldrNR) sldrNR->show();
5018 if (spnrNR) spnrNR->show();
5019 break;
5020 case wide_ui : case touch_ui : default:
5021 btnNR->show();
5022 if (sldrNR) sldrNR->show();//activate();
5023 if (spnrNR) spnrNR->show();//activate();
5024 break;
5025 }
5026 } else {
5027 switch (progStatus.UIsize) {
5028 case small_ui :
5029 btnNR->hide();
5030 if (sldrNR) sldrNR->hide();
5031 if (spnrNR) sldrNR->hide();
5032 break;
5033 case wide_ui : case touch_ui : default :
5034 btnNR->hide();//deactivate();
5035 if (sldrNR) sldrNR->hide();//deactivate();
5036 if (spnrNR) spnrNR->hide();//deactivate();
5037 break;
5038 }
5039 }
5040 }
5041
set_init_if_shift_control()5042 void set_init_if_shift_control()
5043 {
5044 if (!selrig->has_ifshift_control)
5045 return;
5046 if (progStatus.use_rig_data) {
5047 progStatus.shift = selrig->get_if_shift(progStatus.shift_val);
5048 btnIFsh->value(progStatus.shift);
5049 if (sldrIFSHIFT) sldrIFSHIFT->value(progStatus.shift_val);
5050 if (spnrIFSHIFT) spnrIFSHIFT->value(progStatus.shift_val);
5051 } else {
5052 if (progStatus.shift) {
5053 btnIFsh->value(1);
5054 if (sldrIFSHIFT) sldrIFSHIFT->value(progStatus.shift_val);
5055 if (spnrIFSHIFT) spnrIFSHIFT->value(progStatus.shift_val);
5056 selrig->set_if_shift(progStatus.shift_val);
5057 } else {
5058 btnIFsh->value(0);
5059 if (sldrIFSHIFT) sldrIFSHIFT->value(selrig->if_shift_mid);
5060 if (spnrIFSHIFT) spnrIFSHIFT->value(selrig->if_shift_mid);
5061 selrig->set_if_shift(selrig->if_shift_mid);
5062 }
5063 }
5064 }
5065
init_if_shift_control()5066 void init_if_shift_control()
5067 {
5068 if (btnLOCK) btnLOCK->hide();
5069 if (btnCLRPBT) btnCLRPBT->hide();
5070 if (sldrINNER) sldrINNER->hide();
5071 if (sldrOUTER) sldrOUTER->hide();
5072 if (btnIFsh) btnIFsh->hide();
5073 if (sldrIFSHIFT) sldrIFSHIFT->hide();
5074 if (spnrIFSHIFT) spnrIFSHIFT->hide();
5075
5076 if (selrig->has_ifshift_control) {
5077 btnIFsh->show();
5078 sldrIFSHIFT->show();
5079 if (spnrIFSHIFT) spnrIFSHIFT->show();
5080 int min, max, step;
5081 selrig->get_if_min_max_step(min, max, step);
5082 if (sldrIFSHIFT) sldrIFSHIFT->minimum(min);
5083 if (sldrIFSHIFT) sldrIFSHIFT->maximum(max);
5084 if (sldrIFSHIFT) sldrIFSHIFT->step(step);
5085 if (sldrIFSHIFT) sldrIFSHIFT->redraw();
5086 if (spnrIFSHIFT) spnrIFSHIFT->minimum(min);
5087 if (spnrIFSHIFT) spnrIFSHIFT->maximum(max);
5088 if (spnrIFSHIFT) spnrIFSHIFT->step(step);
5089 if (spnrIFSHIFT) spnrIFSHIFT->redraw();
5090 switch (progStatus.UIsize) {
5091 case small_ui :
5092 btnIFsh->show();
5093 if (sldrIFSHIFT) sldrIFSHIFT->show();
5094 if (spnrIFSHIFT) spnrIFSHIFT->show();
5095 break;
5096 case wide_ui : case touch_ui : default :
5097 btnIFsh->activate();
5098 if (sldrIFSHIFT) sldrIFSHIFT->activate();
5099 if (spnrIFSHIFT) spnrIFSHIFT->activate();
5100 break;
5101 }
5102 } else {
5103 switch (progStatus.UIsize) {
5104 case small_ui :
5105 btnIFsh->hide();
5106 if (sldrIFSHIFT) sldrIFSHIFT->hide();
5107 if (spnrIFSHIFT) spnrIFSHIFT->hide();
5108 break;
5109 case wide_ui : case touch_ui : default :
5110 btnIFsh->deactivate();
5111 if (sldrIFSHIFT) sldrIFSHIFT->deactivate();
5112 if (spnrIFSHIFT) spnrIFSHIFT->deactivate();
5113 break;
5114 }
5115 }
5116 if (selrig->has_pbt_controls) {
5117 btnLOCK->show();
5118 btnLOCK->value(progStatus.pbt_lock);
5119 btnCLRPBT->show();
5120 sldrINNER->show();
5121 sldrOUTER->show();
5122 sldrINNER->value(progStatus.pbt_inner);
5123 sldrOUTER->value(progStatus.pbt_outer);
5124 }
5125
5126 if (xcvr_name == rig_TS870S.name_) {
5127 if (progStatus.imode_A == RIG_TS870S::tsCW ||
5128 progStatus.imode_A == RIG_TS870S::tsCWR) {
5129 btnIFsh->activate();
5130 if (sldrIFSHIFT) sldrIFSHIFT->activate();
5131 if (spnrIFSHIFT) spnrIFSHIFT->activate();
5132 } else {
5133 btnIFsh->deactivate();
5134 if (sldrIFSHIFT) sldrIFSHIFT->deactivate();
5135 if (spnrIFSHIFT) spnrIFSHIFT->deactivate();
5136 }
5137 }
5138 }
5139
init_notch_control()5140 void init_notch_control()
5141 {
5142 if (selrig->has_notch_control) {
5143 int min, max, step;
5144 selrig->get_notch_min_max_step(min, max, step);
5145 if (sldrNOTCH) sldrNOTCH->minimum(min);
5146 if (sldrNOTCH) sldrNOTCH->maximum(max);
5147 if (sldrNOTCH) sldrNOTCH->step(step);
5148 if (sldrNOTCH) sldrNOTCH->redraw();
5149 if (spnrNOTCH) spnrNOTCH->minimum(min);
5150 if (spnrNOTCH) spnrNOTCH->maximum(max);
5151 if (spnrNOTCH) spnrNOTCH->step(step);
5152 if (spnrNOTCH) spnrNOTCH->redraw();
5153 switch (progStatus.UIsize) {
5154 case small_ui :
5155 btnNotch->show();
5156 if (sldrNOTCH) sldrNOTCH->show();
5157 if (spnrNOTCH) spnrNOTCH->show();
5158 break;
5159 case wide_ui : case touch_ui : default :
5160 btnNotch->activate();
5161 if (sldrNOTCH) sldrNOTCH->activate();
5162 if (spnrNOTCH) spnrNOTCH->activate();
5163 break;
5164 }
5165 } else {
5166 switch (progStatus.UIsize) {
5167 case small_ui :
5168 btnNotch->hide();
5169 if (sldrNOTCH) sldrNOTCH->hide();
5170 if (spnrNOTCH) spnrNOTCH->hide();
5171 break;
5172 case wide_ui : case touch_ui : default :
5173 btnNotch->deactivate();
5174 if (sldrNOTCH) sldrNOTCH->deactivate();
5175 if (spnrNOTCH) spnrNOTCH->deactivate();
5176 break;
5177 }
5178 }
5179 }
5180
set_init_notch_control()5181 void set_init_notch_control()
5182 {
5183 if (selrig->has_notch_control) {
5184 if (progStatus.use_rig_data) {
5185 progStatus.notch = selrig->get_notch(progStatus.notch_val);
5186 btnNotch->value(progStatus.notch);
5187 if (sldrNOTCH) sldrNOTCH->value(progStatus.notch_val);
5188 if (spnrNOTCH) spnrNOTCH->value(progStatus.notch_val);
5189 } else {
5190 btnNotch->value(progStatus.notch);
5191 if (sldrNOTCH) sldrNOTCH->value(progStatus.notch_val);
5192 if (spnrNOTCH) spnrNOTCH->value(progStatus.notch_val);
5193 selrig->set_notch(progStatus.notch, progStatus.notch_val);
5194 }
5195 }
5196 }
5197
init_micgain_control()5198 void init_micgain_control()
5199 {
5200 if (selrig->has_micgain_control || selrig->has_data_port) {
5201 if (selrig->has_micgain_control) {
5202 int min = 0, max = 0, step = 0;
5203 selrig->get_mic_min_max_step(min, max, step);
5204 if (sldrMICGAIN) sldrMICGAIN->minimum(min);
5205 if (sldrMICGAIN) sldrMICGAIN->maximum(max);
5206 if (sldrMICGAIN) sldrMICGAIN->step(step);
5207 if (spnrMICGAIN) spnrMICGAIN->minimum(min);
5208 if (spnrMICGAIN) spnrMICGAIN->maximum(max);
5209 if (spnrMICGAIN) spnrMICGAIN->step(step);
5210
5211 switch (progStatus.UIsize) {
5212 case small_ui :
5213 if (sldrMICGAIN) sldrMICGAIN->show();
5214 if (spnrMICGAIN) spnrMICGAIN->show();
5215 break;
5216 case wide_ui : case touch_ui : default :
5217 if (sldrMICGAIN) sldrMICGAIN->activate();
5218 if (spnrMICGAIN) spnrMICGAIN->activate();
5219 break;
5220 }
5221 } else {
5222 if (sldrMICGAIN) sldrMICGAIN->deactivate();
5223 if (spnrMICGAIN) spnrMICGAIN->deactivate();
5224 }
5225 } else {
5226 switch (progStatus.UIsize) {
5227 case small_ui :
5228 if (sldrMICGAIN) sldrMICGAIN->hide();
5229 if (spnrMICGAIN) spnrMICGAIN->hide();
5230 break;
5231 case wide_ui : case touch_ui : default :
5232 if (sldrMICGAIN) sldrMICGAIN->deactivate();
5233 if (spnrMICGAIN) spnrMICGAIN->deactivate();
5234 }
5235 }
5236 }
5237
set_init_micgain_control()5238 void set_init_micgain_control()
5239 {
5240 int min, max, step;
5241 if (selrig->has_micgain_control) {
5242 if (progStatus.use_rig_data)
5243 progStatus.mic_gain = selrig->get_mic_gain();
5244 else
5245 selrig->set_mic_gain(progStatus.mic_gain);
5246
5247 selrig->get_mic_min_max_step(min, max, step);
5248 if (sldrMICGAIN) {
5249 sldrMICGAIN->minimum(min);
5250 sldrMICGAIN->maximum(max);
5251 sldrMICGAIN->step(step);
5252 sldrMICGAIN->value(progStatus.mic_gain);
5253 sldrMICGAIN->activate();
5254 }
5255 if (spnrMICGAIN) {
5256 spnrMICGAIN->minimum(min);
5257 spnrMICGAIN->maximum(max);
5258 spnrMICGAIN->step(step);
5259 spnrMICGAIN->value(progStatus.mic_gain);
5260 spnrMICGAIN->activate();
5261 }
5262 } else {
5263 if (sldrMICGAIN) sldrMICGAIN->deactivate();
5264 if (spnrMICGAIN) sldrMICGAIN->deactivate();
5265 }
5266 }
5267
init_power_control()5268 void init_power_control()
5269 {
5270 double min, max, step;
5271 if (selrig->has_power_control) {
5272 if (progStatus.use_rig_data)
5273 progStatus.power_level = selrig->get_power_control();
5274 else
5275 selrig->set_power_control(progStatus.power_level);
5276
5277 sldrPOWER->activate();
5278 selrig->get_pc_min_max_step(min, max, step);
5279 if (sldrPOWER) sldrPOWER->minimum(min);
5280 if (sldrPOWER) sldrPOWER->maximum(max);
5281 if (sldrPOWER) sldrPOWER->step(step);
5282 if (sldrPOWER) sldrPOWER->value(progStatus.power_level);
5283 if (sldrPOWER) sldrPOWER->show();
5284 if (sldrPOWER) sldrPOWER->redraw();
5285
5286 if (spnrPOWER) spnrPOWER->minimum(min);
5287 if (spnrPOWER) spnrPOWER->maximum(max);
5288 if (spnrPOWER) spnrPOWER->step(step);
5289 if (spnrPOWER) spnrPOWER->value(progStatus.power_level);
5290 if (spnrPOWER) spnrPOWER->show();
5291 if (spnrPOWER) spnrPOWER->redraw();
5292
5293 } else {
5294 if (sldrPOWER) sldrPOWER->deactivate();
5295 if (spnrPOWER) spnrPOWER->deactivate();
5296 }
5297 }
5298
set_init_power_control()5299 void set_init_power_control()
5300 {
5301 if (selrig->has_power_control) {
5302 if (progStatus.use_rig_data)
5303 progStatus.power_level = selrig->get_power_control();
5304 else
5305 selrig->set_power_control(progStatus.power_level);
5306 }
5307 set_power_controlImage(progStatus.power_level);
5308 }
5309
init_attenuator_control()5310 void init_attenuator_control()
5311 {
5312 if (selrig->has_attenuator_control) {
5313 if (selrig->name_ == rig_FT891.name_) {
5314 btnAttenuator->label("ATT");
5315 btnAttenuator->redraw_label();
5316 }
5317 switch (progStatus.UIsize) {
5318 case small_ui :
5319 btnAttenuator->show();
5320 break;
5321 case wide_ui : case touch_ui : default :
5322 btnAttenuator->activate();
5323 }
5324 } else {
5325 switch (progStatus.UIsize) {
5326 case small_ui :
5327 btnAttenuator->hide();
5328 break;
5329 case wide_ui : case touch_ui : default :
5330 btnAttenuator->deactivate();
5331 }
5332 }
5333 }
5334
set_init_attenuator_control()5335 void set_init_attenuator_control()
5336 {
5337 if (selrig->has_attenuator_control) {
5338 if (!progStatus.use_rig_data)
5339 selrig->set_attenuator(progStatus.attenuator);
5340 }
5341 }
5342
init_agc_control()5343 void init_agc_control()
5344 {
5345 if (selrig->has_agc_control) {
5346 btnAGC->show();
5347 sldrRFGAIN->label("");
5348 sldrRFGAIN->redraw_label();
5349 } else {
5350 btnAGC->hide();
5351 sldrRFGAIN->label(_("RF"));
5352 sldrRFGAIN->redraw_label();
5353 }
5354 }
5355
init_preamp_control()5356 void init_preamp_control()
5357 {
5358 if (selrig->has_preamp_control) {
5359 if (selrig->name_ == rig_FT891.name_) {
5360 btnPreamp->label("IPO");
5361 btnPreamp->redraw_label();
5362 }
5363 switch (progStatus.UIsize) {
5364 case small_ui :
5365 btnPreamp->show();
5366 break;
5367 case wide_ui : case touch_ui : default :
5368 btnPreamp->activate();
5369 }
5370 } else {
5371 switch (progStatus.UIsize) {
5372 case small_ui :
5373 btnPreamp->hide();
5374 break;
5375 case wide_ui : case touch_ui : default :
5376 btnPreamp->deactivate();
5377 }
5378 }
5379 }
5380
set_init_preamp_control()5381 void set_init_preamp_control()
5382 {
5383 if (selrig->has_preamp_control) {
5384 if (!progStatus.use_rig_data)
5385 selrig->set_preamp(progStatus.preamp);
5386 }
5387 }
5388
init_noise_control()5389 void init_noise_control()
5390 {
5391 int min, max, step;
5392 if (selrig->has_noise_control) {
5393 if (xcvr_name == rig_TS990.name_) {
5394 btnNOISE->label("AGC"); //Set TS990 AGC Label
5395 btnNR->label("NR1"); //Set TS990 NR Button
5396 }
5397 if (selrig->name_ == rig_FT891.name_) {
5398 // On the FT-891, the usual definitions of NB and NR buttons
5399 // as defined in FLRIG are reversed. Relabel them to match
5400 // what the user sees in the radio screens, and handle the
5401 // mapping to appropriate cat controls in the FT891.xx class.
5402 btnNOISE->label("DNR");
5403 btnNOISE->tooltip(_("DSP Noise Reduction On/Off. See RX tab for DNR level."));
5404 }
5405
5406 btnNOISE->show();
5407 btnNOISE->activate();
5408 }
5409 else {
5410 btnNOISE->hide();
5411 btnNOISE->deactivate();
5412 }
5413
5414 if (selrig->has_nb_level) {
5415 selrig->get_nb_min_max_step(min, max, step);
5416 sldr_nb_level->minimum(min);
5417 sldr_nb_level->maximum(max);
5418 sldr_nb_level->step(step);
5419 sldr_nb_level->value(progStatus.nb_level);
5420
5421 if (selrig->name_ == rig_FT891.name_) {
5422 // On the FT-891, the usual definitions of NB and NR buttons
5423 // as defined in FLRIG are reversed. Relabel them to match
5424 // what the user sees in the radio screens, and handle the
5425 // mapping to appropriate cat controls in the FT891.xx class.
5426 sldr_nb_level->label("DNR level");
5427 sldr_nb_level->tooltip(_("Adjust DSP Noise Reduction level"));
5428 }
5429
5430 sldr_nb_level->activate();
5431 sldr_nb_level->redraw();
5432 } else
5433 sldr_nb_level->deactivate();
5434 }
5435
init_split_control()5436 void init_split_control()
5437 {
5438 if (selrig->has_split) {
5439 btnSplit->show();
5440 btnSplit->activate();
5441 } else {
5442 btnSplit->hide();
5443 btnSplit->deactivate();
5444 }
5445 }
5446
set_init_noise_control()5447 void set_init_noise_control()
5448 {
5449 if (selrig->has_noise_control) {
5450 if (progStatus.use_rig_data)
5451 progStatus.noise = selrig->get_noise();
5452 else
5453 selrig->set_noise(progStatus.noise);
5454 btnNOISE->value(progStatus.noise);
5455 btnNOISE->show();
5456 btnNOISE->activate();
5457 } else {
5458 btnNOISE->hide();
5459 btnNOISE->deactivate();
5460 }
5461 }
5462
init_tune_control()5463 void init_tune_control()
5464 {
5465 if (selrig->has_tune_control) {
5466 switch (progStatus.UIsize) {
5467 case small_ui :
5468 btnTune->show();
5469 btn_tune_on_off->show();
5470 break;
5471 case wide_ui : case touch_ui : default :
5472 btnTune->activate();
5473 btn_tune_on_off->activate();
5474 }
5475 } else {
5476 switch (progStatus.UIsize) {
5477 case small_ui :
5478 btnTune->hide();
5479 btn_tune_on_off->hide();
5480 break;
5481 case wide_ui : case touch_ui : default :
5482 btnTune->deactivate();
5483 btn_tune_on_off->deactivate();
5484 }
5485 }
5486 }
5487
init_ptt_control()5488 void init_ptt_control()
5489 {
5490 if (selrig->has_ptt_control ||
5491 progStatus.comm_dtrptt || progStatus.comm_rtsptt ||
5492 progStatus.sep_dtrptt || progStatus.sep_rtsptt) {
5493 btnPTT->activate();
5494 } else {
5495 btnPTT->deactivate();
5496 }
5497 }
5498
init_auto_notch()5499 void init_auto_notch()
5500 {
5501 if (selrig->has_auto_notch) {
5502 if (xcvr_name == rig_RAY152.name_) {
5503 btnAutoNotch->label("AGC");
5504 btnAutoNotch->tooltip("AGC on/off");
5505 } else if (xcvr_name == rig_FT1000MP.name_) {
5506 btnAutoNotch->label("Tuner");
5507 btnAutoNotch->tooltip("Tuner on/off");
5508 } else if (xcvr_name == rig_FT891.name_) {
5509 btnAutoNotch->label("DNF");
5510 btnAutoNotch->tooltip("DSP Auto notch filter on/off");
5511 } else {
5512 btnAutoNotch->label("AN");
5513 btnAutoNotch->tooltip("Auto notch on/off");
5514 }
5515 switch (progStatus.UIsize) {
5516 case small_ui :
5517 btnAutoNotch->show();
5518 break;
5519 case wide_ui : case touch_ui : default :
5520 btnAutoNotch->activate();
5521 }
5522 } else {
5523 switch (progStatus.UIsize) {
5524 case small_ui :
5525 btnAutoNotch->hide();
5526 break;
5527 case wide_ui : case touch_ui : default :
5528 btnAutoNotch->deactivate();
5529 }
5530 }
5531 }
5532
set_init_auto_notch()5533 void set_init_auto_notch()
5534 {
5535 if (selrig->has_auto_notch) {
5536 if (progStatus.use_rig_data)
5537 progStatus.auto_notch = selrig->get_auto_notch();
5538 else
5539 selrig->set_auto_notch(progStatus.auto_notch);
5540 btnAutoNotch->value(progStatus.auto_notch);
5541 }
5542 }
5543
init_swr_control()5544 void init_swr_control()
5545 {
5546 if (selrig->has_swr_control)
5547 btnALC_SWR->activate();
5548 else {
5549 btnALC_SWR->deactivate();
5550 }
5551 }
5552
set_init_compression_control()5553 void set_init_compression_control()
5554 {
5555 if (selrig->has_compON || selrig->has_compression) {
5556 selrig->set_compression(progStatus.compON, progStatus.compression);
5557
5558 if (selrig->name_ == rig_FT891.name_) {
5559 // On the FT-891, compression is called PRC, under function
5560 // menu FUNCTION-1. Set the button to match for consistency.
5561 btnCompON->label("PRC");
5562 btnCompON->tooltip("Set speech processor for SSB modes on/off.");
5563 }
5564 }
5565 }
5566
set_init_break_in()5567 void set_init_break_in()
5568 {
5569 if (!selrig->has_cw_break_in) return;
5570 selrig->get_break_in();
5571 }
5572
init_special_controls()5573 void init_special_controls()
5574 {
5575 if (selrig->has_special)
5576 btnSpecial->show();
5577 else
5578 btnSpecial->hide();
5579 }
5580
init_external_tuner()5581 void init_external_tuner()
5582 {
5583 if (selrig->has_ext_tuner)
5584 btn_ext_tuner->show();
5585 else
5586 btn_ext_tuner->hide();
5587 }
5588
init_CIV()5589 void init_CIV()
5590 {
5591 if (selrig->CIV) {
5592 char hexstr[8];
5593 snprintf(hexstr, sizeof(hexstr), "0x%02X", selrig->CIV);
5594 txtCIV->value(hexstr);
5595 txtCIV->activate();
5596 btnCIVdefault->activate();
5597 if (selrig->name_ == rig_IC7200.name_ ||
5598 selrig->name_ == rig_IC7300.name_ ||
5599 selrig->name_ == rig_IC7600.name_ ||
5600 selrig->name_ == rig_IC7800.name_ ) {
5601 btnUSBaudio->value(progStatus.USBaudio = true);
5602 btnUSBaudio->activate();
5603 } else
5604 btnUSBaudio->deactivate();
5605 } else {
5606 txtCIV->value("");
5607 txtCIV->deactivate();
5608 btnCIVdefault->deactivate();
5609 btnUSBaudio->value(false);
5610 btnUSBaudio->deactivate();
5611 }
5612 }
5613
init_VFOs()5614 void init_VFOs()
5615 {
5616 if (selrig->name_ == rig_TT550.name_) return;
5617 if (selrig->name_ == rig_FT817.name_) {
5618 FreqDispA->value(vfoA.freq);
5619 FreqDispB->value(vfoB.freq);
5620 updateBandwidthControl();
5621 highlight_vfo(NULL);
5622 useB = false;
5623 return;
5624 }
5625
5626 if (!progStatus.use_rig_data) {
5627
5628 vfoB.freq = progStatus.freq_B;
5629 vfoB.imode = progStatus.imode_B;
5630 vfoB.iBW = progStatus.iBW_B;
5631
5632 if (vfoB.iBW == -1)
5633 vfoB.iBW = selrig->def_bandwidth(vfoB.imode);
5634
5635 useB = true;
5636 selrig->selectB();
5637
5638 selrig->set_modeB(vfoB.imode);
5639 selrig->set_bwB(vfoB.iBW);
5640 selrig->set_vfoB(vfoB.freq);
5641 FreqDispB->value(vfoB.freq);
5642
5643 update_progress(progress->value() + 4);
5644
5645 trace(2, "init_VFOs() vfoB ", printXCVR_STATE(vfoB).c_str());
5646
5647 vfoA.freq = progStatus.freq_A;
5648 vfoA.imode = progStatus.imode_A;
5649 vfoA.iBW = progStatus.iBW_A;
5650
5651 if (vfoA.iBW == -1)
5652 vfoA.iBW = selrig->def_bandwidth(vfoA.imode);
5653
5654 useB = false;
5655 selrig->selectA();
5656
5657 selrig->set_modeA(vfoA.imode);
5658 selrig->set_bwA(vfoA.iBW);
5659 selrig->set_vfoA(vfoA.freq);
5660 FreqDispA->value( vfoA.freq );
5661
5662 update_progress(progress->value() + 4);
5663
5664 vfo = &vfoA;
5665 updateBandwidthControl();
5666 highlight_vfo((void *)0);
5667
5668 trace(2, "init_VFOs() vfoA ", printXCVR_STATE(vfoA).c_str());
5669
5670 }
5671 else {
5672 // Capture VFOA mode and bandwidth, since it will be lost in VFO switch
5673 if (selrig->name_ == rig_FT891.name_) {
5674 useB = false;
5675 vfoA.freq = selrig->get_vfoA();
5676 update_progress(progress->value() + 4);
5677 vfoA.imode = selrig->get_modeA();
5678 update_progress(progress->value() + 4);
5679 vfoA.iBW = selrig->get_bwA();
5680 update_progress(progress->value() + 4);
5681 FreqDispA->value(vfoA.freq);
5682 trace(2, "A: ", printXCVR_STATE(vfoA).c_str());
5683
5684
5685 useB = true;
5686 selrig->selectB(); // third select call
5687 vfoB.freq = selrig->get_vfoB();
5688 update_progress(progress->value() + 4);
5689 vfoB.imode = selrig->get_modeB();
5690 update_progress(progress->value() + 4);
5691 vfoB.iBW = selrig->get_bwB();
5692 update_progress(progress->value() + 4);
5693 FreqDispB->value(vfoB.freq);
5694 trace(2, "B: ", printXCVR_STATE(vfoB).c_str());
5695
5696 // Restore radio VFOA mode, then freq and bandwidth
5697 useB = false;
5698 selrig->selectA(); // fourth select call
5699 yaesu891UpdateA(&vfoA);
5700 } else {
5701 vfoB = xcvr_vfoB;
5702 vfoA = xcvr_vfoA;
5703 FreqDispB->value(vfoB.freq);
5704 FreqDispA->value(vfoA.freq);
5705 }
5706
5707
5708 vfo = &vfoA;
5709 setModeControl((void *)0);
5710 update_progress(progress->value() + 4);
5711 updateBandwidthControl();
5712 update_progress(progress->value() + 4);
5713 highlight_vfo((void *)0);
5714 }
5715
5716 selrig->set_split(0); // initialization set split call
5717 }
5718
5719 //void init_IC7300_special()
5720 //{
5721 // if (selrig->name_ == rig_IC7300.name_) {
5722 // selrig->set_break_in();
5723 // redrawAGC();
5724 // }
5725 //}
5726
init_TS990_special()5727 void init_TS990_special()
5728 {
5729 if (xcvr_name == rig_TS990.name_) { // Setup TS990 Mon Button
5730 btnIFsh->label("MON");
5731 }
5732 }
5733
init_K3_KX3_special()5734 void init_K3_KX3_special()
5735 {
5736 if (xcvr_name == rig_K3.name_) {
5737 btnB->hide();
5738 btnA->hide();
5739 btn_KX3_swapAB->hide();
5740 btn_K3_swapAB->show();
5741 } else if (xcvr_name == rig_KX3.name_) {
5742 btnB->hide();
5743 btnA->hide();
5744 btn_K3_swapAB->hide();
5745 btn_KX3_swapAB->show();
5746 } else {
5747 btn_K3_swapAB->hide();
5748 btn_KX3_swapAB->hide();
5749 btnB->show();
5750 btnA->show();
5751 }
5752 }
5753
initRig()5754 void initRig()
5755 {
5756 xcvr_online = false;
5757 if (tabs_dialog && tabs_dialog->visible()) tabs_dialog->hide();
5758
5759 main_group->hide();
5760
5761 grpInitializing->size(mainwindow->w(), mainwindow->h() - grpInitializing->y());
5762 grpInitializing->show();
5763 grpInitializing->redraw();
5764 mainwindow->damage();
5765 mainwindow->redraw();
5766 update_progress(0);
5767 Fl::check();
5768
5769 flrig_abort = false;
5770
5771 sldrRcvSignal->aging(progStatus.rx_peak);
5772 sldrRcvSignal->avg(progStatus.rx_avg);
5773 sldrFwdPwr->aging(progStatus.pwr_peak);
5774 sldrFwdPwr->avg(progStatus.pwr_avg);
5775
5776 if (progStatus.use_tcpip) {
5777 try {
5778 connect_to_remote();
5779 } catch (...) {
5780 grpInitializing->hide();
5781 main_group->show();
5782 mainwindow->redraw();
5783 return;
5784 }
5785 }
5786
5787 // disable the serial thread
5788 {
5789 guard_lock gl_serial(&mutex_serial);
5790 trace(1, "init_rig()");
5791
5792 // Xcvr Auto Power on as soon as possible
5793 if (selrig->has_xcvr_auto_on_off && progStatus.xcvr_auto_on) {
5794 progress->label("Auto Start");
5795 progress->redraw_label();
5796 update_progress(0);
5797 selrig->set_xcvr_auto_on();
5798 progress->label("Initializing");
5799 progress->redraw_label();
5800 update_progress(0);
5801 }
5802
5803 bool check_ok = false;
5804 if (progStatus.xcvr_serial_port != "NONE") check_ok = selrig->check();
5805
5806 init_special_controls();
5807 init_external_tuner();
5808 init_rit();
5809 init_xit();
5810 init_bfo();
5811 init_dsp_controls();
5812 init_volume_control();
5813 init_rf_control();
5814 init_sql_control();
5815 init_noise_reduction_control();
5816 init_if_shift_control();
5817 init_notch_control();
5818 init_micgain_control();
5819 init_power_control();
5820 init_attenuator_control();
5821 init_agc_control();
5822 init_preamp_control();
5823 init_noise_control();
5824 init_tune_control();
5825 init_ptt_control();
5826 init_auto_notch();
5827 init_swr_control();
5828 init_split_control();
5829
5830 selrig->initialize();
5831
5832 if (progStatus.xcvr_serial_port != "NONE") {
5833 if (!check_ok) goto failed;
5834 if (flrig_abort) goto failed;
5835 }
5836
5837 FreqDispA->set_precision(selrig->precision);
5838 FreqDispA->set_ndigits(selrig->ndigits);
5839 FreqDispB->set_precision(selrig->precision);
5840 FreqDispB->set_ndigits(selrig->ndigits);
5841
5842 if (xcvr_name == rig_TT550.name_)
5843 init_TT550();
5844 else
5845 init_generic_rig();
5846
5847 set_init_volume_control();
5848 set_init_rf_gain();
5849 set_init_sql_control();
5850 set_init_noise_reduction_control();
5851 set_init_if_shift_control();
5852 set_init_micgain_control();
5853 set_init_power_control();
5854 set_init_attenuator_control();
5855 set_init_preamp_control();
5856 set_init_noise_control();
5857 set_init_auto_notch();
5858 set_init_notch_control();
5859 set_init_compression_control();
5860 set_init_break_in();
5861
5862 initTabs();
5863 buildlist();
5864
5865 init_CIV();
5866
5867 init_VFOs();
5868
5869 selrig->post_initialize();
5870
5871 // init_IC7300_special();
5872 init_TS990_special();
5873 init_K3_KX3_special();
5874
5875 btnAswapB->show();
5876
5877 } // enable the serial thread
5878
5879
5880 bypass_serial_thread_loop = false;
5881
5882 grpInitializing->hide();
5883
5884 adjust_control_positions();
5885
5886 main_group->show();
5887 mainwindow->redraw();
5888 mainwindow->damage();
5889 Fl::flush();
5890 // Fl::check();
5891
5892 xcvr_online = true;
5893 return;
5894
5895 failed:
5896 xcvr_online = false;
5897 adjust_control_positions();
5898 grpInitializing->hide();
5899 main_group->show();
5900 mainwindow->redraw();
5901
5902 bypass_serial_thread_loop = true;
5903
5904 fl_alert2(_("\
5905 Transceiver not responding!\n\n\
5906 Check serial (COM) port connection\n\
5907 Open menu Config/Setup/Transceiver\n\
5908 Press 'Ser Port' button, reselect port\n\
5909 Press 'Init' button."));
5910
5911 return;
5912 }
5913
init_title()5914 void init_title()
5915 {
5916 title = PACKAGE;
5917 title += " ";
5918 title.append(selrig->name_);
5919 mainwindow->label(title.c_str());
5920 }
5921
initConfigDialog()5922 void initConfigDialog()
5923 {
5924 int picked = selectRig->index();
5925 rigbase *srig = rigs[picked];
5926 xcvr_name = srig->name_;
5927
5928 if (!progStatus.loadXcvrState(xcvr_name) ) {
5929
5930 selectCommPort->index(0);
5931 mnuBaudrate->index( srig->comm_baudrate );
5932 btnOneStopBit->value( srig->stopbits == 1 );
5933 btnTwoStopBit->value( srig->stopbits == 2 );
5934 cntRigCatRetries->value( srig->comm_retries );
5935 cntRigCatTimeout->value( srig->comm_timeout );
5936 cntRigCatWait->value( srig->comm_wait );
5937 query_interval->value( srig->serloop_timing );
5938
5939 btnRigCatEcho->value( srig->comm_echo );
5940 btncatptt->value( srig->comm_catptt );
5941 btnrtsptt->value( srig->comm_rtsptt );
5942 btndtrptt->value( srig->comm_dtrptt );
5943 chkrtscts->value( srig->comm_rtscts );
5944 btnrtsplus->value( srig->comm_rtsplus );
5945 btndtrplus->value( srig->comm_dtrplus );
5946
5947 if (selrig->CIV) {
5948 char hexstr[8];
5949 snprintf(hexstr, sizeof(hexstr), "0x%02X", srig->CIV);
5950 txtCIV->value(hexstr);
5951 txtCIV->activate();
5952 btnCIVdefault->activate();
5953 if (xcvr_name == rig_IC7200.name_ ||
5954 xcvr_name == rig_IC7300.name_ ||
5955 xcvr_name == rig_IC7600.name_ ||
5956 xcvr_name == rig_IC7800.name_) {
5957 btnUSBaudio->value(progStatus.USBaudio = true);
5958 btnUSBaudio->activate();
5959 } else
5960 btnUSBaudio->deactivate();
5961 } else {
5962 txtCIV->value("");
5963 txtCIV->deactivate();
5964 btnCIVdefault->deactivate();
5965 btnUSBaudio->value(false);
5966 btnUSBaudio->deactivate();
5967 }
5968 } else {
5969 initStatusConfigDialog();
5970 trace(1, progStatus.info().c_str());
5971 }
5972 }
5973
initStatusConfigDialog()5974 void initStatusConfigDialog()
5975 {
5976 if (progStatus.CIV) selrig->adjustCIV(progStatus.CIV);
5977
5978 selectRig->value(xcvr_name.c_str());
5979
5980 mnuBaudrate->index( progStatus.comm_baudrate );
5981
5982 selectCommPort->value( progStatus.xcvr_serial_port.c_str() );
5983 selectAuxPort->value( progStatus.aux_serial_port.c_str() );
5984 selectSepPTTPort->value( progStatus.sep_serial_port.c_str() );
5985 btnOneStopBit->value( progStatus.stopbits == 1 );
5986 btnTwoStopBit->value( progStatus.stopbits == 2 );
5987
5988 cntRigCatRetries->value( progStatus.comm_retries );
5989 cntRigCatTimeout->value( progStatus.comm_timeout );
5990 cntRigCatWait->value( progStatus.comm_wait );
5991 btnRigCatEcho->value( progStatus.comm_echo );
5992 query_interval->value( progStatus.serloop_timing );
5993 byte_interval->value( progStatus.byte_interval );
5994
5995 btncatptt->value( progStatus.comm_catptt );
5996 btnrtsptt->value( progStatus.comm_rtsptt );
5997 btndtrptt->value( progStatus.comm_dtrptt );
5998 chkrtscts->value( progStatus.comm_rtscts );
5999 btnrtsplus->value( progStatus.comm_rtsplus );
6000 btndtrplus->value( progStatus.comm_dtrplus );
6001
6002 btnSepDTRplus->value(progStatus.sep_dtrplus);
6003 btnSepDTRptt->value(progStatus.sep_dtrptt);
6004 btnSepRTSplus->value(progStatus.sep_rtsplus);
6005 btnSepRTSptt->value(progStatus.sep_rtsptt);
6006
6007 if (progStatus.use_tcpip) {
6008 box_xcvr_connect->color(FL_BACKGROUND2_COLOR);
6009 box_xcvr_connect->redraw();
6010 } else {
6011 if (!startXcvrSerial()) {
6012 if (progStatus.xcvr_serial_port.compare("NONE") == 0) {
6013 LOG_WARN("No comm port ... test mode");
6014 } else {
6015 fl_alert2("\
6016 Cannot open %s!\n\n\
6017 Check serial (COM) port connection\n\
6018 Open menu Config/Setup/Transceiver\n\
6019 Press 'Ser Port' button, reselect port\n\
6020 Press 'Init' button.", progStatus.xcvr_serial_port.c_str());
6021 LOG_WARN("Cannot open %s", progStatus.xcvr_serial_port.c_str());
6022 progStatus.xcvr_serial_port = "NONE";
6023 selectCommPort->value(progStatus.xcvr_serial_port.c_str());
6024 }
6025 box_xcvr_connect->color(FL_BACKGROUND2_COLOR);
6026 box_xcvr_connect->redraw();
6027 } else {
6028 selectCommPort->value(progStatus.xcvr_serial_port.c_str());
6029 box_xcvr_connect->color(FL_GREEN);
6030 box_xcvr_connect->redraw();
6031 }
6032 if (!startAuxSerial()) {
6033 if (progStatus.aux_serial_port.compare("NONE") != 0) {
6034 LOG_WARN("Cannot open %s", progStatus.aux_serial_port.c_str());
6035 progStatus.aux_serial_port = "NONE";
6036 selectAuxPort->value(progStatus.aux_serial_port.c_str());
6037 }
6038 }
6039 if (!startSepSerial()) {
6040 if (progStatus.sep_serial_port.compare("NONE") != 0) {
6041 LOG_WARN("Cannot open %s", progStatus.sep_serial_port.c_str());
6042 progStatus.sep_serial_port = "NONE";
6043 selectSepPTTPort->value(progStatus.sep_serial_port.c_str());
6044 }
6045 }
6046 }
6047
6048 init_title();
6049
6050 initRig();
6051
6052 }
6053
initRigCombo()6054 void initRigCombo()
6055 {
6056 selectRig->clear();
6057 int i = 0;
6058 while (rigs[i] != NULL)
6059 selectRig->add(rigs[i++]->name_.c_str());
6060
6061 selectRig->index(0);
6062 }
6063
6064 //----------------------------------------------------------------------
6065 // button label and label state changes
6066 // Note that an additional level of service request is made to insure
6067 // that the main thread is actually changing the widget
6068
6069 // noise reduction
6070 static std::string nr_label_;
6071 static bool nr_state_;
6072
do_nr_label(void *)6073 void do_nr_label(void *)
6074 {
6075 btnNR->value(nr_state_ ? 1 : 0);
6076 btnNR->label(nr_label_.c_str());
6077 btnNR->redraw_label();
6078 }
6079
nr_label(const char * l,bool on=false)6080 void nr_label(const char *l, bool on = false)
6081 {
6082 nr_label_ = l;
6083 nr_state_ = on;
6084 Fl::awake(do_nr_label);
6085 }
6086
6087 // noise blanker
6088 static std::string nb_label_;
6089 static bool nb_state_;
6090
do_nb_label(void *)6091 void do_nb_label(void *)
6092 {
6093 btnNOISE->value(nb_state_ ? 1 : 0);
6094 btnNOISE->label(nb_label_.c_str());
6095 btnNOISE->redraw_label();
6096 }
6097
nb_label(const char * l,bool on=false)6098 void nb_label(const char * l, bool on = false)
6099 {
6100 nb_label_ = l;
6101 nb_state_ = on;
6102 Fl::awake(do_nb_label);
6103 }
6104
6105 // preamp label
6106 static std::string preamp_label_;
6107 static bool preamp_state_;
6108
do_preamp_label(void *)6109 void do_preamp_label(void *)
6110 {
6111 btnPreamp->value(preamp_state_ ? 1 : 0);
6112 btnPreamp->label(preamp_label_.c_str());
6113 btnPreamp->redraw_label();
6114 }
6115
preamp_label(const char * l,bool on=false)6116 void preamp_label(const char * l, bool on = false)
6117 {
6118 preamp_label_ = l;
6119 preamp_state_ = on;
6120 Fl::awake(do_preamp_label);
6121 }
6122
6123 // atten label
6124 static std::string atten_label_;
6125 static bool atten_state_;
6126
do_atten_label(void *)6127 void do_atten_label(void *)
6128 {
6129 btnAttenuator->value(atten_state_ ? 1 : 0);
6130 btnAttenuator->label(atten_label_.c_str());
6131 btnAttenuator->redraw_label();
6132 }
6133
atten_label(const char * l,bool on=false)6134 void atten_label(const char * l, bool on = false)
6135 {
6136 atten_label_ = l;
6137 atten_state_ = on;
6138 Fl::awake(do_atten_label);
6139 }
6140
6141 // break-in label
6142 static std::string bkin_label_;
6143
do_bkin_label(void *)6144 void do_bkin_label(void *)
6145 {
6146 btnBreakIn->label(bkin_label_.c_str());
6147 btnBreakIn->redraw_label();
6148 }
6149
break_in_label(const char * l)6150 void break_in_label(const char *l)
6151 {
6152 bkin_label_ = l;
6153 Fl::awake(do_bkin_label);
6154 }
6155
6156 // autonotch label
6157 static std::string auto_notch_label_;
6158 static bool auto_notch_state_;
6159
do_auto_notch_label(void *)6160 void do_auto_notch_label(void *)
6161 {
6162 btnAutoNotch->value(auto_notch_state_ ? 1 : 0);
6163 btnAutoNotch->label(auto_notch_label_.c_str());
6164 btnAutoNotch->redraw_label();
6165 }
6166
auto_notch_label(const char * l,bool on=false)6167 void auto_notch_label(const char * l, bool on = false)
6168 {
6169 auto_notch_label_ = l;
6170 auto_notch_state_ = on;
6171 Fl::awake(do_auto_notch_label);
6172 }
6173
cbAuxPort()6174 void cbAuxPort()
6175 {
6176 AuxSerial->setRTS(progStatus.aux_rts);
6177 AuxSerial->setDTR(progStatus.aux_dtr);
6178 }
6179
cb_agc_level()6180 void cb_agc_level()
6181 {
6182 guard_lock serial_lock(&mutex_serial);
6183 trace(1, "cb_agc_level()");
6184 selrig->set_agc_level();
6185 }
6186
cb_cw_wpm()6187 void cb_cw_wpm()
6188 {
6189 guard_lock serial_lock(&mutex_serial);
6190 trace(1, "cb_cw_wpm()");
6191 selrig->set_cw_wpm();
6192 }
6193
cb_cw_vol()6194 void cb_cw_vol()
6195 {
6196 guard_lock serial_lock(&mutex_serial);
6197 trace(1, "cb_cw_vol()");
6198 selrig->set_cw_vol();
6199 }
6200
cb_cw_spot()6201 void cb_cw_spot()
6202 {
6203 int ret;
6204 guard_lock serial_lock(&mutex_serial);
6205 trace(1, "cb_cw_spot()");
6206 ret = selrig->set_cw_spot();
6207 if (!ret) btnSpot->value(0);
6208 }
6209
cb_cw_spot_tone()6210 void cb_cw_spot_tone()
6211 {
6212 guard_lock serial_lock(&mutex_serial);
6213 trace(1, "cb_cw_spot_tone()");
6214 selrig->set_cw_spot_tone();
6215 }
6216
6217
cb_vox_gain()6218 void cb_vox_gain()
6219 {
6220 guard_lock serial_lock(&mutex_serial);
6221 trace(1, "cb_vox_gain()");
6222 selrig->set_vox_gain();
6223 }
6224
cb_vox_anti()6225 void cb_vox_anti()
6226 {
6227 guard_lock serial_lock(&mutex_serial);
6228 trace(1, "cb_vox_anti()");
6229 selrig->set_vox_anti();
6230 }
6231
cb_vox_hang()6232 void cb_vox_hang()
6233 {
6234 guard_lock serial_lock(&mutex_serial);
6235 trace(1, "cb_vox_hang()");
6236 selrig->set_vox_hang();
6237 }
6238
cb_vox_onoff()6239 void cb_vox_onoff()
6240 {
6241 guard_lock serial_lock(&mutex_serial);
6242 trace(1, "cb_vox_onoff()");
6243 selrig->set_vox_onoff();
6244 }
6245
cb_vox_on_dataport()6246 void cb_vox_on_dataport()
6247 {
6248 guard_lock serial_lock(&mutex_serial);
6249 trace(1, "cb_dataport()");
6250 selrig->set_vox_on_dataport();
6251 }
6252
cb_compression()6253 void cb_compression()
6254 {
6255 guard_lock serial_lock(&mutex_serial);
6256 trace(1, "cb_compression");
6257 selrig->set_compression(progStatus.compON, progStatus.compression);
6258 }
6259
cb_auto_notch()6260 void cb_auto_notch()
6261 {
6262 progStatus.auto_notch = btnAutoNotch->value();
6263 guard_lock serial_lock(&mutex_serial);
6264 trace(1, "cb_autonotch()");
6265 selrig->set_auto_notch(progStatus.auto_notch);
6266 }
6267
cb_vfo_adj()6268 void cb_vfo_adj()
6269 {
6270 if (xcvr_name == rig_TT550.name_)
6271 progStatus.vfo_adj = spnr_tt550_vfo_adj->value();
6272 else
6273 progStatus.vfo_adj = spnr_vfo_adj->value();
6274 guard_lock serial_lock(&mutex_serial);
6275 trace(1, "cb_vfo_adj()");
6276 selrig->setVfoAdj(progStatus.vfo_adj);
6277 }
6278
cb_line_out()6279 void cb_line_out()
6280 {
6281 }
6282
cb_bpf_center()6283 void cb_bpf_center()
6284 {
6285 guard_lock serial_lock(&mutex_serial);
6286 trace(1, "cb_bpf_center()");
6287 selrig->set_if_shift(selrig->pbt);
6288 }
6289
cb_special()6290 void cb_special()
6291 {
6292 guard_lock serial_lock(&mutex_serial);
6293 trace(1, "cb_special()");
6294 selrig->set_special(btnSpecial->value());
6295 }
6296
cbNoise()6297 void cbNoise()
6298 {
6299 guard_lock serial_lock(&mutex_serial);
6300 trace(1, "cbNoise()");
6301
6302 int btn, get, cnt = 0;
6303
6304 btn = progStatus.noise = btnNOISE->value();
6305
6306 selrig->set_noise(btn);
6307 MilliSleep(progStatus.comm_wait);
6308 get = selrig->get_noise();
6309 while ((get != btn) && (cnt++ < 10)) {
6310 MilliSleep(progStatus.comm_wait);
6311 get = selrig->get_noise();
6312 Fl::awake();
6313 }
6314 }
6315
cb_nb_level()6316 void cb_nb_level()
6317 {
6318 if (!selrig->has_nb_level) return;
6319 int set = 0;
6320
6321 trace(1, "cb_nb_level()");
6322
6323 int ev = Fl::event();
6324 if (ev == FL_LEAVE || ev == FL_ENTER) return;
6325 if (ev == FL_DRAG || ev == FL_PUSH) {
6326 inhibit_nb_level = 1;
6327 return;
6328 }
6329 set = sldr_nb_level->value();
6330 guard_lock lock(&mutex_serial);
6331 selrig->set_nb_level(set);
6332 }
6333
cbNR()6334 void cbNR()
6335 {
6336 if (!selrig->has_noise_reduction_control) return;
6337 guard_lock serial_lock(&mutex_serial);
6338 trace(1, "cbNR()");
6339
6340 int btn = 0, set = 0, get, cnt = 0;
6341 if (sldrNR) {
6342 set = sldrNR->value();
6343 btn = btnNR->value();
6344 }
6345 if (spnrNR) {
6346 set = spnrNR->value();
6347 btn = btnNR->value();
6348 }
6349
6350
6351 if (xcvr_name == rig_TS2000.name_) {
6352 if (btn != -1) { // pia
6353 if (selrig->noise_reduction_level() == 0) {
6354 selrig->set_noise_reduction(1);
6355 selrig->set_noise_reduction_val(selrig->nrval1());
6356 progStatus.noise_reduction = 1;
6357 progStatus.noise_reduction_val = selrig->nrval1();
6358 } else if (selrig->currmode() != RIG_TS2000::FM &&
6359 selrig->noise_reduction_level() == 1) {
6360 selrig->set_noise_reduction(2);
6361 selrig->set_noise_reduction_val(selrig->nrval2());
6362 progStatus.noise_reduction = 2;
6363 progStatus.noise_reduction_val = selrig->nrval2();
6364 } else
6365 selrig->set_noise_reduction(0);
6366 } else {
6367 progStatus.noise_reduction_val = set;
6368 selrig->set_noise_reduction_val(set);
6369 }
6370 } else { // not TS2000
6371
6372 progStatus.noise_reduction = btn;
6373
6374 selrig->set_noise_reduction(btn);
6375 MilliSleep(progStatus.comm_wait);
6376
6377 get = selrig->get_noise_reduction();
6378 while ((get != btn) && (cnt++ < 10)) {
6379 MilliSleep(progStatus.comm_wait);
6380 get = selrig->get_noise_reduction();
6381 Fl::awake();
6382 }
6383 progStatus.noise_reduction_val = set;
6384 selrig->set_noise_reduction_val(set);
6385 MilliSleep(progStatus.comm_wait);
6386 get = selrig->get_noise_reduction_val();
6387 cnt = 0;
6388 while ((get != set) && (cnt++ < 10)) {
6389 MilliSleep(progStatus.comm_wait);
6390 get = selrig->get_noise_reduction_val();
6391 Fl::awake();
6392 }
6393 }
6394
6395 }
6396
setNR()6397 void setNR()
6398 {
6399 if (!selrig->has_noise_reduction_control) return;
6400 trace(1, "setNR()");
6401
6402 int btn = 0, set = 0;
6403
6404 int ev = Fl::event();
6405 if (ev == FL_LEAVE || ev == FL_ENTER) return;
6406 if (ev == FL_DRAG || ev == FL_PUSH) {
6407 inhibit_nr = 1;
6408 return;
6409 }
6410
6411 if (xcvr_name == rig_TS2000.name_ ||
6412 xcvr_name == rig_TS590S.name_ ||
6413 xcvr_name == rig_TS590SG.name_ ||
6414 xcvr_name == rig_TS890S.name_ ||
6415 xcvr_name == rig_TS990.name_) {
6416 if (sldrNR) {
6417 set = sldrNR->value();
6418 btn = -1;
6419 }
6420 if (spnrNR) {
6421 set = spnrNR->value();
6422 btn = -1;
6423 }
6424 } else {
6425 if (sldrNR) {
6426 set = sldrNR->value();
6427 btn = btnNR->value();
6428 }
6429 if (spnrNR) {
6430 set = spnrNR->value();
6431 btn = btnNR->value();
6432 }
6433 }
6434
6435 guard_lock lock(&mutex_serial);
6436 selrig->set_noise_reduction_val(set);
6437 selrig->set_noise_reduction(btn);
6438
6439 }
6440
cb_spot()6441 void cb_spot()
6442 {
6443 guard_lock serial_lock(&mutex_serial);
6444 trace(1, "cb_spot()");
6445 selrig->set_cw_spot();
6446 }
6447
cb_enable_keyer()6448 void cb_enable_keyer()
6449 {
6450 guard_lock serial_lock(&mutex_serial);
6451 trace(1, "cb_enable_keyer()");
6452 selrig->enable_keyer();
6453 }
6454
cb_set_break_in()6455 void cb_set_break_in()
6456 {
6457 guard_lock serial_lock(&mutex_serial);
6458 trace(1, "cb_set_break_in()");
6459 selrig->set_break_in();
6460 }
6461
cb_cw_weight()6462 void cb_cw_weight()
6463 {
6464 guard_lock serial_lock(&mutex_serial);
6465 trace(1, "cb_cw_weight()");
6466 selrig->set_cw_weight();
6467 }
6468
cb_cw_qsk()6469 void cb_cw_qsk()
6470 {
6471 guard_lock serial_lock(&mutex_serial);
6472 trace(1, "cb_cw_qsk()");
6473 selrig->set_cw_qsk();
6474 }
6475
cb_cw_delay()6476 void cb_cw_delay()
6477 {
6478 guard_lock serial_lock(&mutex_serial);
6479 trace(1, "cb_cw_delay()");
6480 selrig->set_cw_delay();
6481 }
6482
set_band_label(int band)6483 void set_band_label(int band)
6484 {
6485 switch (band) {
6486 case 1:
6487 break;
6488 case 2:
6489 break;
6490 case 3:
6491 break;
6492 case 4:
6493 break;
6494 case 5:
6495 break;
6496 case 6:
6497 break;
6498 case 7:
6499 break;
6500 case 8:
6501 break;
6502 case 9:
6503 break;
6504 case 10:
6505 break;
6506 case 11:
6507 break;
6508 case 12:
6509 break;
6510 case 13:
6511 break;
6512 }
6513 }
6514
set_band(int band)6515 void set_band(int band)
6516 {
6517 switch (band) {
6518 case 1: progStatus.f160 = vfo->freq;
6519 progStatus.m160 = vfo->imode;
6520 progStatus.txT_160 = choice_FT8n_tTONE->value();
6521 progStatus.rxT_160 = choice_FT8n_rTONE->value();
6522 progStatus.offset_160 = FMoffset->index();
6523 progStatus.oF_160 = FMoff_freq->value();
6524 break; // 160 meters
6525 case 2: progStatus.f80 = vfo->freq;
6526 progStatus.m80 = vfo->imode;
6527 progStatus.txT_80 = choice_FT8n_tTONE->value();
6528 progStatus.rxT_80 = choice_FT8n_rTONE->value();
6529 progStatus.offset_80 = FMoffset->index();
6530 progStatus.oF_80 = FMoff_freq->value();
6531 break; // 80 meters
6532 case 3: progStatus.f40 = vfo->freq;
6533 progStatus.m40 = vfo->imode;
6534 progStatus.txT_40 = choice_FT8n_tTONE->value();
6535 progStatus.rxT_40 = choice_FT8n_rTONE->value();
6536 progStatus.offset_40 = FMoffset->index();
6537 progStatus.oF_40 = FMoff_freq->value();
6538 break; // 40 meters
6539 case 4: progStatus.f30 = vfo->freq;
6540 progStatus.m30 = vfo->imode;
6541 progStatus.txT_30 = choice_FT8n_tTONE->value();
6542 progStatus.rxT_30 = choice_FT8n_rTONE->value();
6543 progStatus.offset_30 = FMoffset->index();
6544 progStatus.oF_30 = FMoff_freq->value();
6545 break; // 30 meters
6546 case 5: progStatus.f20 = vfo->freq;
6547 progStatus.m20 = vfo->imode;
6548 progStatus.txT_20 = choice_FT8n_tTONE->value();
6549 progStatus.rxT_20 = choice_FT8n_rTONE->value();
6550 progStatus.offset_20 = FMoffset->index();
6551 progStatus.oF_20 = FMoff_freq->value();
6552 break; // 20 meters
6553 case 6: progStatus.f17 = vfo->freq;
6554 progStatus.m17 = vfo->imode;
6555 progStatus.txT_17 = choice_FT8n_tTONE->value();
6556 progStatus.rxT_17 = choice_FT8n_rTONE->value();
6557 progStatus.offset_17 = FMoffset->index();
6558 progStatus.oF_17 = FMoff_freq->value();
6559 break; // 17 meters
6560 case 7: progStatus.f15 = vfo->freq;
6561 progStatus.m15 = vfo->imode;
6562 progStatus.txT_15 = choice_FT8n_tTONE->value();
6563 progStatus.rxT_15 = choice_FT8n_rTONE->value();
6564 progStatus.offset_15 = FMoffset->index();
6565 progStatus.oF_15 = FMoff_freq->value();
6566 break; // 15 meters
6567 case 8: progStatus.f12 = vfo->freq;
6568 progStatus.m12 = vfo->imode;
6569 progStatus.txT_12 = choice_FT8n_tTONE->value();
6570 progStatus.rxT_12 = choice_FT8n_rTONE->value();
6571 progStatus.offset_12 = FMoffset->index();
6572 progStatus.oF_12 = FMoff_freq->value();
6573 break; // 12 meters
6574 case 9: progStatus.f10 = vfo->freq;
6575 progStatus.m10 = vfo->imode;
6576 progStatus.txT_10 = choice_FT8n_tTONE->value();
6577 progStatus.rxT_10 = choice_FT8n_rTONE->value();
6578 progStatus.offset_10 = FMoffset->index();
6579 progStatus.oF_10 = FMoff_freq->value();
6580 break; // 10 meters
6581 case 10:progStatus.f6 = vfo->freq;
6582 progStatus.m6 = vfo->imode;
6583 progStatus.txT_6 = choice_FT8n_tTONE->value();
6584 progStatus.rxT_6 = choice_FT8n_rTONE->value();
6585 progStatus.offset_6 = FMoffset->index();
6586 progStatus.oF_6 = FMoff_freq->value();
6587 break; // 6 meters
6588 case 11:progStatus.f2 = vfo->freq;
6589 progStatus.m2 = vfo->imode;
6590 progStatus.txT_2 = choice_FT8n_tTONE->value();
6591 progStatus.rxT_2 = choice_FT8n_rTONE->value();
6592 progStatus.offset_2 = FMoffset->index();
6593 progStatus.oF_2 = FMoff_freq->value();
6594 break; // 2 meters
6595 case 12:progStatus.f70 = vfo->freq;
6596 progStatus.m70 = vfo->imode;
6597 progStatus.txT_70 = choice_FT8n_tTONE->value();
6598 progStatus.rxT_70 = choice_FT8n_rTONE->value();
6599 progStatus.offset_70 = FMoffset->index();
6600 progStatus.oF_70 = FMoff_freq->value();
6601 break; // 70 cent'
6602 case 13:progStatus.f12G = vfo->freq;
6603 progStatus.m12G = vfo->imode;
6604 progStatus.txT_12G = choice_FT8n_tTONE->value();
6605 progStatus.rxT_12G = choice_FT8n_rTONE->value();
6606 progStatus.offset_12G = FMoffset->index();
6607 progStatus.oF_12G = FMoff_freq->value();
6608 break; // 1.2 GHz cent'
6609 }
6610 }
6611
6612
updateCTCSS(int band)6613 void updateCTCSS(int band)
6614 {
6615 switch (band) {
6616 case 1: choice_FT8n_tTONE->value(progStatus.txT_160);
6617 choice_FT8n_rTONE->value(progStatus.txT_160);
6618 FMoffset->index(progStatus.offset_160);
6619 FMoff_freq->value(progStatus.oF_160 );
6620 break; // 160 meters
6621 case 2: choice_FT8n_tTONE->value(progStatus.txT_80);
6622 choice_FT8n_rTONE->value(progStatus.txT_80);
6623 FMoffset->index(progStatus.offset_80);
6624 FMoff_freq->value(progStatus.oF_80 );
6625 break; // 80 meters
6626 case 3: choice_FT8n_tTONE->value(progStatus.txT_40);
6627 choice_FT8n_rTONE->value(progStatus.txT_40);
6628 FMoffset->index(progStatus.offset_40);
6629 FMoff_freq->value(progStatus.oF_40 );
6630 break; // 40 meters
6631 case 4: choice_FT8n_tTONE->value(progStatus.txT_30);
6632 choice_FT8n_rTONE->value(progStatus.txT_30);
6633 FMoffset->index(progStatus.offset_30);
6634 FMoff_freq->value(progStatus.oF_30 );
6635 break; // 30 meters
6636 case 5: choice_FT8n_tTONE->value(progStatus.txT_20);
6637 choice_FT8n_rTONE->value(progStatus.txT_20);
6638 FMoffset->index(progStatus.offset_20);
6639 FMoff_freq->value(progStatus.oF_20 );
6640 break; // 20 meters
6641 case 6: choice_FT8n_tTONE->value(progStatus.txT_17);
6642 choice_FT8n_rTONE->value(progStatus.txT_17);
6643 FMoffset->index(progStatus.offset_17);
6644 FMoff_freq->value(progStatus.oF_17 );
6645 break; // 17 meters
6646 case 7: choice_FT8n_tTONE->value(progStatus.txT_15);
6647 choice_FT8n_rTONE->value(progStatus.txT_15);
6648 FMoffset->index(progStatus.offset_15);
6649 FMoff_freq->value(progStatus.oF_15 );
6650 break; // 15 meters
6651 case 8: choice_FT8n_tTONE->value(progStatus.txT_12);
6652 choice_FT8n_rTONE->value(progStatus.txT_12);
6653 FMoffset->index(progStatus.offset_12);
6654 FMoff_freq->value(progStatus.oF_12 );
6655 break; // 12 meters
6656 case 9: choice_FT8n_tTONE->value(progStatus.txT_10);
6657 choice_FT8n_rTONE->value(progStatus.txT_10);
6658 FMoffset->index(progStatus.offset_10);
6659 FMoff_freq->value(progStatus.oF_10 );
6660 break; // 10 meters
6661 case 10:choice_FT8n_tTONE->value(progStatus.txT_6);
6662 choice_FT8n_rTONE->value(progStatus.txT_6);
6663 FMoffset->index(progStatus.offset_6);
6664 FMoff_freq->value(progStatus.oF_6 );
6665 break; // 6 meters
6666 case 11:choice_FT8n_tTONE->value(progStatus.txT_2);
6667 choice_FT8n_rTONE->value(progStatus.txT_2);
6668 FMoffset->index(progStatus.offset_2);
6669 FMoff_freq->value(progStatus.oF_2 );
6670 break; // 2 meters
6671 case 12:choice_FT8n_tTONE->value(progStatus.txT_70);
6672 choice_FT8n_rTONE->value(progStatus.txT_70);
6673 FMoffset->index(progStatus.offset_70);
6674 FMoff_freq->value(progStatus.oF_70 );
6675 progStatus.m70 = vfo->imode;
6676 break; // 70 cent'
6677 }
6678 }
6679
cbBandSelect(int band)6680 void cbBandSelect(int band)
6681 {
6682 guard_lock gl_serial(&mutex_serial);
6683
6684 if (xcvr_name == rig_FT857D.name_ || xcvr_name == rig_FT897D.name_ ) {
6685 if (Fl::event_button() == FL_LEFT_MOUSE) {
6686 selrig->set_band_selection(band);
6687 updateCTCSS(band);
6688 if (band > 8) { // 10, 6, 2, 70, 1.2G
6689 int tTONE = PL_tones[choice_FT8n_tTONE->value()];
6690 int rTONE = PL_tones[choice_FT8n_rTONE->value()];
6691 selrig->set_tones(tTONE, rTONE);
6692 selrig->set_offset(FMoffset->index(), FMoff_freq->value());
6693 }
6694 } else if (Fl::event_button() == FL_RIGHT_MOUSE)
6695 set_band(band);
6696 return;
6697 }
6698
6699 if (Fl::event_button() == FL_RIGHT_MOUSE) {
6700 selrig->rTONE = choice_rTONE->value();
6701 selrig->tTONE = choice_tTONE->value();
6702 selrig->set_band_selection(band);
6703 return;
6704 }
6705
6706 selrig->get_band_selection(band);
6707
6708 // get freqmdbw
6709 if (!useB) {
6710 vfoA.freq = selrig->get_vfoA();
6711 if (selrig->has_mode_control)
6712 vfoA.imode = selrig->get_modeA();
6713 if (selrig->has_bandwidth_control) {
6714 selrig->adjust_bandwidth(vfoA.imode);
6715 vfoA.iBW = selrig->get_bwA();
6716 }
6717 vfo = &vfoA;
6718 } else {
6719 vfoB.freq = selrig->get_vfoB();
6720 if (selrig->has_mode_control)
6721 vfoB.imode = selrig->get_modeB();
6722 if (selrig->has_bandwidth_control) {
6723 selrig->adjust_bandwidth(vfoB.imode);
6724 vfoB.iBW = selrig->get_bwB();
6725 }
6726 vfo = &vfoB;
6727 }
6728 // local display freqmdbw
6729 if (selrig->has_mode_control) {
6730 setModeControl(NULL);
6731 }
6732 if (selrig->has_bandwidth_control) {
6733 set_bandwidth_control();
6734 setBWControl(NULL);
6735 }
6736 if (!useB) { FreqDispA->value(vfo->freq); FreqDispA->redraw(); }
6737 else { FreqDispB->value(vfo->freq); FreqDispB->redraw(); }
6738
6739 if (selrig->CIV && (selrig->name_ != rig_IC7200.name_)) {
6740 choice_tTONE->value(selrig->tTONE);
6741 choice_tTONE->redraw();
6742 choice_rTONE->value(selrig->rTONE);
6743 choice_rTONE->redraw();
6744 }
6745
6746 }
6747
enable_yaesu_bandselect(int btn_num,bool enable)6748 void enable_yaesu_bandselect(int btn_num, bool enable)
6749 {
6750 switch (btn_num) {
6751 case 1:
6752 case 9:
6753 break;
6754 case 10: // 6m
6755 if (enable) btn_yaesu_select_10->show();
6756 else btn_yaesu_select_10->hide();
6757 break;
6758 case 11: // GEN
6759 if (enable) btn_yaesu_select_11->show();
6760 else btn_yaesu_select_11->hide();
6761 break;
6762 case 13:
6763 if (enable) op_yaesu_select60->show();
6764 else op_yaesu_select60->hide();
6765 break;
6766 default:
6767 break;
6768 }
6769 }
6770
6771 // trim leading and trailing whitspace and double quote
lt_trim(const string & pString,const string & pWhitespace)6772 const string lt_trim(const string& pString, const string& pWhitespace)
6773 {
6774 size_t beginStr, endStr, range;
6775 beginStr = pString.find_first_not_of(pWhitespace);
6776 if (beginStr == string::npos) return ""; // no content
6777 endStr = pString.find_last_not_of(pWhitespace);
6778 range = endStr - beginStr + 1;
6779
6780 return pString.substr(beginStr, range);
6781 }
6782
editAlphaTag()6783 void editAlphaTag()
6784 {
6785 int indx;
6786 string atag;
6787 if (FreqSelect->value() < 1) {
6788 inAlphaTag->value("");
6789 return; // no memory selected
6790 }
6791 indx = FreqSelect->value() - 1;
6792 atag = inAlphaTag->value();
6793 // delete leading, trailing spaces
6794 atag = lt_trim(atag);
6795 memset(oplist[indx].alpha_tag, 0, ATAGSIZE);
6796 snprintf(oplist[indx].alpha_tag, ATAGSIZE, "%s", atag.c_str());
6797 // update browser list
6798 updateSelect();
6799 FreqSelect->value(indx + 1);
6800 inAlphaTag->value(oplist[indx].alpha_tag);
6801 }
6802
6803