From e79dbdbbe7312a4cc90b07e6c9919ef1fbd988cd Mon Sep 17 00:00:00 2001 From: phdlee Date: Mon, 6 Aug 2018 13:59:55 +0900 Subject: [PATCH] for Release Version 1.097 --- ubitx_20/ubitx.h | 8 ++--- ubitx_20/ubitx_20.ino | 10 ++++-- ubitx_20/ubitx_lcd_nextion.ino | 61 +++++++++++++++++----------------- ubitx_20/ubitx_ui.ino | 9 +++-- 4 files changed, 47 insertions(+), 41 deletions(-) diff --git a/ubitx_20/ubitx.h b/ubitx_20/ubitx.h index f954d78..fedb46e 100644 --- a/ubitx_20/ubitx.h +++ b/ubitx_20/ubitx.h @@ -28,8 +28,8 @@ //#define UBITX_DISPLAY_LCD1602I //I2C type 16 x 02 LCD //#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_LCD2004I //I2C type 24 x 04 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 @@ -187,7 +187,7 @@ extern byte I2C_LCD_SECOND_ADDRESS; //only using Dual LCD Mode * ground and six pins. Each of these six pins can be individually programmed * either as an analog input, a digital input or a digital output. * The pins are assigned as follows (left to right, display facing you): - * Pin 1 (Violet), A7, SPARE + * Pin 1 (Violet), A7, SPARE => Analog S-Meter * Pin 2 (Blue), A6, KEYER (DATA) * Pin 3 (Green), +5v * Pin 4 (Yellow), Gnd @@ -217,7 +217,7 @@ extern byte I2C_LCD_SECOND_ADDRESS; //only using Dual LCD Mode * The second set of 16 pins on the Raduino's bottom connector are have the three clock outputs and the digital lines to control the rig. * This assignment is as follows : * Pin 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 - * GND +5V CLK0 GND GND CLK1 GND GND CLK2 GND D2 D3 D4 D5 D6 D7 + * GND +5V CLK2 GND GND CLK1 GND GND CLK0 GND D2 D3 D4 D5 D6 D7 * These too are flexible with what you may do with them, for the Raduino, we use them to : * - TX_RX line : Switches between Transmit and Receive after sensing the PTT or the morse keyer * - CW_KEY line : turns on the carrier for CW diff --git a/ubitx_20/ubitx_20.ino b/ubitx_20/ubitx_20.ino index c6e45be..c9b235f 100644 --- a/ubitx_20/ubitx_20.ino +++ b/ubitx_20/ubitx_20.ino @@ -1255,9 +1255,15 @@ void setup() initSettings(); initPorts(); -#ifndef USE_SW_SERIAL +#ifdef USE_SW_SERIAL +// if (userCallsignLength > 0 && ((userCallsignLength & 0x80) == 0x80)) +// { + userCallsignLength = userCallsignLength & 0x7F; +// } +#else //for Chracter LCD - if (userCallsignLength > 0 && ((userCallsignLength & 0x80) == 0x80)) { + if (userCallsignLength > 0 && ((userCallsignLength & 0x80) == 0x80)) + { userCallsignLength = userCallsignLength & 0x7F; DisplayCallsign(userCallsignLength); } diff --git a/ubitx_20/ubitx_lcd_nextion.ino b/ubitx_20/ubitx_lcd_nextion.ino index cbac8ac..096b86b 100644 --- a/ubitx_20/ubitx_lcd_nextion.ino +++ b/ubitx_20/ubitx_lcd_nextion.ino @@ -230,16 +230,37 @@ void SendHeader(char varType, char varIndex) } } +#define INT_ETX 0 +#define STR_ETX 1 +#define TMP_ETX 2 +//Send 0xFF, 0xFF, 0xFF +//etxType : INT_ETX = 0xFF, 0xFF, 0xFF +// STR_ETX = ", 0xFF, 0xFF, 0xFF +// TEMP_ETX = softTemp, 0xFF, 0xFF, 0xff + +void SendCommandETX(char etxType) +{ + if (etxType == 2) + { + SWSerial_Print(softTemp); + } + else if (etxType == 1) + { + SWSerial_Print("\""); + } + + SWSerial_Write(0xff); + SWSerial_Write(0xff); + SWSerial_Write(0xff); +} + void SendCommandUL(char varIndex, unsigned long sendValue) { SendHeader(SWS_HEADER_INT_TYPE, varIndex); memset(softTemp, 0, 20); ultoa(sendValue, softTemp, DEC); - SWSerial_Print(softTemp); - SWSerial_Write(0xff); - SWSerial_Write(0xff); - SWSerial_Write(0xff); + SendCommandETX(TMP_ETX); } void SendCommandL(char varIndex, long sendValue) @@ -248,10 +269,7 @@ void SendCommandL(char varIndex, long sendValue) memset(softTemp, 0, 20); ltoa(sendValue, softTemp, DEC); - SWSerial_Print(softTemp); - SWSerial_Write(0xff); - SWSerial_Write(0xff); - SWSerial_Write(0xff); + SendCommandETX(TMP_ETX); } void SendCommandStr(char varIndex, char* sendValue) @@ -259,10 +277,7 @@ void SendCommandStr(char varIndex, char* sendValue) SendHeader(SWS_HEADER_STR_TYPE, varIndex); SWSerial_Print(sendValue); - SWSerial_Write('\"'); - SWSerial_Write(0xFF); - SWSerial_Write(0xFF); - SWSerial_Write(0xFF); + SendCommandETX(STR_ETX); } //Send String data with duplicate check @@ -274,10 +289,7 @@ void SendTextLineBuff(char lineNumber) SendHeader(SWS_HEADER_STR_TYPE, lineNumber + 0x30); //s0.txt, s1.txt SWSerial_Print(softBuffLines[lineNumber]); - SWSerial_Write('\"'); - SWSerial_Write(0xFF); - SWSerial_Write(0xFF); - SWSerial_Write(0xFF); + SendCommandETX(STR_ETX); strcpy(softBuffSended[lineNumber], softBuffLines[lineNumber]); } @@ -312,10 +324,7 @@ void SendEEPromData(char varIndex, int eepromStartIndex, int eepromEndIndex, cha SWSerial_Write(EEPROM.read((offsetTtype == 0 ? USER_CALLSIGN_DAT : WSPR_MESSAGE1) + i)); } - SWSerial_Write('\"'); - SWSerial_Write(0xFF); - SWSerial_Write(0xFF); - SWSerial_Write(0xFF); + SendCommandETX(STR_ETX); } uint8_t softBuff1Num[14] = {'p', 'm', '.', 'c', '0', '.', 'v', 'a', 'l', '=', 0, 0xFF, 0xFF, 0xFF}; @@ -646,7 +655,6 @@ void updateDisplay() { #define RESPONSE_EEPROM_STR 87 //String 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) @@ -718,10 +726,8 @@ void sendResponseData(int protocolType, unsigned long startFreq, unsigned int se SWSerial_Write(HexCodes[readedValue & 0xf]); } } - - for (int i = 0; i < 4; i++) - SWSerial_Write(ResponseFooter[i]); - + + SendCommandETX(STR_ETX); } //end of for } @@ -995,12 +1001,7 @@ void idle_process() #else int newSMeter; - //VK2ETA S-Meter from MAX9814 TC pin newSMeter = analogRead(ANALOG_SMETER) / 4; - - //Faster attack, Slower release - //currentSMeter = (newSMeter > currentSMeter ? ((currentSMeter * 3 + newSMeter * 7) + 5) / 10 : ((currentSMeter * 7 + newSMeter * 3) + 5) / 10); - //currentSMeter = ((currentSMeter * 7 + newSMeter * 3) + 5) / 10; currentSMeter = newSMeter; scaledSMeter = 0; diff --git a/ubitx_20/ubitx_ui.ino b/ubitx_20/ubitx_ui.ino index 8ab1579..0aa7c30 100644 --- a/ubitx_20/ubitx_ui.ino +++ b/ubitx_20/ubitx_ui.ino @@ -290,11 +290,10 @@ int GetI2CSmeterValue(int valueType) { return Wire.read(); } - //else - //{ - // delay(10); - // return Wire.read(); - //} + else + { + return 0; + } }