* CW read CW sense on select Icom transceivers to correctly
    manage notch filter position
This commit is contained in:
David Freese 2020-03-18 12:19:04 -05:00
parent dac9fc5d50
commit 6fa841ce44
7 changed files with 153 additions and 27 deletions

View file

@ -28,6 +28,8 @@ public:
RIG_IC7100(); RIG_IC7100();
~RIG_IC7100(){} ~RIG_IC7100(){}
bool CW_sense;
void initialize(); void initialize();
void selectA(); void selectA();

View file

@ -30,6 +30,8 @@ public:
RIG_IC7200(); RIG_IC7200();
~RIG_IC7200(){} ~RIG_IC7200(){}
bool CW_sense;
void initialize(); void initialize();
bool check(); bool check();

View file

@ -30,6 +30,8 @@ public:
RIG_IC7300(); RIG_IC7300();
~RIG_IC7300(){} ~RIG_IC7300(){}
bool CW_sense;
void initialize(); void initialize();
void selectA(); void selectA();

View file

@ -58,7 +58,7 @@ enum {
static const char mdval[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 17, 0, 1, 2, 5}; static const char mdval[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 17, 0, 1, 2, 5};
static const char IC7100_mode_type[] = { static char IC7100_mode_type[] = {
'L', 'U', 'U', 'L', 'L', 'L', 'U', 'U', 'L', 'L',
'U', 'U', 'U', 'U', 'U', 'U', 'U', 'U', 'U', 'U',
'L', 'U', 'U', 'U' }; 'L', 'U', 'U', 'U' };
@ -261,7 +261,7 @@ RIG_IC7100::RIG_IC7100() {
B.imode = 1; B.imode = 1;
B.iBW = 34; B.iBW = 34;
CW_sense = 0;
}; };
//====================================================================== //======================================================================
@ -479,6 +479,7 @@ void RIG_IC7100::set_modeA(int val)
int RIG_IC7100::get_modeA() int RIG_IC7100::get_modeA()
{ {
int md = 0; int md = 0;
size_t p = 0;
cmd = pre_to; cmd = pre_to;
cmd += '\x04'; cmd += '\x04';
cmd.append(post); cmd.append(post);
@ -486,7 +487,7 @@ int RIG_IC7100::get_modeA()
resp += '\x04'; resp += '\x04';
if (waitFOR(8, "get mode A")) { if (waitFOR(8, "get mode A")) {
size_t p = replystr.rfind(resp); p = replystr.rfind(resp);
if (p != std::string::npos) { if (p != std::string::npos) {
for (md = 0; md < nummodes; md++) for (md = 0; md < nummodes; md++)
if (replystr[p+5] == IC7100_mode_nbr[md]) if (replystr[p+5] == IC7100_mode_nbr[md])
@ -510,7 +511,7 @@ int RIG_IC7100::get_modeA()
resp = pre_fm; resp = pre_fm;
resp.append("\x1a\x06"); resp.append("\x1a\x06");
if (waitFOR(9, "get digital setting")) { if (waitFOR(9, "get digital setting")) {
size_t p = replystr.rfind(resp); p = replystr.rfind(resp);
if (p != string::npos) { if (p != string::npos) {
if ((replystr[p+6] & 0x01) == 0x01) { if ((replystr[p+6] & 0x01) == 0x01) {
if (md == USB7100) md = USBD7100; if (md == USB7100) md = USBD7100;
@ -529,6 +530,19 @@ int RIG_IC7100::get_modeA()
get_trace(2, "get_data_modeA()", str2hex(replystr.c_str(), replystr.length())); get_trace(2, "get_data_modeA()", str2hex(replystr.c_str(), replystr.length()));
get_trace(4, "mode_filterA[", IC7100modes_[md], "] = ", szfilter[A.filter-1]); get_trace(4, "mode_filterA[", IC7100modes_[md], "] = ", szfilter[A.filter-1]);
if (A.imode == CW7100 || A.imode == CWR7100) {
cmd.assign(pre_to).append("\x1A\x05");
cmd += '\x00'; cmd += '\x32';
resp.assign(pre_fm).append("\x1A\x05");
resp += '\x00'; resp += '\x32';
if (waitFOR(10, "get CW sideband")) {
p = replystr.rfind(resp);
CW_sense = replystr[p + 8];
if (CW_sense) IC7100_mode_type[A.imode] = 'U';
else IC7100_mode_type[A.imode] = 'L';
}
}
return A.imode; return A.imode;
} }
@ -558,6 +572,8 @@ void RIG_IC7100::set_modeB(int val)
int RIG_IC7100::get_modeB() int RIG_IC7100::get_modeB()
{ {
int md = 0; int md = 0;
size_t p = 0;
cmd = pre_to; cmd = pre_to;
cmd += '\x04'; cmd += '\x04';
cmd.append(post); cmd.append(post);
@ -565,7 +581,7 @@ int RIG_IC7100::get_modeB()
resp += '\x04'; resp += '\x04';
if (waitFOR(8, "get mode B")) { if (waitFOR(8, "get mode B")) {
size_t p = replystr.rfind(resp); p = replystr.rfind(resp);
if (p != std::string::npos) { if (p != std::string::npos) {
for (md = 0; md < nummodes; md++) for (md = 0; md < nummodes; md++)
if (replystr[p+5] == IC7100_mode_nbr[md]) if (replystr[p+5] == IC7100_mode_nbr[md])
@ -590,7 +606,7 @@ int RIG_IC7100::get_modeB()
resp = pre_fm; resp = pre_fm;
resp.append("\x1a\x06"); resp.append("\x1a\x06");
if (waitFOR(9, "get digital setting")) { if (waitFOR(9, "get digital setting")) {
size_t p = replystr.rfind(resp); p = replystr.rfind(resp);
if (p != string::npos) { if (p != string::npos) {
if ((replystr[p+6] & 0x01) == 0x01) { if ((replystr[p+6] & 0x01) == 0x01) {
if (md == USB7100) md = USBD7100; if (md == USB7100) md = USBD7100;
@ -609,7 +625,20 @@ int RIG_IC7100::get_modeB()
get_trace(2, "get_data_modeB()", str2hex(replystr.c_str(), replystr.length())); get_trace(2, "get_data_modeB()", str2hex(replystr.c_str(), replystr.length()));
get_trace(4, "mode_filterB[", IC7100modes_[md], "] = ", szfilter[A.filter-1]); get_trace(4, "mode_filterB[", IC7100modes_[md], "] = ", szfilter[A.filter-1]);
return A.imode; if (B.imode == CW7100 || B.imode == CWR7100) {
cmd.assign(pre_to).append("\x1A\x05");
cmd += '\x00'; cmd += '\x32';
resp.assign(pre_fm).append("\x1A\x05");
resp += '\x00'; resp += '\x32';
if (waitFOR(10, "get CW sideband")) {
p = replystr.rfind(resp);
CW_sense = replystr[p + 8];
if (CW_sense) IC7100_mode_type[B.imode] = 'U';
else IC7100_mode_type[B.imode] = 'L';
}
}
return B.imode;
} }
int RIG_IC7100::get_bwA() int RIG_IC7100::get_bwA()
@ -1297,10 +1326,16 @@ void RIG_IC7100::set_notch(bool on, int freq)
hexval = 1500 - freq; hexval = 1500 - freq;
break; break;
case CW7100: case CW7100:
hexval = progStatus.cw_spot_tone - freq; if (CW_sense)
hexval = freq - progStatus.cw_spot_tone;
else
hexval = progStatus.cw_spot_tone - freq;
break; break;
case CWR7100: case CWR7100:
hexval = freq - progStatus.cw_spot_tone; if (CW_sense)
hexval = progStatus.cw_spot_tone - freq;
else
hexval = freq - progStatus.cw_spot_tone;
break; break;
} }
@ -1361,10 +1396,16 @@ bool RIG_IC7100::get_notch(int &val)
val = 1500 - val; val = 1500 - val;
break; break;
case CW7100: case CW7100:
val = progStatus.cw_spot_tone - val; if (CW_sense)
val = progStatus.cw_spot_tone + val;
else
val = progStatus.cw_spot_tone - val;
break; break;
case CWR7100: case CWR7100:
val = progStatus.cw_spot_tone + val; if (CW_sense)
val = progStatus.cw_spot_tone - val;
else
val = progStatus.cw_spot_tone + val;
break; break;
} }
} }

View file

@ -54,7 +54,7 @@ const char *IC7200modes_[] = {
const char mdval[] = { 0, 1, 2, 3, 4, 7, 8, 0, 1}; const char mdval[] = { 0, 1, 2, 3, 4, 7, 8, 0, 1};
const char IC7200_mode_type[] = { static char IC7200_mode_type[] = {
'L', 'U', 'U', 'L', 'L', 'U', 'U', 'L', 'U', 'U', 'L', 'L', 'U', 'U',
'L', 'U' }; 'L', 'U' };
@ -220,6 +220,7 @@ RIG_IC7200::RIG_IC7200() {
precision = 1; precision = 1;
ndigits = 8; ndigits = 8;
CW_sense = 0; // normal
}; };
static inline void minmax(int min, int max, int &val) static inline void minmax(int min, int max, int &val)
@ -859,6 +860,7 @@ void RIG_IC7200::set_mic_gain(int val)
int RIG_IC7200::get_modeA() int RIG_IC7200::get_modeA()
{ {
int md = A.imode; int md = A.imode;
size_t p = 0;
string resp = pre_fm; string resp = pre_fm;
resp += '\x04'; resp += '\x04';
@ -867,7 +869,7 @@ int RIG_IC7200::get_modeA()
cmd.append(post); cmd.append(post);
if (waitFOR(8, "get mode A")) { if (waitFOR(8, "get mode A")) {
size_t p = replystr.rfind(resp); p = replystr.rfind(resp);
if (p != string::npos) { if (p != string::npos) {
md = replystr[p + 5]; md = replystr[p + 5];
if (md > 6) md -= 2; if (md > 6) md -= 2;
@ -882,7 +884,7 @@ int RIG_IC7200::get_modeA()
resp = pre_fm; resp = pre_fm;
resp += "\x1A\x04"; resp += "\x1A\x04";
if (waitFOR(9, "data mode?")) { if (waitFOR(9, "data mode?")) {
size_t p = replystr.rfind(resp); p = replystr.rfind(resp);
if (p != string::npos) { if (p != string::npos) {
if ((replystr[p+6] & 0x01) == 0x01) { if ((replystr[p+6] & 0x01) == 0x01) {
if (md == 0) md = 7; if (md == 0) md = 7;
@ -896,6 +898,17 @@ int RIG_IC7200::get_modeA()
get_trace(2, "get_data_modeA()", str2hex(replystr.c_str(), replystr.length())); get_trace(2, "get_data_modeA()", str2hex(replystr.c_str(), replystr.length()));
get_trace(4, "mode_filterA[", IC7200modes_[md], "] = ", szfilter[A.filter-1]); get_trace(4, "mode_filterA[", IC7200modes_[md], "] = ", szfilter[A.filter-1]);
if (A.imode == CW7200 || A.imode == CWR7200) {
cmd.assign(pre_to).append("\x1A\x03\x37");
resp.assign(pre_fm).append("\x1A\x03\x37");
if (waitFOR(9, "get CW sideband")) {
p = replystr.rfind(resp);
CW_sense = replystr[p + 7];
if (CW_sense) IC7200_mode_type[A.imode] = 'U';
else IC7200_mode_type[A.imode] = 'L';
}
}
return (A.imode = md); return (A.imode = md);
} }
@ -928,13 +941,15 @@ void RIG_IC7200::set_modeA(int val)
int RIG_IC7200::get_modeB() int RIG_IC7200::get_modeB()
{ {
int md = B.imode; int md = B.imode;
size_t p = 0;
cmd = pre_to; cmd = pre_to;
cmd += '\x04'; cmd += '\x04';
cmd.append(post); cmd.append(post);
string resp = pre_fm; string resp = pre_fm;
resp += '\x04'; resp += '\x04';
if (waitFOR(8, "get mode B")) { if (waitFOR(8, "get mode B")) {
size_t p = replystr.rfind(resp); p = replystr.rfind(resp);
if (p != string::npos) { if (p != string::npos) {
md = replystr[p+5]; md = replystr[p+5];
if (md > 6) md -= 2; if (md > 6) md -= 2;
@ -949,7 +964,7 @@ int RIG_IC7200::get_modeB()
resp = pre_fm; resp = pre_fm;
resp += "\x1A\x04"; resp += "\x1A\x04";
if (waitFOR(9, "get data B")) { if (waitFOR(9, "get data B")) {
size_t p = replystr.rfind(resp); p = replystr.rfind(resp);
if (p != string::npos) { if (p != string::npos) {
if ((replystr[p+6] & 0x01) == 0x01) { if ((replystr[p+6] & 0x01) == 0x01) {
if (md == 0) md = 7; if (md == 0) md = 7;
@ -963,6 +978,17 @@ int RIG_IC7200::get_modeB()
get_trace(2, "get_data_modeB()", str2hex(replystr.c_str(), replystr.length())); get_trace(2, "get_data_modeB()", str2hex(replystr.c_str(), replystr.length()));
get_trace(4, "mode_filterB[", IC7200modes_[md], "] = ", szfilter[B.filter-1]); get_trace(4, "mode_filterB[", IC7200modes_[md], "] = ", szfilter[B.filter-1]);
if (B.imode == CW7200 || B.imode == CWR7200) {
cmd.assign(pre_to).append("\x1A\x03\x37");
resp.assign(pre_fm).append("\x1A\x03\x37");
if (waitFOR(9, "get CW sideband")) {
p = replystr.rfind(resp);
CW_sense = replystr[p + 7];
if (CW_sense) IC7200_mode_type[B.imode] = 'U';
else IC7200_mode_type[B.imode] = 'L';
}
}
return (B.imode = md); return (B.imode = md);
} }
@ -1379,10 +1405,16 @@ void RIG_IC7200::set_notch(bool on, int freq)
hexval = 1500 - freq; hexval = 1500 - freq;
break; break;
case CW7200: case CW7200:
hexval = progStatus.cw_spot_tone - freq; if (CW_sense)
hexval = freq - progStatus.cw_spot_tone;
else
hexval = progStatus.cw_spot_tone - freq;
break; break;
case CWR7200: case CWR7200:
hexval = freq - progStatus.cw_spot_tone; if (CW_sense)
hexval = progStatus.cw_spot_tone - freq;
else
hexval = freq - progStatus.cw_spot_tone;
break; break;
} }
@ -1439,10 +1471,16 @@ bool RIG_IC7200::get_notch(int &val)
val = 1500 - val; val = 1500 - val;
break; break;
case CW7200: case CW7200:
val = progStatus.cw_spot_tone - val; if (CW_sense)
val = progStatus.cw_spot_tone + val;
else
val = progStatus.cw_spot_tone - val;
break; break;
case CWR7200: case CWR7200:
val = progStatus.cw_spot_tone + val; if (CW_sense)
val = progStatus.cw_spot_tone - val;
else
val = progStatus.cw_spot_tone + val;
break; break;
} }
} }

View file

@ -59,7 +59,7 @@ const char *IC7300modes_[] = {
"LSB", "USB", "AM", "FM", "CW", "CW-R", "RTTY", "RTTY-R", "LSB", "USB", "AM", "FM", "CW", "CW-R", "RTTY", "RTTY-R",
"LSB-D", "USB-D", "AM-D", "FM-D", NULL}; "LSB-D", "USB-D", "AM-D", "FM-D", NULL};
const char IC7300_mode_type[] = { char IC7300_mode_type[] = {
'L', 'U', 'U', 'U', 'L', 'U', 'L', 'U', 'L', 'U', 'U', 'U', 'L', 'U', 'L', 'U',
'L', 'U', 'U', 'U' }; 'L', 'U', 'U', 'U' };
@ -252,6 +252,7 @@ RIG_IC7300::RIG_IC7300() {
can_change_alt_vfo = true; can_change_alt_vfo = true;
has_a2b = true; has_a2b = true;
CW_sense = 0; // CW is LSB
}; };
static inline void minmax(int min, int max, int &val) static inline void minmax(int min, int max, int &val)
@ -470,9 +471,22 @@ int RIG_IC7300::get_modeA()
mode_filterA[A.imode] = A.filter; mode_filterA[A.imode] = A.filter;
} }
end_wait_modeA:
get_trace(4, "get mode A[", IC7300modes_[A.imode], "] ", str2hex(replystr.c_str(), replystr.length())); get_trace(4, "get mode A[", IC7300modes_[A.imode], "] ", str2hex(replystr.c_str(), replystr.length()));
end_wait_modeA: if (A.imode == CW7300 || A.imode == CWR7300) {
cmd.assign(pre_to).append("\x1A\x05");
cmd += '\x00'; cmd += '\x53';
resp.assign(pre_fm).append("\x1A\x05");
resp += '\x00'; resp += '\x53';
if (waitFOR(10, "get CW sideband")) {
p = replystr.rfind(resp);
CW_sense = replystr[p+8];
if (CW_sense) IC7300_mode_type[A.imode] = 'U';
else IC7300_mode_type[A.imode] = 'L';
}
}
return A.imode; return A.imode;
} }
@ -534,12 +548,26 @@ int RIG_IC7300::get_modeB()
B.filter = replystr[p+8]; B.filter = replystr[p+8];
} }
end_wait_modeB:
get_trace(4, "get mode B[", IC7300modes_[B.imode], "] ", str2hex(replystr.c_str(), replystr.length())); get_trace(4, "get mode B[", IC7300modes_[B.imode], "] ", str2hex(replystr.c_str(), replystr.length()));
if (B.filter > 0 && B.filter < 4) if (B.filter > 0 && B.filter < 4)
mode_filterB[B.imode] = B.filter; mode_filterB[B.imode] = B.filter;
end_wait_modeB: get_trace(4, "get mode A[", IC7300modes_[B.imode], "] ", str2hex(replystr.c_str(), replystr.length()));
if (B.imode == CW7300 || B.imode == CWR7300) {
cmd.assign(pre_to).append("\x1A\x05");
cmd += '\x00'; cmd += '\x53';
resp.assign(pre_fm).append("\x1A\x05");
resp += '\x00'; resp += '\x53';
if (waitFOR(10, "get CW sideband")) {
p = replystr.rfind(resp);
CW_sense = replystr[p+8];
if (CW_sense) IC7300_mode_type[B.imode] = 'U';
else IC7300_mode_type[B.imode] = 'L';
}
}
return B.imode; return B.imode;
} }
@ -1673,10 +1701,16 @@ void RIG_IC7300::set_notch(bool on, int freq)
hexval = 1500 - freq; hexval = 1500 - freq;
break; break;
case CW7300: case CW7300:
hexval = progStatus.cw_spot_tone - freq; if (CW_sense)
hexval = freq - progStatus.cw_spot_tone;
else
hexval = progStatus.cw_spot_tone - freq;
break; break;
case CWR7300: case CWR7300:
hexval = freq - progStatus.cw_spot_tone; if (CW_sense)
hexval = progStatus.cw_spot_tone - freq;
else
hexval = freq - progStatus.cw_spot_tone;
break; break;
} }
@ -1736,10 +1770,16 @@ bool RIG_IC7300::get_notch(int &val)
val = 1500 - val; val = 1500 - val;
break; break;
case CW7300: case CW7300:
val = progStatus.cw_spot_tone - val; if (CW_sense)
val = progStatus.cw_spot_tone + val;
else
val = progStatus.cw_spot_tone - val;
break; break;
case CWR7300: case CWR7300:
val = progStatus.cw_spot_tone + val; if (CW_sense)
val = progStatus.cw_spot_tone - val;
else
val = progStatus.cw_spot_tone + val;
break; break;
} }
} }

View file

@ -135,6 +135,7 @@ RIG_IC756PRO2::RIG_IC756PRO2() {
has_swr_control = true; has_swr_control = true;
has_alc_control = true; has_alc_control = true;
has_smeter = true; has_smeter = true;
has_power_out = true;
has_power_control = true; has_power_control = true;
has_volume_control = true; has_volume_control = true;
has_mode_control = true; has_mode_control = true;