From 2da162f7c20343e5f2ee2d4f8db777336e2eeaed Mon Sep 17 00:00:00 2001 From: Rob French Date: Sat, 13 Jun 2020 09:59:11 -0500 Subject: [PATCH] Somehow this compiled... --- iopcomm/iopcomm.cpp | 114 ++++++++++++------------- iopcomm/iopcomm.h | 180 ++++++++++++++++++---------------------- ubitx_iop/RigMode.h | 20 ++--- ubitx_iop/cat.ino | 27 ++---- ubitx_iop/config.h | 38 ++------- ubitx_iop/menu.h | 11 +-- ubitx_iop/rig.h | 71 ++++++++-------- ubitx_iop/ubitx_iop.ino | 30 +++---- 8 files changed, 213 insertions(+), 278 deletions(-) diff --git a/iopcomm/iopcomm.cpp b/iopcomm/iopcomm.cpp index 8d54b63..4c8830c 100644 --- a/iopcomm/iopcomm.cpp +++ b/iopcomm/iopcomm.cpp @@ -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; m.id = IOP_MODE_COMMAND; @@ -101,69 +101,69 @@ void sendIOPDebugMessage(const char* text) sendIOPMessage(m); }; -//====================================================================== -// SSB STATUS MESSAGE -//====================================================================== +////====================================================================== +//// SSB STATUS MESSAGE +////====================================================================== -void sendIOPSSBStatus(SSBConfig const &c) -{ - IOPMessage m; - m.id = IOP_SSB_STATUS_MSG; - m.len = 4; - 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[2] = RX_FILTER_LETTER[c.filter]; - m.data[3] = '\0'; - sendIOPMessage(m); -} +//void sendIOPSSBStatus(SSBConfig const &c) +//{ + //IOPMessage m; + //m.id = IOP_SSB_STATUS_MSG; + //m.len = 4; + //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[2] = RX_FILTER_LETTER[c.filter]; + //m.data[3] = '\0'; + //sendIOPMessage(m); +//} -//====================================================================== -// DGT STATUS MESSAGE -//====================================================================== +////====================================================================== +//// DGT STATUS MESSAGE +////====================================================================== -void sendIOPDGTStatus(DGTConfig const &c) -{ - IOPMessage m; - m.id = IOP_DGT_STATUS_MSG; - m.len = 4; - 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[2] = RX_FILTER_LETTER[c.filter]; - m.data[3] = '\0'; - sendIOPMessage(m); -} +//void sendIOPDGTStatus(DGTConfig const &c) +//{ + //IOPMessage m; + //m.id = IOP_DGT_STATUS_MSG; + //m.len = 4; + //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[2] = RX_FILTER_LETTER[c.filter]; + //m.data[3] = '\0'; + //sendIOPMessage(m); +//} -//====================================================================== -// CW STATUS MESSAGE -//====================================================================== +////====================================================================== +//// CW STATUS MESSAGE +////====================================================================== -void sendIOPCWStatus(CWConfig const &c) -{ - IOPMessage m; - m.id = IOP_CW_STATUS_MSG; - m.len = 4; - 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[2] = RX_FILTER_LETTER[c.filter]; - m.data[3] = '\0'; - sendIOPMessage(m); -} +//void sendIOPCWStatus(CWConfig const &c) +//{ + //IOPMessage m; + //m.id = IOP_CW_STATUS_MSG; + //m.len = 4; + //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[2] = RX_FILTER_LETTER[c.filter]; + //m.data[3] = '\0'; + //sendIOPMessage(m); +//} -//====================================================================== -// TEST STATUS MESSAGE -//====================================================================== +////====================================================================== +//// TEST STATUS MESSAGE +////====================================================================== -void sendIOPTestStatus() -{ - IOPMessage m; - m.id = IOP_TEST_STATUS_MSG; - m.len = 4; - m.data[0] = ' '; - m.data[1] = 'T'; - m.data[2] = 'T'; - m.data[3] = '\0'; - sendIOPMessage(m); -} +//void sendIOPTestStatus() +//{ + //IOPMessage m; + //m.id = IOP_TEST_STATUS_MSG; + //m.len = 4; + //m.data[0] = ' '; + //m.data[1] = 'T'; + //m.data[2] = 'T'; + //m.data[3] = '\0'; + //sendIOPMessage(m); +//} //====================================================================== // MENU DISPLAY MESSAGE diff --git a/iopcomm/iopcomm.h b/iopcomm/iopcomm.h index 2fa8336..4b06874 100644 --- a/iopcomm/iopcomm.h +++ b/iopcomm/iopcomm.h @@ -97,42 +97,46 @@ enum MessageID { * (e.g. USB, LSB, etc.) */ -enum RigMode { - RIG_MODE_LSB = 0, - RIG_MODE_USB, - RIG_MODE_CWL, - RIG_MODE_CWU, - RIG_MODE_DGL, - RIG_MODE_DGU, - RIG_MODE_TTL, - RIG_MODE_TTU, +enum rig_mode { + lsb = 0, + usb, + cw, + cwr, + dig, // add new items here - NUM_RIG_MODES + num_rig_modes }; /* Keyer modes. */ -enum KeyerMode { - KEYER_MODE_STRAIGHT = 0, - KEYER_MODE_IAMBIC_A, - KEYER_MODE_IAMBIC_B, - //KEYER_ULTIMATIC, - //KEYER_BUG, - // add any new elements here - NUM_KEYER_MODES +enum keyer_mode { + straight = 0, + iambic_a, + iambic_b, + //ultimatic, + //bug, + // add any new items here + num_keyer_modes }; -enum RxFilter { - RX_FILTER_WIDE = 0, - RX_FILTER_MEDIUM, - RX_FILTER_NARROW, - NUM_RX_FILTERS +enum rx_filter { + wide = 0, + medium, + narrow, + num_rx_filters }; -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'}; +enum digi_mode { + rtty = 0, + 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 REVERSED = 1; @@ -150,67 +154,86 @@ struct IOPMessage { // Interface to a configuration object. //====================================================================== -class IConfig { - public: - virtual ~IConfig() {} +struct filter_config { + float lo; + 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 //====================================================================== -class SSBConfig : public IConfig { - public: - SSBConfig(RxFilter f): filter(f) {} - // parameters - RxFilter filter = RX_FILTER_MEDIUM; -// bool comp_enable = false; -// float comp_threshold = 0.1; -// float comp_ratio = 20.0; -// float comp_gain = 2.0; +const filter_config ssb_filter_config[num_rx_filters] = + {filter_config{ 300.0, 3100.0, 1.0}, + filter_config{ 500.0, 2900.0, 1.0}, + filter_config{ 700.0, 2500.0, 1.0}}; + +struct ssb_config : public mode_config { + ssb_config() : mode_config(true, wide, ssb_filter_config) {} + // speech compressor parameters + 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 { - public: - DGTConfig(RxFilter f): filter(f) {} - // parameters - RxFilter filter = RX_FILTER_MEDIUM; +const filter_config dig_filter_config[num_rx_filters] = + {filter_config{ 300.0, 3100.0, 1.0}, + filter_config{ 500.0, 2900.0, 1.0}, + filter_config{1250.0, 1750.0, 1.0}}; + +struct dig_config : public mode_config { + dig_config() : mode_config(true, wide, dig_filter_config) {} + digi_mode submode = user_defined; }; //====================================================================== // CW CONFIGURATION //====================================================================== -class CWConfig : public IConfig { - public: - CWConfig(KeyerMode m, bool rev, uint8_t w, float wt, uint16_t st, RxFilter f): - mode(m), reversed(rev), wpm(w), weight(wt), sidetone(st), filter(f) {} - // mode - KeyerMode mode = KEYER_MODE_IAMBIC_A; +const filter_config cw_filter_config[num_rx_filters] = + {filter_config{ 300.0, 1300.0, 1.0}, + filter_config{ 450.0, 950.0, 1.0}, + filter_config{ 575.0, 825.0, 1.0}}; + +struct cw_config : public mode_config { + cw_config() : mode_config(true, wide, cw_filter_config) {} + keyer_mode mode = iambic_a; // flags bool reversed = false; // parameters uint8_t wpm = 15; float weight = 3.0; uint16_t sidetone = 700; - RxFilter filter = RX_FILTER_MEDIUM; }; //====================================================================== // TT CONFIGURATION //====================================================================== - -class TTConfig : public IConfig { +/* +struct TTConfig : public IConfig { public: TTConfig(RxFilter f): filter(f) {} // parameters RxFilter filter = RX_FILTER_MEDIUM; }; - +*/ //====================================================================== // FUNCTION PROTOTYPES //====================================================================== @@ -219,58 +242,19 @@ void sendCATMessage(const uint8_t*); void sendIOPMessage(IOPMessage const&); void recvIOPMessage(IOPMessage&, const uint8_t*, int); -void sendIOPModeCommand(RigMode); +void sendIOPModeCommand(rig_mode); void sendIOPStartTxCommand(); void sendIOPStopTxCommand(); void sendIOPDebugMessage(const char*); void sendIOPModeRequest(); -void sendIOPSSBStatus(SSBConfig const&); -void sendIOPDGTStatus(DGTConfig const&); -void sendIOPCWStatus(CWConfig const&); -void sendIOPTestStatus(); +//void sendIOPSSBStatus(SSBConfig const&); +//void sendIOPDGTStatus(DGTConfig const&); +//void sendIOPCWStatus(CWConfig const&); +//void sendIOPTestStatus(); void sendIOPMenuDisplay(const char*); 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 //====================================================================== diff --git a/ubitx_iop/RigMode.h b/ubitx_iop/RigMode.h index 2b1e89d..5c0f21b 100644 --- a/ubitx_iop/RigMode.h +++ b/ubitx_iop/RigMode.h @@ -24,14 +24,14 @@ class IMode { 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) { } virtual ~IMode() {} - inline IConfig& config() { return _config; } + inline mode_config& config() { return _config; } inline RigAudio& audio() { return _audio; } @@ -110,7 +110,7 @@ class IMode { private: - IConfig& _config; + mode_config& _config; RigAudio& _audio; IFilter& _filter; bool _active; @@ -125,7 +125,7 @@ class SSBMode : public IMode { 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) { } @@ -215,7 +215,7 @@ class DGTMode : public IMode { public: - DGTMode(IConfig& c, RigAudio& a, IFilter& f): + DGTMode(mode_config& c, RigAudio& a, IFilter& f): IMode(c, a, f) { } @@ -277,7 +277,7 @@ class CWMode : public IMode { public: - CWMode(IConfig& c, RigAudio& a, IFilter& f): + CWMode(mode_config& c, RigAudio& a, IFilter& f): IMode(c, a, f) { } @@ -310,7 +310,7 @@ class CWMode : public IMode } virtual void setWideRxFilter(){ - float st = float(((CWConfig&)config()).sidetone); + float st = float(((cw_config&)config()).sidetone); float width = 1000.0; float low = st - (width * 0.5); if (low < 300.0) { @@ -322,7 +322,7 @@ class CWMode : public IMode } virtual void setMediumRxFilter(){ - float st = float(((CWConfig&)config()).sidetone); + float st = float(((cw_config&)config()).sidetone); float width = 500.0; float low = st - (width * 0.5); if (low < 300.0) { @@ -334,7 +334,7 @@ class CWMode : public IMode } virtual void setNarrowRxFilter(){ - float st = float(((CWConfig&)config()).sidetone); + float st = float(((cw_config&)config()).sidetone); float width = 250.0; float low = st - (width * 0.5); if (low < 300.0) { @@ -355,7 +355,7 @@ class TTMode : public IMode { public: - TTMode(IConfig& c, RigAudio& a, IFilter& f): + TTMode(mode_config& c, RigAudio& a, IFilter& f): IMode(c, a, f) { } diff --git a/ubitx_iop/cat.ino b/ubitx_iop/cat.ino index 70d54ac..11a2216 100644 --- a/ubitx_iop/cat.ino +++ b/ubitx_iop/cat.ino @@ -57,32 +57,23 @@ void processIOPCommand(IOPMessage const& m) if (m.len < 1) { return; } else { - rig.switchMode(RigMode(m.data[0])); + rig.switchMode(rig_mode(m.data[0])); #if defined(DEBUG) switch(rig.modeNum()) { - case RIG_MODE_CWL: - USBDEBUG("new mode - CWL"); + case cwr: + USBDEBUG("new mode - CWR"); break; - case RIG_MODE_CWU: - USBDEBUG("new mode - CWU"); + case cw: + USBDEBUG("new mode - CW"); break; - case RIG_MODE_LSB: + case lsb: USBDEBUG("new mode - LSB"); break; - case RIG_MODE_USB: + case usb: USBDEBUG("new mode - USB"); break; - case RIG_MODE_DGL: - USBDEBUG("new mode - DGL"); - 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"); + case dig: + USBDEBUG("new mode - DIG"); break; default: char errormessage[32]; diff --git a/ubitx_iop/config.h b/ubitx_iop/config.h index 7b31863..a9a7f6f 100644 --- a/ubitx_iop/config.h +++ b/ubitx_iop/config.h @@ -115,42 +115,18 @@ class AudioConfig { class RigConfig { public: + RigConfig() {} // audio configuration AudioConfig audio; - // SSB configuration - SSBConfig lsb{RX_FILTER_WIDE}; - SSBConfig usb{RX_FILTER_WIDE}; - - // 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}; + // mode configuration + ssb_config ssb; + dig_config dig; + cw_config cw; // General rig configuration entries. - RigMode numModes = NUM_RIG_MODES; - RigMode startMode = RIG_MODE_LSB; + rig_mode numModes = num_rig_modes; + rig_mode startMode = lsb; }; extern RigConfig rigConfig; diff --git a/ubitx_iop/menu.h b/ubitx_iop/menu.h index 1109d63..43e0eb5 100644 --- a/ubitx_iop/menu.h +++ b/ubitx_iop/menu.h @@ -211,15 +211,12 @@ class Parm_float : public Config_parm { //====================================================================== 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"}, // USB - {"1.0", "500", "250"}, // CWL - {"1.0", "500", "250"}, // CWU - {"2.8", "2.4", "500"}, // DGL - {"2.8", "2.4", "500"}, // DGU - {"2.8", "2.4", "1.8"}, // TTL - {"2.8", "2.4", "1.8"}, // TTU + {"1.0", "500", "250"}, // CW + {"1.0", "500", "250"}, // CWR + {"2.8", "2.4", "500"}, // DIG }; //====================================================================== diff --git a/ubitx_iop/rig.h b/ubitx_iop/rig.h index 878574e..d1a71d0 100644 --- a/ubitx_iop/rig.h +++ b/ubitx_iop/rig.h @@ -21,7 +21,7 @@ class Rig { // 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]; _modesLen = c.numModes; @@ -38,12 +38,12 @@ class Rig { _modes[RIG_MODE_TTL] = new TTMode(c.ttl, a); _modes[RIG_MODE_TTU] = new TTMode(c.ttu, a);*/ /* - _rxFilters = new (IFilter*)[NUM_RX_FILTERS]; - _rxFiltersLen = NUM_RX_FILTERS; + _rxFilters = new (IFilter*)[num_rx_filters]; + _rxFiltersLen = num_rx_filters; _rxFiltersIndex = 0; // need to get default filter from current mode... - _rxFilters[RX_FILTER_WIDE] = mode()->filterWide(); - _rxFilters[RX_FILTER_MEDIUM] = mode()->filterMedium(); - _rxFilters[RX_FILTER_NARROW] = mode()->filterNarrow(); + _rxFilters[wide] = mode()->filterWide(); + _rxFilters[medium] = mode()->filterMedium(); + _rxFilters[narrow] = mode()->filterNarrow(); */ } @@ -69,21 +69,16 @@ class Rig { return _modeText; } */ - inline bool isSSBMode() const { return (_modesIndex == RIG_MODE_USB || _modesIndex == RIG_MODE_LSB); } - inline bool isUSBMode() const { return (_modesIndex == RIG_MODE_USB); } - inline bool isLSBMode() const { return (_modesIndex == RIG_MODE_LSB); } - inline bool isDGTMode() const { return (_modesIndex == RIG_MODE_DGU || _modesIndex == RIG_MODE_DGL); } - inline bool isDGUMode() const { return (_modesIndex == RIG_MODE_DGU); } - inline bool isDGLMode() const { return (_modesIndex == RIG_MODE_DGL); } - inline bool isCWMode() const { return (_modesIndex == RIG_MODE_CWU || _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); } + inline bool isSSBMode() const { return (_modesIndex == usb || _modesIndex == lsb); } +// inline bool isUSBMode() const { return (_modesIndex == usb); } +// inline bool isLSBMode() const { return (_modesIndex == lsb); } + inline bool isDIGMode() const { return (_modesIndex == dig); } + inline bool isCWMode() const { return (_modesIndex == cw || _modesIndex == cwr); } +// inline bool isCWUMode() const { return (_modesIndex == RIG_MODE_CWU); } +// inline bool isCWLMode() const { return (_modesIndex == RIG_MODE_CWL); } // 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) { return false; } else { @@ -98,7 +93,7 @@ class Rig { } // Returns the array index of the current mode. - inline RigMode modeNum() const { + inline rig_mode modeNum() const { return _modesIndex; } @@ -109,12 +104,12 @@ class Rig { // Switch to the mode specified by the provided index. Returns a // pointer to the new mode. - IMode* switchMode(RigMode i) { + IMode* switchMode(rig_mode i) { // exit the previous mode mode()->exit(); // NOTE: This could currently occur during TX, which is NOT desirable. // select the new mode - _modesIndex = RigMode(i % _modesLen); + _modesIndex = rig_mode(i % _modesLen); //enter the new mode mode()->enter(); @@ -132,9 +127,9 @@ class Rig { // select the new mode if (prev) { - _modesIndex = RigMode(_modesIndex > 0 ? _modesIndex - 1 : _modesLen - 1); + _modesIndex = rig_mode(_modesIndex > 0 ? _modesIndex - 1 : _modesLen - 1); } else { - _modesIndex = RigMode((_modesIndex + 1) % _modesLen); + _modesIndex = rig_mode((_modesIndex + 1) % _modesLen); } // enter the new mode @@ -170,51 +165,51 @@ class Rig { //-------------------------------------------------------------------- inline void setWideRxFilter() { - _filter = RX_FILTER_WIDE; + _filter = wide; mode()->setWideRxFilter(); USBDEBUG("selected wide RX filter"); } inline void setMediumRxFilter() { - _filter = RX_FILTER_MEDIUM; + _filter = medium; mode()->setMediumRxFilter(); USBDEBUG("selected medium RX filter"); } inline void setNarrowRxFilter() { - _filter = RX_FILTER_NARROW; + _filter = narrow; mode()->setNarrowRxFilter(); USBDEBUG("selected narrow RX filter"); } - void switchRxFilter(RxFilter f) { + void switchRxFilter(rx_filter f) { switch(f) { - case RX_FILTER_WIDE: + case wide: setWideRxFilter(); break; - case RX_FILTER_MEDIUM: + case medium: setMediumRxFilter(); break; - case RX_FILTER_NARROW: + case narrow: setNarrowRxFilter(); break; } } void switchRxFilter(bool prev=false) { - RxFilter f; + rx_filter f; if (prev) { - f = RxFilter(_filter > 0 ? _filter - 1 : NUM_RX_FILTERS - 1); + f = rx_filter(_filter > 0 ? _filter - 1 : num_rx_filters - 1); } else { - f = RxFilter((_filter + 1) % NUM_RX_FILTERS); + f = rx_filter((_filter + 1) % num_rx_filters); } switchRxFilter(f); } // Returns the array index of the current mode. - inline RxFilter filterNum() const { + inline rx_filter filterNum() const { return _filter; } @@ -321,10 +316,10 @@ class Rig { RigAudio& _audio; IMode** _modes; - RigMode _modesLen; - RigMode _modesIndex; + rig_mode _modesLen; + rig_mode _modesIndex; - RxFilter _filter; + rx_filter _filter; // char _modeText[17]; diff --git a/ubitx_iop/ubitx_iop.ino b/ubitx_iop/ubitx_iop.ino index 325b449..25b531e 100644 --- a/ubitx_iop/ubitx_iop.ino +++ b/ubitx_iop/ubitx_iop.ino @@ -20,14 +20,9 @@ Rig rig{rigConfig, rigAudio}; BPFilter rxFilter{300, 3100, false}; -SSBMode lsbMode{rigConfig.lsb, rigAudio, rxFilter}; -SSBMode usbMode{rigConfig.usb, rigAudio, rxFilter}; -CWMode cwlMode{rigConfig.cwl, 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}; +SSBMode ssbMode{rigConfig.ssb, rigAudio, rxFilter}; +DGTMode digMode{rigConfig.dig, rigAudio, rxFilter}; +CWMode cwMode {rigConfig.cw, rigAudio, rxFilter}; CATSwitch catPTT; //MicSwitch micPTTHelper; @@ -63,14 +58,11 @@ void setup() { rxFilter.init(); // adding all of the modes to the rig - rig.addNewMode(RIG_MODE_LSB, &lsbMode); - rig.addNewMode(RIG_MODE_USB, &usbMode); - rig.addNewMode(RIG_MODE_CWL, &cwlMode); - rig.addNewMode(RIG_MODE_CWU, &cwuMode); - rig.addNewMode(RIG_MODE_DGL, &dglMode); - rig.addNewMode(RIG_MODE_DGU, &dguMode); - rig.addNewMode(RIG_MODE_TTL, &ttlMode); - rig.addNewMode(RIG_MODE_TTU, &ttuMode); + rig.addNewMode(lsb, &ssbMode); + rig.addNewMode(usb, &ssbMode); + rig.addNewMode(cw, &cwMode); + rig.addNewMode(cwr, &cwMode); + rig.addNewMode(dig, &digMode); initKeyLine(); rigAudio.init(); @@ -122,7 +114,7 @@ void loop() static bool paddle_loop = false; // long oldPos = knobPos; - RigMode oldRigMode; + rig_mode oldRigMode; frameCounter++; @@ -169,14 +161,14 @@ void loop() // need to make it inactive if we're in DGT mode, since only CAT will be // used to start transmitting in that case. 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 // 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 // used to start transmitting in that case. linePTT.setSSBMode(rig.isSSBMode()); - linePTT.update(rig.mode(), !rig.isDGTMode()); + linePTT.update(rig.mode(), !rig.isDIGMode()); serviceCAT();