diff --git a/ubitx_20/ubitx.h b/ubitx_20/ubitx.h index 0c7f3e2..d7c5118 100644 --- a/ubitx_20/ubitx.h +++ b/ubitx_20/ubitx.h @@ -29,12 +29,14 @@ //#define UBITX_DISPLAY_LCD1602I_DUAL //I2C type 16 x02 LCD Dual //#define UBITX_DISPLAY_LCD2004P //24 x 04 LCD (Parallel) //#define UBITX_DISPLAY_LCD2004I //I2C type 24 x 04 LCD -#define UBITX_DISPLAY_NEXTION //NEXTION LCD +#define UBITX_DISPLAY_NEXTION //NEXTION LCD //#define UBITX_DISPLAY_NEXTION_SAFE //Only EEProm Write 770~775 #define I2C_LCD_MASTER_ADDRESS_DEFAULT 0x27 //0x27 //DEFAULT, if Set I2C Address by uBITX Manager, read from EEProm #define I2C_LCD_SECOND_ADDRESS_DEFAULT 0x3F //0x27 //only using Dual LCD Mode +//Select betwen Analog S-Meter and DSP (I2C) Meter +//#define USE_I2CSMETER #define EXTEND_KEY_GROUP1 //MODE, BAND(-), BAND(+), STEP //#define EXTEND_KEY_GROUP2 //Numeric (0~9), Point(.), Enter //Not supported in Version 1.0x @@ -120,6 +122,24 @@ extern byte I2C_LCD_SECOND_ADDRESS; //only using Dual LCD Mode #define TX_LPF_C (3) //Relay #define CW_KEY (2) +//****************************************************** +//DSP (I2C) Meter +//****************************************************** +//S-Meter Address +#define I2CMETER_ADDR 0x58 +//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 + //============================================================================== // for public, Variable, functions //============================================================================== @@ -196,6 +216,9 @@ extern char byteToChar(byte srcByte); extern void DisplayCallsign(byte callSignLength); extern void DisplayVersionInfo(const char* fwVersionInfo); +//I2C Signal Meter, Version 1.097 +extern int GetI2CSmeterValue(int valueType); //ubitx_ui.ino + #endif //end of if header define diff --git a/ubitx_20/ubitx_lcd_1602.ino b/ubitx_20/ubitx_lcd_1602.ino index 67ca38c..76f2e5b 100644 --- a/ubitx_20/ubitx_lcd_1602.ino +++ b/ubitx_20/ubitx_lcd_1602.ino @@ -738,6 +738,9 @@ void idle_process() { int newSMeter; +#ifdef USE_I2CSMETER + scaledSMeter = GetI2CSmeterValue(I2CMETER_CALCS); +#else //VK2ETA S-Meter from MAX9814 TC pin / divide 4 by KD8CEC for reduce EEPromSize newSMeter = analogRead(ANALOG_SMETER) / 4; @@ -752,6 +755,7 @@ void idle_process() break; } } +#endif DisplayMeter(0, scaledSMeter, 13); checkCountSMeter = 0; //Reset Latency time diff --git a/ubitx_20/ubitx_lcd_1602Dual.ino b/ubitx_20/ubitx_lcd_1602Dual.ino index 211b3ef..48598cb 100644 --- a/ubitx_20/ubitx_lcd_1602Dual.ino +++ b/ubitx_20/ubitx_lcd_1602Dual.ino @@ -669,6 +669,9 @@ void idle_process() int newSMeter; displaySDRON = 0; +#ifdef USE_I2CSMETER + scaledSMeter = GetI2CSmeterValue(I2CMETER_CALCS); +#else //VK2ETA S-Meter from MAX9814 TC pin / divide 4 by KD8CEC for reduce EEPromSize newSMeter = analogRead(ANALOG_SMETER) / 4; @@ -684,9 +687,9 @@ void idle_process() break; } } +#endif DisplayMeter(0, scaledSMeter, 0); - checkCountSMeter = 0; } //end of S-Meter _Addr = I2C_LCD_MASTER_ADDRESS; diff --git a/ubitx_20/ubitx_lcd_2004.ino b/ubitx_20/ubitx_lcd_2004.ino index 2a5a2da..06d44fa 100644 --- a/ubitx_20/ubitx_lcd_2004.ino +++ b/ubitx_20/ubitx_lcd_2004.ino @@ -690,7 +690,10 @@ void idle_process() if (((displayOption1 & 0x08) == 0x08 && (sdrModeOn == 0)) && (++checkCountSMeter > SMeterLatency)) { int newSMeter; - + +#ifdef USE_I2CSMETER + scaledSMeter = GetI2CSmeterValue(I2CMETER_CALCS); +#else //VK2ETA S-Meter from MAX9814 TC pin newSMeter = analogRead(ANALOG_SMETER) / 4; @@ -706,6 +709,7 @@ void idle_process() break; } } +#endif DisplayMeter(0, scaledSMeter, 0); checkCountSMeter = 0; //Reset Latency time diff --git a/ubitx_20/ubitx_lcd_nextion.ino b/ubitx_20/ubitx_lcd_nextion.ino index 2fc746f..23d70ab 100644 --- a/ubitx_20/ubitx_lcd_nextion.ino +++ b/ubitx_20/ubitx_lcd_nextion.ino @@ -1,5 +1,8 @@ /************************************************************************* KD8CEC's uBITX Display Routine for Nextion LCD + + Uses the default protocol of Nextion LCD. + Do not assign a 2 byte address to Nextion LCD. ----------------------------------------------------------------------------- This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -56,53 +59,6 @@ void LCD_Init(void) //initMeter(); //for Meter Display } -//=================================================================== -//I2C Signal Meter, Version 1.097 -// -//=================================================================== - -#define USE_I2CSMETER -//S-Meter Address -#define I2CMETER_ADDR 0x58 -//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 // @@ -678,6 +634,9 @@ void updateDisplay() { sendUIData(0); //UI } +//**************************************************************** +// Spectrum for Range scan and Band Scan +//**************************************************************** #define RESPONSE_SPECTRUM 0 #define RESPONSE_EEPROM 1 #define RESPONSE_EEPROM_HEX_F 89 //C Language order @@ -686,8 +645,8 @@ void updateDisplay() { const uint8_t ResponseHeader[11]={'p', 'm', '.', 's', 'h', '.', 't', 'x', 't', '=', '"'}; const uint8_t ResponseFooter[4]={'"', 0xFF, 0xFF, 0xFF}; - const char HexCodes[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', }; + //void sendSpectrumData(unsigned long startFreq, unsigned long incStep, int scanCount, int delayTime, int sendCount) //sendResponseData(RESPONSE_EEPROM, 0, eepromIndex, eepromReadLength, eepromDataType, 1); //protocol Type : 0 - Spectrum, 1 : EEProm @@ -764,17 +723,15 @@ void sendResponseData(int protocolType, unsigned long startFreq, unsigned int se } //end of for } -//sendSpectrumData(unsigned long startFreq, unsigned int incStep, int scanCount, int delayTime, int sendCount) -//sendSpectrumData(frequency - (1000L * 50), 1000, 100, 0, 10); +//**************************************************************** +//Receive command and processing from External device (LCD or MCU) +//**************************************************************** int spectrumSendCount = 10; //count of full scan and Send int spectrumOffset = 0; //offset position int spectrumScanCount = 100; //Maximum 200 unsigned int spectrumIncStep = 1000; //Increaase Step - -// tern static uint8_t swr_receive_buffer[20]; extern uint8_t receivedCommandLength; extern void SWSerial_Read(uint8_t * receive_cmdBuffer); -//extern void byteToMode(byte modeValue, byte autoSetModebyFreq); uint8_t swr_buffer[20]; //SoftwareSerial_Process diff --git a/ubitx_20/ubitx_ui.ino b/ubitx_20/ubitx_ui.ino index aa3bae9..91b271c 100644 --- a/ubitx_20/ubitx_ui.ino +++ b/ubitx_20/ubitx_ui.ino @@ -268,4 +268,34 @@ int enc_read(void) { return(result); } +//=================================================================== +//I2C Signal Meter, Version 1.097 +//=================================================================== + +// 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); + } + } +} +