//====================================================================== // rig.h //====================================================================== #ifndef __rig_h__ #define __rig_h__ #include #include "audio.h" #include "RigMode.h" //#include "menu.h" //====================================================================== // Rig class //====================================================================== class Rig { public: //-------------------------------------------------------------------- // Constructor/destructor. //-------------------------------------------------------------------- Rig(RigConfig& c, RigAudio& a): _config(c), _audio(a), _filter(wide) { _modes = new IMode*[c.numModes]; _modesLen = c.numModes; _modesIndex = c.startMode; // for (int i = 0; i < 16; i++) { _modeText[i] = ' '; } // _modeText[16] = '\0'; /* _modes[RIG_MODE_LSB] = new SSBMode(c.lsb, a); _modes[RIG_MODE_USB] = new SSBMode(c.usb, a); _modes[RIG_MODE_CWL] = new CWMode(c.cwl, a); _modes[RIG_MODE_CWU] = new CWMode(c.cwu, a); _modes[RIG_MODE_DGL] = new DGTMode(c.dgl, a); _modes[RIG_MODE_DGU] = new DGTMode(c.dgu, a); _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; _rxFiltersIndex = 0; // need to get default filter from current mode... _rxFilters[wide] = mode()->filterWide(); _rxFilters[medium] = mode()->filterMedium(); _rxFilters[narrow] = mode()->filterNarrow(); */ } ~Rig() { for (unsigned i = 0; i < _modesLen; i++) { delete _modes[i]; } delete _modes; } void init() { switchRxFilter(_filter); } //-------------------------------------------------------------------- // Mode control. //-------------------------------------------------------------------- /* const char* modeText() { sprintf(_modeText, "%1c- %6s %6s", modeID[_modesIndex], mode()->rxInfo(), mode()->txInfo()); return _modeText; } */ 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(rig_mode i, IMode* mode) { if (i > _modesLen) { return false; } else { _modes[i] = mode; return true; } } // Returns a pointer to the current mode. inline IMode* mode() const { return _modes[_modesIndex]; } // Returns the array index of the current mode. inline rig_mode modeNum() const { return _modesIndex; } /* // Returns a pointer to the specified mode. inline IMode* mode(RigMode m) const { return _modes[m]; }*/ // Switch to the mode specified by the provided index. Returns a // pointer to the new mode. 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 = rig_mode(i % _modesLen); //enter the new mode mode()->enter(); // return a pointer to the new mode return mode(); } // Advance to the next (or previous) mode. Returns a pointer to the // new mode. IMode* switchMode(bool prev=false) { // exit the previous mode mode()->exit(); // select the new mode if (prev) { _modesIndex = rig_mode(_modesIndex > 0 ? _modesIndex - 1 : _modesLen - 1); } else { _modesIndex = rig_mode((_modesIndex + 1) % _modesLen); } // enter the new mode mode()->enter(); // return a pointer to the new mode return mode(); } //-------------------------------------------------------------------- // Transmit/Receive (T/R) control. //-------------------------------------------------------------------- inline bool isTx() const { return mode()->isTx(); } inline bool isRx() const { return mode()->isRx(); } // Enter the transmit state. This is delegated to the mode. inline void tx() { mode()->tx(); } // Enter the receive state. This is delegated to the mode. inline void rx() { mode()->rx(); } //-------------------------------------------------------------------- // Transmit processor control. //-------------------------------------------------------------------- void switchProcessor(bool prev=false) { } //-------------------------------------------------------------------- // RX filter control. //-------------------------------------------------------------------- inline void setWideRxFilter() { _filter = wide; mode()->setWideRxFilter(); USBDEBUG("selected wide RX filter"); } inline void setMediumRxFilter() { _filter = medium; mode()->setMediumRxFilter(); USBDEBUG("selected medium RX filter"); } inline void setNarrowRxFilter() { _filter = narrow; mode()->setNarrowRxFilter(); USBDEBUG("selected narrow RX filter"); } void switchRxFilter(rx_filter f) { switch(f) { case wide: setWideRxFilter(); break; case medium: setMediumRxFilter(); break; case narrow: setNarrowRxFilter(); break; } } void switchRxFilter(bool prev=false) { rx_filter f; if (prev) { f = rx_filter(_filter > 0 ? _filter - 1 : num_rx_filters - 1); } else { f = rx_filter((_filter + 1) % num_rx_filters); } switchRxFilter(f); } // Returns the array index of the current mode. inline rx_filter filterNum() const { return _filter; } /* // Returns a pointer to the current RX filter. IFilter* rxFilter() { return _rxFilters[_rxFiltersIndex]; } IFilter* switchRxFilter(bool prev=false) { if (prev) { _rxFiltersIndex--; } else { _rxFiltersIndex++; } _rxFiltersIndex %= _rxFiltersLen; return _rxFiltersList[_rxFiltersIndex]; } IFilter* switchRxFilterWide() { } IFilter* switchFilterMedium() { } IFilter* switchFilterNarrow() { } */ // Audio output control. inline void muteSpkrOut() const { _audio.muteSpkrOut(); } inline void unmuteSpkrOut() const { _audio.unmuteSpkrOut(); } inline void muteLineOut() const { _audio.muteLineOut(); } inline void unmuteLineOut() const { _audio.unmuteLineOut(); } inline void muteUSBOut() const { _audio.muteUSBOut(); } inline void unmuteUSBOut() const { _audio.unmuteUSBOut(); } // Audio input control. inline void muteAllTx() const { _audio.muteAllTx(); } inline void muteMicIn() const { _audio.muteMicIn(); } inline void unmuteMicIn() const { _audio.unmuteMicIn(); } inline void muteLineIn() const { _audio.muteLineIn(); } inline void unmuteLineIn() const { _audio.unmuteLineIn(); } inline void muteUSBIn() const { _audio.muteUSBIn(); } inline void unmuteUSBIn() const { _audio.unmuteUSBOut(); } inline void muteTTIn() const { _audio.muteTTIn(); } inline void unmuteTTIn() const { _audio.unmuteTTIn(); } // Update the rig state. This should be called once each time through // the main loop. void update() { } private: RigConfig& _config; RigAudio& _audio; IMode** _modes; rig_mode _modesLen; rig_mode _modesIndex; rx_filter _filter; // char _modeText[17]; /* IFilter** _rxFilters; uint8_t _rxFiltersLen; uint8_t _rxFiltersIndex; */ }; #endif //====================================================================== // EOF //======================================================================