compiles successfully
This commit is contained in:
parent
48cb6cf304
commit
87b6e3fbde
@ -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 {
|
||||
|
@ -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', '='};
|
||||
|
@ -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);
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include "Sensors.h"
|
||||
|
||||
UBitxSensors Sensors;
|
||||
|
||||
ADC adc;
|
||||
|
@ -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;
|
||||
|
@ -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>
|
||||
@ -81,7 +81,7 @@ void responseConfig()
|
||||
//Result : if found .val=, 1 else 0
|
||||
/*!
|
||||
@brief Parse commands...
|
||||
*/
|
||||
*/
|
||||
|
||||
char commandParser(int lastIndex)
|
||||
{
|
||||
@ -114,13 +114,13 @@ 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
|
||||
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
|
||||
@ -199,7 +199,7 @@ char commandParser(int lastIndex)
|
||||
|
||||
/*!
|
||||
@brief Forwards serial data from the RX line to the TX line.
|
||||
*/
|
||||
*/
|
||||
|
||||
void forwardData(void)
|
||||
{
|
||||
@ -260,13 +260,13 @@ 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)
|
||||
@ -357,7 +357,7 @@ 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;
|
||||
@ -376,15 +376,15 @@ 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:
|
||||
@ -464,7 +464,7 @@ 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();
|
||||
@ -474,7 +474,7 @@ void loop()
|
||||
|
||||
// Send SWR meter information.
|
||||
if (L_scaledVSWR != scaledVSWR) {
|
||||
L_scaledVSWR = scaledVSWR
|
||||
L_scaledVSWR = scaledVSWR;
|
||||
sendCommand1Num(CMD_SMETER, scaledVSWR);
|
||||
}
|
||||
|
||||
@ -503,9 +503,9 @@ void loop()
|
||||
//} //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);
|
||||
}
|
||||
|
||||
@ -523,13 +523,13 @@ void loop()
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user