Various changes. Compiles. Hasn't been tested.
This commit is contained in:
parent
c8aecdfb0d
commit
1f3585d8e4
@ -330,6 +330,11 @@ class UBitxDSP {
|
||||
* Transmit Voice-Operated-Switch (VOX)
|
||||
********************************************************************/
|
||||
|
||||
inline void enableVOX() { state.vox[txSrc].enable = true; }
|
||||
inline void disableVOX() { state.vox[txSrc].enable = false; }
|
||||
inline bool voxEnabled() { return state.vox[txSrc].enable; }
|
||||
inline bool voxDisabled() { return !state.vox[txSrc].enable; }
|
||||
|
||||
inline bool voxActive() { return isVoxActive; }
|
||||
inline bool voxInactive() { return !isVoxActive; }
|
||||
|
||||
|
@ -3,6 +3,9 @@
|
||||
|
||||
#include "RigState.h"
|
||||
|
||||
struct RigState {
|
||||
};
|
||||
|
||||
class UBitxRig {
|
||||
public:
|
||||
inline void begin() {}
|
||||
@ -41,6 +44,7 @@ class UBitxRig {
|
||||
inline void setUSB() { catState.setUSB(); }
|
||||
inline void setLSB() { catState.setLSB(); }
|
||||
|
||||
inline void setAI(bool on) { autoInfo = on; }
|
||||
inline void aiOn() { autoInfo = true; }
|
||||
inline void aiOff() { autoInfo = false; }
|
||||
|
||||
@ -61,7 +65,7 @@ class UBitxRig {
|
||||
private:
|
||||
UBitxRigState catState;
|
||||
UBitxRigState radState;
|
||||
bool autoInfo = false;
|
||||
bool autoInfo = false; // TODO: Move this to rig state struct
|
||||
};
|
||||
|
||||
extern UBitxRig Rig;
|
||||
|
@ -8,7 +8,7 @@
|
||||
UBitxTR TR(DSP);
|
||||
|
||||
void UBitxTR::update(bool cw, bool extKey) {
|
||||
updateKey();
|
||||
updateLinePTT();
|
||||
|
||||
if (cw) {
|
||||
if ((keyEnable && keyDown) || extKey) {
|
||||
@ -19,33 +19,35 @@ void UBitxTR::update(bool cw, bool extKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
updatePTT();
|
||||
updateVOX();
|
||||
updateMicPTT();
|
||||
updateMicVOX();
|
||||
updateDataVOX();
|
||||
|
||||
if (isTX) {
|
||||
// If we are currently transmitting, then ANY T/R release (key
|
||||
// release) will result in exitting transmit... except for VOX
|
||||
// release) will result in exiting transmit... except for VOX
|
||||
// and CAT which can only function as a release if it was enabled.
|
||||
if (pttReleased() || keyReleased() ||
|
||||
(voxEnable && voxDeactivated()) ||
|
||||
(catEnable && catDeactivated())) {
|
||||
if (micPTTReleased() || linePTTReleased() ||
|
||||
(micVOXEnabled() && micVOXDeactivated()) ||
|
||||
(catEnabled() && catDeactivated()) ||
|
||||
(dataVOXEnabled() && dataVOXDeactivated())) {
|
||||
// first, stop transmitting; then, setup RX audio
|
||||
DBGCMD( setRX() );
|
||||
DBGCMD( dsp.rx() );
|
||||
}
|
||||
} else {
|
||||
if ((pttEnable && pttPressed()) || (voxEnable && voxActivated())) {
|
||||
if ((micPTTEnabled() && micPTTPressed()) || (micVOXEnabled() && micVOXActivated())) {
|
||||
// first, setup TX audio; then, start transmitting (from Mic)
|
||||
DBGCMD( dsp.tx(MIC_IN) );
|
||||
DBGCMD( setTX() );
|
||||
} else if (keyEnable && keyPressed()) {
|
||||
DBGCMD( dsp.tx(MIC_IN) );
|
||||
DBGCMD( setTX() );
|
||||
} else if ((linePTTEnabled() && linePTTPressed())) {
|
||||
// first, setup TX audio; then, start transmitting (from Line In)
|
||||
DBGCMD( dsp.tx(LINE_IN) );
|
||||
DBGCMD( setTX() );
|
||||
DBGCMD( setTX() );
|
||||
} else if (catEnable && catActivated()) {
|
||||
// first, setup TX audio; then, start transmitting (USB)
|
||||
DBGCMD( dsp.tx(USB_IN) );
|
||||
DBGCMD( setTX() );
|
||||
DBGCMD( dsp.tx(USB_IN) );
|
||||
DBGCMD( setTX() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,34 +32,40 @@ class UBitxTR {
|
||||
ptt.interval(5);
|
||||
|
||||
// default configuration: PTT, key, and CAT enabled; VOX disabled
|
||||
DBGCMD( enablePTT() );
|
||||
DBGCMD( disableVOX() );
|
||||
DBGCMD( enableKey() );
|
||||
DBGCMD( enableMicPTT() );
|
||||
DBGCMD( disableMicVOX() );
|
||||
DBGCMD( enableLinePTT() );
|
||||
DBGCMD( enableCAT() );
|
||||
|
||||
DBGCMD( setRX() );
|
||||
}
|
||||
|
||||
inline void enablePTT() { pttEnable = true; }
|
||||
inline void enableVOX() { voxEnable = true; }
|
||||
inline void enableKey() { keyEnable = true; }
|
||||
inline void enableMicPTT() { pttEnable = true; }
|
||||
inline void enableMicVOX() { voxEnable = true; }
|
||||
inline void enableLinePTT() { keyEnable = true; }
|
||||
inline void enableDataVOX() { dsp.enableVOX(); }
|
||||
inline void enableCAT() { catEnable = true; }
|
||||
inline void disablePTT() { pttEnable = false; }
|
||||
inline void disableVOX() { voxEnable = false; }
|
||||
inline void disableKey() { keyEnable = false; }
|
||||
|
||||
inline void disableMicPTT() { pttEnable = false; }
|
||||
inline void disableMicVOX() { voxEnable = false; }
|
||||
inline void disableLinePTT() { keyEnable = false; }
|
||||
inline void disableDataVOX() { dsp.disableVOX(); }
|
||||
inline void disableCAT() { catEnable = false; }
|
||||
|
||||
inline bool pttEnabled() { return pttEnable; }
|
||||
inline bool voxEnabled() { return voxEnable; }
|
||||
inline bool keyEnabled() { return keyEnable; }
|
||||
inline bool micPTTEnabled() { return pttEnable; }
|
||||
inline bool micVOXEnabled() { return voxEnable; }
|
||||
inline bool linePTTEnabled() { return keyEnable; }
|
||||
inline bool dataVOXEnabled() { return dsp.voxEnabled(); }
|
||||
inline bool catEnabled() { return catEnable; }
|
||||
|
||||
inline bool pttPressed() { return ptt.fell(); }
|
||||
inline bool pttReleased() { return ptt.rose(); }
|
||||
inline bool voxActivated() { return (L_voxActive != voxActive) && L_voxActive; }
|
||||
inline bool voxDeactivated() { return (L_voxActive != voxActive) && voxActive; }
|
||||
inline bool keyPressed() { return (L_keyDown != keyDown) && L_keyDown; }
|
||||
inline bool keyReleased() { return (L_keyDown != keyDown) && keyDown; }
|
||||
inline bool micPTTPressed() { return ptt.fell(); }
|
||||
inline bool micPTTReleased() { return ptt.rose(); }
|
||||
inline bool micVOXActivated() { return (L_voxActive != voxActive) && L_voxActive; }
|
||||
inline bool micVOXDeactivated() { return (L_voxActive != voxActive) && voxActive; }
|
||||
inline bool linePTTPressed() { return (L_keyDown != keyDown) && L_keyDown; }
|
||||
inline bool linePTTReleased() { return (L_keyDown != keyDown) && keyDown; }
|
||||
inline bool dataVOXActivated() { return (L_dvoxActive != dvoxActive) && L_dvoxActive; }
|
||||
inline bool dataVOXDeactivated() { return (L_dvoxActive != dvoxActive) && dvoxActive; }
|
||||
inline bool catActivated() { return (L_catActive != catActive) && L_catActive; }
|
||||
inline bool catDeactivated() { return (L_catActive != catActive) && catActive; }
|
||||
|
||||
@ -109,20 +115,25 @@ class UBitxTR {
|
||||
digitalWrite(outPin, HIGH);
|
||||
}
|
||||
|
||||
inline void updatePTT() {
|
||||
inline void updateMicPTT() {
|
||||
ptt.update();
|
||||
}
|
||||
|
||||
inline void updateVOX() {
|
||||
inline void updateMicVOX() {
|
||||
L_voxActive = voxActive;
|
||||
voxActive = (digitalRead(voxPin) == LOW);
|
||||
}
|
||||
|
||||
inline void updateKey() {
|
||||
inline void updateLinePTT() {
|
||||
L_keyDown = keyDown;
|
||||
keyDown = (digitalRead(keyPin) == LOW);
|
||||
}
|
||||
|
||||
inline void updateDataVOX() {
|
||||
L_dvoxActive = dvoxActive;
|
||||
dvoxActive = dsp.voxActive();
|
||||
}
|
||||
|
||||
UBitxDSP& dsp;
|
||||
|
||||
Bounce ptt;
|
||||
@ -141,6 +152,8 @@ class UBitxTR {
|
||||
|
||||
bool voxActive = false;
|
||||
bool L_voxActive = false;
|
||||
bool dvoxActive = false;
|
||||
bool L_dvoxActive = false;
|
||||
bool keyDown = false;
|
||||
bool L_keyDown = false;
|
||||
bool catActive = false;
|
||||
|
@ -142,8 +142,17 @@ TS590Error TS590Command::theError = NoError;
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
void TS590Command_Bool::handleCommand(const char* cmd) {
|
||||
setter(cmd[length()] == '0' ? false : true);
|
||||
}
|
||||
|
||||
void TS590Command_Bool::sendResponse(const char* cmd) {
|
||||
ts590SendCommand("%s%s", prefix(), getter() ? "1" : "0");
|
||||
}
|
||||
/**********************************************************************/
|
||||
|
||||
void TS590Command_UL::handleCommand(const char* cmd) {
|
||||
unsigned val = static_cast<unsigned>(strtoul(&prefix()[length()], NULL, 10));
|
||||
unsigned val = static_cast<unsigned>(strtoul(&cmd[length()], NULL, 10));
|
||||
if (val < myMin) {
|
||||
val = myMin;
|
||||
} else if (val > myMax) {
|
||||
@ -361,6 +370,8 @@ unsigned getIDFunc() {
|
||||
|
||||
SetUL setAG = SetUL::create<UBitxDSP, &UBitxDSP::setLineOut255>(DSP);
|
||||
GetUL getAG = GetUL::create<UBitxDSP, &UBitxDSP::getLineOut255>(DSP);
|
||||
SetUL setAI = [](unsigned v) -> void { v == 0 ? Rig.aiOff() : Rig.aiOn(); };
|
||||
GetUL getAI = []() -> unsigned { return Rig.isAI() ? 4 : 0; };
|
||||
//SetUL setSidetone = SetUL::create<UBitxDSP, ...>(...);
|
||||
//GetUL getSidetone = GetUL::create<UBitxDSP, ...>(...);
|
||||
SetUL setUSBin = SetUL::create<UBitxDSP, &UBitxDSP::setUSBIn9>(DSP);
|
||||
@ -381,6 +392,15 @@ SetUL setID = SetUL::create<nullSetFunc>();
|
||||
GetUL getID = GetUL::create<getIDFunc>();
|
||||
|
||||
TS590Command_UL TS590_AG("AG0", 3, 0, 255, setAG, getAG);
|
||||
TS590Command_UL TS590_AI("AI", 1, 0, 4, setAI, getAI);
|
||||
// TS590_AS
|
||||
// TS590_BD
|
||||
// TS590_BU
|
||||
// TS590_CA
|
||||
// TS590_CD0
|
||||
// TS590_CD1
|
||||
// TS590_CD2
|
||||
// TS590_CH
|
||||
#ifndef USE_TS590SG_CAT
|
||||
//TS590Command_UL TS590_EX034("EX0340000", 2, 0, 14, 50, 300, setSideTone, getSideTone);
|
||||
TS590Command_UL TS590_EX064("EX0640000", 1, 0, 9, setUSBin, getUSBin);
|
||||
|
@ -169,6 +169,24 @@ class TS590Command {
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
typedef etl::delegate<void(bool)> SetBool;
|
||||
typedef etl::delegate<bool(void)> GetBool;
|
||||
|
||||
class TS590Command_Bool : public TS590Command {
|
||||
public:
|
||||
TS590Command_Bool(const char* prefix, SetBool set, GetBool get)
|
||||
: TS590Command(prefix), setter(set), getter(get) {}
|
||||
|
||||
virtual void handleCommand(const char* cmd);
|
||||
virtual void sendResponse(const char* cmd);
|
||||
|
||||
private:
|
||||
SetBool setter;
|
||||
GetBool getter;
|
||||
};
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
typedef etl::delegate<void(unsigned)> SetUL;
|
||||
typedef etl::delegate<unsigned(void)> GetUL;
|
||||
|
||||
@ -193,6 +211,24 @@ class TS590Command_UL : public TS590Command {
|
||||
GetUL getter;
|
||||
};
|
||||
|
||||
/**********************************************************************/
|
||||
/*
|
||||
typedef etl::delegate<void(bool)> SetULArray;
|
||||
typedef etl::delegate<bool(void)> GetULArray;
|
||||
|
||||
class TS590Command_ULArray : public TS590Command {
|
||||
public:
|
||||
TS590Command_ULArray(const char* prefix, SetUL set, GetUL get)
|
||||
: TS590Command(prefix), setter(set), getter(get) {}
|
||||
|
||||
virtual void handleCommand(const char* cmd);
|
||||
virtual void sendResponse(const char* cmd);
|
||||
|
||||
private:
|
||||
SetUL setter;
|
||||
GetUL getter;
|
||||
};
|
||||
*/
|
||||
/**********************************************************************/
|
||||
|
||||
/*!
|
||||
|
@ -593,11 +593,11 @@ void loop()
|
||||
Serial.println(AudioMemoryUsageMax());
|
||||
Serial.println("----------------------------------------------------------------------");
|
||||
Serial.print("Enabled/Active: PTT: ");
|
||||
Serial.print(TR.pttEnabled() ? "Y" : "N"); Serial.print("/"); Serial.print(TR.pttPressed() ? "Y" : "N");
|
||||
Serial.print(TR.micPTTEnabled() ? "Y" : "N"); Serial.print("/"); Serial.print(TR.micPTTPressed() ? "Y" : "N");
|
||||
Serial.print(", VOX: ");
|
||||
Serial.print(TR.voxEnabled() ? "Y" : "N"); Serial.print("/"); Serial.print(TR.voxActivated() ? "Y" : "N");
|
||||
Serial.print(TR.micVOXEnabled() ? "Y" : "N"); Serial.print("/"); Serial.print(TR.micVOXActivated() ? "Y" : "N");
|
||||
Serial.print(", Key: ");
|
||||
Serial.print(TR.keyEnabled() ? "Y" : "N"); Serial.print("/"); Serial.print(TR.keyPressed() ? "Y" : "N");
|
||||
Serial.print(TR.linePTTEnabled() ? "Y" : "N"); Serial.print("/"); Serial.print(TR.linePTTPressed() ? "Y" : "N");
|
||||
Serial.print(", CAT: ");
|
||||
Serial.print(TR.catEnabled() ? "Y" : "N"); Serial.print("/"); Serial.print(TR.catActivated() ? "Y" : "N");
|
||||
Serial.println();
|
||||
|
Loading…
x
Reference in New Issue
Block a user