compiles successfully

This commit is contained in:
Rob French 2021-01-26 22:49:07 -06:00
parent 48cb6cf304
commit 87b6e3fbde
6 changed files with 241 additions and 198 deletions

View File

@ -4,7 +4,7 @@
/**********************************************************************/
#ifndef HF_PWR_DEFAULT_LOAD
#define HF_PWR_DEDAULT_LOAD 50.0
#define HF_PWR_DEFAULT_LOAD 50.0
#endif
#ifndef HF_VSWR_MAX_REPORTED
@ -120,7 +120,7 @@ namespace HF {
* @return Voltage Standing Wave Ratio (VSWR). This is calculated
* as VSWR = (Vfwd + Vrev) / (Vfwd - Vrev).
*/
float VSWR(float Vfwd, float Vrev, float VSWRmax = vswrMaxReported) {
inline float VSWR(float Vfwd, float Vrev, float VSWRmax = vswrMaxReported) {
if (Vfwd - Vrev == 0.0) {
return VSWRmax;
} else {

View File

@ -1,5 +1,41 @@
#include "Nextion.h"
char L_nowdisp = -1; //Sended nowdisp
char L_vfoActive; //vfoActive
unsigned long L_vfoCurr; //vfoA
byte L_vfoCurr_mode; //vfoA_mode
unsigned long L_vfoA; //vfoA
byte L_vfoA_mode; //vfoA_mode
unsigned long L_vfoB; //vfoB
byte L_vfoB_mode; //vfoB_mode
char L_ritOn;
unsigned long L_ritTxFrequency; //ritTxFrequency
char L_inTx;
byte L_isDialLock; //byte isDialLock
byte L_Split; //isTxType
byte L_TXStop; //isTxType
byte L_tuneStepIndex; //byte tuneStepIndex
byte L_scaledSMeter; //scaledSMeter
unsigned long L_sideTone; //sideTone
byte L_cwKeyType; //L_cwKeyType 0: straight, 1 : iambica, 2: iambicb
unsigned int L_cwSpeed; //cwSpeed
byte L_cwDelayTime; //cwDelayTime
byte L_delayBeforeCWStartTime; //byte delayBeforeCWStartTime
byte L_attLevel;
byte L_isIFShift; //1 = ifShift, 2 extend
int L_ifShiftValue;
byte L_sdrModeOn;
byte scaledSMeter = 0;
float calcVSWR = 0.0;
float L_calcVSWR = 0.0;
byte scaledVSWR = 0;
byte L_scaledVSWR = 0;
int fwdPower = 0;
int L_fwdPower = 0;
int revPower = 0;
int L_revPower = 0;
//Control must have prefix 'v' or 's'
char softSTRHeader[11] = {'p', 'm', '.', 's', '0', '.', 't', 'x', 't', '=', '\"'};
char softINTHeader[10] = {'p', 'm', '.', 'v', '0', '.', 'v', 'a', 'l', '='};

View File

@ -1,6 +1,8 @@
#ifndef __Nextion_h__
#define __Nextion_h__
#include <Arduino.h>
#define SWS_HEADER_CHAR_TYPE 'c' //1Byte Protocol Prefix
#define SWS_HEADER_INT_TYPE 'v' //Numeric Protocol Prefex
#define SWS_HEADER_STR_TYPE 's' //for TEXT Line compatiable Character LCD Control
@ -15,72 +17,72 @@
//===================================================================
#define CMD_NOW_DISP '0' //c0
char L_nowdisp = -1; //Sended nowdisp
extern char L_nowdisp; //Sended nowdisp
#define CMD_VFO_TYPE 'v' //cv
char L_vfoActive; //vfoActive
extern char L_vfoActive; //vfoActive
#define CMD_CURR_FREQ 'c' //vc
unsigned long L_vfoCurr; //vfoA
extern unsigned long L_vfoCurr; //vfoA
#define CMD_CURR_MODE 'c' //cc
byte L_vfoCurr_mode; //vfoA_mode
extern byte L_vfoCurr_mode; //vfoA_mode
#define CMD_VFOA_FREQ 'a' //va
unsigned long L_vfoA; //vfoA
extern unsigned long L_vfoA; //vfoA
#define CMD_VFOA_MODE 'a' //ca
byte L_vfoA_mode; //vfoA_mode
extern byte L_vfoA_mode; //vfoA_mode
#define CMD_VFOB_FREQ 'b' //vb
unsigned long L_vfoB; //vfoB
extern unsigned long L_vfoB; //vfoB
#define CMD_VFOB_MODE 'b' //cb
byte L_vfoB_mode; //vfoB_mode
extern byte L_vfoB_mode; //vfoB_mode
#define CMD_IS_RIT 'r' //cr
char L_ritOn;
extern char L_ritOn;
#define CMD_RIT_FREQ 'r' //vr
unsigned long L_ritTxFrequency; //ritTxFrequency
extern unsigned long L_ritTxFrequency; //ritTxFrequency
#define CMD_IS_TX 't' //ct
char L_inTx;
extern char L_inTx;
#define CMD_IS_DIALLOCK 'l' //cl
byte L_isDialLock; //byte isDialLock
extern byte L_isDialLock; //byte isDialLock
#define CMD_IS_SPLIT 's' //cs
byte L_Split; //isTxType
extern byte L_Split; //isTxType
#define CMD_IS_TXSTOP 'x' //cx
byte L_TXStop; //isTxType
extern byte L_TXStop; //isTxType
#define CMD_TUNEINDEX 'n' //cn
byte L_tuneStepIndex; //byte tuneStepIndex
extern byte L_tuneStepIndex; //byte tuneStepIndex
#define CMD_SMETER 'p' //cs
byte L_scaledSMeter; //scaledSMeter
extern byte L_scaledSMeter; //scaledSMeter
#define CMD_SIDE_TONE 't' //vt
unsigned long L_sideTone; //sideTone
extern unsigned long L_sideTone; //sideTone
#define CMD_KEY_TYPE 'k' //ck
byte L_cwKeyType; //L_cwKeyType 0: straight, 1 : iambica, 2: iambicb
extern byte L_cwKeyType; //L_cwKeyType 0: straight, 1 : iambica, 2: iambicb
#define CMD_CW_SPEED 's' //vs
unsigned int L_cwSpeed; //cwSpeed
extern unsigned int L_cwSpeed; //cwSpeed
#define CMD_CW_DELAY 'y' //vy
byte L_cwDelayTime; //cwDelayTime
extern byte L_cwDelayTime; //cwDelayTime
#define CMD_CW_STARTDELAY 'e' //ve
byte L_delayBeforeCWStartTime; //byte delayBeforeCWStartTime
extern byte L_delayBeforeCWStartTime; //byte delayBeforeCWStartTime
#define CMD_ATT_LEVEL 'f' //vf
byte L_attLevel;
extern byte L_attLevel;
byte L_isIFShift; //1 = ifShift, 2 extend
extern byte L_isIFShift; //1 = ifShift, 2 extend
#define CMD_IS_IFSHIFT 'i' //ci
int L_ifShiftValue;
extern int L_ifShiftValue;
#define CMD_IFSHIFT_VALUE 'i' //vi
byte L_sdrModeOn;
extern byte L_sdrModeOn;
#define CMD_SDR_MODE 'j' //cj
#define CMD_UBITX_INFO 'm' //cm Complete Send uBITX Information
@ -96,19 +98,19 @@ byte L_sdrModeOn;
#define CMD_AR_TUNE5 '5' //v5
//int idleStep = 0;
byte scaledSMeter = 0;
extern byte scaledSMeter;
float calcVSWR = 0.0;
float L_calcVSWR = 0.0;
extern float calcVSWR;
extern float L_calcVSWR;
byte scaledVSWR = 0;
byte L_scaledVSWR = 0;
extern byte scaledVSWR;
extern byte L_scaledVSWR;
int fwdPower = 0;
int L_fwdPower = 0;
extern int fwdPower;
extern int L_fwdPower;
int revPower = 0;
int L_revPower = 0;
extern int revPower;
extern int L_revPower;
void sendHeader(char varType, char varIndex);
void sendCommandUL(char varIndex, unsigned long sendValue);

View File

@ -1,3 +1,5 @@
#include "Sensors.h"
UBitxSensors Sensors;
ADC adc;

View File

@ -100,7 +100,7 @@ const int uBitxSensorsSMeterPin = UBITX_SENSORS_S_METER_PIN;
const int uBitxSensorsFwdPwrPin = UBITX_SENSORS_FWD_PWR_PIN;
const int uBitxSensorsRevPwrPin = UBITX_SENSORS_REV_PWR_PIN;
const int uBitxSensorsSupplyPin = UBITX_SENSORS_SUPPLY_PIN;
const int uBitxSensorsAvgSamples = UBITX_SENSORS_AVERAGE_SAMPLES;
const int uBitxSensorsAvgSamples = UBITX_SENSORS_AVG_SAMPLES;
const float uBitxSensorsSMeterR1 = UBITX_SENSORS_S_METER_R1;
const float uBitxSensorsSMeterR2 = UBITX_SENSORS_S_METER_R2;
const float uBitxSensorsFwdPwrR1 = UBITX_SENSORS_FWD_PWR_R1;
@ -121,9 +121,12 @@ const int uBitxSensorsSMeterValues[] = {
UBITX_SENSORS_S_METER_LVL7,
UBITX_SENSORS_S_METER_LVL8
};
const int uBitxSensorsSMeterLevels = sizeof(uBitxSensorsSMeterValues) /
sizeof(uBitxSensorsSMeterValues[0]);
extern ADC adc;
/**********************************************************************/
/*!
@ -146,7 +149,7 @@ class TrailingAverage {
current(0),
divisor(T(N))
{
for (i = 0; i < N; i++) {
for (int i = 0; i < N; i++) {
data[i] = T(0);
}
}
@ -223,10 +226,10 @@ class UBitxSensors {
float fwdV = HF::adcIn(value.result_adc0);
float revV = HF::adcIn(value.result_adc1);
fwdV = HF::divIn(fwdV);
fwdV = HF::divIn(fwdV, uBitxSensorsFwdPwrR1, uBitxSensorsFwdPwrR2);
fwdV = HF::bridgeFwd(fwdV);
revV = HF::divIn(revV);
revV = HF::divIn(revV, uBitxSensorsRevPwrR1, uBitxSensorsRevPwrR2);
revV = HF::bridgeFwd(revV);
fwdPwr.add(HF::P(fwdV));
@ -239,8 +242,8 @@ class UBitxSensors {
* reading the associated ADC pin.
*/
inline void updateSupply() {
float value = HF::adcIn(adc.analogRead(supplyPin);
value = HF::divIn(value);
float value = HF::adcIn(adc.analogRead(supplyPin));
value = HF::divIn(value, uBitxSensorsSupplyR1, uBitxSensorsSupplyR2);
supply.add(value);
}
@ -322,15 +325,15 @@ class UBitxSensors {
// Pins
int sMeterPin;
int fwdPwrPin;
int revPwdPin;
int revPwrPin;
int supplyPin;
// Buffers for averages
AverageBuffer<int, uBitxSensorsAvgSamples> sMeter;
AverageBuffer<float, uBitxSensorsAvgSamples> fwdPwr;
AverageBuffer<float, uBitxSensorsAvgSamples> revPwr;
AverageBuffer<float, uBitxSensorsAvgSamples> vswr;
AverageBuffer<float, uBitxSensorsAvgSamples> supply;
TrailingAverage<int, uBitxSensorsAvgSamples> sMeter;
TrailingAverage<float, uBitxSensorsAvgSamples> fwdPwr;
TrailingAverage<float, uBitxSensorsAvgSamples> revPwr;
TrailingAverage<float, uBitxSensorsAvgSamples> vswr;
TrailingAverage<float, uBitxSensorsAvgSamples> supply;
};
extern UBitxSensors Sensors;

View File

@ -1,10 +1,10 @@
/*
FFT, CW Decode for uBITX
KD8CEC, Ian Lee
FFT, CW Decode for uBITX
KD8CEC, Ian Lee
Version : 0.8
-----------------------------------------------------------------------
License : See fftfunctions.cpp for FFT and CW Decode.
Version : 0.8
-----------------------------------------------------------------------
License : See fftfunctions.cpp for FFT and CW Decode.
**********************************************************************/
#include <ADC.h>
@ -59,7 +59,7 @@ void responseConfig()
{
returnValue = 100 + cwDecodeHz;
}
returnValue = returnValue << 8;
returnValue = returnValue | (SMeterToUartSend & 0xFF);
returnValue = returnValue << 8;
@ -68,12 +68,12 @@ void responseConfig()
tmpValue = 255;
else if (magnitudelimit_low < 1)
tmpValue = 0;
else
else
tmpValue = magnitudelimit_low;
returnValue = returnValue | (tmpValue & 0xFF);
sendCommandUL('v', returnValue); //Return data
sendCommandUL('g', 0x6A); //Return data
sendCommandUL('v', returnValue); //Return data
sendCommandUL('g', 0x6A); //Return data
}
responseCommand = 0;
}
@ -81,15 +81,15 @@ void responseConfig()
//Result : if found .val=, 1 else 0
/*!
@brief Parse commands...
*/
*/
char commandParser(int lastIndex)
{
//Analysing Forward data
//59 58 68 4A 1C 5F 6A E5 FF FF 73
//59 58 68 4A 1C 5F 6A E5 FF FF 73
//Find Loopback protocol
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
//70 6D 2E 76 76 2E 76 61 6C 3D 33 38 34 38 39 35 33 36 32 38 FF FF FF
//70 6D 2E 76 76 2E 76 61 6C 3D 33 38 34 38 39 35 33 36 32 38 FF FF FF
//pm.vv.val=3848953628\xFF\xFF\xFF
//1234567890XXX
//
@ -114,15 +114,15 @@ char commandParser(int lastIndex)
for (int i = lastIndex - 3; i >= startIndex + 7; i--)
{
//Find =
if (forwardBuff[i-3] == 'v' && forwardBuff[i-2] == 'a' && forwardBuff[i-1] == 'l' && forwardBuff[i] == '=') //0x3D
if (forwardBuff[i - 3] == 'v' && forwardBuff[i - 2] == 'a' && forwardBuff[i - 1] == 'l' && forwardBuff[i] == '=') //0x3D
{
uint8_t command1 = forwardBuff[i-6]; //v
uint8_t command2 = forwardBuff[i-5]; //v
// i-4 //.
uint8_t command1 = forwardBuff[i - 6]; //v
uint8_t command2 = forwardBuff[i - 5]; //v
// i-4 //.
forwardBuff[lastIndex - 2] = 0;
long commandVal=atol(&forwardBuff[i + 1]);
long commandVal = atol(&forwardBuff[i + 1]);
uint8_t *readBuff = (uint8_t *)&commandVal;
//Loop Back
if (command1 == 'v' && command2 == 'v')
{
@ -199,7 +199,7 @@ char commandParser(int lastIndex)
/*!
@brief Forwards serial data from the RX line to the TX line.
*/
*/
void forwardData(void)
{
@ -250,7 +250,7 @@ void forwardData(void)
}
else
{
// check timeout
// check timeout
}
}
@ -260,21 +260,21 @@ void sendMeterData(uint8_t isSend)
{
scaledSMeter = Sensors.sMeterScaled();
/*
1 : with noise (not use 0 ~ S3)
2 : -93 ~ -89
3 : -88 ~ -81
4 : -80 ~ -78
5 : -77 ~ -72
6 : -71 ~ -69
*/
/*
1 : with noise (not use 0 ~ S3)
2 : -93 ~ -89
3 : -88 ~ -81
4 : -80 ~ -78
5 : -77 ~ -72
6 : -71 ~ -69
*/
if (isSend == 1)
{
if (L_scaledSMeter != scaledSMeter)
{
L_scaledSMeter = scaledSMeter;
sendCommand1Num(CMD_SMETER, L_scaledSMeter);
sendCommand1Num(CMD_SMETER, L_scaledSMeter);
}
}
}
@ -306,7 +306,7 @@ void sendMeterData(uint8_t isSend)
// Serial1.write(responseFooter[i]);
//}
void setup()
void setup()
{
// load configuration
EEPROM.get(EEPROM_DSPTYPE, DSPType);
@ -321,7 +321,7 @@ void setup()
{
SMeterToUartSend = 1;
}
// something with CW decoding...
EEPROM.get(EEPROM_CW_FREQ, cwDecodeHz);
if (cwDecodeHz > 40 || cwDecodeHz < 1)
@ -335,7 +335,7 @@ void setup()
{
magnitudelimit_low = 50;
}
// put your setup code here, to run once:
// slave Wire1 configuration for communication with the Raduino
@ -346,7 +346,7 @@ void setup()
// Serial1 configuration for communication with Raduino (RX) and Nextion (TX)
Serial1.begin(9600, SERIAL_8N1);
Serial1.flush();
SAMPLE_INTERVAL = round(1000000 * (1.0 / SAMPLE_FREQUENCY));
//calculateCoeff(cwDecodeHz); //Set 750Hz //9 * 50 + 300 = 750Hz
//Serial1.println("Start...");
@ -357,16 +357,16 @@ void setup()
indicate which data the DSP should be preparing to return.
@param numBytes
Number of bytes received--not used in this procedure.
*/
*/
void i2cReceiveEvent(size_t numBytes)
{
int readCommand = 0;
while (Wire1.available() > 0) // for Last command
{
readCommand = Wire1.read();
// KC4UPR: Note that this looks to be only reading the last command, i.e.
// if multiple commands have been queued up, only the last will get executed.
readCommand = Wire1.read();
// KC4UPR: Note that this looks to be only reading the last command, i.e.
// if multiple commands have been queued up, only the last will get executed.
}
if (0x50 <= readCommand && readCommand <= 0x59)
@ -376,39 +376,39 @@ void i2cReceiveEvent(size_t numBytes)
}
/*!
* @brief Respond to a request from the I2C Master (Raduino). Returns the appropriate data
* based on whatever command was previously issued.
*/
@brief Respond to a request from the I2C Master (Raduino). Returns the appropriate data
based on whatever command was previously issued.
*/
void i2cRequestEvent(void)
{
int maxValue = 0;
int minValue = 30000;
int readValue = 0;
unsigned long curr = 0;
//int maxValue = 0;
//int minValue = 30000;
//int readValue = 0;
//unsigned long curr = 0;
switch (i2cCommand) {
case I2CMETER_CALCS:
// Returns an already-calculated S-meter value.
Wire1.write(scaledSMeter);
break;
// Returns an already-calculated S-meter value.
Wire1.write(scaledSMeter);
break;
case I2CMETER_UNCALCS:
// Returns a raw signal strength value.
Wire1.write(Sensors.sMeterUnscaled() >> 2); // divided by 4... do we want this?
break;
// Returns a raw signal strength value.
Wire1.write(Sensors.sMeterUnscaled() >> 2); // divided by 4... do we want this?
break;
case I2CMETER_CALCP:
// Returns a raw forward power value.
Wire1.write(fwdPower);
break;
// Returns a raw forward power value.
Wire1.write(fwdPower);
break;
case I2CMETER_CALCR:
// Returns a raw reverse power value.
Wire1.write(revPower);
break;
// Returns a raw reverse power value.
Wire1.write(revPower);
break;
default:
break;
break;
}
}
@ -442,13 +442,13 @@ const int adcIntervalMillis = ADC_INTERVAL_MS;
// MAIN LOOP
//======================================================================
void loop()
void loop()
{
//char isProcess = 0; // 0: init, 1: complete ADC sampling, 2: complete FFT
//isProcess = 0;
forwardData();
if (isBooted < 100)
{
//Delay 20msec
@ -464,17 +464,17 @@ void loop()
if (sinceFrameMillis > frameIntervalMillis) {
// Do stuff that we do once per frame--I/O.
// TODO: debug output (frame skipping / utilization).
sinceFrame = 0;
sinceFrameMillis = 0;
if (isTX) {
calcVSWR = Sensors.VSWR();
scaledVSWR = byte(Sensors.scaledVSWR());
fwdPower = Sensors.Pfwd();
revPower = Sensors.Prev();
// Send SWR meter information.
if (L_scaledVSWR != scaledVSWR) {
L_scaledVSWR = scaledVSWR
L_scaledVSWR = scaledVSWR;
sendCommand1Num(CMD_SMETER, scaledVSWR);
}
@ -491,9 +491,9 @@ void loop()
// sendCommandL('m', revPower * 100); // watts x 100?
// sendCommand1Num('m', 2);
//}
// Does there need to be some kind of 250-500ms delay after this???
// Delay 250msec ~ 500msec for Nextion LCD Processing (using m protocol)
// Delay 250msec ~ 500msec for Nextion LCD Processing (using m protocol)
//for (int i = 0; i < 10; i++) {
// forwardData();
// if (!isTX) { //if TX -> RX break
@ -501,14 +501,14 @@ void loop()
// }
// delay(25);
//} //end of delay time
// Send SWR.
if (L_calcSWR != calcSWR) {
L_calcSWR = calcSWR;
sendCommandL('m', int(calcSWR * 100.0)); // SWR x 100?
if (L_calcVSWR != calcVSWR) {
L_calcVSWR = calcVSWR;
sendCommandL('m', int(calcVSWR * 100.0)); // SWR x 100?
sendCommand1Num('m', 3);
}
} else { // RX
// Send Signal Meter to UART
@ -519,17 +519,17 @@ void loop()
} else {
sendMeterData(0); //only calculate Signal Level
}
}
// Forward any data that came in while we were updating stuff.
ForwardData();
forwardData();
}
if (sinceADCMillis > adcIntervalMillis) {
// Do stuff that we do once per ADC interval--ADC colllection.
// TODO: debug output (frame skipping / utilization).
sinceADC = 0;
sinceADCMillis = 0;
if (isTX) {
Sensors.updatePower();
@ -539,7 +539,7 @@ void loop()
}
// Forward any data that came in while we were reading sensors.
//ForwardData();
//forwardData();
}
// Check Response Command
@ -548,80 +548,80 @@ void loop()
responseConfig();
}
// //===========================================
// //TRANSCEIVER STATUS : RX
// //===========================================
// //===================================================================================
// // DSP Routine
// //===================================================================================
// if (DSPType == 1 && sinceForward > LAST_TIME_INTERVAL) // spectrum: FFT => send To UART
// {
// FFTToUartIdleCount = 0;
//
// if (isProcess == 1)
// {
// FFT(FFTReal, FFTImag, SAMPLESIZE, 7);
// isProcess = 2;
// }
//
// forwardData();
//
// if (isProcess == 2)
// {
// for (uint16_t k = 0; k < SAMPLESIZE; k++)
// {
// FFTReal[k] = sqrt(FFTReal[k] * FFTReal[k] + FFTImag[k] * FFTImag[k]);
// }
//
// isProcess = 3;
// }
//
// forwardData();
//
// if (isProcess == 3)
// {
// if (nowSendingProtocol == 0) //Idle Status
// {
// sendFFTData();
// }
// }
// }
// else if (DSPType == 2) //Decode Morse
// {
// //Implement Goertzel_algorithm
// //https://en.wikipedia.org/wiki/Goertzel_algorithm
//
// /*
// ω = 2 * π * Kterm / Nterms;
// cr = cos(ω);
// ci = sin(ω);
// coeff = 2 * cr;
//
// sprev = 0;
// sprev2 = 0;
// for each index n in range 0 to Nterms-1
// s = x[n] + coeff * sprev - sprev2;
// sprev2 = sprev;
// sprev = s;
// end
//
// power = sprev2 * sprev2 + sprev * sprev - coeff * sprev * sprev2;
// */
// double Q1 = 0;
// double Q2 = 0;
//
// for (unsigned index = 0; index < DECODE_MORSE_SAMPLESIZE; index++)
// {
// float Q0;
// Q0 = coeff * Q1 - Q2 + FFTReal[index];
// Q2 = Q1;
// Q1 = Q0;
// }
// double magnitudeSquared = (Q1*Q1)+(Q2*Q2)-Q1*Q2*coeff; // we do only need the real part //
// double magnitude = sqrt(magnitudeSquared);
//
// Decode_Morse(magnitude);
// } //end of if
// //===========================================
// //TRANSCEIVER STATUS : RX
// //===========================================
// //===================================================================================
// // DSP Routine
// //===================================================================================
// if (DSPType == 1 && sinceForward > LAST_TIME_INTERVAL) // spectrum: FFT => send To UART
// {
// FFTToUartIdleCount = 0;
//
// if (isProcess == 1)
// {
// FFT(FFTReal, FFTImag, SAMPLESIZE, 7);
// isProcess = 2;
// }
//
// forwardData();
//
// if (isProcess == 2)
// {
// for (uint16_t k = 0; k < SAMPLESIZE; k++)
// {
// FFTReal[k] = sqrt(FFTReal[k] * FFTReal[k] + FFTImag[k] * FFTImag[k]);
// }
//
// isProcess = 3;
// }
//
// forwardData();
//
// if (isProcess == 3)
// {
// if (nowSendingProtocol == 0) //Idle Status
// {
// sendFFTData();
// }
// }
// }
// else if (DSPType == 2) //Decode Morse
// {
// //Implement Goertzel_algorithm
// //https://en.wikipedia.org/wiki/Goertzel_algorithm
//
// /*
// ω = 2 * π * Kterm / Nterms;
// cr = cos(ω);
// ci = sin(ω);
// coeff = 2 * cr;
//
// sprev = 0;
// sprev2 = 0;
// for each index n in range 0 to Nterms-1
// s = x[n] + coeff * sprev - sprev2;
// sprev2 = sprev;
// sprev = s;
// end
//
// power = sprev2 * sprev2 + sprev * sprev - coeff * sprev * sprev2;
// */
// double Q1 = 0;
// double Q2 = 0;
//
// for (unsigned index = 0; index < DECODE_MORSE_SAMPLESIZE; index++)
// {
// float Q0;
// Q0 = coeff * Q1 - Q2 + FFTReal[index];
// Q2 = Q1;
// Q1 = Q0;
// }
// double magnitudeSquared = (Q1*Q1)+(Q2*Q2)-Q1*Q2*coeff; // we do only need the real part //
// double magnitude = sqrt(magnitudeSquared);
//
// Decode_Morse(magnitude);
// } //end of if
}