Somehow this compiled...

This commit is contained in:
Rob French 2020-06-13 09:59:11 -05:00
parent 28cbb0363f
commit 2da162f7c2
8 changed files with 213 additions and 278 deletions

View File

@ -48,7 +48,7 @@ void recvIOPMessage(IOPMessage& msg, const uint8_t* buf, int len)
//====================================================================== //======================================================================
void sendIOPModeCommand(RigMode mode) void sendIOPModeCommand(rig_mode mode)
{ {
IOPMessage m; IOPMessage m;
m.id = IOP_MODE_COMMAND; m.id = IOP_MODE_COMMAND;
@ -101,69 +101,69 @@ void sendIOPDebugMessage(const char* text)
sendIOPMessage(m); sendIOPMessage(m);
}; };
//====================================================================== ////======================================================================
// SSB STATUS MESSAGE //// SSB STATUS MESSAGE
//====================================================================== ////======================================================================
void sendIOPSSBStatus(SSBConfig const &c) //void sendIOPSSBStatus(SSBConfig const &c)
{ //{
IOPMessage m; //IOPMessage m;
m.id = IOP_SSB_STATUS_MSG; //m.id = IOP_SSB_STATUS_MSG;
m.len = 4; //m.len = 4;
m.data[0] = 'S'; // current mode; redundant w/ Raduino mode, but maybe useful for debugging //m.data[0] = 'S'; // current mode; redundant w/ Raduino mode, but maybe useful for debugging
m.data[1] = '-'; // placeholder for transmit filter/compressor //m.data[1] = '-'; // placeholder for transmit filter/compressor
m.data[2] = RX_FILTER_LETTER[c.filter]; //m.data[2] = RX_FILTER_LETTER[c.filter];
m.data[3] = '\0'; //m.data[3] = '\0';
sendIOPMessage(m); //sendIOPMessage(m);
} //}
//====================================================================== ////======================================================================
// DGT STATUS MESSAGE //// DGT STATUS MESSAGE
//====================================================================== ////======================================================================
void sendIOPDGTStatus(DGTConfig const &c) //void sendIOPDGTStatus(DGTConfig const &c)
{ //{
IOPMessage m; //IOPMessage m;
m.id = IOP_DGT_STATUS_MSG; //m.id = IOP_DGT_STATUS_MSG;
m.len = 4; //m.len = 4;
m.data[0] = 'D'; // current mode; redundant w/ Raduino mode, but maybe useful for debugging //m.data[0] = 'D'; // current mode; redundant w/ Raduino mode, but maybe useful for debugging
m.data[1] = '-'; // placeholder for future digital submodes? //m.data[1] = '-'; // placeholder for future digital submodes?
m.data[2] = RX_FILTER_LETTER[c.filter]; //m.data[2] = RX_FILTER_LETTER[c.filter];
m.data[3] = '\0'; //m.data[3] = '\0';
sendIOPMessage(m); //sendIOPMessage(m);
} //}
//====================================================================== ////======================================================================
// CW STATUS MESSAGE //// CW STATUS MESSAGE
//====================================================================== ////======================================================================
void sendIOPCWStatus(CWConfig const &c) //void sendIOPCWStatus(CWConfig const &c)
{ //{
IOPMessage m; //IOPMessage m;
m.id = IOP_CW_STATUS_MSG; //m.id = IOP_CW_STATUS_MSG;
m.len = 4; //m.len = 4;
m.data[0] = 'C'; // current mode; redundant w/ Raduino mode, but maybe useful for debugging //m.data[0] = 'C'; // current mode; redundant w/ Raduino mode, but maybe useful for debugging
m.data[1] = KEYER_MODE_LETTER[c.mode]; //m.data[1] = KEYER_MODE_LETTER[c.mode];
m.data[2] = RX_FILTER_LETTER[c.filter]; //m.data[2] = RX_FILTER_LETTER[c.filter];
m.data[3] = '\0'; //m.data[3] = '\0';
sendIOPMessage(m); //sendIOPMessage(m);
} //}
//====================================================================== ////======================================================================
// TEST STATUS MESSAGE //// TEST STATUS MESSAGE
//====================================================================== ////======================================================================
void sendIOPTestStatus() //void sendIOPTestStatus()
{ //{
IOPMessage m; //IOPMessage m;
m.id = IOP_TEST_STATUS_MSG; //m.id = IOP_TEST_STATUS_MSG;
m.len = 4; //m.len = 4;
m.data[0] = ' '; //m.data[0] = ' ';
m.data[1] = 'T'; //m.data[1] = 'T';
m.data[2] = 'T'; //m.data[2] = 'T';
m.data[3] = '\0'; //m.data[3] = '\0';
sendIOPMessage(m); //sendIOPMessage(m);
} //}
//====================================================================== //======================================================================
// MENU DISPLAY MESSAGE // MENU DISPLAY MESSAGE

View File

@ -97,42 +97,46 @@ enum MessageID {
* (e.g. USB, LSB, etc.) * (e.g. USB, LSB, etc.)
*/ */
enum RigMode { enum rig_mode {
RIG_MODE_LSB = 0, lsb = 0,
RIG_MODE_USB, usb,
RIG_MODE_CWL, cw,
RIG_MODE_CWU, cwr,
RIG_MODE_DGL, dig,
RIG_MODE_DGU,
RIG_MODE_TTL,
RIG_MODE_TTU,
// add new items here // add new items here
NUM_RIG_MODES num_rig_modes
}; };
/* Keyer modes. /* Keyer modes.
*/ */
enum KeyerMode { enum keyer_mode {
KEYER_MODE_STRAIGHT = 0, straight = 0,
KEYER_MODE_IAMBIC_A, iambic_a,
KEYER_MODE_IAMBIC_B, iambic_b,
//KEYER_ULTIMATIC, //ultimatic,
//KEYER_BUG, //bug,
// add any new elements here // add any new items here
NUM_KEYER_MODES num_keyer_modes
}; };
enum RxFilter { enum rx_filter {
RX_FILTER_WIDE = 0, wide = 0,
RX_FILTER_MEDIUM, medium,
RX_FILTER_NARROW, narrow,
NUM_RX_FILTERS num_rx_filters
}; };
const unsigned char RIG_MODE_LETTER[NUM_RIG_MODES] = {'s', 'S', 'c', 'C', 'd', 'D', 't', 'T'}; enum digi_mode {
const unsigned char KEYER_MODE_LETTER[NUM_KEYER_MODES] = {'S', 'A', 'B'}; rtty = 0,
const unsigned char RX_FILTER_LETTER[NUM_RX_FILTERS] = {'W', 'M', 'N'}; psk31,
user_defined,
num_digi_modes
};
//const unsigned char RIG_MODE_LETTER[num_rig_modes] = {'s', 'S', 'c', 'C', 'd', 'D', 't', 'T'};
//const unsigned char KEYER_MODE_LETTER[num_keyer_modes] = {'S', 'A', 'B'};
//const unsigned char RX_FILTER_LETTER[num_rx_filters] = {'W', 'M', 'N'};
const uint8_t NO_FLAGS = 0; const uint8_t NO_FLAGS = 0;
const uint8_t REVERSED = 1; const uint8_t REVERSED = 1;
@ -150,67 +154,86 @@ struct IOPMessage {
// Interface to a configuration object. // Interface to a configuration object.
//====================================================================== //======================================================================
class IConfig { struct filter_config {
public: float lo;
virtual ~IConfig() {} float hi;
float gain;
};
struct mode_config {
mode_config(bool usb, rx_filter f, const filter_config *fc) : is_usb(usb), filter(f) {
for (int i = 0; i < num_rx_filters; i++) {
filtercfg[i] = fc[i];
}
}
bool is_usb;
rx_filter filter;
filter_config filtercfg[num_rx_filters];
}; };
//====================================================================== //======================================================================
// SSB CONFIGURATION // SSB CONFIGURATION
//====================================================================== //======================================================================
class SSBConfig : public IConfig { const filter_config ssb_filter_config[num_rx_filters] =
public: {filter_config{ 300.0, 3100.0, 1.0},
SSBConfig(RxFilter f): filter(f) {} filter_config{ 500.0, 2900.0, 1.0},
// parameters filter_config{ 700.0, 2500.0, 1.0}};
RxFilter filter = RX_FILTER_MEDIUM;
// bool comp_enable = false; struct ssb_config : public mode_config {
// float comp_threshold = 0.1; ssb_config() : mode_config(true, wide, ssb_filter_config) {}
// float comp_ratio = 20.0; // speech compressor parameters
// float comp_gain = 2.0; bool comp_enable = false;
float comp_threshold = 0.1;
float comp_ratio = 20.0;
float comp_gain = 2.0;
}; };
//====================================================================== //======================================================================
// DGT CONFIGURATION // DIG CONFIGURATION
//====================================================================== //======================================================================
class DGTConfig : public IConfig { const filter_config dig_filter_config[num_rx_filters] =
public: {filter_config{ 300.0, 3100.0, 1.0},
DGTConfig(RxFilter f): filter(f) {} filter_config{ 500.0, 2900.0, 1.0},
// parameters filter_config{1250.0, 1750.0, 1.0}};
RxFilter filter = RX_FILTER_MEDIUM;
struct dig_config : public mode_config {
dig_config() : mode_config(true, wide, dig_filter_config) {}
digi_mode submode = user_defined;
}; };
//====================================================================== //======================================================================
// CW CONFIGURATION // CW CONFIGURATION
//====================================================================== //======================================================================
class CWConfig : public IConfig { const filter_config cw_filter_config[num_rx_filters] =
public: {filter_config{ 300.0, 1300.0, 1.0},
CWConfig(KeyerMode m, bool rev, uint8_t w, float wt, uint16_t st, RxFilter f): filter_config{ 450.0, 950.0, 1.0},
mode(m), reversed(rev), wpm(w), weight(wt), sidetone(st), filter(f) {} filter_config{ 575.0, 825.0, 1.0}};
// mode
KeyerMode mode = KEYER_MODE_IAMBIC_A; struct cw_config : public mode_config {
cw_config() : mode_config(true, wide, cw_filter_config) {}
keyer_mode mode = iambic_a;
// flags // flags
bool reversed = false; bool reversed = false;
// parameters // parameters
uint8_t wpm = 15; uint8_t wpm = 15;
float weight = 3.0; float weight = 3.0;
uint16_t sidetone = 700; uint16_t sidetone = 700;
RxFilter filter = RX_FILTER_MEDIUM;
}; };
//====================================================================== //======================================================================
// TT CONFIGURATION // TT CONFIGURATION
//====================================================================== //======================================================================
/*
class TTConfig : public IConfig { struct TTConfig : public IConfig {
public: public:
TTConfig(RxFilter f): filter(f) {} TTConfig(RxFilter f): filter(f) {}
// parameters // parameters
RxFilter filter = RX_FILTER_MEDIUM; RxFilter filter = RX_FILTER_MEDIUM;
}; };
*/
//====================================================================== //======================================================================
// FUNCTION PROTOTYPES // FUNCTION PROTOTYPES
//====================================================================== //======================================================================
@ -219,58 +242,19 @@ void sendCATMessage(const uint8_t*);
void sendIOPMessage(IOPMessage const&); void sendIOPMessage(IOPMessage const&);
void recvIOPMessage(IOPMessage&, const uint8_t*, int); void recvIOPMessage(IOPMessage&, const uint8_t*, int);
void sendIOPModeCommand(RigMode); void sendIOPModeCommand(rig_mode);
void sendIOPStartTxCommand(); void sendIOPStartTxCommand();
void sendIOPStopTxCommand(); void sendIOPStopTxCommand();
void sendIOPDebugMessage(const char*); void sendIOPDebugMessage(const char*);
void sendIOPModeRequest(); void sendIOPModeRequest();
void sendIOPSSBStatus(SSBConfig const&); //void sendIOPSSBStatus(SSBConfig const&);
void sendIOPDGTStatus(DGTConfig const&); //void sendIOPDGTStatus(DGTConfig const&);
void sendIOPCWStatus(CWConfig const&); //void sendIOPCWStatus(CWConfig const&);
void sendIOPTestStatus(); //void sendIOPTestStatus();
void sendIOPMenuDisplay(const char*); void sendIOPMenuDisplay(const char*);
void sendIOPMenuInactive(); void sendIOPMenuInactive();
//======================================================================
// TRANSLATOR
//======================================================================
/*
class Translator
{
public:
Translator(RigMode&, CWConfig&, Stream&);
void registerPrefixCb(PrefixID id, void (*func)(void*));
void registerMessageCb(MessageID id, void (*func)(void*));
void sendACK();
void sendIOPMessage(IOPMessage const&);
void receive();
void pack_ModeCommand(IOPMessage&, RigMode);
void pack_CWConfig(IOPMessage&, CWConfig const&);
void pack_ModeRequest(IOPMessage&);
void unpack(IOPMessage const&);
protected:
void unpack_ModeCommand(IOPMessage const&);
void unpack_CWConfig(IOPMessage const&);
void unpack_ModeRequest(IOPMessage const&);
private:
RigMode& mode;
CWConfig& cwConfig;
Stream& serial;
void (*prefixCb[NUM_PREFIX_IDS])(void*);
void (*messageCb[NUM_MESSAGE_IDS])(void*);
};
*/
#endif #endif
//====================================================================== //======================================================================

View File

@ -24,14 +24,14 @@
class IMode { class IMode {
public: public:
IMode(IConfig& c, RigAudio& a, IFilter& f): IMode(mode_config& c, RigAudio& a, IFilter& f):
_config(c), _audio(a), _filter(f), _active(false), _transmitting(false) _config(c), _audio(a), _filter(f), _active(false), _transmitting(false)
{ {
} }
virtual ~IMode() {} virtual ~IMode() {}
inline IConfig& config() { return _config; } inline mode_config& config() { return _config; }
inline RigAudio& audio() { return _audio; } inline RigAudio& audio() { return _audio; }
@ -110,7 +110,7 @@ class IMode {
private: private:
IConfig& _config; mode_config& _config;
RigAudio& _audio; RigAudio& _audio;
IFilter& _filter; IFilter& _filter;
bool _active; bool _active;
@ -125,7 +125,7 @@ class SSBMode : public IMode
{ {
public: public:
SSBMode(IConfig& c, RigAudio& a, IFilter& f, bool default_mic=true): SSBMode(mode_config& c, RigAudio& a, IFilter& f, bool default_mic=true):
IMode(c, a, f), _use_mic(default_mic) IMode(c, a, f), _use_mic(default_mic)
{ {
} }
@ -215,7 +215,7 @@ class DGTMode : public IMode
{ {
public: public:
DGTMode(IConfig& c, RigAudio& a, IFilter& f): DGTMode(mode_config& c, RigAudio& a, IFilter& f):
IMode(c, a, f) IMode(c, a, f)
{ {
} }
@ -277,7 +277,7 @@ class CWMode : public IMode
{ {
public: public:
CWMode(IConfig& c, RigAudio& a, IFilter& f): CWMode(mode_config& c, RigAudio& a, IFilter& f):
IMode(c, a, f) IMode(c, a, f)
{ {
} }
@ -310,7 +310,7 @@ class CWMode : public IMode
} }
virtual void setWideRxFilter(){ virtual void setWideRxFilter(){
float st = float(((CWConfig&)config()).sidetone); float st = float(((cw_config&)config()).sidetone);
float width = 1000.0; float width = 1000.0;
float low = st - (width * 0.5); float low = st - (width * 0.5);
if (low < 300.0) { if (low < 300.0) {
@ -322,7 +322,7 @@ class CWMode : public IMode
} }
virtual void setMediumRxFilter(){ virtual void setMediumRxFilter(){
float st = float(((CWConfig&)config()).sidetone); float st = float(((cw_config&)config()).sidetone);
float width = 500.0; float width = 500.0;
float low = st - (width * 0.5); float low = st - (width * 0.5);
if (low < 300.0) { if (low < 300.0) {
@ -334,7 +334,7 @@ class CWMode : public IMode
} }
virtual void setNarrowRxFilter(){ virtual void setNarrowRxFilter(){
float st = float(((CWConfig&)config()).sidetone); float st = float(((cw_config&)config()).sidetone);
float width = 250.0; float width = 250.0;
float low = st - (width * 0.5); float low = st - (width * 0.5);
if (low < 300.0) { if (low < 300.0) {
@ -355,7 +355,7 @@ class TTMode : public IMode
{ {
public: public:
TTMode(IConfig& c, RigAudio& a, IFilter& f): TTMode(mode_config& c, RigAudio& a, IFilter& f):
IMode(c, a, f) IMode(c, a, f)
{ {
} }

View File

@ -57,32 +57,23 @@ void processIOPCommand(IOPMessage const& m)
if (m.len < 1) { if (m.len < 1) {
return; return;
} else { } else {
rig.switchMode(RigMode(m.data[0])); rig.switchMode(rig_mode(m.data[0]));
#if defined(DEBUG) #if defined(DEBUG)
switch(rig.modeNum()) { switch(rig.modeNum()) {
case RIG_MODE_CWL: case cwr:
USBDEBUG("new mode - CWL"); USBDEBUG("new mode - CWR");
break; break;
case RIG_MODE_CWU: case cw:
USBDEBUG("new mode - CWU"); USBDEBUG("new mode - CW");
break; break;
case RIG_MODE_LSB: case lsb:
USBDEBUG("new mode - LSB"); USBDEBUG("new mode - LSB");
break; break;
case RIG_MODE_USB: case usb:
USBDEBUG("new mode - USB"); USBDEBUG("new mode - USB");
break; break;
case RIG_MODE_DGL: case dig:
USBDEBUG("new mode - DGL"); USBDEBUG("new mode - DIG");
break;
case RIG_MODE_DGU:
USBDEBUG("new mode - DGU");
break;
case RIG_MODE_TTL:
USBDEBUG("new mode - TTL");
break;
case RIG_MODE_TTU:
USBDEBUG("new mode - TTU");
break; break;
default: default:
char errormessage[32]; char errormessage[32];

View File

@ -115,42 +115,18 @@ class AudioConfig {
class RigConfig { class RigConfig {
public: public:
RigConfig() {}
// audio configuration // audio configuration
AudioConfig audio; AudioConfig audio;
// SSB configuration // mode configuration
SSBConfig lsb{RX_FILTER_WIDE}; ssb_config ssb;
SSBConfig usb{RX_FILTER_WIDE}; dig_config dig;
cw_config cw;
// DGT configuration
DGTConfig dgl{RX_FILTER_WIDE};
DGTConfig dgu{RX_FILTER_WIDE};
// CW configuration
CWConfig cwl{
KEYER_MODE_IAMBIC_A,
false,
15,
3.0,
700,
RX_FILTER_WIDE,
};
CWConfig cwu{
KEYER_MODE_IAMBIC_A,
false,
15,
3.0,
700,
RX_FILTER_WIDE,
};
// TT configuration
TTConfig ttl{RX_FILTER_WIDE};
TTConfig ttu{RX_FILTER_WIDE};
// General rig configuration entries. // General rig configuration entries.
RigMode numModes = NUM_RIG_MODES; rig_mode numModes = num_rig_modes;
RigMode startMode = RIG_MODE_LSB; rig_mode startMode = lsb;
}; };
extern RigConfig rigConfig; extern RigConfig rigConfig;

View File

@ -211,15 +211,12 @@ class Parm_float : public Config_parm<float> {
//====================================================================== //======================================================================
const char modeID[] = {'s', 'S', 'c', 'C', 'd', 'D', 't', 'T'}; const char modeID[] = {'s', 'S', 'c', 'C', 'd', 'D', 't', 'T'};
const char* const filterID[NUM_RIG_MODES][NUM_RX_FILTERS] = { const char* const filterID[num_rig_modes][num_rx_filters] = {
{"2.8", "2.4", "1.8"}, // LSB {"2.8", "2.4", "1.8"}, // LSB
{"2.8", "2.4", "1.8"}, // USB {"2.8", "2.4", "1.8"}, // USB
{"1.0", "500", "250"}, // CWL {"1.0", "500", "250"}, // CW
{"1.0", "500", "250"}, // CWU {"1.0", "500", "250"}, // CWR
{"2.8", "2.4", "500"}, // DGL {"2.8", "2.4", "500"}, // DIG
{"2.8", "2.4", "500"}, // DGU
{"2.8", "2.4", "1.8"}, // TTL
{"2.8", "2.4", "1.8"}, // TTU
}; };
//====================================================================== //======================================================================

View File

@ -21,7 +21,7 @@ class Rig {
// Constructor/destructor. // Constructor/destructor.
//-------------------------------------------------------------------- //--------------------------------------------------------------------
Rig(RigConfig& c, RigAudio& a): _config(c), _audio(a), _filter(RX_FILTER_WIDE) Rig(RigConfig& c, RigAudio& a): _config(c), _audio(a), _filter(wide)
{ {
_modes = new IMode*[c.numModes]; _modes = new IMode*[c.numModes];
_modesLen = c.numModes; _modesLen = c.numModes;
@ -38,12 +38,12 @@ class Rig {
_modes[RIG_MODE_TTL] = new TTMode(c.ttl, a); _modes[RIG_MODE_TTL] = new TTMode(c.ttl, a);
_modes[RIG_MODE_TTU] = new TTMode(c.ttu, a);*/ _modes[RIG_MODE_TTU] = new TTMode(c.ttu, a);*/
/* /*
_rxFilters = new (IFilter*)[NUM_RX_FILTERS]; _rxFilters = new (IFilter*)[num_rx_filters];
_rxFiltersLen = NUM_RX_FILTERS; _rxFiltersLen = num_rx_filters;
_rxFiltersIndex = 0; // need to get default filter from current mode... _rxFiltersIndex = 0; // need to get default filter from current mode...
_rxFilters[RX_FILTER_WIDE] = mode()->filterWide(); _rxFilters[wide] = mode()->filterWide();
_rxFilters[RX_FILTER_MEDIUM] = mode()->filterMedium(); _rxFilters[medium] = mode()->filterMedium();
_rxFilters[RX_FILTER_NARROW] = mode()->filterNarrow(); _rxFilters[narrow] = mode()->filterNarrow();
*/ */
} }
@ -69,21 +69,16 @@ class Rig {
return _modeText; return _modeText;
} }
*/ */
inline bool isSSBMode() const { return (_modesIndex == RIG_MODE_USB || _modesIndex == RIG_MODE_LSB); } inline bool isSSBMode() const { return (_modesIndex == usb || _modesIndex == lsb); }
inline bool isUSBMode() const { return (_modesIndex == RIG_MODE_USB); } // inline bool isUSBMode() const { return (_modesIndex == usb); }
inline bool isLSBMode() const { return (_modesIndex == RIG_MODE_LSB); } // inline bool isLSBMode() const { return (_modesIndex == lsb); }
inline bool isDGTMode() const { return (_modesIndex == RIG_MODE_DGU || _modesIndex == RIG_MODE_DGL); } inline bool isDIGMode() const { return (_modesIndex == dig); }
inline bool isDGUMode() const { return (_modesIndex == RIG_MODE_DGU); } inline bool isCWMode() const { return (_modesIndex == cw || _modesIndex == cwr); }
inline bool isDGLMode() const { return (_modesIndex == RIG_MODE_DGL); } // inline bool isCWUMode() const { return (_modesIndex == RIG_MODE_CWU); }
inline bool isCWMode() const { return (_modesIndex == RIG_MODE_CWU || _modesIndex == RIG_MODE_CWL); } // inline bool isCWLMode() const { return (_modesIndex == RIG_MODE_CWL); }
inline bool isCWUMode() const { return (_modesIndex == RIG_MODE_CWU); }
inline bool isCWLMode() const { return (_modesIndex == RIG_MODE_CWL); }
inline bool isTTMode() const { return (_modesIndex == RIG_MODE_TTU || _modesIndex == RIG_MODE_TTL); }
inline bool isTTUMode() const { return (_modesIndex == RIG_MODE_TTU); }
inline bool isTTLMode() const { return (_modesIndex == RIG_MODE_TTL); }
// Assign a pointer to a mode object. Returns true if successful, false otherwise. // Assign a pointer to a mode object. Returns true if successful, false otherwise.
bool addNewMode(RigMode i, IMode* mode) { bool addNewMode(rig_mode i, IMode* mode) {
if (i > _modesLen) { if (i > _modesLen) {
return false; return false;
} else { } else {
@ -98,7 +93,7 @@ class Rig {
} }
// Returns the array index of the current mode. // Returns the array index of the current mode.
inline RigMode modeNum() const { inline rig_mode modeNum() const {
return _modesIndex; return _modesIndex;
} }
@ -109,12 +104,12 @@ class Rig {
// Switch to the mode specified by the provided index. Returns a // Switch to the mode specified by the provided index. Returns a
// pointer to the new mode. // pointer to the new mode.
IMode* switchMode(RigMode i) { IMode* switchMode(rig_mode i) {
// exit the previous mode // exit the previous mode
mode()->exit(); // NOTE: This could currently occur during TX, which is NOT desirable. mode()->exit(); // NOTE: This could currently occur during TX, which is NOT desirable.
// select the new mode // select the new mode
_modesIndex = RigMode(i % _modesLen); _modesIndex = rig_mode(i % _modesLen);
//enter the new mode //enter the new mode
mode()->enter(); mode()->enter();
@ -132,9 +127,9 @@ class Rig {
// select the new mode // select the new mode
if (prev) { if (prev) {
_modesIndex = RigMode(_modesIndex > 0 ? _modesIndex - 1 : _modesLen - 1); _modesIndex = rig_mode(_modesIndex > 0 ? _modesIndex - 1 : _modesLen - 1);
} else { } else {
_modesIndex = RigMode((_modesIndex + 1) % _modesLen); _modesIndex = rig_mode((_modesIndex + 1) % _modesLen);
} }
// enter the new mode // enter the new mode
@ -170,51 +165,51 @@ class Rig {
//-------------------------------------------------------------------- //--------------------------------------------------------------------
inline void setWideRxFilter() { inline void setWideRxFilter() {
_filter = RX_FILTER_WIDE; _filter = wide;
mode()->setWideRxFilter(); mode()->setWideRxFilter();
USBDEBUG("selected wide RX filter"); USBDEBUG("selected wide RX filter");
} }
inline void setMediumRxFilter() { inline void setMediumRxFilter() {
_filter = RX_FILTER_MEDIUM; _filter = medium;
mode()->setMediumRxFilter(); mode()->setMediumRxFilter();
USBDEBUG("selected medium RX filter"); USBDEBUG("selected medium RX filter");
} }
inline void setNarrowRxFilter() { inline void setNarrowRxFilter() {
_filter = RX_FILTER_NARROW; _filter = narrow;
mode()->setNarrowRxFilter(); mode()->setNarrowRxFilter();
USBDEBUG("selected narrow RX filter"); USBDEBUG("selected narrow RX filter");
} }
void switchRxFilter(RxFilter f) { void switchRxFilter(rx_filter f) {
switch(f) { switch(f) {
case RX_FILTER_WIDE: case wide:
setWideRxFilter(); setWideRxFilter();
break; break;
case RX_FILTER_MEDIUM: case medium:
setMediumRxFilter(); setMediumRxFilter();
break; break;
case RX_FILTER_NARROW: case narrow:
setNarrowRxFilter(); setNarrowRxFilter();
break; break;
} }
} }
void switchRxFilter(bool prev=false) { void switchRxFilter(bool prev=false) {
RxFilter f; rx_filter f;
if (prev) { if (prev) {
f = RxFilter(_filter > 0 ? _filter - 1 : NUM_RX_FILTERS - 1); f = rx_filter(_filter > 0 ? _filter - 1 : num_rx_filters - 1);
} else { } else {
f = RxFilter((_filter + 1) % NUM_RX_FILTERS); f = rx_filter((_filter + 1) % num_rx_filters);
} }
switchRxFilter(f); switchRxFilter(f);
} }
// Returns the array index of the current mode. // Returns the array index of the current mode.
inline RxFilter filterNum() const { inline rx_filter filterNum() const {
return _filter; return _filter;
} }
@ -321,10 +316,10 @@ class Rig {
RigAudio& _audio; RigAudio& _audio;
IMode** _modes; IMode** _modes;
RigMode _modesLen; rig_mode _modesLen;
RigMode _modesIndex; rig_mode _modesIndex;
RxFilter _filter; rx_filter _filter;
// char _modeText[17]; // char _modeText[17];

View File

@ -20,14 +20,9 @@ Rig rig{rigConfig, rigAudio};
BPFilter rxFilter{300, 3100, false}; BPFilter rxFilter{300, 3100, false};
SSBMode lsbMode{rigConfig.lsb, rigAudio, rxFilter}; SSBMode ssbMode{rigConfig.ssb, rigAudio, rxFilter};
SSBMode usbMode{rigConfig.usb, rigAudio, rxFilter}; DGTMode digMode{rigConfig.dig, rigAudio, rxFilter};
CWMode cwlMode{rigConfig.cwl, rigAudio, rxFilter}; CWMode cwMode {rigConfig.cw, rigAudio, rxFilter};
CWMode cwuMode{rigConfig.cwu, rigAudio, rxFilter};
DGTMode dglMode{rigConfig.dgl, rigAudio, rxFilter};
DGTMode dguMode{rigConfig.dgu, rigAudio, rxFilter};
TTMode ttlMode{rigConfig.ttl, rigAudio, rxFilter};
TTMode ttuMode{rigConfig.ttu, rigAudio, rxFilter};
CATSwitch catPTT; CATSwitch catPTT;
//MicSwitch micPTTHelper; //MicSwitch micPTTHelper;
@ -63,14 +58,11 @@ void setup() {
rxFilter.init(); rxFilter.init();
// adding all of the modes to the rig // adding all of the modes to the rig
rig.addNewMode(RIG_MODE_LSB, &lsbMode); rig.addNewMode(lsb, &ssbMode);
rig.addNewMode(RIG_MODE_USB, &usbMode); rig.addNewMode(usb, &ssbMode);
rig.addNewMode(RIG_MODE_CWL, &cwlMode); rig.addNewMode(cw, &cwMode);
rig.addNewMode(RIG_MODE_CWU, &cwuMode); rig.addNewMode(cwr, &cwMode);
rig.addNewMode(RIG_MODE_DGL, &dglMode); rig.addNewMode(dig, &digMode);
rig.addNewMode(RIG_MODE_DGU, &dguMode);
rig.addNewMode(RIG_MODE_TTL, &ttlMode);
rig.addNewMode(RIG_MODE_TTU, &ttuMode);
initKeyLine(); initKeyLine();
rigAudio.init(); rigAudio.init();
@ -122,7 +114,7 @@ void loop()
static bool paddle_loop = false; static bool paddle_loop = false;
// long oldPos = knobPos; // long oldPos = knobPos;
RigMode oldRigMode; rig_mode oldRigMode;
frameCounter++; frameCounter++;
@ -169,14 +161,14 @@ void loop()
// need to make it inactive if we're in DGT mode, since only CAT will be // need to make it inactive if we're in DGT mode, since only CAT will be
// used to start transmitting in that case. // used to start transmitting in that case.
micPTT.setSSBMode(rig.isSSBMode()); micPTT.setSSBMode(rig.isSSBMode());
micPTT.update(rig.mode(), !rig.isDGTMode()); micPTT.update(rig.mode(), !rig.isDIGMode());
// Update the line PTT. We need to tell it if we're in SSB mode, so that // Update the line PTT. We need to tell it if we're in SSB mode, so that
// it knows if it should switch to the line input if pressed. We also // it knows if it should switch to the line input if pressed. We also
// need to make it inactive if we're in DGT mode, since only CAT will be // need to make it inactive if we're in DGT mode, since only CAT will be
// used to start transmitting in that case. // used to start transmitting in that case.
linePTT.setSSBMode(rig.isSSBMode()); linePTT.setSSBMode(rig.isSSBMode());
linePTT.update(rig.mode(), !rig.isDGTMode()); linePTT.update(rig.mode(), !rig.isDIGMode());
serviceCAT(); serviceCAT();