From 1f3585d8e491b267b8be657e5735cc2f6e2bab55 Mon Sep 17 00:00:00 2001 From: Rob French Date: Fri, 19 Mar 2021 15:30:30 -0500 Subject: [PATCH] Various changes. Compiles. Hasn't been tested. --- TeensyDSP/DSP.h | 5 ++++ TeensyDSP/Rig.h | 6 ++++- TeensyDSP/TR.cpp | 30 +++++++++++----------- TeensyDSP/TR.h | 55 +++++++++++++++++++++++++---------------- TeensyDSP/TS590.cpp | 22 ++++++++++++++++- TeensyDSP/TS590.h | 36 +++++++++++++++++++++++++++ TeensyDSP/TeensyDSP.ino | 6 ++--- 7 files changed, 120 insertions(+), 40 deletions(-) diff --git a/TeensyDSP/DSP.h b/TeensyDSP/DSP.h index 65010bf..e9cea44 100644 --- a/TeensyDSP/DSP.h +++ b/TeensyDSP/DSP.h @@ -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; } diff --git a/TeensyDSP/Rig.h b/TeensyDSP/Rig.h index 65cf04c..ecfba15 100644 --- a/TeensyDSP/Rig.h +++ b/TeensyDSP/Rig.h @@ -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; diff --git a/TeensyDSP/TR.cpp b/TeensyDSP/TR.cpp index 3d30f98..acb2892 100644 --- a/TeensyDSP/TR.cpp +++ b/TeensyDSP/TR.cpp @@ -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() ); } } } diff --git a/TeensyDSP/TR.h b/TeensyDSP/TR.h index 9700e51..382903c 100644 --- a/TeensyDSP/TR.h +++ b/TeensyDSP/TR.h @@ -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; diff --git a/TeensyDSP/TS590.cpp b/TeensyDSP/TS590.cpp index 55d2305..0f5358c 100644 --- a/TeensyDSP/TS590.cpp +++ b/TeensyDSP/TS590.cpp @@ -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(strtoul(&prefix()[length()], NULL, 10)); + unsigned val = static_cast(strtoul(&cmd[length()], NULL, 10)); if (val < myMin) { val = myMin; } else if (val > myMax) { @@ -361,6 +370,8 @@ unsigned getIDFunc() { SetUL setAG = SetUL::create(DSP); GetUL getAG = GetUL::create(DSP); +SetUL setAI = [](unsigned v) -> void { v == 0 ? Rig.aiOff() : Rig.aiOn(); }; +GetUL getAI = []() -> unsigned { return Rig.isAI() ? 4 : 0; }; //SetUL setSidetone = SetUL::create(...); //GetUL getSidetone = GetUL::create(...); SetUL setUSBin = SetUL::create(DSP); @@ -381,6 +392,15 @@ SetUL setID = SetUL::create(); GetUL getID = GetUL::create(); 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); diff --git a/TeensyDSP/TS590.h b/TeensyDSP/TS590.h index 26e1f06..cb3567e 100644 --- a/TeensyDSP/TS590.h +++ b/TeensyDSP/TS590.h @@ -169,6 +169,24 @@ class TS590Command { /**********************************************************************/ +typedef etl::delegate SetBool; +typedef etl::delegate 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 SetUL; typedef etl::delegate GetUL; @@ -193,6 +211,24 @@ class TS590Command_UL : public TS590Command { GetUL getter; }; +/**********************************************************************/ +/* +typedef etl::delegate SetULArray; +typedef etl::delegate 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; +}; +*/ /**********************************************************************/ /*! diff --git a/TeensyDSP/TeensyDSP.ino b/TeensyDSP/TeensyDSP.ino index d7ecda3..121f4f0 100644 --- a/TeensyDSP/TeensyDSP.ino +++ b/TeensyDSP/TeensyDSP.ino @@ -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();