Support I2C S-Meter

This commit is contained in:
phdlee 2018-07-17 11:21:24 +09:00
parent 1ce889eef0
commit 41548163cf
2 changed files with 60 additions and 4 deletions

View File

@ -6,7 +6,7 @@
// So I put + in the sense that it was improved one by one based on Original Firmware.
// This firmware has been gradually changed based on the original firmware created by Farhan, Jack, Jerry and others.
#define FIRMWARE_VERSION_INFO F("+v1.095")
#define FIRMWARE_VERSION_INFO F("+v1.097")
#define FIRMWARE_VERSION_NUM 0x04 //1st Complete Project : 1 (Version 1.061), 2st Project : 2, 1.08: 3, 1.09 : 4
/**

View File

@ -56,6 +56,53 @@ void LCD_Init(void)
//initMeter(); //for Meter Display
}
//===================================================================
//I2C Signal Meter, Version 1.097
//
//===================================================================
#define USE_I2CSMETER
//S-Meter Address
#define I2CMETER_ADDR 0x6A
//VALUE TYPE============================================
//Signal
#define I2CMETER_CALCS 0x59 //Calculated Signal Meter
#define I2CMETER_UNCALCS 0x58 //Uncalculated Signal Meter
//Power
#define I2CMETER_CALCP 0x57 //Calculated Power Meter
#define I2CMETER_UNCALCP 0x56 //UnCalculated Power Meter
//SWR
#define I2CMETER_CALCR 0x55 //Calculated SWR Meter
#define I2CMETER_UNCALCR 0x54 //Uncalculated SWR Meter
// 0xA0 ~ 0xCF : CW Decode Mode + 100Hz ~
// 0xD0 ~ 0xF3 : RTTY Decode Mode + 100Hz ~
// 0x10 ~ 0x30 : Spectrum Mode
int GetI2CSmeterValue(int valueType)
{
if (valueType > 0)
{
Wire.beginTransmission(I2CMETER_ADDR); //j : S-Meter
Wire.write(valueType); //Y : Get Value Type
Wire.endTransmission();
}
Wire.requestFrom(I2CMETER_ADDR, 1);
for (int i = 0; i < 100; i++)
{
if (Wire.available() > 0)
{
return Wire.read();
}
else
{
delay(1);
}
}
}
//===================================================================
//Begin of Nextion LCD Protocol
//
@ -676,6 +723,10 @@ void sendResponseData(int protocolType, unsigned long startFreq, unsigned int se
//Wait time for charging
//delay(10);
#ifdef USE_I2CSMETER
readedValue = GetI2CSmeterValue(I2CMETER_UNCALCS);
#else
//ADC
readedValue = analogRead(ANALOG_SMETER);
readedValue -= (sendOption2 * 3); //0 ~ 765
@ -689,6 +740,7 @@ void sendResponseData(int protocolType, unsigned long startFreq, unsigned int se
{
readedValue=255;
}
#endif
}
else
{
@ -961,6 +1013,9 @@ void idle_process()
{
int newSMeter;
#ifdef USE_I2CSMETER
scaledSMeter = GetI2CSmeterValue(I2CMETER_CALCS);
#else
//VK2ETA S-Meter from MAX9814 TC pin
newSMeter = analogRead(ANALOG_SMETER) / 4;
@ -977,6 +1032,7 @@ void idle_process()
}
}
#endif
checkCountSMeter = 0; //Reset Latency time
} //end of S-Meter
@ -1001,7 +1057,7 @@ void SendUbitxData(void)
EEPROM.get(EXTERNAL_DEVICE_OPT1, nextionDisplayOption);
SendCommandUL(CMD_DISP_OPTION2, nextionDisplayOption);
SendCommandStr(CMD_VERSION, "+v1.095"); //Version
SendCommandStr(CMD_VERSION, "+v1.097"); //Version
SendEEPromData(CMD_CALLSIGN, 0, userCallsignLength -1, 0);
/*