diff --git a/src/UI/rigpanel.cxx b/src/UI/rigpanel.cxx index 4e763645..53716f5b 100644 --- a/src/UI/rigpanel.cxx +++ b/src/UI/rigpanel.cxx @@ -265,8 +265,8 @@ Fl_ComboBox *opBW = (Fl_ComboBox *)0; Fl_ComboBox *opDSP_lo = (Fl_ComboBox *)0; Fl_ComboBox *opCENTER = (Fl_ComboBox *)0; -Fl_Counter *opBW_A = (Fl_Counter *)0; -Fl_Counter *opBW_B = (Fl_Counter *)0; +Fl_ComboBox *opBW_A = (Fl_ComboBox *)0; //(Fl_Counter *)0; +Fl_ComboBox *opBW_B = (Fl_ComboBox *)0; //(Fl_Counter *)0; Fl_Counter *opFilterInner = (Fl_Counter *)0; Fl_Counter *opFilterOuter = (Fl_Counter *)0; diff --git a/src/UI/ui_small.cxx b/src/UI/ui_small.cxx index 26f9a356..dcb7de51 100644 --- a/src/UI/ui_small.cxx +++ b/src/UI/ui_small.cxx @@ -409,7 +409,7 @@ CTRL click: FreqB -> FreqA\ btnCENTER->tooltip(_("Center/Wid")); btnCENTER->hide(); - opBW = new Fl_ComboBox(212, 84, 105, 18, _("Bandwidth")); + opBW = new Fl_ComboBox(212, 84, 105, 18, ""); opBW->tooltip(_("Select Transceiver Bandwidth")); opBW->box(FL_NO_BOX); opBW->color(FL_BACKGROUND2_COLOR); @@ -424,6 +424,38 @@ CTRL click: FreqB -> FreqA\ opBW->readonly(); opBW->end(); + opBW_A = new Fl_ComboBox(212, 84, 86, 18, ""); + opBW_A->tooltip("BW vfoA"); + opBW_A->box(FL_NO_BOX); + opBW_A->color(FL_BACKGROUND2_COLOR); + opBW_A->selection_color(FL_BACKGROUND_COLOR); + opBW_A->labeltype(FL_NORMAL_LABEL); + opBW_A->labelfont(0); + opBW_A->labelsize(12); + opBW_A->labelcolor(FL_FOREGROUND_COLOR); + opBW_A->callback((Fl_Callback*)cb_opBW); + opBW_A->align(Fl_Align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE)); + opBW_A->when(FL_WHEN_RELEASE); + opBW_A->readonly(); + opBW_A->hide(); + opBW_A->end(); + + opBW_B = new Fl_ComboBox(212, 84, 86, 18, ""); + opBW_B->tooltip("BW vfoB"); + opBW_B->box(FL_NO_BOX); + opBW_B->color(FL_BACKGROUND2_COLOR); + opBW_B->selection_color(FL_BACKGROUND_COLOR); + opBW_B->labeltype(FL_NORMAL_LABEL); + opBW_B->labelfont(0); + opBW_B->labelsize(12); + opBW_B->labelcolor(FL_FOREGROUND_COLOR); + opBW_B->callback((Fl_Callback*)cb_opBW); + opBW_B->align(Fl_Align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE)); + opBW_B->when(FL_WHEN_RELEASE); + opBW_B->readonly(); + opBW_B->hide(); + opBW_B->end(); + opCENTER = new Fl_ComboBox(231, 84, 86, 18, ""); opCENTER->tooltip(_("Center Frequency")); opCENTER->box(FL_FLAT_BOX); @@ -499,24 +531,6 @@ CTRL click: FreqB -> FreqA\ opFilterOuter->tooltip("Outer cutoff"); opFilterOuter->hide(); - opBW_A = new Fl_Counter(231, 84, 86, 18, ""); - opBW_A->minimum(50); - opBW_A->maximum(4000); - opBW_A->step(10); - opBW_A->lstep(100); - opBW_A->align(Fl_Align(FL_ALIGN_INSIDE)); - opBW_A->tooltip("BW vfoA"); - opBW_A->hide(); - - opBW_B = new Fl_Counter(231, 84, 86, 18, ""); - opBW_B->minimum(50); - opBW_B->maximum(4000); - opBW_B->step(10); - opBW_B->lstep(100); - opBW_B->align(Fl_Align(FL_ALIGN_INSIDE)); - opBW_B->tooltip("BW vfoB"); - opBW_B->hide(); - opMODE = new Fl_ComboBox(318, 84, 105, 18, _("Mode")); opMODE->tooltip(_("Select transceiver operating mode")); opMODE->box(FL_NO_BOX); diff --git a/src/UI/ui_touch.cxx b/src/UI/ui_touch.cxx index 3b5eeb6e..c9e982cb 100644 --- a/src/UI/ui_touch.cxx +++ b/src/UI/ui_touch.cxx @@ -423,22 +423,16 @@ Fl_Group *touch_main_group(int X, int Y, int W, int H) opFilterOuter->tooltip("Outer cutoff"); opFilterOuter->hide(); - opBW_A = new Fl_Counter(xpos+30, ypos, opBW->w() - 30, 35, _("BW vfoA")); - opBW_A->minimum(50); - opBW_A->maximum(4000); - opBW_A->step(10); - opBW_A->lstep(100); - opBW_A->align(Fl_Align(FL_ALIGN_LEFT)); + opBW_A = new Fl_ComboBox(xpos+30, ypos, opBW->w() - 30, 35, _("BW vfoA")); opBW_A->tooltip("BW vfoA"); + opBW_A->align(Fl_Align(FL_ALIGN_LEFT)); + opBW_A->end(); opBW_A->hide(); - opBW_B = new Fl_Counter(xpos+30, ypos, opBW->w() - 30, 35, _("BW vfoB")); - opBW_B->minimum(50); - opBW_B->maximum(4000); - opBW_B->step(10); - opBW_B->lstep(100); + opBW_B = new Fl_ComboBox(xpos+30, ypos, opBW->w() - 30, 35, _("BW vfoB")); opBW_B->align(Fl_Align(FL_ALIGN_LEFT)); opBW_B->tooltip("Bw vfoB"); + opBW_B->end(); opBW_B->hide(); grpcombos->end(); diff --git a/src/UI/ui_wide.cxx b/src/UI/ui_wide.cxx index 682d185b..aa4228b3 100644 --- a/src/UI/ui_wide.cxx +++ b/src/UI/ui_wide.cxx @@ -424,22 +424,16 @@ Fl_Group *wide_main_group(int X, int Y, int W, int H) opFilterOuter->tooltip("Outer cutoff"); opFilterOuter->hide(); - opBW_A = new Fl_Counter(xpos + 20, ypos, w1a - 20, 20, _("BW vfoA")); - opBW_A->minimum(50); - opBW_A->maximum(4000); - opBW_A->step(10); - opBW_A->lstep(100); + opBW_A = new Fl_ComboBox(xpos + 20, ypos, w1a - 20, 20, _("BW vfoA")); opBW_A->align(Fl_Align(FL_ALIGN_LEFT)); opBW_A->tooltip("BW vfoA"); + opBW_A->end(); opBW_A->hide(); - opBW_B = new Fl_Counter(xpos + 20, ypos, w1a - 20, 20, _("BW vfoB")); - opBW_B->minimum(50); - opBW_B->maximum(4000); - opBW_B->step(10); - opBW_B->lstep(100); + opBW_B = new Fl_ComboBox(xpos + 20, ypos, w1a - 20, 20, _("BW vfoB")); opBW_B->align(Fl_Align(FL_ALIGN_LEFT)); opBW_B->tooltip("BW vfoB"); + opBW_B->end(); opBW_B->hide(); opMODE = new Fl_ComboBox( diff --git a/src/include/rigbase.h b/src/include/rigbase.h index c93b58ab..b41eb34a 100644 --- a/src/include/rigbase.h +++ b/src/include/rigbase.h @@ -253,7 +253,6 @@ public: bool has_volume_control; bool has_mode_control; bool has_bandwidth_control; - bool has_int_bandwidth_control; bool has_dsp_controls; bool has_FILTER; bool has_micgain_control; diff --git a/src/include/rigpanel.h b/src/include/rigpanel.h index fed39eff..0c26c2a6 100644 --- a/src/include/rigpanel.h +++ b/src/include/rigpanel.h @@ -114,8 +114,8 @@ extern Fl_Group *grp_row1a; extern Fl_ComboBox *opCENTER; extern Fl_ComboBox *opBW; -extern Fl_Counter *opBW_A; -extern Fl_Counter *opBW_B; +extern Fl_ComboBox *opBW_A; +extern Fl_ComboBox *opBW_B; extern Fl_Button *btnDSP; extern Fl_ComboBox *opDSP_lo; diff --git a/src/rigs/elecraft/K3.cxx b/src/rigs/elecraft/K3.cxx index 5dbfd65a..2e01f6c9 100644 --- a/src/rigs/elecraft/K3.cxx +++ b/src/rigs/elecraft/K3.cxx @@ -94,8 +94,7 @@ RIG_K3::RIG_K3() { has_split_AB = has_micgain_control = has_rf_control = -// has_bandwidth_control = - has_int_bandwidth_control = + has_bandwidth_control = has_power_control = has_volume_control = has_mode_control = @@ -626,8 +625,12 @@ int RIG_K3::get_noise() void RIG_K3::set_bwA(int val) { char command[10]; - short bw = val; - if (bw > 4000) bw = 4000; + short bw = 0; + try { + sscanf(K3_widths.at(val).c_str(), "%hd", &bw); + } catch (...) { + bw = 1800; + } snprintf(command, sizeof(command), "BW%04d;", (bw/10)); cmd = command; @@ -642,19 +645,29 @@ int RIG_K3::get_bwA() { cmd = "BW;"; get_trace(1, "get bwA val"); - wait_char(';', 7, KX3_WAIT_TIME, "get bwA val", ASC); + wait_char(';', 7, K3_WAIT_TIME, "get bwA val", ASC); gett(""); - int bw = bwA / 10; + int bw = 0; //atol(bwA); sscanf(replystr.c_str(), "BW%d", &bw); bw *= 10; - return bwA = bw; + int n = 0; + try { + while (atol(K3_widths.at(n).c_str()) < bw) n++; + } catch (...) { + n = 0; + } + return bwA = n;// bw; } void RIG_K3::set_bwB(int val) { char command[10]; - short bw = val; - if (bw > 4000) bw = 4000; + short bw = 0; + try { + sscanf(K3_widths.at(val).c_str(), "%hd", &bw); + } catch (...) { + bw = 1800; + } snprintf(command, sizeof(command), "BW$%04d;", (bw/10)); cmd = command; @@ -669,12 +682,18 @@ int RIG_K3::get_bwB() { cmd = "BW$;"; get_trace(1, "get bwB val"); - wait_char(';', 7, KX3_WAIT_TIME, "get bwB val", ASC); + wait_char(';', 7, K3_WAIT_TIME, "get bwB val", ASC); gett(""); - int bw = bwB /10; + int bw = 0; //atol(bwA); sscanf(replystr.c_str(), "BW$%d", &bw); bw *= 10; - return bwB = bw; + int n = 0; + try { + while (atol(K3_widths.at(n).c_str()) < bw) n++; + } catch (...) { + n = 0; + } + return bwB = n;// bw; } int RIG_K3::get_power_out() diff --git a/src/rigs/elecraft/K4.cxx b/src/rigs/elecraft/K4.cxx index a516ee68..fc96d9dd 100644 --- a/src/rigs/elecraft/K4.cxx +++ b/src/rigs/elecraft/K4.cxx @@ -35,23 +35,13 @@ static const char K4_mode_type[] = { 'L', 'U', 'L', 'U', 'U', 'U', 'U', 'L' }; static std::vectorK4_widths; -static const char *vK4_widths[] = { - "50", "100", "150", "200", "250", "300", "350", "400", "450", "500", - "550", "600", "650", "700", "750", "800", "850", "900", "950", "1000", - "1100", "1200", "1300", "1400", "1500", "1600", "1700", "1800", "1900", "2000", - "2200", "2400", "2600", "2800", "3000", "3100", "3200", "3300", "3400", "3500", - "3600", "3700", "3800", "3900", "4000"}; -static int K4_bw_vals[] = { - 1, 2, 3, 4, 5, 6, 7, 8, 9,10, -11,12,13,14,15,16,17,18,19,20, -21,22,23,24,25,26,27,28,29,30, -31,32,33,34,35,36,37,38, 39,40, -41,42,43,44,45, WVALS_LIMIT}; static int mode_bwA[] = { -1, -1, -1, -1, -1, -1, -1, -1 }; static int mode_bwB[] = { -1, -1, -1, -1, -1, -1, -1, -1 }; -static int mode_def_bw[] = { 2800, 2800, 800, 3600, 3600, 2800, 800, 2800 }; +// entry # = (FREQ - 50)/10; FREQ: 50...5000, #: 0...495 +static int mode_def_bw[] = { 275, 275, 75, 495, 395, 275, 75, 275 }; + static GUI k4_widgets[]= { { (Fl_Widget *)btnVol, 2, 125, 50 }, { (Fl_Widget *)sldrVOLUME, 54, 125, 156 }, @@ -78,7 +68,6 @@ RIG_K4::RIG_K4() { name_ = K4name_; modes_ = K4modes_; bandwidths_ = K4_widths; - bw_vals_ = K4_bw_vals; serial_baudrate = BR38400; @@ -107,8 +96,7 @@ RIG_K4::RIG_K4() { has_split_AB = true; has_micgain_control = has_rf_control = true; -// has_bandwidth_control = - has_int_bandwidth_control = + has_bandwidth_control = has_power_control = true; has_volume_control = has_mode_control = @@ -139,14 +127,22 @@ RIG_K4::RIG_K4() { int RIG_K4::adjust_bandwidth(int m) { - int width = (inuse == onA ? mode_bwA[m] : mode_bwB[m]); - if (width == -1) - return mode_def_bw[m]; - return width; + return def_bandwidth(m); } int RIG_K4::def_bandwidth(int m) { +/* +std::cout << vK4modes_[0] << ":" << mode_bwA[0] << ":" << mode_bwB[0] << ", " << + vK4modes_[1] << ":" << mode_bwA[1] << ":" << mode_bwB[1] << ", " << + vK4modes_[2] << ":" << mode_bwA[2] << ":" << mode_bwB[2] << ", " << + vK4modes_[3] << ":" << mode_bwA[3] << ":" << mode_bwB[3] << ", " << + vK4modes_[4] << ":" << mode_bwA[4] << ":" << mode_bwB[4] << ", " << + vK4modes_[5] << ":" << mode_bwA[5] << ":" << mode_bwB[5] << ", " << + vK4modes_[6] << ":" << mode_bwA[6] << ":" << mode_bwB[6] << ", " << + vK4modes_[7] << ":" << mode_bwA[7] << ":" << mode_bwB[7] << std::endl; +*/ + if (m < 0 || m > 7) return 0; int width = (inuse == onA ? mode_bwA[m] : mode_bwB[m]); if (width == -1) return mode_def_bw[m]; @@ -154,15 +150,21 @@ int RIG_K4::def_bandwidth(int m) } #define K4_WAIT_TIME 800 +#define VECTOR(a,b) { a.clear(); for (size_t n = 0; n < sizeof(b)/sizeof(*b); n++) {a.push_back(b[n]);} } void RIG_K4::initialize() { VECTOR (K4modes_, vK4modes_); - VECTOR (K4_widths, vK4_widths); + + char width[10]; + K4_widths.clear(); + for (int n = 50; n <= 5000; n += 10) { + snprintf(width, sizeof(width), "%d", n); + K4_widths.push_back(width); + } modes_ = K4modes_; bandwidths_ = K4_widths; - bw_vals_ = K4_bw_vals; LOG_INFO("K4"); k4_widgets[0].W = btnVol; @@ -491,11 +493,11 @@ int RIG_K4::get_modeA() gett(""); size_t p = replystr.rfind("MD"); - if (replystr[p+2] == '0' || replystr[p+2] == '8') return modeA; +// if (replystr[p+2] == '0' || replystr[p+2] == '8') return modeA; if (p == std::string::npos) return modeA; int md = replystr[p + 2] - '1'; - if (md == 8) md--; + if (md < 0 || md > 7) return modeA; if (md != modeA) set_pbt_values(md); return (modeA = md); } @@ -520,11 +522,11 @@ int RIG_K4::get_modeB() gett(""); size_t p = replystr.rfind("MD$"); - if (replystr[p+3] == '0' || replystr[p+3] == '8') return modeB; +// if (replystr[p+3] == '0' || replystr[p+3] == '8') return modeB; if (p == std::string::npos) return modeB; int md = replystr[p + 3] - '1'; - if (md == 8) md--; + if (md < 0 || md > 7) return modeA; if (md != modeB) set_pbt_values(md); return (modeB = md); } @@ -534,13 +536,11 @@ int RIG_K4::get_modetype(int n) return K4_mode_type[n]; } -/* -PAn; -n = 0 (off) -n = 1 (10 dB regular preamp) -n = 2 (160-15 m: 18 dB regular preamp; 12-6 m: 20 dB LNA) -n = 3 (12-6 m only: 10 dB regular preamp + 20 dB LNA) -*/ +// SET/RESP format: PA$nm; where n is as shown below, and m is 0 (off) or 1 (on). +// n = 0 (off) +// n = 1 (10 dB regular preamp) +// n = 2 (160-15 m: 18 dB regular preamp; 12-6 m: 20 dB LNA) +// n = 3 (12-6 m only: 10 dB regular preamp + 20 dB LNA) void RIG_K4::set_preamp(int val) { @@ -551,6 +551,9 @@ void RIG_K4::set_preamp(int val) case 0: cmd.append("00;"); break; case 1: cmd.append("11;"); break; case 2: cmd.append("21;"); break; +#ifdef HAVE_LNA + case 3: cmd.append("31;"); break; +#endif } preamp_level = val; sendCommand(cmd); @@ -587,14 +590,14 @@ int RIG_K4::get_preamp() return val; } - +// THIS IS A DO NOTHING METHOD !! void K4_return(int val) { } int RIG_K4::next_attenuator() { - if (atten_level < 8) atten_level++; + if (atten_level < 7) atten_level++; else atten_level = 0; return atten_level; @@ -602,7 +605,11 @@ int RIG_K4::next_attenuator() int RIG_K4::next_preamp() { +#ifdef HAVE_LNA + if (preamp_level < 3) preamp_level++; +#else if (preamp_level < 2) preamp_level++; +#endif else preamp_level = 0; return preamp_level; @@ -613,8 +620,11 @@ const char *RIG_K4::PRE_label() switch (preamp_level) { default: case 0: break; - case 1: return("Pre1"); break; - case 2: return("Pre2"); break; + case 1: return("10 db"); break; + case 2: return("18 db"); break; +#ifdef HAVE_LNA + case 3: return("30 db"); break; +#endif } return("PRE"); } @@ -632,7 +642,7 @@ const char *RIG_K4::ATT_label() case 6: return("18 db"); break; case 7: return("21 db"); break; } - return("OFF"); + return("ATT"); } @@ -646,6 +656,7 @@ void RIG_K4::set_attenuator(int val) if (isOnA()) cmd = "RA"; else cmd = "RA$"; switch (val) { + default: case 0: cmd.append("000;"); break; case 1: cmd.append("031;");break; case 2: cmd.append("061;"); break; @@ -654,18 +665,15 @@ void RIG_K4::set_attenuator(int val) case 5: cmd.append("151;"); break; case 6: cmd.append("181;"); break; case 7: cmd.append("211;"); break; - case 8: cmd.append("000;"); break; } set_trace(1, "set attenuator"); sendCommand(cmd); sett(""); - K4_return(val); } int RIG_K4::get_attenuator() { - int val; - + std::string valstr; if (isOnA()) { cmd = "RA;"; get_trace(1, "get attenuator"); @@ -674,7 +682,7 @@ int RIG_K4::get_attenuator() size_t p = replystr.rfind("RA"); if (p == std::string::npos) return 0; - val = (replystr[p+2] - '0')*10 + replystr[p+3] - '0'; + valstr = replystr.substr(p + 2, 2); } else { cmd = "RA$;"; get_trace(1, "get attenuator"); @@ -683,23 +691,18 @@ int RIG_K4::get_attenuator() size_t p = replystr.rfind("RA$"); if (p == std::string::npos) return 0; - val = (replystr[p+3] - '0')*10 + replystr[p+3] - '0'; + valstr = replystr.substr(p + 3, 2); } - switch (val) { - default: - case 0: atten_level = 0; break; - case 3: atten_level = 1; break; - case 6: atten_level = 2; break; - case 9: atten_level = 3; break; - case 12: atten_level = 4; break; - case 15: atten_level = 5; break; - case 18: atten_level = 6; break; - case 21: atten_level = 7; break; - } - - K4_return(atten_level); - return atten_level; + if (valstr == "03") return 1; + if (valstr == "06") return 2; + if (valstr == "09") return 3; + if (valstr == "12") return 4; + if (valstr == "15") return 5; + if (valstr == "18") return 6; + if (valstr == "21") return 7; + + return 0; } // Transceiver power level @@ -942,8 +945,12 @@ int RIG_K4::get_noise() void RIG_K4::set_bwA(int val) { char command[10]; - short bw = val; - if (bw > 4000) bw = 4000; + short bw = 0; + try { + sscanf(K4_widths.at(val).c_str(), "%hd", &bw); + } catch (...) { + bw = 1800; + } snprintf(command, sizeof(command), "BW%04d;", (bw/10)); cmd = command; @@ -958,19 +965,29 @@ int RIG_K4::get_bwA() { cmd = "BW;"; get_trace(1, "get bwA val"); - wait_char(';', 7, KX3_WAIT_TIME, "get bwA val", ASC); + wait_char(';', 7, K4_WAIT_TIME, "get bwA val", ASC); gett(""); - int bw = bwA / 10; + int bw = 0; sscanf(replystr.c_str(), "BW%d", &bw); bw *= 10; - return bwA = bw; + int n = 0; + try { + while (atol(K4_widths.at(n).c_str()) < bw) n++; + } catch (...) { + n = 0; + } + return bwA = n; } void RIG_K4::set_bwB(int val) { char command[10]; - short bw = val; - if (bw > 4000) bw = 4000; + short bw = 0; + try { + sscanf(K4_widths.at(val).c_str(), "%hd", &bw); + } catch (...) { + bw = 1800; + } snprintf(command, sizeof(command), "BW$%04d;", (bw/10)); cmd = command; @@ -985,12 +1002,18 @@ int RIG_K4::get_bwB() { cmd = "BW$;"; get_trace(1, "get bwB val"); - wait_char(';', 7, KX3_WAIT_TIME, "get bwB val", ASC); + wait_char(';', 7, K4_WAIT_TIME, "get bwB val", ASC); gett(""); - int bw = bwB /10; + int bw = 0; sscanf(replystr.c_str(), "BW$%d", &bw); bw *= 10; - return bwB = bw; + int n = 0; + try { + while (atol(K4_widths.at(n).c_str()) < bw) n++; + } catch (...) { + n = 0; + } + return bwB = n; } int RIG_K4::get_power_out() diff --git a/src/rigs/elecraft/KX3.cxx b/src/rigs/elecraft/KX3.cxx index 88e42638..95f236b3 100644 --- a/src/rigs/elecraft/KX3.cxx +++ b/src/rigs/elecraft/KX3.cxx @@ -40,22 +40,42 @@ static const char KX3_mode_type[] = static std::vectorKX3_widths; static const char *vKX3_widths[] = { - "50", "100", "150", "200", "250", "300", "350", "400", "450", "500", - "550", "600", "650", "700", "750", "800", "850", "900", "950", "1000", - "1100", "1200", "1300", "1400", "1500", "1600", "1700", "1800", "1900", "2000", - "2100", "2200", "2300", "2400", "2500", "2600", "2700", "2800", "2900", "3000", - "3200", "3400", "3600", "3800", "4000"}; + "50", "60", "70", "80", "90", + "100", "110", "120", "130", "140", "150", "160", "170", "180", "190", + "200", "210", "220", "230", "240", "250", "260", "270", "280", "290", + "300", "310", "220", "330", "340", "350", "360", "370", "380", "390", + "400", "410", "220", "430", "440", "450", "460", "470", "480", "490", + "500", "510", "220", "530", "540", "550", "560", "570", "580", "590", + "600", "610", "220", "630", "640", "650", "660", "670", "680", "690", + "700", "710", "220", "730", "740", "750", "760", "770", "780", "790", + "800", "810", "220", "830", "840", "850", "860", "870", "880", "890", + "900", "910", "220", "930", "940", "950", "960", "970", "980", "990", + "1000", "1100", "1200", "1300", "1400", "1500", "1600", "1700", "1800", "1900", + "2000", "2100", "2200", "2300", "2400", "2500", "2600", "2700", "2800", "2900", + "3000", "3100", "3200", "3300", "3400", "3500", "3600", "3700", "3800", "3900", + "4000"}; -static int KX3_bw_vals[] = { - 1, 2, 3, 4, 5, 6, 7, 8, 9,10, -11,12,13,14,15,16,17,18,19,20, -21,22,23,24,25,26,27,28,29,30, -31,32,33,34,35,36,37,38,39,40, -41,42,43,44,45, WVALS_LIMIT}; +static int KX3_bw_vals[] = { + 1, 2, 3, 4, 5, // 50 + 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // 100 + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, // 200 + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, // 300 + 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, // 400 + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, // 500 + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, // 600 + 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, // 700 + 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, // 800 + 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, // 900 + 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, // 1000 + 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, // 2000 + 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, // 3000 + 126, WVALS_LIMIT }; // 4000 static int mode_bwA[] = { -1, -1, -1, -1, -1, -1, -1, -1 }; static int mode_bwB[] = { -1, -1, -1, -1, -1, -1, -1, -1 }; -static int mode_def_bw[] = { 2800, 2800, 800, 3600, 3600, 2800, 800, 2800 }; + +// { 2800, 2800, 800, 3600, 3600, 2800, 800, 2800 }; +static int mode_def_bw[] = { 114, 114, 76, 122, 122, 114, 76, 114 }; static int ret = 0; @@ -100,8 +120,7 @@ RIG_KX3::RIG_KX3() { has_split_AB = has_micgain_control = has_rf_control = -// has_bandwidth_control = - has_int_bandwidth_control = + has_bandwidth_control = has_power_control = has_volume_control = has_mode_control = @@ -918,8 +937,12 @@ int RIG_KX3::get_noise() void RIG_KX3::set_bwA(int val) { char command[10]; - short bw = val; - if (bw > 4000) bw = 4000; + short bw = 0; + try { + sscanf(KX3_widths.at(val).c_str(), "%hd", &bw); + } catch (...) { + bw = 1800; + } snprintf(command, sizeof(command), "BW%04d;", (bw/10)); cmd = command; @@ -934,19 +957,29 @@ int RIG_KX3::get_bwA() { cmd = "BW;"; get_trace(1, "get bwA val"); - ret = wait_char(';', 7, KX3_WAIT_TIME, "get bwA val", ASC); + wait_char(';', 7, KX3_WAIT_TIME, "get bwA val", ASC); gett(""); - if (ret < 7) return bwA; - int bw = bwA / 10; - if (sscanf(replystr.c_str(), "BW%d", &bw) != 1) return bwA; - return bwA = bw * 10; + int bw = 0; //atol(bwA); + sscanf(replystr.c_str(), "BW%d", &bw); + bw *= 10; + int n = 0; + try { + while (atol(KX3_widths.at(n).c_str()) < bw) n++; + } catch (...) { + n = 0; + } + return bwA = n;// bw; } void RIG_KX3::set_bwB(int val) { char command[10]; - short bw = val; - if (bw > 4000) bw = 4000; + short bw = 0; + try { + sscanf(KX3_widths.at(val).c_str(), "%hd", &bw); + } catch (...) { + bw = 1800; + } snprintf(command, sizeof(command), "BW$%04d;", (bw/10)); cmd = command; @@ -961,12 +994,18 @@ int RIG_KX3::get_bwB() { cmd = "BW$;"; get_trace(1, "get bwB val"); - ret = wait_char(';', 7, KX3_WAIT_TIME, "get bwB val", ASC); + wait_char(';', 7, KX3_WAIT_TIME, "get bwB val", ASC); gett(""); - if (ret < 7) return bwB; - int bw = bwB /10; - if (sscanf(replystr.c_str(), "BW$%d", &bw) != 1) return bwB; - return bwB = bw * 10; + int bw = 0; //atol(bwA); + sscanf(replystr.c_str(), "BW$%d", &bw); + bw *= 10; + int n = 0; + try { + while (atol(KX3_widths.at(n).c_str()) < bw) n++; + } catch (...) { + n = 0; + } + return bwB = n;// bw; } bool RIG_KX3::can_split() diff --git a/src/rigs/rigbase.cxx b/src/rigs/rigbase.cxx index 49957464..b97a3a6c 100644 --- a/src/rigs/rigbase.cxx +++ b/src/rigs/rigbase.cxx @@ -93,7 +93,6 @@ rigbase::rigbase() has_volume_control = has_mode_control = has_bandwidth_control = - has_int_bandwidth_control = has_dsp_controls = has_micgain_control = has_mic_line_control = diff --git a/src/server/xml_server.cxx b/src/server/xml_server.cxx index d8643cdd..6b4538ed 100644 --- a/src/server/xml_server.cxx +++ b/src/server/xml_server.cxx @@ -1051,15 +1051,6 @@ public : std::vector& dsplo = selrig->lotable(mode); std::vector& dsphi = selrig->hitable(mode); - // single bandwidth table - if (!selrig->has_dsp_controls) { - bws[0][0] = "Bandwidth"; - int n = 1; - for (size_t i = 0; i < bwt.size(); i++) { - if (!bwt.at(i).empty()) - bws[0][n++] = bwt.at(i); - } - } // double table either lo/hi or center/width if (selrig->has_dsp_controls) { int n = 1; @@ -1079,6 +1070,15 @@ public : bws[1][n++] = dsphi[i]; } } + // single bandwidth table + else { + bws[0][0] = "Bandwidth"; + int n = 1; + for (size_t i = 0; i < bwt.size(); i++) { + if (!bwt.at(i).empty()) + bws[0][n++] = bwt.at(i); + } + } } catch (const std::exception& e) { LOG_ERROR("%s", e.what()); } @@ -1114,14 +1114,6 @@ public: guard_lock service_lock(&mutex_srvc_reqs, "xml rig_get_bw"); guard_lock serial_lock(&mutex_serial, "xml rig_get_bw"); - if (selrig->has_int_bandwidth_control) { - char reply[10]; - snprintf(reply, sizeof(reply), "%d", BW); - result[0] = reply; - std::string s1 = result[0], s2 = result[1]; - xml_trace( 5, "bandwidth on ", ((selrig->inuse == onB) ? "B " : "A "), s1.c_str(), " | ", s2.c_str()); - return; - } if (!selrig->has_bandwidth_control) return; @@ -1172,15 +1164,6 @@ public: guard_lock service_lock(&mutex_srvc_reqs, "xml rig_get_bwA"); guard_lock serial_lock(&mutex_serial, "xml rig_get_bwA"); - if (selrig->has_int_bandwidth_control) { - char reply[10]; - snprintf(reply, sizeof(reply), "%d", BW); - result[0] = reply; - std::string s1 = result[0], s2 = result[1]; - xml_trace( 4, "bandwidth on A", s1.c_str(), " | ", s2.c_str()); - return; - } - if (!selrig->has_bandwidth_control) return; @@ -1233,14 +1216,6 @@ public: guard_lock service_lock(&mutex_srvc_reqs, "xml rig_get_bwB"); guard_lock serial_lock(&mutex_serial, "xml rig_get_bwB"); - if (selrig->has_int_bandwidth_control) { - char reply[10]; - snprintf(reply, sizeof(reply), "%d", BW); - result[0] = reply; - std::string s1 = result[0], s2 = result[1]; - xml_trace( 4, "bandwidth on B", s1.c_str(), " | ", s2.c_str()); - return; - } if (!selrig->has_bandwidth_control) return; @@ -2592,6 +2567,22 @@ public: //------------------------------------------------------------------------------ // Set bandwidth //------------------------------------------------------------------------------ +int int_bw; +extern void cb_bw_A(Fl_ComboBox *, void *); +extern void cb_bw_B(Fl_ComboBox *, void *); + +void exec_set_int_bw(void *) +{ + if (selrig->inuse == onA) { + opBW_A->index(int_bw); + opBW_A->redraw(); + cb_bw_A((Fl_ComboBox *)0, (void*)0); + } else { + opBW_B->index(int_bw); + opBW_B->redraw(); + cb_bw_B((Fl_ComboBox *)0, (void*)0); + } +} class rig_set_bandwidth : public XmlRpcServerMethod { public: @@ -2609,31 +2600,20 @@ public: XCVR_STATE nuvals; - if (selrig->has_int_bandwidth_control) { - - int bwmod = bw % 10; - bw /= 10; - if (bwmod >= 5) ++bw; - bw *= 10; - if (bw < 50) bw = 50; - if (bw > 4000) bw = 4000; - nuvals.iBW = bw; - - } else { - try { - size_t i = 0; - for (i = 0; i < selrig->bandwidths_.size(); i++) - if (atol (selrig->bandwidths_.at(i).c_str()) > bw) break; - if (--i < 0) i = 0; - bw = atol(selrig->bandwidths_.at(i).c_str()); - nuvals.iBW = i; - std::ostringstream s; - s << "nearest bandwidth " << selrig->bandwidths_[i]; - xml_trace(2,"Set to ", s.str().c_str()); - } catch (const std::exception& e) { - LOG_ERROR("%s", e.what()); - } + try { + size_t i = 0; + for (i = 0; i < selrig->bandwidths_.size(); i++) + if (atol (selrig->bandwidths_.at(i).c_str()) > bw) break; + if (--i < 0) i = 0; + bw = atol(selrig->bandwidths_.at(i).c_str()); + nuvals.iBW = i; + std::ostringstream s; + s << "nearest bandwidth " << selrig->bandwidths_[i]; + xml_trace(2,"Set to ", s.str().c_str()); + } catch (const std::exception& e) { + LOG_ERROR("%s", e.what()); } + if (selrig->inuse == onB) { nuvals.freq = vfoB.freq; nuvals.imode = vfoB.imode; @@ -2643,7 +2623,7 @@ public: nuvals.imode = vfoA.imode; serviceA(nuvals); } - + result = 1; } std::string help() { return std::string("set_bw to nearest requested"); } @@ -2665,32 +2645,20 @@ public: XCVR_STATE nuvals; - if (selrig->has_int_bandwidth_control) { - - int bwmod = bw % 10; - bw /= 10; - if (bwmod >= 5) ++bw; - bw *= 10; - if (bw < 50) bw = 50; - if (bw > 4000) bw = 4000; - nuvals.iBW = bw; - - } else { - try { - size_t i = 0; - for (i = 0; i < selrig->bandwidths_.size(); i++) - if (atol (selrig->bandwidths_.at(i).c_str()) > bw) break; - if (--i < 0) i = 0; - bw = atol(selrig->bandwidths_.at(i).c_str()); - nuvals.iBW = i; - std::ostringstream s; - s << "nearest bandwidth " << selrig->bandwidths_.at(i); - xml_trace(2,"Set to ", s.str().c_str()); - } catch (const std::exception& e) { - LOG_ERROR("%s", e.what()); - } - + try { + size_t i = 0; + for (i = 0; i < selrig->bandwidths_.size(); i++) + if (atol (selrig->bandwidths_.at(i).c_str()) > bw) break; + if (--i < 0) i = 0; + bw = atol(selrig->bandwidths_.at(i).c_str()); + nuvals.iBW = i; + std::ostringstream s; + s << "nearest bandwidth " << selrig->bandwidths_.at(i); + xml_trace(2,"Set to ", s.str().c_str()); + } catch (const std::exception& e) { + LOG_ERROR("%s", e.what()); } + int retbw; if (selrig->inuse == onB) { nuvals.freq = vfoB.freq; @@ -2721,16 +2689,17 @@ public: return; } int bw = (int)params[0]; + + XCVR_STATE nuvals; + std::vector& widths = selrig->bandwidths_; if (bw < 0 || bw >= (int) widths.size()) { result = 0; return; } - guard_lock que_lock ( &mutex_srvc_reqs, "xml rig_set_bw" ); guard_lock serial_lock(&mutex_serial, "xml rig_get_bw"); - XCVR_STATE nuvals; nuvals.iBW = bw; if (selrig->inuse == onB) { nuvals.freq = vfoB.freq; @@ -2741,7 +2710,7 @@ public: nuvals.imode = vfoA.imode; serviceA(nuvals); } - + result = 1; } std::string help() { return std::string("set_bw to VAL"); } @@ -2759,6 +2728,8 @@ public: std::string bwstr = params; int bw = (int)params[0]; + XCVR_STATE nuvals; + std::vector& widths = selrig->bandwidths_; if (bw < 0 || bw >= (int) widths.size()) { result = 0; @@ -2768,7 +2739,6 @@ public: guard_lock que_lock ( &mutex_srvc_reqs, "xml rig_set_verify_bw" ); guard_lock serial_lock(&mutex_serial, "xml rig_get_bw"); - XCVR_STATE nuvals; int retbw; nuvals.iBW = bw; if (selrig->inuse == onB) { @@ -2800,18 +2770,17 @@ public: std::string bwstr = params; int bw = (int)params[0]; + XCVR_STATE nuvals; + std::vector& widths = selrig->bandwidths_; if (bw < 0 || bw >= (int) widths.size()) { result = 0; return; } - guard_lock que_lock ( &mutex_srvc_reqs, "xml rig_set_BW" ); guard_lock serial_lock(&mutex_serial, "xml rig_get_BW"); - - XCVR_STATE nuvals; if (selrig->inuse == onB) { - nuvals.freq = vfoB.freq; + nuvals.freq = vfoB.freq; nuvals.imode = vfoB.imode; nuvals.iBW = bw; serviceB(nuvals); @@ -2821,7 +2790,6 @@ public: nuvals.iBW = bw; serviceA(nuvals); } - result = 1; } std::string help() { return std::string("set_bw to VAL"); } @@ -2840,16 +2808,15 @@ public: std::string bwstr = params; int bw = (int)params[0]; + XCVR_STATE nuvals; + std::vector& widths = selrig->bandwidths_; if (bw < 0 || bw >= (int) widths.size()) { result = 0; return; } - guard_lock que_lock ( &mutex_srvc_reqs, "xml rig_set_BW" ); guard_lock serial_lock(&mutex_serial, "xml rig_get_BW"); - - XCVR_STATE nuvals; int retbw; nuvals.iBW = bw; if (selrig->inuse == onB) { diff --git a/src/support/init_rig.cxx b/src/support/init_rig.cxx index 890f15fd..ef469633 100644 --- a/src/support/init_rig.cxx +++ b/src/support/init_rig.cxx @@ -240,24 +240,15 @@ void TRACED(init_generic_rig) opMODE->deactivate(); } - if (xcvr_name == rig_K3.name_ || - xcvr_name == rig_KX3.name_ || + if (xcvr_name == rig_KX3.name_ || xcvr_name == rig_K4.name_) { opBW->hide(); opBW_A->show(); opBW_B->show(); if (progStatus.iBW_A < 1) progStatus.iBW_A = selrig->def_bandwidth(vfoA.imode); if (progStatus.iBW_B < 1) progStatus.iBW_B = selrig->def_bandwidth(vfoB.imode); - if ( (selrig->name_ == rig_K3.name_ && progStatus.iBW_A < 41) || - (selrig->name_ == rig_KX3.name_ && progStatus.iBW_A < 46) || - (selrig->name_ == rig_K4.name_ && progStatus.iBW_A < 46) ) - progStatus.iBW_A = atol(selrig->bandwidths_[progStatus.iBW_A - 1].c_str()); - if ( (selrig->name_ == rig_K3.name_ && progStatus.iBW_B < 41) || - (selrig->name_ == rig_KX3.name_ && progStatus.iBW_B < 46) || - (selrig->name_ == rig_K4.name_ && progStatus.iBW_B < 46) ) - progStatus.iBW_B = atol(selrig->bandwidths_[progStatus.iBW_B - 1].c_str()); - opBW_A->value(selrig->bwA = vfoA.iBW = progStatus.iBW_A); - opBW_B->value(selrig->bwB = vfoB.iBW = progStatus.iBW_B); + opBW_A->index(selrig->bwA = vfoA.iBW = progStatus.iBW_A); + opBW_B->index(selrig->bwB = vfoB.iBW = progStatus.iBW_B); opBW_A->redraw(); opBW_B->redraw(); } diff --git a/src/support/init_user_interface.cxx b/src/support/init_user_interface.cxx index 42b042d8..ff5c34cc 100644 --- a/src/support/init_user_interface.cxx +++ b/src/support/init_user_interface.cxx @@ -1294,17 +1294,6 @@ static void cb_pbt(Fl_Counter *, void *) void TRACED(init_dsp_controls) - if (selrig->has_int_bandwidth_control) { - opBW->hide(); - opDSP_lo->hide(); - opDSP_hi->hide(); - btnDSP->hide(); - btnFILT->hide(); - opBW_A->show(); - opBW_B->show(); - return; - } - if (selrig->has_dsp_controls) { opDSP_lo->clear(); opDSP_hi->clear(); @@ -1318,7 +1307,7 @@ void TRACED(init_dsp_controls) opDSP_hi->add(selrig->dsp_SH.at(i).c_str()); opDSP_hi->tooltip(selrig->SH_tooltip); } catch (const std::exception& e) { - std::cout << e.what() << '\n'; + LOG_ERROR("%s", e.what()); } if (vfo->iBW > 256) { opDSP_lo->index(vfo->iBW & 0xFF); @@ -1338,7 +1327,7 @@ void TRACED(init_dsp_controls) btnFILT->hide(); opBW->show(); } - } else if (selrig->has_FILTER) { // && (xcvr_name != rig_KX3.name_) ) { + } else if (selrig->has_FILTER) { btnDSP->hide(); opDSP_lo->hide(); opDSP_hi->hide(); @@ -1346,7 +1335,7 @@ void TRACED(init_dsp_controls) opBW->resize(opDSP_lo->x(), opDSP_lo->y(), opDSP_lo->w(), opDSP_lo->h()); opBW->redraw(); opBW->show(); - } else { //if ( (xcvr_name != rig_KX3.name_) ){ + } else { btnDSP->hide(); opDSP_lo->hide(); opDSP_hi->hide(); @@ -2273,17 +2262,35 @@ Slider controls TX monitor level"); } } -static void cb_bw_A(Fl_Counter *, void *) +void cb_bw_A(Fl_ComboBox *, void *) { - selrig->set_bwA( opBW_A->value() ); + int nubw = opBW_A->index(); + guard_lock serial(&mutex_serial); + selrig->set_bwA( nubw ); + vfoA.iBW = nubw; +// int timeout = 500; // msec +// while (timeout && (selrig->get_bwA() != nubw)) { +// MilliSleep(50); +// timeout -= 50; +// Fl::awake(); +// } } -static void cb_bw_B(Fl_Counter *, void *) +void cb_bw_B(Fl_ComboBox *, void *) { - selrig->set_bwB( opBW_B->value() ); + int nubw = opBW_B->index(); + guard_lock serial(&mutex_serial); + selrig->set_bwB( nubw ); + vfoB.iBW = nubw; +// int timeout = 500; // msec +// while (timeout && (selrig->get_bwB() != nubw)) { +// MilliSleep(50); +// timeout -= 50; +// Fl::awake(); +// } } -void TRACED(init_K3_KX3_special) +void TRACED(init_elecraft_xcvrs) if (!(xcvr_name == rig_K3.name_ || xcvr_name == rig_KX3.name_ || xcvr_name == rig_K4.name_ ) ) return; @@ -2295,15 +2302,13 @@ void TRACED(init_K3_KX3_special) btn_KX3_swapAB->hide(); btn_K3_swapAB->show(); btn_K3_A2B->show(); - } else if (xcvr_name == rig_KX3.name_) { - btnB->hide(); - btnA->hide(); - btnAswapB->hide(); - btn_K3_swapAB->hide(); - btn_K3_A2B->hide(); - btn_KX3_swapAB->show(); - btn_KX3_A2B->show(); - } else { + opBW_A->hide(); + opBW_B->hide(); + opBW->show(); + return; + } + + if (xcvr_name == rig_KX3.name_ || xcvr_name == rig_K4.name_) { btn_K3_swapAB->hide(); btn_K3_A2B->hide(); btn_KX3_swapAB->hide(); @@ -2312,18 +2317,38 @@ void TRACED(init_K3_KX3_special) btnB->show(); btnA->show(); btnAswapB->show(); - } + opDSP_lo->hide(); + opDSP_hi->hide(); + btnDSP->hide(); + btnFILT->hide(); + opBW->hide(); - if (progStatus.UIsize == small_ui) { - opBW_A->resize(212, 103, 104, 18); - opBW_A->redraw(); - opBW_B->resize(318, 103, 104, 18); - opBW_B->redraw(); + if (progStatus.UIsize == small_ui) { + opBW_A->resize(opBW->x(), opBW->y() + opBW->h(), opBW->w(), opBW->h()); + opBW_A->redraw(); + opBW_B->resize(opMODE->x(), opBW_A->y(), opBW_A->w(), opBW_A->h()); + opBW_B->redraw(); + } + try { + selrig->bandwidths_ = selrig->bwtable(vfo->imode); + for (size_t i = 0; i < selrig->bandwidths_.size(); i++) { + opBW_A->add(selrig->bandwidths_.at(i).c_str()); + opBW_B->add(selrig->bandwidths_.at(i).c_str()); + } + opBW_A->index(vfoA.iBW); + opBW_B->index(vfoB.iBW); + } catch (const std::exception& e) { + LOG_ERROR("%s", e.what()); + opBW_A->index(0); + opBW_B->index(0); + } + opBW_A->callback((Fl_Callback*)cb_bw_A); + opBW_B->callback((Fl_Callback*)cb_bw_B); + + opBW_A->redraw(); opBW_A->show(); + opBW_B->redraw(); opBW_B->show(); + return; } - opBW_A->callback((Fl_Callback*)cb_bw_A); - opBW_A->show(); - opBW_B->callback((Fl_Callback*)cb_bw_B); - opBW_B->show(); } extern void read_menus(); @@ -2500,7 +2525,7 @@ Press 'Init' button.")); selrig->post_initialize(); init_TS990_special(); - init_K3_KX3_special(); + init_elecraft_xcvrs(); if (selrig->has_power_control) { if (progStatus.use_rig_data) @@ -2721,7 +2746,6 @@ void TRACED(initRigCombo) int i = 0; while (rigs[i] != NULL) { selectRig->add(rigs[i]->name_.c_str(), (void*)rigs[i]); -//std::cout << i+1 << " : " << rigs[i]->name_ << std::endl; i++; } diff --git a/src/support/support.cxx b/src/support/support.cxx index 32477a0a..7a3cf679 100644 --- a/src/support/support.cxx +++ b/src/support/support.cxx @@ -159,9 +159,7 @@ std::string printXCVR_STATE(XCVR_STATE data) str << data.freq; str << ", " << selrig->modes_.at(data.imode); - if (selrig->has_int_bandwidth_control) { - str << ", " << data.iBW; - } else if (selrig->has_dsp_controls) { + if (selrig->has_dsp_controls) { std::vector& dsplo = selrig->lotable(data.imode); std::vector& dsphi = selrig->hitable(data.imode); if (data.iBW > 256) { @@ -215,11 +213,7 @@ Data Source: %s\n\ selrig->modes_.at(data.imode).c_str()); prstr.assign(str); str[0] = 0; - if (selrig->has_int_bandwidth_control) { - snprintf(str, sizeof(str), "\ - bandwidth ...... %d\n", - data.iBW); - } else if (selrig->has_FILTER) { + if (selrig->has_FILTER) { snprintf(str, sizeof(str), "\ filter ......... %s\n\ bwt index ...... %2d, [%s] [%s]\n", @@ -489,13 +483,7 @@ void read_mode() } void TRACED(setBWControl, void *) - if (selrig->has_int_bandwidth_control) { - opBW->hide(); - opBW_A->show(); - opBW_B->show(); - return; - } - else if (selrig->has_dsp_controls) { + if (selrig->has_dsp_controls) { if (vfo->iBW > 256) { opBW->hide(); opDSP_hi->index((vfo->iBW >> 8) & 0x7F); @@ -525,43 +513,42 @@ void TRACED(setBWControl, void *) opDSP_lo->hide(); opDSP_hi->hide(); btnDSP->hide(); - if (!( selrig->name_ == rig_tci_sundx.name_ || - selrig->name_ == rig_tci_sunpro.name_ || - selrig->name_ == rig_FLEX1500.name_) ) { + opBW_A->hide(); + opBW_B->hide(); + +// if (!( selrig->name_ == rig_tci_sundx.name_ || +// selrig->name_ == rig_tci_sunpro.name_ || +// selrig->name_ == rig_FLEX1500.name_) ) { opBW->index(vfo->iBW); opBW->show(); opBW->redraw(); - } +// } } } void set_Kx_bandwidths(void *) { - opBW->hide(); - opBW_A->value(vfoA.bw_val); - opBW_B->value(vfoB.bw_val); +// std::cout << printXCVR_STATE(*vfo); + + opBW_A->index(vfoA.iBW); + opBW_B->index(vfoB.iBW); opBW_A->redraw(); opBW_B->redraw(); } void TRACED(read_bandwidth) - if (xcvr_name == rig_K2.name_ || - xcvr_name == rig_K3.name_ || - xcvr_name == rig_KX3.name_ || - xcvr_name == rig_K4.name_) { - int nu_BW; - nu_BW = selrig->get_bwA(); - if (nu_BW != vfoA.iBW) { - vfoA.iBW = vfo->iBW = nu_BW; - Fl::awake(setBWControl); - } - nu_BW = selrig->get_bwB(); - if (nu_BW != vfoB.iBW) { - vfoB.iBW = nu_BW; - } - vfoA.bw_val = selrig->get_bwA(); - vfoB.bw_val = selrig->get_bwB(); + if (xcvr_name == rig_K2.name_ || xcvr_name == rig_K3.name_ ) { + vfoA.iBW = vfo->iBW = selrig->get_bwA();//nu_BW; + Fl::awake(setBWControl); + vfoB.iBW = selrig->get_bwB();//nu_BW; + return; + } + if (xcvr_name == rig_KX3.name_ || xcvr_name == rig_K4.name_) { + vfoA.iBW = selrig->get_bwA(); + vfoB.iBW = selrig->get_bwB(); + Fl::awake(set_Kx_bandwidths); + return; } @@ -1430,10 +1417,6 @@ void serviceQUE() void find_bandwidth(XCVR_STATE &nuvals) { - if (selrig->has_int_bandwidth_control) { - nuvals.iBW = (onA ? selrig->bwA : selrig->bwB); - return; - } if (nuvals.iBW == 255) return; if (!selrig->has_bandwidth_control) { nuvals.iBW = 255; @@ -1529,13 +1512,9 @@ void serviceA(XCVR_STATE nuvals) vfoA = nuvals; set_bandwidth_control(); } else { - std::string m1, m2; - m1 = selrig->modes_[nuvals.imode]; - m2 = selrig->modes_[vfoA.imode]; selrig->set_modeA(vfoA.imode = nuvals.imode); selrig->get_modeA(); set_bandwidth_control(); - vfoA.iBW = selrig->get_bwA(); } } if (vfoA.iBW != nuvals.iBW) { @@ -2104,12 +2083,12 @@ void set_bandwidth_control() { if (!selrig->has_bandwidth_control) return; - if (selrig->name_ != rig_K3.name_) { - vfo->iBW = selrig->def_bandwidth(vfo->imode); - if (vfo->iBW < 256) { - vfo->iBW = selrig->def_bandwidth(vfo->imode); - } - } +// if (selrig->name_ != rig_K3.name_) { +// vfo->iBW = selrig->def_bandwidth(vfo->imode); +// if (vfo->iBW < 256) { +// vfo->iBW = selrig->def_bandwidth(vfo->imode); +// } +// } if (selrig->inuse == onB) { vfoB.iBW = vfo->iBW = selrig->get_bwB(); } else { @@ -2120,9 +2099,10 @@ void set_bandwidth_control() } void TRACED ( updateBandwidthControl, void *d ) - if (xcvr_name == rig_K3.name_ || - xcvr_name == rig_KX3.name_ || - xcvr_name == rig_K4.name_) { + if (//xcvr_name == rig_K3.name_ || + xcvr_name == rig_KX3.name_ + || xcvr_name == rig_K4.name_ + ) { return; } if (selrig->has_dsp_controls) { @@ -2138,7 +2118,6 @@ void TRACED ( updateBandwidthControl, void *d ) LOG_ERROR("%s", e.what()); } opBW->hide(); - opBW->hide(); opDSP_lo->index(vfo->iBW & 0xFF); opDSP_lo->hide(); opDSP_hi->index((vfo->iBW >> 8) & 0x7F); @@ -2770,6 +2749,8 @@ void addFreq() { int bw; if (btnDSP->visible()) bw = ((opDSP_hi->index() << 8) | 0x8000) | (opDSP_lo->index() & 0xFF) ; + else if (opBW_B->visible()) + bw = opBW_B->index(); else bw = opBW->index(); for (int n = 0; n < numinlist; n++) @@ -2788,6 +2769,8 @@ void addFreq() { int bw; if (btnDSP->visible()) bw = ((opDSP_hi->index() << 8) | 0x8000) | (opDSP_lo->index() & 0xFF) ; + else if (opBW_A->visible()) + bw = opBW_A->index(); else bw = opBW->index(); for (int n = 0; n < numinlist; n++) @@ -2831,8 +2814,13 @@ void cbAttenuator() { trace(1, "cbAttenuator()"); - selrig->set_attenuator ( progStatus.attenuator = selrig->next_attenuator() ); + { + guard_lock serial_lock(&mutex_serial); + selrig->set_attenuator ( progStatus.attenuator = selrig->next_attenuator() ); + if (xcvr_name == rig_K4.name_) + selrig->get_attenuator(); + } btnAttenuator->value( progStatus.attenuator > 0 ? 1 : 0); btnAttenuator->label( selrig->ATT_label() ); btnAttenuator->redraw_label(); @@ -2856,7 +2844,12 @@ void cbPreamp() return; } - selrig->set_preamp ( progStatus.preamp = selrig->next_preamp() ); + { + guard_lock serial_lock(&mutex_serial); + selrig->set_preamp ( progStatus.preamp = selrig->next_preamp() ); + if (xcvr_name == rig_K4.name_) + selrig->get_preamp(); + } btnPreamp->value( progStatus.preamp > 0 ? 1 : 0); btnPreamp->label( selrig->PRE_label() );