Extended key (select key type)

This commit is contained in:
phdlee 2018-04-24 17:26:34 +09:00
parent 6be127d811
commit 6add092391
7 changed files with 154 additions and 80 deletions

View File

@ -278,7 +278,19 @@ void WriteEEPRom(void) //for remove warning
} }
else else
{ {
EEPROM.write(eepromStartIndex, write1Byte); //Special Command
if (eepromStartIndex == 13131) //Magic Key
{
if (write1Byte == 0x51) //Restart
{
asm volatile (" jmp 0");
}
}
else
{
EEPROM.write(eepromStartIndex, write1Byte);
}
Serial.write(0x77); //OK Serial.write(0x77); //OK
Serial.write(ACK); Serial.write(ACK);
} }

View File

@ -34,7 +34,7 @@
//#define EXTEND_KEY_GROUP2 //Numeric (0~9), Point(.), Enter //Not supported in Version 1.0x //#define EXTEND_KEY_GROUP2 //Numeric (0~9), Point(.), Enter //Not supported in Version 1.0x
#define ENABLE_FACTORYALIGN #define ENABLE_FACTORYALIGN
#define ENABLE_ADCMONITOR //Starting with Version 1.07, you can read ADC values directly from uBITX Manager. So this function is not necessary. //#define ENABLE_ADCMONITOR //Starting with Version 1.07, you can read ADC values directly from uBITX Manager. So this function is not necessary.
extern byte I2C_LCD_MASTER_ADDRESS; //0x27 //if Set I2C Address by uBITX Manager, read from EEProm extern byte I2C_LCD_MASTER_ADDRESS; //0x27 //if Set I2C Address by uBITX Manager, read from EEProm
extern byte I2C_LCD_SECOND_ADDRESS; //only using Dual LCD Mode extern byte I2C_LCD_SECOND_ADDRESS; //only using Dual LCD Mode
@ -112,17 +112,41 @@ extern byte I2C_LCD_SECOND_ADDRESS; //only using Dual LCD Mode
#define printLineF1(x) (printLineF(1, x)) #define printLineF1(x) (printLineF(1, x))
#define printLineF2(x) (printLineF(0, x)) #define printLineF2(x) (printLineF(0, x))
//0x00 : None, 0x01 : MODE, 0x02:BAND+, 0x03:BAND-, 0x04:TUNE_STEP, 0x05:VFO Toggle, 0x06:SplitOn/Off, 0x07:TX/ON-OFF, 0x08:SDR Mode On / Off, 0x09:Rit Toggle
#define FUNCTION_KEY_ADC 80 //MODE, BAND(-), BAND(+), STEP #define FUNCTION_KEY_ADC 80 //MODE, BAND(-), BAND(+), STEP
#define FKEY_PRESS 120 #define FKEY_PRESS 0x78
#define FKEY_MODE 0 #define FKEY_MODE 0x01
#define FKEY_BANDUP 1 #define FKEY_BANDUP 0x02
#define FKEY_BANDDOWN 2 #define FKEY_BANDDOWN 0x03
#define FKEY_STEP 3 #define FKEY_STEP 0x04
#define FKEY_VFOCHANGE 0x05
#define FKEY_SPLIT 0x06
#define FKEY_TXOFF 0x07
#define FKEY_SDRMODE 0x08
#define FKEY_RIT 0x09
#define FKEY_ENTER 0x0A
#define FKEY_POINT 0x0B
#define FKEY_DELETE 0x0C
#define FKEY_CANCEL 0x0D
#define FKEY_NUM0 0x10
#define FKEY_NUM1 0x11
#define FKEY_NUM2 0x12
#define FKEY_NUM3 0x13
#define FKEY_NUM4 0x14
#define FKEY_NUM5 0x15
#define FKEY_NUM6 0x16
#define FKEY_NUM7 0x17
#define FKEY_NUM8 0x18
#define FKEY_NUM9 0x19
#define FKEY_TYPE_MAX 0x1F
extern unsigned long frequency; extern unsigned long frequency;
extern byte WsprMSGCount; extern byte WsprMSGCount;
extern byte sMeterLevels[9]; extern byte sMeterLevels[9];
extern byte KeyValues[16][2]; //ADC value Ranges for Extend Key extern byte KeyValues[16][3]; //Set : Start Value, End Value, Key Type, 16 Set (3 * 16 = 48)
extern void printLine1(const char *c); extern void printLine1(const char *c);
extern void printLine2(const char *c); extern void printLine2(const char *c);

View File

@ -185,31 +185,7 @@ byte sMeterLevels[9];
byte I2C_LCD_MASTER_ADDRESS; //0x27 //if Set I2C Address by uBITX Manager, read from EEProm byte I2C_LCD_MASTER_ADDRESS; //0x27 //if Set I2C Address by uBITX Manager, read from EEProm
byte I2C_LCD_SECOND_ADDRESS; //only using Dual LCD Mode byte I2C_LCD_SECOND_ADDRESS; //only using Dual LCD Mode
byte KeyValues[16][3];
byte KeyValues[16][2];
/*= {
{1023, 1025}, //1
{707, 711}, //5
{570, 574}, //9
{493, 500}, //13
{932, 936}, //2
{860, 864}, //3
{800, 805}, //4
{672, 676}, //6
{642, 646}, //7
{616, 620}, //8
{552, 556}, //10
{535, 539}, //11
{520, 524}, //12
{438, 442}, //14
{403, 407}, //15
{378, 382} //16
};
*/
byte isIFShift = 0; //1 = ifShift, 2 extend byte isIFShift = 0; //1 = ifShift, 2 extend
int ifShiftValue = 0; // int ifShiftValue = 0; //
@ -426,7 +402,7 @@ void setFrequency(unsigned long f){
// Offset Frequency : 30Mhz and current Frequncy is 14.074 => 34.074Mhz // Offset Frequency : 30Mhz and current Frequncy is 14.074 => 34.074Mhz
moveFrequency = (f % 10000000); moveFrequency = (f % 10000000);
} }
else if (sdrOption == 3) //Khzz move else if (sdrOption == 3) //Khz move
{ {
//Offset Frequency + Khz, //Offset Frequency + Khz,
//Example : Offset Frequency : 30Mhz and current Frequncy is 7.080 => 30.080Mhz //Example : Offset Frequency : 30Mhz and current Frequncy is 7.080 => 30.080Mhz
@ -458,31 +434,6 @@ void setFrequency(unsigned long f){
} }
} }
/*
if (cwMode == 0)
{
if (isUSB){
si5351bx_setfreq(2, SECOND_OSC_USB - appliedCarrier + f);
si5351bx_setfreq(1, SECOND_OSC_USB);
}
else{
si5351bx_setfreq(2, SECOND_OSC_LSB + appliedCarrier + f);
si5351bx_setfreq(1, SECOND_OSC_LSB);
}
}
else
{
if (cwMode == 1){ //CWL
si5351bx_setfreq(2, SECOND_OSC_LSB + appliedCarrier + f);
si5351bx_setfreq(1, SECOND_OSC_LSB);
}
else{ //CWU
si5351bx_setfreq(2, SECOND_OSC_USB - appliedCarrier + f);
si5351bx_setfreq(1, SECOND_OSC_USB);
}
}
*/
frequency = f; frequency = f;
} }
@ -634,6 +585,8 @@ void checkPTT(){
} }
#ifdef EXTEND_KEY_GROUP1 #ifdef EXTEND_KEY_GROUP1
void checkButton(){ void checkButton(){
char currentBandIndex = -1;
//only if the button is pressed //only if the button is pressed
int keyStatus = getBtnStatus(); int keyStatus = getBtnStatus();
if (keyStatus == -1) if (keyStatus == -1)
@ -646,8 +599,69 @@ void checkButton(){
if (keyStatus == FKEY_PRESS) //Menu Key if (keyStatus == FKEY_PRESS) //Menu Key
doMenu(); doMenu();
else if (keyStatus <= FKEY_STEP) //EXTEND KEY GROUP #1 else if (keyStatus <= FKEY_TYPE_MAX) //EXTEND KEY GROUP #1
{ {
switch(keyStatus)
{
case FKEY_MODE :
if (cwMode == 1)
{
cwMode = 2;
}
else if (cwMode == 2)
{
cwMode = 0;
isUSB = 0;
}
else if (isUSB == 0)
{
isUSB = 1;
}
else
{
cwMode = 1;
}
break;
case FKEY_BANDUP :
case FKEY_BANDDOWN :
//Save Band Information
if (tuneTXType == 2 || tuneTXType == 3 || tuneTXType == 102 || tuneTXType == 103) { //only ham band move
currentBandIndex = getIndexHambanBbyFreq(frequency);
if (currentBandIndex >= 0) {
saveBandFreqByIndex(frequency, modeToByte(), currentBandIndex);
}
}
setNextHamBandFreq(frequency, keyStatus == FKEY_BANDDOWN ? -1 : 1); //Prior Band
break;
case FKEY_STEP :
if (++tuneStepIndex > 5)
tuneStepIndex = 1;
EEPROM.put(TUNING_STEP, tuneStepIndex);
printLine2ClearAndUpdate();
break;
case FKEY_VFOCHANGE :
menuVfoToggle(1); //Vfo Toggle
break;
case FKEY_SPLIT :
menuSplitOnOff(1);
break;
case FKEY_TXOFF:
menuTxOnOff(1, 0x01);
break;
case FKEY_SDRMODE :
menuSDROnOff(1);
break;
case FKEY_RIT :
menuRitToggle(1);
break;
}
/*
if (keyStatus == FKEY_MODE) //Press Mode Key if (keyStatus == FKEY_MODE) //Press Mode Key
{ {
if (cwMode == 1) if (cwMode == 1)
@ -668,10 +682,6 @@ void checkButton(){
cwMode = 1; cwMode = 1;
} }
} }
//else if (keyStatus == FKEY_BANDDOWN) //Press Mode Key
//{
// setNextHamBandFreq(frequency, -1); //Prior Band
//}
else if (keyStatus == FKEY_BANDUP || keyStatus == FKEY_BANDDOWN) //Press Mode Key else if (keyStatus == FKEY_BANDUP || keyStatus == FKEY_BANDDOWN) //Press Mode Key
{ {
@ -696,6 +706,28 @@ void checkButton(){
EEPROM.put(TUNING_STEP, tuneStepIndex); EEPROM.put(TUNING_STEP, tuneStepIndex);
printLine2ClearAndUpdate(); printLine2ClearAndUpdate();
} }
else if (keyStatus == FKEY_VFOCHANGE)
{
menuVfoToggle(1); //Vfo Toggle
}
else if (keyStatus == FKEY_SPLIT)
{
menuSplitOnOff(1);
}
else if (keyStatus == FKEY_TXOFF)
{
menuTxOnOff(1, 0x01);
}
else if (keyStatus == FKEY_SDRMODE)
{
menuSDROnOff(1);
}
else if (keyStatus == FKEY_RIT)
{
menuRitToggle(1);
}
*/
FrequencyToVFO(1); FrequencyToVFO(1);
SetCarrierFreq(); SetCarrierFreq();
@ -942,8 +974,9 @@ void initSettings(){
//KeyValues //KeyValues
for (byte i = 0; i < 16; i++) { for (byte i = 0; i < 16; i++) {
KeyValues[i][0] = EEPROM.read(EXTENDED_KEY_RANGE + (i * 2)); KeyValues[i][0] = EEPROM.read(EXTENDED_KEY_RANGE + (i * 3)); //RANGE : Start Value
KeyValues[i][1] = EEPROM.read(EXTENDED_KEY_RANGE + (i * 2) + 1); KeyValues[i][1] = EEPROM.read(EXTENDED_KEY_RANGE + (i * 3) + 1); //RANGE : End Value
KeyValues[i][2] = EEPROM.read(EXTENDED_KEY_RANGE + (i * 3) + 2); //KEY TYPE
} }
//User callsign information //User callsign information

View File

@ -50,10 +50,13 @@
// 256 ~ 1023 (EEProm Section #1) // 256 ~ 1023 (EEProm Section #1)
// 255 ~ 101 (EEProm Section #2) // 255 ~ 101 (EEProm Section #2)
//============================================================================== //==============================================================================
//0x00 : None, 0x01 : MODE, 0x02:BAND+, 0x03:BAND-, 0x04:TUNE_STEP, 0x05:VFO Toggle, 0x06:SplitOn/Off, 0x07:TX/ON-OFF, 0x08:SDR Mode On / Off, 0x09:Rit Toggle
#define EXTENDED_KEY_RANGE 140 //Extended Key => Set : Start Value, End Value, Key Type, 16 Set (3 * 16 = 48)
#define I2C_LCD_MASTER 190 #define I2C_LCD_MASTER 190
#define I2C_LCD_SECOND 191 #define I2C_LCD_SECOND 191
//RESERVE 192 ~ 195
#define EXTENDED_KEY_RANGE 196 //Extended Key, KEY RANGE (MODE, BAND+, BAND-, TUNE_STEP, NUM0~NUM9, POINT, ENTER
#define S_METER_LEVELS 230 //LEVEL0 ~ LEVEL7 #define S_METER_LEVELS 230 //LEVEL0 ~ LEVEL7
#define ADVANCED_FREQ_OPTION1 240 //Bit0: use IFTune_Value, Bit1 : use Stored enabled SDR Mode, Bit2 : dynamic sdr frequency #define ADVANCED_FREQ_OPTION1 240 //Bit0: use IFTune_Value, Bit1 : use Stored enabled SDR Mode, Bit2 : dynamic sdr frequency

View File

@ -403,15 +403,15 @@ void menuSplitOnOff(int btn){
else { else {
if (splitOn == 1){ if (splitOn == 1){
splitOn = 0; splitOn = 0;
//printLineF2(F("Split Off!")); printLineF2(F("SPT Off"));
printLineF2(F("[OFF]")); //printLineF2(F("[OFF]"));
} }
else { else {
splitOn = 1; splitOn = 1;
if (ritOn == 1) if (ritOn == 1)
ritOn = 0; ritOn = 0;
//printLineF2(F("Split On!")); printLineF2(F("SPT On"));
printLineF2(F("[ON]")); //printLineF2(F("[ON]"));
} }
menuClearExit(500); menuClearExit(500);
@ -430,11 +430,11 @@ void menuTxOnOff(int btn, byte optionType){
else { else {
if ((isTxType & optionType) == 0){ if ((isTxType & optionType) == 0){
isTxType |= optionType; isTxType |= optionType;
printLineF2(F("TX OFF!")); printLineF2(F("TX OFF"));
} }
else { else {
isTxType &= ~(optionType); isTxType &= ~(optionType);
printLineF2(F("TX ON!")); printLineF2(F("TX ON"));
} }
menuClearExit(500); menuClearExit(500);
@ -453,7 +453,7 @@ void menuSDROnOff(int btn)
else { else {
if (sdrModeOn == 1){ if (sdrModeOn == 1){
sdrModeOn = 0; sdrModeOn = 0;
printLineF2(F("[OFF]")); printLineF2(F("SPK MODE"));
} }
else { else {
sdrModeOn = 1; sdrModeOn = 1;
@ -464,7 +464,7 @@ void menuSDROnOff(int btn)
if (splitOn == 1) if (splitOn == 1)
splitOn = 0; splitOn = 0;
printLineF2(F("[ON]")); printLineF2(F("SDR MODE"));
} }
EEPROM.put(ENABLE_SDR, sdrModeOn); EEPROM.put(ENABLE_SDR, sdrModeOn);

View File

@ -15,7 +15,6 @@
************************************************************************************/ ************************************************************************************/
// ************* SI5315 routines - tks Jerry Gaffke, KE7ER *********************** // ************* SI5315 routines - tks Jerry Gaffke, KE7ER ***********************
// An minimalist standalone set of Si5351 routines. // An minimalist standalone set of Si5351 routines.
// VCOA is fixed at 875mhz, VCOB not used. // VCOA is fixed at 875mhz, VCOB not used.
// The output msynth dividers are used to generate 3 independent clocks // The output msynth dividers are used to generate 3 independent clocks
@ -127,7 +126,9 @@ void si5351_set_calibration(int32_t cal){
void SetCarrierFreq() void SetCarrierFreq()
{ {
unsigned long appliedCarrier = ((cwMode == 0 ? usbCarrier : cwmCarrier) + (isIFShift && (inTx == 0) ? ifShiftValue : 0)); unsigned long appliedCarrier = ((cwMode == 0 ? usbCarrier : cwmCarrier) + (isIFShift && (inTx == 0) ? ifShiftValue : 0));
si5351bx_setfreq(0, (sdrModeOn ? 0 : appliedCarrier)); //si5351bx_setfreq(0, (sdrModeOn ? 0 : appliedCarrier));
si5351bx_setfreq(0, ((sdrModeOn && (inTx == 0)) ? 0 : appliedCarrier)); //found bug by KG4GEK
/* /*
if (cwMode == 0) if (cwMode == 0)

View File

@ -185,10 +185,11 @@ int getBtnStatus(void){
else else
{ {
readButtonValue = readButtonValue / 4; readButtonValue = readButtonValue / 4;
//return FKEY_VFOCHANGE;
for (int i = 0; i < 16; i++) for (int i = 0; i < 16; i++)
if (KeyValues[i][0] <= readButtonValue && KeyValues[i][1] >= readButtonValue) if (KeyValues[i][0] <= readButtonValue && KeyValues[i][1] >= readButtonValue)
return i; return KeyValues[i][2];
//return i;
} }
return -1; return -1;