Updating before switching back to previous commit, to see if it works.

This isn't transmiting.
This commit is contained in:
Rob French 2020-05-03 00:37:21 -05:00
parent f819e211da
commit faa73e1330
6 changed files with 339 additions and 48 deletions

View File

@ -5,6 +5,8 @@
#ifndef __iop_audio_h__ #ifndef __iop_audio_h__
#define __iop_audio_h__ #define __iop_audio_h__
#include "config.h"
enum RxInput { enum RxInput {
RX_RIG_IN = 0, RX_RIG_IN = 0,
RX_USB_IN, RX_USB_IN,
@ -31,6 +33,7 @@ void audioInit();
void audioSelectTxInput(TxInput); void audioSelectTxInput(TxInput);
void audioTransmit(); void audioTransmit();
void audioReceive(); void audioReceive();
void audioCalibrate(IOPConfig *, char, char, char, float, bool);
#endif #endif

269
audio.ino
View File

@ -230,6 +230,21 @@ void audioTransmit()
// Now switch to the mic input, and set the mic gain. // Now switch to the mic input, and set the mic gain.
audioCtrl.inputSelect(AUDIO_INPUT_MIC); audioCtrl.inputSelect(AUDIO_INPUT_MIC);
updateTxMicIn(); updateTxMicIn();
#if defined(FACTORY_CALIBRATION)
USBSERIAL.println("==============================");
USBSERIAL.println("Transmitting with Mic input");
USBSERIAL.print("Mic gain: ");
USBSERIAL.println(iopConfig.txMicInGain);
USBSERIAL.print("Mic volume: ");
USBSERIAL.println(iopConfig.txMicInVol);
USBSERIAL.print("Mic calibration: ");
USBSERIAL.println(iopConfig.txMicInCal);
USBSERIAL.print("TX audio level: ");
USBSERIAL.println(iopConfig.txRigOutLevel);
USBSERIAL.print("TX audio calibration: ");
USBSERIAL.println(iopConfig.txRigOutCal);
USBSERIAL.println("==============================");
#endif
} }
// Allow both transmit and receive audio output channels. This is safe // Allow both transmit and receive audio output channels. This is safe
@ -269,6 +284,260 @@ void audioReceive()
} }
} }
//======================================================================
void audioCalibrate(IOPConfig* c, char cmd, char subcmd, char parm, float value, bool set_value=true)
{
switch(cmd) {
case 'r':
case 'R':
// RX audio parameters
switch(subcmd) {
case 'r':
case 'R':
// Rig input
switch(parm) {
case 'l':
case 'L':
// level
if (set_value) {
c->rxRigInLevel = int(value);
updateRxRigIn();
}
USBSERIAL.print("rxRigInLevel: ");
USBSERIAL.println(c->rxRigInLevel);
break;
case 'v':
case 'V':
// volume
if (set_value) {
c->rxRigInVol = value;
updateRxRigIn();
}
USBSERIAL.print("rxRigInVol: ");
USBSERIAL.println(c->rxRigInVol);
break;
case 'c':
case 'C':
// calibration
if (set_value) {
c->rxRigInCal = value;
updateRxRigIn();
}
USBSERIAL.print("rxRigInCal: ");
USBSERIAL.println(c->rxRigInCal);
break;
}
break;
case 's':
case 'S':
// Speaker output
switch(parm) {
case 'c':
case 'C':
// calibration
if (set_value) {
c->rxSpkrOutCal = value;
updateRxSpkrOut();
}
USBSERIAL.print("rxSpkrOutCal: ");
USBSERIAL.println(c->rxSpkrOutCal);
break;
}
break;
case 'l':
case 'L':
// Line output
switch(parm) {
case 'l':
case 'L':
// level
if (set_value) {
c->rxLineOutLevel = int(value);
updateRxLineOut();
}
USBSERIAL.print("rxLineOutLevel: ");
USBSERIAL.println(c->rxLineOutLevel);
break;
case 'c':
case 'C':
// calibration
if (set_value) {
c->rxLineOutCal = value;
updateRxLineOut();
}
USBSERIAL.print("rxLineOutCal: ");
USBSERIAL.println(c->rxLineOutCal);
break;
}
break;
case 'u':
case 'U':
// USB output
switch(parm) {
case 'c':
case 'C':
// calibration
if (set_value) {
c->rxUSBOutCal = value;
updateRxUSBOut();
}
USBSERIAL.print("rxUSBOutCal: ");
USBSERIAL.println(c->rxUSBOutCal);
break;
}
break;
}
break;
case 't':
case 'T':
//TX audio parameters
switch(subcmd) {
case 'm':
case 'M':
// Mic input
switch(parm) {
case 'g':
case 'G':
// mic gain
if (set_value) {
c->txMicInGain = int(value);
updateTxMicIn();
}
USBSERIAL.print("txMicInGain: ");
USBSERIAL.println(c->txMicInGain);
break;
case 'v':
case 'V':
// volume
if (set_value) {
c->txMicInVol = value;
updateTxMicIn();
}
USBSERIAL.print("txMicInVol: ");
USBSERIAL.println(c->txMicInVol);
break;
case 'c':
case 'C':
// calibration
if (set_value) {
c->txMicInCal = value;
updateTxMicIn();
}
USBSERIAL.print("txMicInCal: ");
USBSERIAL.println(c->txMicInCal);
break;
}
break;
case 'l':
case 'L':
// Line input
switch(parm) {
case 'l':
case 'L':
// level
if (set_value) {
c->txLineInLevel = int(value);
updateTxLineIn();
}
USBSERIAL.print("txLineInLevel: ");
USBSERIAL.println(c->txLineInLevel);
break;
case 'v':
case 'V':
// volume
if (set_value) {
c->txLineInVol = value;
updateTxLineIn();
}
USBSERIAL.print("txLineInVol: ");
USBSERIAL.println(c->txLineInVol);
break;
case 'c':
case 'C':
// calibration
if (set_value) {
c->txLineInCal = value;
updateTxLineIn();
}
USBSERIAL.print("txLineInCal: ");
USBSERIAL.println(c->txLineInCal);
break;
}
break;
case 'u':
case 'U':
// USB input
switch(parm) {
case 'v':
case 'V':
// volume
if (set_value) {
c->txUSBInVol = value;
updateTxUSBIn();
}
USBSERIAL.print("txUSBInVol: ");
USBSERIAL.println(c->txUSBInVol);
break;
case 'c':
case 'C':
// calibration
if (set_value) {
c->txUSBInCal = value;
updateTxUSBIn();
}
USBSERIAL.print("txUSBInCal: ");
USBSERIAL.println(c->txUSBInCal);
break;
}
break;
case 'r':
case 'R':
// Rig output
switch(parm) {
case 'l':
case 'L':
// level
if (set_value) {
c->txRigOutLevel = int(value);
updateTxRigOut();
}
USBSERIAL.print("txRigOutLevel: ");
USBSERIAL.println(c->txRigOutLevel);
break;
case 'c':
case 'C':
// calibration
if (set_value) {
c->txRigOutCal = value;
updateTxRigOut();
}
USBSERIAL.print("txRigOutCal: ");
USBSERIAL.println(c->txRigOutCal);
break;
}
break;
}
break;
}
}
//====================================================================== //======================================================================
// EOF // EOF
//====================================================================== //======================================================================

2
cat.h
View File

@ -5,6 +5,8 @@
#ifndef __iop_cat_h__ #ifndef __iop_cat_h__
#define __iop_cat_h__ #define __iop_cat_h__
#include "config.h"
#define USBSERIAL Serial #define USBSERIAL Serial
#define HWSERIAL Serial1 #define HWSERIAL Serial1

61
cat.ino
View File

@ -33,9 +33,11 @@ void initCAT(long baud, int portConfig)
USBSERIAL.begin(baud); USBSERIAL.begin(baud);
USBSERIAL.flush(); USBSERIAL.flush();
#if not defined(FACTORY_CALIBRATION)
// CAT with Raduino via UART // CAT with Raduino via UART
HWSERIAL.begin(baud, portConfig); HWSERIAL.begin(baud, portConfig);
USBSERIAL.flush(); USBSERIAL.flush();
#endif
} }
//====================================================================== //======================================================================
@ -46,6 +48,35 @@ void processIOPCommand(const byte* buf, int len)
//====================================================================== //======================================================================
void processCalCommand(const char* buf)
{
int count;
char cmd;
char subcmd;
char parm;
float value;
count = sscanf(buf, "%1c %1c %1c %f", &cmd, &subcmd, &parm, &value);
if (count < 3) {
USBSERIAL.println("Calibration: invalid command");
} else {
switch(cmd) {
case 'r':
case 'R':
case 't':
case 'T':
audioCalibrate(&iopConfig, cmd, subcmd, parm, value, (count == 4));
break;
default:
USBSERIAL.println("Calibration: invalid command");
}
}
}
//======================================================================
enum serial_mode_t { enum serial_mode_t {
NORMAL = 0, NORMAL = 0,
CAT_MODE, CAT_MODE,
@ -58,6 +89,7 @@ int readLength = 0;
int cmdLength = 0; int cmdLength = 0;
byte cmdBuffer[16]; byte cmdBuffer[16];
char cmdString[17]; // added a char for null termination when required
uint16_t eepromStartIndex; uint16_t eepromStartIndex;
uint16_t eepromReadLength; uint16_t eepromReadLength;
@ -72,6 +104,34 @@ void serviceCAT()
// 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();
#if defined(FACTORY_CALIBRATION)
// unless we're in factory calibration mode, in which case we're going
// to process calibration commands...
switch(incomingByte) {
case ';':
cmdString[cmdLength] = '\0';
if (cmdLength > 0) {
processCalCommand(cmdString);
cmdLength = 0;
}
break;
case '\n':
case '\r':
cmdString[0] = '\0';
cmdLength = 0;
break;
default:
cmdString[cmdLength++] = char(incomingByte);
if (cmdLength == 16) {
cmdString[cmdLength] = '\0';
processCalCommand(cmdString);
cmdLength = 0;
}
}
#else
HWSERIAL.write(incomingByte); HWSERIAL.write(incomingByte);
} }
@ -179,6 +239,7 @@ void serviceCAT()
// should never happen... // should never happen...
break; break;
} }
#endif
} }
} }

View File

@ -5,6 +5,8 @@
#ifndef __iop_eeprom_h__ #ifndef __iop_eeprom_h__
#define __iop_eeprom_h__ #define __iop_eeprom_h__
#include "config.h"
#endif #endif
//====================================================================== //======================================================================

View File

@ -5,6 +5,7 @@
#ifndef __ubitx_iop_h__ #ifndef __ubitx_iop_h__
#define __ubitx_iop_h__ #define __ubitx_iop_h__
#include "config.h"
#include "audio.h" #include "audio.h"
#include "cat.h" #include "cat.h"
#include "eeprom.h" #include "eeprom.h"
@ -18,54 +19,7 @@ enum RigMode {
MODE_CW, MODE_CW,
}; };
// IOPConfig
// Used to store configuration parameters during runtime, as well as to
// save them to EEPROM.
//
// NOTE: Need to put version info and a version check here.
struct IOPConfig {
// RECEIVE PARAMETERS
// rig-in parameters (RX)
uint8_t rxRigInLevel = 5;
float rxRigInVol = 1.0;
float rxRigInCal = 1.0;
// USB-in parameters (RX) - debug/monitor use only
bool rxUSBInEnable = false;
float rxUSBInVol = 1.0;
float rxUSBInCal = 1.0;
// speaker-out (DAC) parameters (RX)
float rxSpkrOutCal = 1.0;
// line-out parameters (RX)
uint8_t rxLineOutLevel = 29;
float rxLineOutCal = 1.0;
// USB-out parameters (RX)
float rxUSBOutCal = 1.0;
// TRANSMIT PARAMETERS
// microphone-in parameters (TX)
uint8_t txMicInGain = 32;
float txMicInVol = 1.0;
float txMicInCal = 1.0;
// line-in parameters (TX)
uint8_t txLineInLevel = 5;
float txLineInVol = 1.0;
float txLineInCal = 1.0;
// USB-in parameters (TX)
float txUSBInVol = 1.0;
float txUSBInCal = 1.0;
// rig-out parameters (TX)
uint8_t txRigOutLevel = 29;
float txRigOutCal = 1.0;
// USB-out parameters (TX)- debug/monitor use only
bool txUSBOutEnable = true;
float txUSBOutCal = 1.0;
};
extern RigMode rigMode; extern RigMode rigMode;
extern IOPConfig iopConfig;
#endif #endif