added protocol

This commit is contained in:
phdlee 2018-06-13 23:15:58 +09:00
parent 3050374504
commit 9da71429cb
4 changed files with 59 additions and 32 deletions

View File

@ -235,30 +235,6 @@ void sendCWChar(char cwKeyChar)
}
}
/*
void sendAutoCW(int cwSendLength, char *sendString)
{
byte i;
if (!inTx){
keyDown = 0;
cwTimeout = millis() + cwDelayTime * 10;
startTx(TX_CW, 0); //disable updateDisplay Command for reduce latency time
updateDisplay();
delay_background(delayBeforeCWStartTime * 2, 2);
}
for (i = 0; i < cwSendLength; i++)
{
sendCWChar(sendString[i]);
if (i != cwSendLength -1) delay_background(cwSpeed * 3, 3);
}
delay_background(cwDelayTime * 10, 2);
stopTx();
}
*/
byte isNeedScroll = 0;
unsigned long scrollDispayTime = 0;
#define scrollSpeed 500

View File

@ -24,12 +24,12 @@
//==============================================================================
//Depending on the type of LCD mounted on the uBITX, uncomment one of the options below.
//You must select only one.
#define UBITX_DISPLAY_LCD1602P //LCD mounted on unmodified uBITX (Parallel)
//#define UBITX_DISPLAY_LCD1602P //LCD mounted on unmodified uBITX (Parallel)
//#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_NEXTION //NEXTION LCD
//#define UBITX_CONTROL_MCU //CONTROL MCU
#define I2C_LCD_MASTER_ADDRESS_DEFAULT 0x27 //0x27 //DEFAULT, if Set I2C Address by uBITX Manager, read from EEProm
@ -58,9 +58,11 @@ extern byte I2C_LCD_SECOND_ADDRESS; //only using Dual LCD Mode
#ifdef UBITX_DISPLAY_NEXTION
#define USE_SW_SERIAL
#undef ENABLE_ADCMONITOR
#undef FACTORY_RECOVERY_BOOTUP
#elif defined(UBITX_CONTROL_MCU)
#define USE_SW_SERIAL
#undef ENABLE_ADCMONITOR
#undef FACTORY_RECOVERY_BOOTUP
#endif

View File

@ -1311,8 +1311,6 @@ void setup()
if (userCallsignLength > 0 && ((userCallsignLength & 0x80) == 0x80)) {
userCallsignLength = userCallsignLength & 0x7F;
//printLineFromEEPRom(0, 0, 0, userCallsignLength -1, 0); //eeprom to lcd use offset (USER_CALLSIGN_DAT)
//delay(500);
DisplayCallsign(userCallsignLength);
}
else {

View File

@ -185,6 +185,9 @@ byte L_displayOption2; //byte displayOption2 (Reserve)
#define TS_CMD_SPECTRUMOPT 15 //Option for Spectrum
#define TS_CMD_SPECTRUM 16 //Get Spectrum Value
#define TS_CMD_SWTRIG 21 //SW Action Trigger for WSPR and more
#define TS_CMD_READMEM 31 //Read EEProm
#define TS_CMD_WRITEMEM 32 //Write EEProm
#define TS_CMD_FACTORYRESET 33 //Factory Reset
char nowdisp = 0;
@ -782,13 +785,11 @@ void SWS_Process(void)
{
if (receivedCommandLength > 0)
{
//receivedCommandLength = 0;
break;
}
//SendCommandL('x', analogRead(ADCIndex[swr_buffer[commandStartIndex + 4]]));
SendCommandL('n', nowCheckIndex); //Index Input
SendCommandL('x', analogRead(ADCIndex[nowCheckIndex++]));
SendCommandL('n', nowCheckIndex); //Index Input
if (nowCheckIndex > endIndex)
nowCheckIndex = startIndex;
@ -805,7 +806,6 @@ void SWS_Process(void)
{
//sendSpectrumData(unsigned long startFreq, unsigned int incStep, int scanCount, int delayTime, int sendCount)
//sendSpectrumData(frequency - (1000L * 50), 1000, 100, 0, 10);
//*(long *)(&swr_buffer[commandStartIndex + 4])
//sendSpectrumData(*(long *)(&swr_buffer[commandStartIndex + 4]), spectrumIncStep, spectrumScanCount, spectrumDelayTime, spectrumSendCount);
sendSpectrumData(*(long *)(&swr_buffer[commandStartIndex + 4]), 1000, 100, 0, 32);
}
@ -822,6 +822,39 @@ void SWS_Process(void)
{
TriggerBySW = 1; //Action Trigger by Software
}
else if (commandType == TS_CMD_READMEM || commandType == TS_CMD_WRITEMEM) //Read Mem
{
uint16_t eepromIndex = *(uint16_t *)(&swr_buffer[commandStartIndex + 4]);
byte eepromData = swr_buffer[commandStartIndex + 6];
byte eepromCheckSum = swr_buffer[commandStartIndex + 7];
//Check Checksum
if (eepromCheckSum == (swr_buffer[commandStartIndex + 4] + swr_buffer[commandStartIndex + 5] + swr_buffer[commandStartIndex + 6]))
{
if (commandType == TS_CMD_WRITEMEM)
{
if (eepromIndex > 64)
EEPROM.write(eepromIndex, eepromData);
}
else
{
SendCommandL('x', EEPROM.read(eepromIndex));
}
}
else
{
eepromIndex = -2;
}
SendCommandL('n', eepromIndex); //Index Input
}
else if (commandType == TS_CMD_FACTORYRESET)
{
if (*(unsigned long *)&swr_buffer[commandStartIndex + 4] == 1497712748)
{
for (unsigned int i = 0; i < 32; i++) //factory setting range
EEPROM.write(i, EEPROM.read(FACTORY_VALUES + i)); //65~96 => 0~31
}
}
setFrequency(frequency);
SetCarrierFreq();
@ -881,6 +914,24 @@ void SendUbitxData(void)
SendCommandStr(CMD_VERSION, "+v1.092"); //Version
SendEEPromData(CMD_CALLSIGN, 0, userCallsignLength -1, 0);
/*
//Frequency of Bands
for (int i = 0; i < 11; i++)
SWSerial_Write(SpectrumHeader[i]);
byte *tmpByte;
tmpByte = (byte *)hamBandRange;
for (byte i = 0; i < (useHamBandCount -1) * 4; i++)
{
SWSerial_Write(HexCodes[*tmpByte >> 4]);
SWSerial_Write(HexCodes[*tmpByte & 0xf]);
tmpByte++;
}
for (int i = 0; i < 4; i++)
SWSerial_Write(SpectrumFooter[i]);
*/
//Complte Send Info
SendCommand1Num(CMD_UBITX_INFO, 1);