ubitx-v5x/TeensyDSP/Rig.h

92 lines
3.3 KiB
C
Raw Normal View History

2021-02-07 23:12:08 +00:00
#ifndef __Rig_h__
#define __Rig_h__
#include "RigState.h"
enum UpdateSource {
NoSource,
RaduinoSource,
CATSource
};
class UBitxRig {
public:
inline void begin() {}
inline void update() {}
inline unsigned getFreqA() const { return catState.getFreqA(); }
inline unsigned getFreqB() const { return catState.getFreqB(); }
inline int getRIT() const { return catState.getRIT(); }
inline int getXIT() const { return catState.getXIT(); }
inline bool isVFOA() const { return catState.isVFOA(); }
inline bool isVFOB() const { return catState.isVFOB(); }
inline bool isSplit() const { return catState.isSplit(); }
inline bool isRITOn() const { return catState.isRITOn(); }
inline bool isXITOn() const { return catState.isXITOn(); }
inline bool isModeCW() const { return catState.isCW() && catState.isUSB(); }
inline bool isModeCWR() const { return catState.isCW() && catState.isLSB(); }
inline bool isModeUSB() const { return catState.isUSB() && !catState.isCW(); }
inline bool isModeLSB() const { return catState.isLSB() && !catState.isCW(); }
inline bool isAI() const { return autoInfo; }
//inline bool updatedByCAT() const { return lastUpdatedBy == CATSource; }
//inline bool updatedByRaduino() const { return lastUpdatedBy == RaduinoSource; }
//inline void clearUpdate() { lastUpdatedBy = NoSource; }
//inline void setRaduinoUpdate() { lastUpdatedBy = RaduinoSource; }
//inline void setCATUpdate() { lastUpdatedBy = CATSource; }
inline void setFreqA(unsigned freq) { catState.setFreqA(freq); }
inline void setFreqB(unsigned freq) { catState.setFreqB(freq); }
inline void setRIT(int freq) { catState.setRIT(freq); }
inline void setXIT(int freq) { catState.setXIT(freq); }
inline void selectVFOA() { catState.selectVFOA(); }
inline void selectVFOB() { catState.selectVFOA(); }
inline void toggleVFO() { catState.toggleVFO(); }
inline void setSplitOn() { catState.setSplitOn(); }
inline void setSplitOff() { catState.setSplitOff(); }
inline void setRITOn() { catState.setRITOn(); }
inline void setRITOff() { catState.setRITOff(); }
inline void setXITOn() { catState.setXITOn(); }
inline void setXITOff() { catState.setXITOff(); }
inline void setModeCW() { catState.setUSB(); catState.setCW(); }
inline void setModeCWR() { catState.setLSB(); catState.setCW(); }
inline void setModeUSB() { catState.setUSB(); catState.setCW(); }
inline void setModeLSB() { catState.setLSB(); catState.setCW(); }
2021-02-07 23:12:08 +00:00
inline void aiOn() { autoInfo = true; }
inline void aiOff() { autoInfo = false; }
inline void updateState(UBitxRigState& r, bool isCAT = false) {
if ((r.vfo[0] == state.vfo[0]) &&
(r.vfo[1] == state.vfo[1]) &&
(r.rit == state.rit) &&
(r.xit == state.xit) &&
(r.flags == state.flags)) {
return;
} else {
state = r;
lastUpdatedBy = isCAT ? CATSource : RaduinoSource;
}
}
/********************************************************************/
// New functional/mode-based Rig methods
// AG
//void setVolOut(uint8_t level);
//uint8_t getVolOut();
// BD/BU
//void setBand();
//void getBand();
2021-02-07 23:12:08 +00:00
private:
bool autoInfo = false;
UpdateSource lastUpdatedBy = NoSource;
UBitxRigState catState;
UBitxRigState radState;
2021-02-07 23:12:08 +00:00
};
extern UBitxRig Rig;
#endif