commit
1a60adaf2f
|
@ -1,6 +1,8 @@
|
||||||
/*
|
/*
|
||||||
FFT, CW Decode for uBITX
|
FFT, CW Decode for uBITX
|
||||||
KD8CEC, Ian Lee
|
KD8CEC, Ian Lee
|
||||||
|
|
||||||
|
Version : 0.8
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
License : See fftfunctions.cpp for FFT and CW Decode.
|
License : See fftfunctions.cpp for FFT and CW Decode.
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
@ -177,7 +179,7 @@ void SendCommandStr(char varIndex, char* sendValue)
|
||||||
SWSerial_Write(0xFF);
|
SWSerial_Write(0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
char softBuff1Num[14] = {'p', 'm', '.', 'c', '0', '.', 'v', 'a', 'l', '=', 0, 0xFF, 0xFF, 0xFF};
|
unsigned char softBuff1Num[14] = {'p', 'm', '.', 'c', '0', '.', 'v', 'a', 'l', '=', 0, 0xFF, 0xFF, 0xFF};
|
||||||
void SendCommand1Num(char varType, char sendValue) //0~9 : Mode, nowDisp, ActiveVFO, IsDialLock, IsTxtType, IsSplitType
|
void SendCommand1Num(char varType, char sendValue) //0~9 : Mode, nowDisp, ActiveVFO, IsDialLock, IsTxtType, IsSplitType
|
||||||
{
|
{
|
||||||
softBuff1Num[4] = varType;
|
softBuff1Num[4] = varType;
|
||||||
|
@ -472,58 +474,6 @@ int ForwardData(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
int SendMeterData(uint8_t isSend)
|
|
||||||
{
|
|
||||||
int newScaledSMeter = 0;
|
|
||||||
if (ADC_DIFF > 11)
|
|
||||||
{
|
|
||||||
newScaledSMeter = 8;
|
|
||||||
}
|
|
||||||
else if (ADC_DIFF > 9)
|
|
||||||
{
|
|
||||||
newScaledSMeter = 7;
|
|
||||||
}
|
|
||||||
else if (ADC_DIFF > 8)
|
|
||||||
{
|
|
||||||
newScaledSMeter = 6;
|
|
||||||
}
|
|
||||||
else if (ADC_DIFF > 7)
|
|
||||||
{
|
|
||||||
newScaledSMeter = 5;
|
|
||||||
}
|
|
||||||
else if (ADC_DIFF > 6)
|
|
||||||
{
|
|
||||||
newScaledSMeter = 4;
|
|
||||||
}
|
|
||||||
else if (ADC_DIFF > 5)
|
|
||||||
{
|
|
||||||
newScaledSMeter = 3;
|
|
||||||
}
|
|
||||||
else if (ADC_DIFF > 4)
|
|
||||||
{
|
|
||||||
newScaledSMeter = 2;
|
|
||||||
}
|
|
||||||
else if (ADC_DIFF > 3)
|
|
||||||
{
|
|
||||||
newScaledSMeter = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
newScaledSMeter = 0;
|
|
||||||
}
|
|
||||||
scaledSMeter = newScaledSMeter;
|
|
||||||
|
|
||||||
if (isSend == 1)
|
|
||||||
{
|
|
||||||
if (L_scaledSMeter != scaledSMeter)
|
|
||||||
{
|
|
||||||
L_scaledSMeter = scaledSMeter;
|
|
||||||
SendCommand1Num(CMD_SMETER, L_scaledSMeter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
int SendMeterData(uint8_t isSend)
|
int SendMeterData(uint8_t isSend)
|
||||||
{
|
{
|
||||||
//basic : 1.5Khz
|
//basic : 1.5Khz
|
||||||
|
@ -788,7 +738,14 @@ extern double coeff;
|
||||||
|
|
||||||
#define LAST_TIME_INTERVAL 159
|
#define LAST_TIME_INTERVAL 159
|
||||||
|
|
||||||
int SWRAdcValue = 0;
|
//int SWRAdcValue = 0;
|
||||||
|
float adcFWD = 0;
|
||||||
|
float adcRWD = 0;
|
||||||
|
uint16_t adjustPower = 230;
|
||||||
|
float swrMeasured;
|
||||||
|
|
||||||
|
int clcCount = 0;
|
||||||
|
|
||||||
|
|
||||||
//for boot Delay, a alot of data transfer
|
//for boot Delay, a alot of data transfer
|
||||||
//Delay 2.5 Sec
|
//Delay 2.5 Sec
|
||||||
|
@ -817,6 +774,7 @@ void loop()
|
||||||
//===========================================
|
//===========================================
|
||||||
if (TXStatus == 1) //TX Mode
|
if (TXStatus == 1) //TX Mode
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
int readedValue = 0;
|
int readedValue = 0;
|
||||||
SMeterToUartIdleCount++;
|
SMeterToUartIdleCount++;
|
||||||
if (SMeterToUartIdleCount > 130) //SWR
|
if (SMeterToUartIdleCount > 130) //SWR
|
||||||
|
@ -834,9 +792,94 @@ void loop()
|
||||||
SendCommand1Num('m',2);
|
SendCommand1Num('m',2);
|
||||||
//PWR Send
|
//PWR Send
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
//************************************************
|
||||||
|
//Read FWD and RWD
|
||||||
|
adcFWD = adcFWD * 0.8 + analogRead(A2) * 0.2;
|
||||||
|
adcRWD = adcRWD * 0.8 + analogRead(A3) * 0.2;
|
||||||
|
|
||||||
|
if (adcRWD > adcFWD)
|
||||||
|
{
|
||||||
|
adcRWD = adcFWD;
|
||||||
|
}
|
||||||
|
|
||||||
|
//for Realtime LCD Display
|
||||||
ForwardData();
|
ForwardData();
|
||||||
delay(5);
|
|
||||||
|
|
||||||
|
if (clcCount++ > 10)
|
||||||
|
{
|
||||||
|
//Calculated Power and swr and Send Information
|
||||||
|
clcCount = 0;
|
||||||
|
|
||||||
|
//Calc PWR
|
||||||
|
float PWR = pow(adcFWD, 2);
|
||||||
|
PWR = PWR / adjustPower / 100;
|
||||||
|
|
||||||
|
//Calc SWR
|
||||||
|
float Vratio = adcRWD / adcFWD;
|
||||||
|
if (adcRWD < 0.05 && adcFWD < 0.05)
|
||||||
|
{
|
||||||
|
//No signal
|
||||||
|
swrMeasured = 0;
|
||||||
|
}
|
||||||
|
else if (Vratio > 0.99)
|
||||||
|
{
|
||||||
|
swrMeasured = 1999;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
swrMeasured = ((1 + Vratio)/ (1 - Vratio));
|
||||||
|
}
|
||||||
|
|
||||||
|
//For Version 0.8
|
||||||
|
//Send SWR Information using Receive Signal Meter Protocol
|
||||||
|
scaledSMeter = (int)(swrMeasured + 0.5);
|
||||||
|
if (scaledSMeter > 9)
|
||||||
|
{
|
||||||
|
scaledSMeter = 9;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (L_scaledSMeter != scaledSMeter)
|
||||||
|
{
|
||||||
|
L_scaledSMeter = scaledSMeter;
|
||||||
|
SendCommand1Num(CMD_SMETER, L_scaledSMeter);
|
||||||
|
}
|
||||||
|
|
||||||
|
//For Version 1.0
|
||||||
|
//need mod uBITX firmware and Nextion LCD and add Power adjust value option (uBITX Manager)
|
||||||
|
//Send Information
|
||||||
|
//SWR Send
|
||||||
|
//SendCommandL('m', SWRAdcValue);
|
||||||
|
//SendCommand1Num('m', 3);
|
||||||
|
//SMeterToUartIdleCount = 0;
|
||||||
|
//Send Power Information
|
||||||
|
int readedValue = (int)(PWR * 100);
|
||||||
|
SendCommandL('m', readedValue);
|
||||||
|
SendCommand1Num('m',2);
|
||||||
|
|
||||||
|
//Delay 250msec ~ 500msec for Nextion LCD Processing (using m protocol)
|
||||||
|
|
||||||
|
for (int i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
|
ForwardData();
|
||||||
|
if (TXStatus != 1) //if TX -> RX break
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
delay(25);
|
||||||
|
} //end of delay time
|
||||||
|
|
||||||
|
//Send SWR
|
||||||
|
readedValue = (int)(swrMeasured * 100);
|
||||||
|
SendCommandL('m', readedValue);
|
||||||
|
SendCommand1Num('m', 3);
|
||||||
|
|
||||||
|
//delay(50);
|
||||||
|
//return;
|
||||||
|
}
|
||||||
|
|
||||||
|
delay(30);
|
||||||
return; //Do not processing ADC, FFT, Decode Morse or RTTY, only Power and SWR Data Return
|
return; //Do not processing ADC, FFT, Decode Morse or RTTY, only Power and SWR Data Return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -969,5 +1012,3 @@ void loop()
|
||||||
Decode_Morse(magnitude);
|
Decode_Morse(magnitude);
|
||||||
} //enf of if
|
} //enf of if
|
||||||
} //end of main
|
} //end of main
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue