//====================================================================== // rig.h //====================================================================== #ifndef __rig_h__ #define __rig_h__ #include #include "audio.h" #include "RigMode.h" //#include "menu.h" //====================================================================== // Rig class //====================================================================== const char * const modeID[] = {"s", "S", "c", "C", "d", "D", "t", "T"}; class Rig { public: //-------------------------------------------------------------------- // Constructor/destructor. //-------------------------------------------------------------------- Rig(RigConfig& c, RigAudio& a): _config(c), _audio(a), _filter(RX_FILTER_WIDE) { _modes = new IMode*[c.numModes]; _modesLen = c.numModes; _modesIndex = c.startMode; /* _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[RX_FILTER_WIDE] = mode()->filterWide(); _rxFilters[RX_FILTER_MEDIUM] = mode()->filterMedium(); _rxFilters[RX_FILTER_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() { strcpy(&_modeText[0], modeID[_modesIndex]); strcpy(&_modeText[3], mode()->rxInfo()); strcpy(&_modeText[10], mode()->txInfo()); 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); } // Assign a pointer to a mode object. Returns true if successful, false otherwise. bool addNewMode(RigMode 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 RigMode 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(RigMode 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); //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 = RigMode((_modesIndex > 0 ? _modesIndex - 1 : _modesLen - 1)); } else { _modesIndex = RigMode((_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 = RX_FILTER_WIDE; mode()->setWideRxFilter(); } inline void setMediumRxFilter() { _filter = RX_FILTER_MEDIUM; mode()->setMediumRxFilter(); } inline void setNarrowRxFilter() { _filter = RX_FILTER_NARROW; mode()->setNarrowRxFilter(); } void switchRxFilter(RxFilter i) { switch(i) { case RX_FILTER_WIDE: setWideRxFilter(); break; case RX_FILTER_MEDIUM: setMediumRxFilter(); break; case RX_FILTER_NARROW: setNarrowRxFilter(); break; } } void switchRxFilter(bool prev=false) { if (prev) { _filter = RxFilter((_filter - 1) % NUM_RX_FILTERS); } else { _filter = RxFilter((_filter + 1) % NUM_RX_FILTERS); } } /* // 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; RigMode _modesLen; RigMode _modesIndex; RxFilter _filter; char _modeText[17]; /* IFilter** _rxFilters; uint8_t _rxFiltersLen; uint8_t _rxFiltersIndex; */ }; #endif //====================================================================== // EOF //======================================================================