Fixed comms between the Raduino and the IOP. Implemented the wrapper
that allows messages to go back from the IOP to Raduino. I don't know if actual CAT from the PC works currently, however.
This commit is contained in:
parent
ccae79925b
commit
9c1a490963
@ -16,6 +16,16 @@
|
|||||||
|
|
||||||
//======================================================================
|
//======================================================================
|
||||||
|
|
||||||
|
void sendCATMessage(const uint8_t* buf)
|
||||||
|
{
|
||||||
|
MYSERIAL.write(prefixAndLengthToByte(CAT_PREFIX, 5));
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
MYSERIAL.write(buf[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//======================================================================
|
||||||
|
|
||||||
void sendIOPMessage(IOPMessage const& msg)
|
void sendIOPMessage(IOPMessage const& msg)
|
||||||
{
|
{
|
||||||
MYSERIAL.write(prefixAndLengthToByte(IOP_PREFIX, msg.len + 1));
|
MYSERIAL.write(prefixAndLengthToByte(IOP_PREFIX, msg.len + 1));
|
||||||
@ -77,6 +87,70 @@ void sendIOPModeRequest()
|
|||||||
sendIOPMessage(m);
|
sendIOPMessage(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//======================================================================
|
||||||
|
// SSB STATUS MESSAGE
|
||||||
|
//======================================================================
|
||||||
|
|
||||||
|
void sendIOPSSBStatus(SSBConfig const &c)
|
||||||
|
{
|
||||||
|
IOPMessage m;
|
||||||
|
m.id = IOP_SSB_STATUS_MSG;
|
||||||
|
m.len = 4;
|
||||||
|
m.data[0] = 'S'; // current mode; redundant w/ Raduino mode, but maybe useful for debugging
|
||||||
|
m.data[1] = '-'; // placeholder for transmit filter/compressor
|
||||||
|
m.data[2] = RX_FILTER_LETTER[c.filter];
|
||||||
|
m.data[3] = '\0';
|
||||||
|
sendIOPMessage(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
//======================================================================
|
||||||
|
// DIGI STATUS MESSAGE
|
||||||
|
//======================================================================
|
||||||
|
|
||||||
|
void sendIOPDigiStatus(DigiConfig const &c)
|
||||||
|
{
|
||||||
|
IOPMessage m;
|
||||||
|
m.id = IOP_DIGI_STATUS_MSG;
|
||||||
|
m.len = 4;
|
||||||
|
m.data[0] = 'D'; // current mode; redundant w/ Raduino mode, but maybe useful for debugging
|
||||||
|
m.data[1] = '-'; // placeholder for future digital submodes?
|
||||||
|
m.data[2] = RX_FILTER_LETTER[c.filter];
|
||||||
|
m.data[3] = '\0';
|
||||||
|
sendIOPMessage(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
//======================================================================
|
||||||
|
// CW STATUS MESSAGE
|
||||||
|
//======================================================================
|
||||||
|
|
||||||
|
void sendIOPCWStatus(CWConfig const &c)
|
||||||
|
{
|
||||||
|
IOPMessage m;
|
||||||
|
m.id = IOP_CW_STATUS_MSG;
|
||||||
|
m.len = 4;
|
||||||
|
m.data[0] = 'C'; // current mode; redundant w/ Raduino mode, but maybe useful for debugging
|
||||||
|
m.data[1] = KEYER_MODE_LETTER[c.mode];
|
||||||
|
m.data[2] = RX_FILTER_LETTER[c.filter];
|
||||||
|
m.data[3] = '\0';
|
||||||
|
sendIOPMessage(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
//======================================================================
|
||||||
|
// TEST STATUS MESSAGE
|
||||||
|
//======================================================================
|
||||||
|
|
||||||
|
void sendIOPTestStatus()
|
||||||
|
{
|
||||||
|
IOPMessage m;
|
||||||
|
m.id = IOP_TEST_STATUS_MSG;
|
||||||
|
m.len = 4;
|
||||||
|
m.data[0] = ' ';
|
||||||
|
m.data[1] = 'T';
|
||||||
|
m.data[2] = 'T';
|
||||||
|
m.data[3] = '\0';
|
||||||
|
sendIOPMessage(m);
|
||||||
|
}
|
||||||
|
|
||||||
//======================================================================
|
//======================================================================
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -70,7 +70,10 @@ enum MessageID {
|
|||||||
|
|
||||||
// Requests
|
// Requests
|
||||||
IOP_MODE_REQUEST,
|
IOP_MODE_REQUEST,
|
||||||
|
IOP_SSB_STATUS_MSG,
|
||||||
|
IOP_DIGI_STATUS_MSG,
|
||||||
IOP_CW_STATUS_MSG,
|
IOP_CW_STATUS_MSG,
|
||||||
|
IOP_TEST_STATUS_MSG,
|
||||||
|
|
||||||
// add any new elements here
|
// add any new elements here
|
||||||
NUM_MESSAGE_IDS
|
NUM_MESSAGE_IDS
|
||||||
@ -92,10 +95,10 @@ enum MessageID {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
enum RigMode {
|
enum RigMode {
|
||||||
MODE_SSB = 0,
|
RIG_MODE_SSB = 0,
|
||||||
MODE_DIGI,
|
RIG_MODE_DIGI,
|
||||||
MODE_CW,
|
RIG_MODE_CW,
|
||||||
MODE_TEST,
|
RIG_MODE_TEST,
|
||||||
// add any new elements here
|
// add any new elements here
|
||||||
NUM_RIG_MODES
|
NUM_RIG_MODES
|
||||||
};
|
};
|
||||||
@ -103,17 +106,26 @@ enum RigMode {
|
|||||||
/* Keyer modes.
|
/* Keyer modes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum KeyMode {
|
enum KeyerMode {
|
||||||
STRAIGHT = 0,
|
KEYER_MODE_STRAIGHT = 0,
|
||||||
IAMBIC_A,
|
KEYER_MODE_IAMBIC_A,
|
||||||
IAMBIC_B,
|
KEYER_MODE_IAMBIC_B,
|
||||||
//ULTIMATIC,
|
//KEYER_ULTIMATIC,
|
||||||
//BUG,
|
//KEYER_BUG,
|
||||||
// add any new elements here
|
// add any new elements here
|
||||||
NUM_KEY_MODES
|
NUM_KEYER_MODES
|
||||||
};
|
};
|
||||||
|
|
||||||
const unsigned char MODE_LETTER[3] = {'S', 'A', 'B'};
|
enum RxFilter {
|
||||||
|
RX_FILTER_NORMAL = 0,
|
||||||
|
RX_FILTER_NARROW,
|
||||||
|
RX_FILTER_WIDE,
|
||||||
|
NUM_RX_FILTERS
|
||||||
|
};
|
||||||
|
|
||||||
|
const unsigned char RIG_MODE_LETTER[NUM_RIG_MODES] = {'S', 'D', 'C', 'T'};
|
||||||
|
const unsigned char KEYER_MODE_LETTER[NUM_KEYER_MODES] = {'S', 'A', 'B'};
|
||||||
|
const unsigned char RX_FILTER_LETTER[NUM_RX_FILTERS] = {'-', 'N', 'W'};
|
||||||
|
|
||||||
const uint8_t NO_FLAGS = 0;
|
const uint8_t NO_FLAGS = 0;
|
||||||
const uint8_t REVERSED = 1;
|
const uint8_t REVERSED = 1;
|
||||||
@ -124,14 +136,23 @@ struct IOPMessage {
|
|||||||
uint8_t data[IOP_MESSAGE_MAX_LEN];
|
uint8_t data[IOP_MESSAGE_MAX_LEN];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//======================================================================
|
||||||
|
// SSB CONFIGURATION
|
||||||
|
//======================================================================
|
||||||
|
|
||||||
void sendIOPMessage(IOPMessage const&);
|
struct SSBConfig {
|
||||||
void recvIOPMessage(IOPMessage&, const uint8_t*, int);
|
// parameters
|
||||||
|
RxFilter filter = RX_FILTER_NORMAL;
|
||||||
|
};
|
||||||
|
|
||||||
void sendIOPModeCommand(RigMode);
|
//======================================================================
|
||||||
void sendIOPStartTxCommand();
|
// DIGI CONFIGURATION
|
||||||
void sendIOPStopTxCommand();
|
//======================================================================
|
||||||
void sendIOPModeRequest();
|
|
||||||
|
struct DigiConfig {
|
||||||
|
// parameters
|
||||||
|
RxFilter filter = RX_FILTER_NORMAL;
|
||||||
|
};
|
||||||
|
|
||||||
//======================================================================
|
//======================================================================
|
||||||
// CW CONFIGURATION
|
// CW CONFIGURATION
|
||||||
@ -139,15 +160,34 @@ void sendIOPModeRequest();
|
|||||||
|
|
||||||
struct CWConfig {
|
struct CWConfig {
|
||||||
// mode
|
// mode
|
||||||
KeyMode mode = IAMBIC_A;
|
KeyerMode mode = KEYER_MODE_IAMBIC_A;
|
||||||
// flags
|
// flags
|
||||||
bool reversed = false;
|
bool reversed = false;
|
||||||
// parameters
|
// parameters
|
||||||
uint8_t wpm = 15;
|
uint8_t wpm = 15;
|
||||||
float weight = 3.0;
|
float weight = 3.0;
|
||||||
uint16_t sidetone = 700;
|
uint16_t sidetone = 700;
|
||||||
|
RxFilter filter = RX_FILTER_NORMAL;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//======================================================================
|
||||||
|
// FUNCTION PROTOTYPES
|
||||||
|
//======================================================================
|
||||||
|
|
||||||
|
void sendCATMessage(const uint8_t*);
|
||||||
|
void sendIOPMessage(IOPMessage const&);
|
||||||
|
void recvIOPMessage(IOPMessage&, const uint8_t*, int);
|
||||||
|
|
||||||
|
void sendIOPModeCommand(RigMode);
|
||||||
|
void sendIOPStartTxCommand();
|
||||||
|
void sendIOPStopTxCommand();
|
||||||
|
|
||||||
|
void sendIOPModeRequest();
|
||||||
|
void sendIOPSSBStatus(SSBConfig const&);
|
||||||
|
void sendIOPDigiStatus(DigiConfig const&);
|
||||||
|
void sendIOPCWStatus(CWConfig const&);
|
||||||
|
void sendIOPTestStatus();
|
||||||
|
|
||||||
//======================================================================
|
//======================================================================
|
||||||
// TRANSLATOR
|
// TRANSLATOR
|
||||||
//======================================================================
|
//======================================================================
|
||||||
@ -187,23 +227,6 @@ class Translator
|
|||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//======================================================================
|
|
||||||
// CW STATUS MESSAGE
|
|
||||||
//======================================================================
|
|
||||||
|
|
||||||
//void packT_DisplayText(TMessage &m, CWConfig const &c)
|
|
||||||
//{
|
|
||||||
// m.id = IOP_CW_STATUS_MSG;
|
|
||||||
// m.len = 3;
|
|
||||||
// m.data[0] = ' '; // growth
|
|
||||||
// m.data[1] = MODE_LETTER[c.mode];
|
|
||||||
// m.data[2] = ' '; // TODO: RX filter width
|
|
||||||
//}
|
|
||||||
|
|
||||||
// No unpack required: this is a string to put on the display.
|
|
||||||
|
|
||||||
//======================================================================
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//======================================================================
|
//======================================================================
|
||||||
|
@ -304,10 +304,10 @@ void audioTransmit()
|
|||||||
{
|
{
|
||||||
switch(rigMode) {
|
switch(rigMode) {
|
||||||
// Nothing special for CW, TX audio inputs are already muted.
|
// Nothing special for CW, TX audio inputs are already muted.
|
||||||
//case MODE_CW:
|
//case RIG_MODE_CW:
|
||||||
//break;
|
//break;
|
||||||
|
|
||||||
case MODE_SSB:
|
case RIG_MODE_SSB:
|
||||||
// Mute the incoming RX audio. Can't think of a good reason
|
// Mute the incoming RX audio. Can't think of a good reason
|
||||||
// to let RX audio in while we're transmitting.
|
// to let RX audio in while we're transmitting.
|
||||||
muteRxRigIn();
|
muteRxRigIn();
|
||||||
@ -335,14 +335,14 @@ void audioTransmit()
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_DIGI:
|
case RIG_MODE_DIGI:
|
||||||
// Mute the incoming RX audio. Can't think of a good reason
|
// Mute the incoming RX audio. Can't think of a good reason
|
||||||
// to let RX audio in while we're transmitting.
|
// to let RX audio in while we're transmitting.
|
||||||
muteRxRigIn();
|
muteRxRigIn();
|
||||||
updateTxUSBIn();
|
updateTxUSBIn();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_TEST:
|
case RIG_MODE_TEST:
|
||||||
muteRxRigIn();
|
muteRxRigIn();
|
||||||
updateTxTwoToneIn();
|
updateTxTwoToneIn();
|
||||||
break;
|
break;
|
||||||
@ -359,10 +359,10 @@ void audioTransmit()
|
|||||||
void audioReceive()
|
void audioReceive()
|
||||||
{
|
{
|
||||||
switch(rigMode) {
|
switch(rigMode) {
|
||||||
//case MODE_CW:
|
//case RIG_MODE_CW:
|
||||||
//break;
|
//break;
|
||||||
|
|
||||||
case MODE_SSB:
|
case RIG_MODE_SSB:
|
||||||
if (audioTxInput == TX_MIC_IN) {
|
if (audioTxInput == TX_MIC_IN) {
|
||||||
muteTxMicIn();
|
muteTxMicIn();
|
||||||
audioCtrl.inputSelect(AUDIO_INPUT_LINEIN);
|
audioCtrl.inputSelect(AUDIO_INPUT_LINEIN);
|
||||||
@ -372,12 +372,12 @@ void audioReceive()
|
|||||||
restoreRxRigIn();
|
restoreRxRigIn();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_DIGI:
|
case RIG_MODE_DIGI:
|
||||||
muteTxUSBIn();
|
muteTxUSBIn();
|
||||||
restoreRxRigIn();
|
restoreRxRigIn();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_TEST:
|
case RIG_MODE_TEST:
|
||||||
muteTxTwoToneIn();
|
muteTxTwoToneIn();
|
||||||
restoreRxRigIn();
|
restoreRxRigIn();
|
||||||
break;
|
break;
|
||||||
|
@ -30,16 +30,12 @@ void initCAT(long baud, int portConfig)
|
|||||||
// CAT with PC via USB
|
// CAT with PC via USB
|
||||||
USBSERIAL.begin(baud);
|
USBSERIAL.begin(baud);
|
||||||
USBSERIAL.flush();
|
USBSERIAL.flush();
|
||||||
#if defined(DEBUG)
|
USBDEBUG("opened USB serial port (to PC)");
|
||||||
USBSERIAL.println("IOP: opened USB serial port (to PC)");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Comm (including CAT passthru) with Raduino via UART
|
// Comm (including CAT passthru) with Raduino via UART
|
||||||
HWSERIAL.begin(baud, portConfig);
|
HWSERIAL.begin(baud, portConfig);
|
||||||
HWSERIAL.flush();
|
HWSERIAL.flush();
|
||||||
#if defined(DEBUG)
|
USBDEBUG("opened H/W serial port (to Raduino)");
|
||||||
USBSERIAL.println("IOP: opened H/W serial port (to Raduino)");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//sendIOPModeRequest(); // Raduino doesn't support this yet
|
//sendIOPModeRequest(); // Raduino doesn't support this yet
|
||||||
}
|
}
|
||||||
@ -54,19 +50,19 @@ void processIOPCommand(IOPMessage const& m)
|
|||||||
if (m.len < 1) {
|
if (m.len < 1) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
setRigMode(m.data[0]);
|
setRigMode(RigMode(m.data[0]));
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
switch(rigMode) {
|
switch(rigMode) {
|
||||||
case MODE_CW:
|
case RIG_MODE_CW:
|
||||||
USBDEBUG("new mode - CW");
|
USBDEBUG("new mode - CW");
|
||||||
break;
|
break;
|
||||||
case MODE_SSB:
|
case RIG_MODE_SSB:
|
||||||
USBDEBUG("new mode - SSB");
|
USBDEBUG("new mode - SSB");
|
||||||
break;
|
break;
|
||||||
case MODE_DIGI:
|
case RIG_MODE_DIGI:
|
||||||
USBDEBUG("new mode - DIGI");
|
USBDEBUG("new mode - DIGI");
|
||||||
break;
|
break;
|
||||||
case MODE_TEST:
|
case RIG_MODE_TEST:
|
||||||
USBDEBUG("new mode - TEST");
|
USBDEBUG("new mode - TEST");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -126,8 +122,8 @@ enum SerialState {
|
|||||||
EEPROM_WRITE,
|
EEPROM_WRITE,
|
||||||
} serialState = NORMAL;
|
} serialState = NORMAL;
|
||||||
|
|
||||||
uint8_t readPrefix = 0;
|
PrefixID readPrefix;
|
||||||
uint8_t readLength = 0;
|
uint8_t readLength;
|
||||||
|
|
||||||
int cmdLength = 0;
|
int cmdLength = 0;
|
||||||
byte cmdBuffer[16];
|
byte cmdBuffer[16];
|
||||||
@ -139,13 +135,37 @@ int magicFlag = 0;
|
|||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
|
uint8_t usbCatLength = 0;
|
||||||
|
byte usbCatBuffer[5];
|
||||||
|
elapsedMillis usbCatTimer;
|
||||||
|
|
||||||
|
#define CAT_RECEIVE_TIMEOUT 500
|
||||||
|
|
||||||
void serviceCAT()
|
void serviceCAT()
|
||||||
{
|
{
|
||||||
uint8_t incomingByte;
|
uint8_t incomingByte;
|
||||||
|
|
||||||
|
if ((usbCatLength > 0) && (usbCatTimer > CAT_RECEIVE_TIMEOUT)) {
|
||||||
|
// timeout... clear the buffer and start over
|
||||||
|
usbCatLength = 0;
|
||||||
|
usbCatTimer = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// read from the USB serial, pass through to UART serial
|
// read from the USB serial, pass through to UART serial
|
||||||
for (int i = 0; i < USBSERIAL.available(); i++) {
|
for (int i = 0; i < USBSERIAL.available(); i++) {
|
||||||
incomingByte = USBSERIAL.read();
|
incomingByte = USBSERIAL.read();
|
||||||
|
usbCatTimer = 0;
|
||||||
|
|
||||||
|
#if not defined(FACTORY_CALIBRATION)
|
||||||
|
usbCatBuffer[usbCatLength++] = incomingByte;
|
||||||
|
if (usbCatLength == 5) {
|
||||||
|
sendCATMessage(usbCatBuffer);
|
||||||
|
usbCatLength = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: This code does NOT handle any interrupts in COMMS from the PC...
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(FACTORY_CALIBRATION)
|
#if defined(FACTORY_CALIBRATION)
|
||||||
// unless we're in factory calibration mode, in which case we're going
|
// unless we're in factory calibration mode, in which case we're going
|
||||||
@ -176,7 +196,7 @@ void serviceCAT()
|
|||||||
#else
|
#else
|
||||||
// Don't pass CAT commands through if in DEBUG mode.
|
// Don't pass CAT commands through if in DEBUG mode.
|
||||||
#if not defined(DEBUG)
|
#if not defined(DEBUG)
|
||||||
HWSERIAL.write(incomingByte);
|
//HWSERIAL.write(incomingByte);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// Uncomment to use the "factory" calibration mode. This is intended to
|
// Uncomment to use the "factory" calibration mode. This is intended to
|
||||||
// allow calibration of IOP settings, separately from the uBITX/Raduino.
|
// allow calibration of IOP settings, separately from the uBITX/Raduino.
|
||||||
// There will be no pass-thru of any CAT.
|
// There will be no pass-thru of any CAT.
|
||||||
#define FACTORY_CALIBRATION
|
//#define FACTORY_CALIBRATION
|
||||||
|
|
||||||
// IOPConfig
|
// IOPConfig
|
||||||
// Used to store configuration parameters during runtime, as well as to
|
// Used to store configuration parameters during runtime, as well as to
|
||||||
@ -84,11 +84,17 @@ struct IOPConfig {
|
|||||||
float txSine2Vol = 1.0;
|
float txSine2Vol = 1.0;
|
||||||
// rig-out parameters (TX) - default settings are based on hitting 70% of 25mVrms w/ mic
|
// rig-out parameters (TX) - default settings are based on hitting 70% of 25mVrms w/ mic
|
||||||
uint8_t txRigOutLevel = 31;
|
uint8_t txRigOutLevel = 31;
|
||||||
float txRigOutCal = 0.043;
|
float txRigOutCal = 0.1; // 0.061;
|
||||||
// USB-out parameters (TX)- debug/monitor use only
|
// USB-out parameters (TX)- debug/monitor use only
|
||||||
bool txUSBOutEnable = true;
|
bool txUSBOutEnable = true;
|
||||||
float txUSBOutCal = 1.0;
|
float txUSBOutCal = 1.0;
|
||||||
|
|
||||||
|
// SSB configuration
|
||||||
|
SSBConfig ssb;
|
||||||
|
|
||||||
|
// Digi configuration
|
||||||
|
DigiConfig digi;
|
||||||
|
|
||||||
// CW configuration
|
// CW configuration
|
||||||
CWConfig cw;
|
CWConfig cw;
|
||||||
};
|
};
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include "keyer.h"
|
#include "keyer.h"
|
||||||
|
|
||||||
// comment this out to disable debugging code
|
// comment this out to disable debugging code
|
||||||
//#define DEBUG
|
#define DEBUG
|
||||||
|
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
#define USBDEBUG(x) USBSERIAL.print("IOP: "); USBSERIAL.println(x);
|
#define USBDEBUG(x) USBSERIAL.print("IOP: "); USBSERIAL.println(x);
|
||||||
|
@ -8,7 +8,8 @@
|
|||||||
#include <Bounce2.h>
|
#include <Bounce2.h>
|
||||||
#define BOUNCE_WITH_PROMPT_DETECTION
|
#define BOUNCE_WITH_PROMPT_DETECTION
|
||||||
|
|
||||||
RigMode rigMode = MODE_SSB;
|
RigMode rigMode = RIG_MODE_SSB;
|
||||||
|
RxFilter rxFilter = RX_FILTER_NORMAL;
|
||||||
IOPConfig iopConfig;
|
IOPConfig iopConfig;
|
||||||
|
|
||||||
#define MIC_PTT_PIN 21
|
#define MIC_PTT_PIN 21
|
||||||
@ -44,10 +45,10 @@ void catPTTOn()
|
|||||||
// CAT should not start or stop TX in CW mode... we really should
|
// CAT should not start or stop TX in CW mode... we really should
|
||||||
// not even get this command. But maybe the rig control software is
|
// not even get this command. But maybe the rig control software is
|
||||||
// doing it (but then, we should inhibit this in the Raduino).
|
// doing it (but then, we should inhibit this in the Raduino).
|
||||||
//case MODE_CW:
|
//case RIG_MODE_CW:
|
||||||
//break;
|
//break;
|
||||||
|
|
||||||
case MODE_SSB:
|
case RIG_MODE_SSB:
|
||||||
// In SSB mode, CAT-PTT will always (de-)activate the Line-In TX
|
// In SSB mode, CAT-PTT will always (de-)activate the Line-In TX
|
||||||
// audio source.
|
// audio source.
|
||||||
txState = TX_CAT;
|
txState = TX_CAT;
|
||||||
@ -56,7 +57,7 @@ void catPTTOn()
|
|||||||
digitalWrite(PTT_KEY_OUT_PIN, LOW);
|
digitalWrite(PTT_KEY_OUT_PIN, LOW);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_DIGI:
|
case RIG_MODE_DIGI:
|
||||||
// In Digital (USB) mode, CAT-PTT will always (de-)activate the
|
// In Digital (USB) mode, CAT-PTT will always (de-)activate the
|
||||||
// USB-In TX audio source.
|
// USB-In TX audio source.
|
||||||
txState = TX_CAT;
|
txState = TX_CAT;
|
||||||
@ -82,10 +83,10 @@ void catPTTOff()
|
|||||||
// CAT should not start or stop TX in CW mode... we really should
|
// CAT should not start or stop TX in CW mode... we really should
|
||||||
// not even get this command. But maybe the rig control software is
|
// not even get this command. But maybe the rig control software is
|
||||||
// doing it (but then, we should inhibit this in the Raduino).
|
// doing it (but then, we should inhibit this in the Raduino).
|
||||||
//case MODE_CW:
|
//case RIG_MODE_CW:
|
||||||
//break;
|
//break;
|
||||||
|
|
||||||
case MODE_SSB:
|
case RIG_MODE_SSB:
|
||||||
// In SSB mode, CAT-PTT will always (de-)activate the Line-In TX
|
// In SSB mode, CAT-PTT will always (de-)activate the Line-In TX
|
||||||
// audio source.
|
// audio source.
|
||||||
digitalWrite(PTT_KEY_OUT_PIN, HIGH);
|
digitalWrite(PTT_KEY_OUT_PIN, HIGH);
|
||||||
@ -93,7 +94,7 @@ void catPTTOff()
|
|||||||
txState = TX_OFF;
|
txState = TX_OFF;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_DIGI:
|
case RIG_MODE_DIGI:
|
||||||
// In Digital (USB) mode, CAT-PTT will always (de-)activate the
|
// In Digital (USB) mode, CAT-PTT will always (de-)activate the
|
||||||
// USB-In TX audio source.
|
// USB-In TX audio source.
|
||||||
digitalWrite(PTT_KEY_OUT_PIN, HIGH);
|
digitalWrite(PTT_KEY_OUT_PIN, HIGH);
|
||||||
@ -115,39 +116,35 @@ void checkMicPTT()
|
|||||||
// was released--the Mic-PTT can always be used to terminate a
|
// was released--the Mic-PTT can always be used to terminate a
|
||||||
// transmission from another source.
|
// transmission from another source.
|
||||||
if ((txState != TX_OFF) && micPTT.rose()) {
|
if ((txState != TX_OFF) && micPTT.rose()) {
|
||||||
#if defined(DEBUG)
|
USBDEBUG("mic PTT released");
|
||||||
USBSERIAL.println("DEBUG: mic PTT released");
|
|
||||||
#endif
|
|
||||||
digitalWrite(PTT_KEY_OUT_PIN, HIGH);
|
digitalWrite(PTT_KEY_OUT_PIN, HIGH);
|
||||||
// In CW mode, we get a sidetone from the uBITX, so we don't mute
|
// In CW mode, we get a sidetone from the uBITX, so we don't mute
|
||||||
// the receive audio.
|
// the receive audio.
|
||||||
if (rigMode != MODE_CW) audioReceive();
|
if (rigMode != RIG_MODE_CW) audioReceive();
|
||||||
txState = TX_OFF;
|
txState = TX_OFF;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((txState == TX_OFF) && micPTT.fell()) {
|
if ((txState == TX_OFF) && micPTT.fell()) {
|
||||||
#if defined(DEBUG)
|
USBDEBUG("mic PTT depressed");
|
||||||
USBSERIAL.println("DEBUG: mic PTT depressed");
|
|
||||||
#endif
|
|
||||||
switch(rigMode) {
|
switch(rigMode) {
|
||||||
case MODE_CW:
|
case RIG_MODE_CW:
|
||||||
txState = TX_MIC;
|
txState = TX_MIC;
|
||||||
digitalWrite(PTT_KEY_OUT_PIN, LOW);
|
digitalWrite(PTT_KEY_OUT_PIN, LOW);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_SSB:
|
case RIG_MODE_SSB:
|
||||||
txState = TX_MIC;
|
txState = TX_MIC;
|
||||||
audioSelectTxInput(TX_MIC_IN);
|
audioSelectTxInput(TX_MIC_IN);
|
||||||
audioTransmit();
|
audioTransmit();
|
||||||
digitalWrite(PTT_KEY_OUT_PIN, LOW);
|
digitalWrite(PTT_KEY_OUT_PIN, LOW);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_DIGI:
|
case RIG_MODE_DIGI:
|
||||||
// Mic PTT actuation during Digital does nothing.
|
// Mic PTT actuation during Digital does nothing.
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_TEST:
|
case RIG_MODE_TEST:
|
||||||
txState = TX_MIC;
|
txState = TX_MIC;
|
||||||
audioSelectTxInput(TX_TEST_IN);
|
audioSelectTxInput(TX_TEST_IN);
|
||||||
audioTransmit();
|
audioTransmit();
|
||||||
@ -172,30 +169,30 @@ void checkLinePTT()
|
|||||||
digitalWrite(PTT_KEY_OUT_PIN, HIGH);
|
digitalWrite(PTT_KEY_OUT_PIN, HIGH);
|
||||||
// In CW mode, we get a sidetone from the uBITX, so we don't mute
|
// In CW mode, we get a sidetone from the uBITX, so we don't mute
|
||||||
// the receive audio.
|
// the receive audio.
|
||||||
if (rigMode != MODE_CW) audioReceive();
|
if (rigMode != RIG_MODE_CW) audioReceive();
|
||||||
txState = TX_OFF;
|
txState = TX_OFF;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((txState == TX_OFF) && linePTT.fell()) {
|
if ((txState == TX_OFF) && linePTT.fell()) {
|
||||||
switch(rigMode) {
|
switch(rigMode) {
|
||||||
case MODE_CW:
|
case RIG_MODE_CW:
|
||||||
txState = TX_LINE;
|
txState = TX_LINE;
|
||||||
digitalWrite(PTT_KEY_OUT_PIN, LOW);
|
digitalWrite(PTT_KEY_OUT_PIN, LOW);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_SSB:
|
case RIG_MODE_SSB:
|
||||||
txState = TX_LINE;
|
txState = TX_LINE;
|
||||||
audioSelectTxInput(TX_LINE_IN);
|
audioSelectTxInput(TX_LINE_IN);
|
||||||
audioTransmit();
|
audioTransmit();
|
||||||
digitalWrite(PTT_KEY_OUT_PIN, LOW);
|
digitalWrite(PTT_KEY_OUT_PIN, LOW);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_DIGI:
|
case RIG_MODE_DIGI:
|
||||||
// Line PTT actuation during Digital does nothing.
|
// Line PTT actuation during Digital does nothing.
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_TEST:
|
case RIG_MODE_TEST:
|
||||||
txState = TX_LINE;
|
txState = TX_LINE;
|
||||||
audioSelectTxInput(TX_TEST_IN);
|
audioSelectTxInput(TX_TEST_IN);
|
||||||
audioTransmit();
|
audioTransmit();
|
||||||
@ -212,8 +209,8 @@ void setRigMode(RigMode m)
|
|||||||
rigMode = m;
|
rigMode = m;
|
||||||
|
|
||||||
switch(rigMode) {
|
switch(rigMode) {
|
||||||
case MODE_SSB:
|
case RIG_MODE_SSB:
|
||||||
case MODE_TEST:
|
case RIG_MODE_TEST:
|
||||||
// SSB sets the TX audio input to line-in. Note that this will be
|
// SSB sets the TX audio input to line-in. Note that this will be
|
||||||
// automatically overridden by mic-in, if the mic PTT is pressed.
|
// automatically overridden by mic-in, if the mic PTT is pressed.
|
||||||
audioSelectTxInput(TX_LINE_IN);
|
audioSelectTxInput(TX_LINE_IN);
|
||||||
@ -221,7 +218,7 @@ void setRigMode(RigMode m)
|
|||||||
// dspMenu = &ssbMenu;
|
// dspMenu = &ssbMenu;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_DIGI:
|
case RIG_MODE_DIGI:
|
||||||
// Digi sets the TX audio input to USB-in. Keying in this case must
|
// Digi sets the TX audio input to USB-in. Keying in this case must
|
||||||
// be via CAT control. Digital modes can also be used through the
|
// be via CAT control. Digital modes can also be used through the
|
||||||
// line-in, but the rig mode should be set to SSB in that case, and
|
// line-in, but the rig mode should be set to SSB in that case, and
|
||||||
@ -234,7 +231,7 @@ void setRigMode(RigMode m)
|
|||||||
// dspMenu = &digiMenu;
|
// dspMenu = &digiMenu;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_CW:
|
case RIG_MODE_CW:
|
||||||
// CW just gets the radio off of Mic-In; but it won't use Line-In.
|
// CW just gets the radio off of Mic-In; but it won't use Line-In.
|
||||||
audioSelectTxInput(TX_LINE_IN);
|
audioSelectTxInput(TX_LINE_IN);
|
||||||
audioCWFilter();
|
audioCWFilter();
|
||||||
@ -245,6 +242,8 @@ void setRigMode(RigMode m)
|
|||||||
|
|
||||||
//======================================================================
|
//======================================================================
|
||||||
|
|
||||||
|
//elapsedMillis frame10hz = 0;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// put your setup code here, to run once:
|
// put your setup code here, to run once:
|
||||||
initCAT(38400, SERIAL_8N1);
|
initCAT(38400, SERIAL_8N1);
|
||||||
@ -261,19 +260,23 @@ void setup() {
|
|||||||
|
|
||||||
audioInit();
|
audioInit();
|
||||||
#if defined(FACTORY_CALIBRATION)
|
#if defined(FACTORY_CALIBRATION)
|
||||||
setRigMode(MODE_TEST);
|
setRigMode(RIG_MODE_TEST);
|
||||||
#else
|
#else
|
||||||
setRigMode(MODE_SSB);
|
setRigMode(RIG_MODE_SSB);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//frame10Hz = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//======================================================================
|
//======================================================================
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
elapsedMillis elapsed = 0;
|
// elapsedMillis elapsed = 0;
|
||||||
|
RigMode oldRigMode = rigMode;
|
||||||
|
RxFilter oldRxFilter = rxFilter;
|
||||||
|
|
||||||
switch(rigMode) {
|
switch(rigMode) {
|
||||||
case MODE_CW:
|
case RIG_MODE_CW:
|
||||||
if (keyer.do_paddles()) {
|
if (keyer.do_paddles()) {
|
||||||
if (keyer.is_down()) {
|
if (keyer.is_down()) {
|
||||||
digitalWrite(PTT_KEY_OUT_PIN, LOW);
|
digitalWrite(PTT_KEY_OUT_PIN, LOW);
|
||||||
@ -293,6 +296,28 @@ void loop() {
|
|||||||
serviceCAT();
|
serviceCAT();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// send current status @ 10 Hz
|
||||||
|
//if (frame10Hz > 100) {
|
||||||
|
if ((rigMode != oldRigMode) || (rxFilter != oldRxFilter)) {
|
||||||
|
switch(rigMode) {
|
||||||
|
case RIG_MODE_SSB:
|
||||||
|
sendIOPSSBStatus(iopConfig.ssb);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RIG_MODE_DIGI:
|
||||||
|
sendIOPDigiStatus(iopConfig.digi);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RIG_MODE_CW:
|
||||||
|
sendIOPCWStatus(iopConfig.cw);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RIG_MODE_TEST:
|
||||||
|
sendIOPTestStatus();
|
||||||
|
}
|
||||||
|
//frame10Hz = 0;
|
||||||
|
}
|
||||||
|
|
||||||
//dspMenu->update();
|
//dspMenu->update();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user