Skip to content

Commit 5c40718

Browse files
authored
Merge pull request #31 from phdlee/version1.073
Version1.073
2 parents 3b4bdaf + 6add092 commit 5c40718

11 files changed

+996
-111
lines changed

ubitx_20/cat_libs.ino

+13-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,19 @@ void WriteEEPRom(void) //for remove warning
278278
}
279279
else
280280
{
281-
EEPROM.write(eepromStartIndex, write1Byte);
281+
//Special Command
282+
if (eepromStartIndex == 13131) //Magic Key
283+
{
284+
if (write1Byte == 0x51) //Restart
285+
{
286+
asm volatile (" jmp 0");
287+
}
288+
}
289+
else
290+
{
291+
EEPROM.write(eepromStartIndex, write1Byte);
292+
}
293+
282294
Serial.write(0x77); //OK
283295
Serial.write(ACK);
284296
}

ubitx_20/ubitx.h

+48-11
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,34 @@
2121
//==============================================================================
2222
//Depending on the type of LCD mounted on the uBITX, uncomment one of the options below.
2323
//You must select only one.
24-
//#define UBITX_DISPLAY_LCD1602P //LCD mounted on unmodified uBITX
24+
#define UBITX_DISPLAY_LCD1602P //LCD mounted on unmodified uBITX
2525
//#define UBITX_DISPLAY_LCD1602I //I2C type 16 x 02 LCD
26-
#define UBITX_DISPLAY_LCD2004P //24 x 04 LCD (Parallel)
26+
//#define UBITX_DISPLAY_LCD1602I_DUAL
27+
//#define UBITX_DISPLAY_LCD2004P //24 x 04 LCD (Parallel)
2728
//#define UBITX_DISPLAY_LCD2004I //I2C type 24 x 04 LCD
2829

29-
#define I2C_DISPLAY_ADDRESS 0x3F //0x27 //DEFAULT, if Set I2C Address by uBITX Manager, read from EEProm
30+
#define I2C_LCD_MASTER_ADDRESS_DEFAULT 0x3F //0x27 //DEFAULT, if Set I2C Address by uBITX Manager, read from EEProm
31+
#define I2C_LCD_SECOND_ADDRESS_DEFAULT 0x27 //0x27 //only using Dual LCD Mode
3032

31-
//#define EXTEND_KEY_GROUP1 //MODE, BAND(-), BAND(+), STEP
33+
#define EXTEND_KEY_GROUP1 //MODE, BAND(-), BAND(+), STEP
3234
//#define EXTEND_KEY_GROUP2 //Numeric (0~9), Point(.), Enter //Not supported in Version 1.0x
3335

3436
#define ENABLE_FACTORYALIGN
35-
#define ENABLE_ADCMONITOR //Starting with Version 1.07, you can read ADC values directly from uBITX Manager. So this function is not necessary.
37+
//#define ENABLE_ADCMONITOR //Starting with Version 1.07, you can read ADC values directly from uBITX Manager. So this function is not necessary.
38+
39+
extern byte I2C_LCD_MASTER_ADDRESS; //0x27 //if Set I2C Address by uBITX Manager, read from EEProm
40+
extern byte I2C_LCD_SECOND_ADDRESS; //only using Dual LCD Mode
3641

3742
#define SMeterLatency 3 //1 is 0.25 sec
3843

44+
#ifdef UBITX_DISPLAY_LCD1602I
45+
#define USE_I2C_LCD
46+
#elif defined(UBITX_DISPLAY_LCD1602I_DUAL)
47+
#define USE_I2C_LCD
48+
#elif defined(UBITX_DISPLAY_LCD2004I)
49+
#define USE_I2C_LCD
50+
#endif
51+
3952
//==============================================================================
4053
// Hardware, Define PIN Usage
4154
//==============================================================================
@@ -99,17 +112,41 @@
99112
#define printLineF1(x) (printLineF(1, x))
100113
#define printLineF2(x) (printLineF(0, x))
101114

115+
//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
102116
#define FUNCTION_KEY_ADC 80 //MODE, BAND(-), BAND(+), STEP
103-
#define FKEY_PRESS 120
104-
#define FKEY_MODE 0
105-
#define FKEY_BANDUP 1
106-
#define FKEY_BANDDOWN 2
107-
#define FKEY_STEP 3
117+
#define FKEY_PRESS 0x78
118+
#define FKEY_MODE 0x01
119+
#define FKEY_BANDUP 0x02
120+
#define FKEY_BANDDOWN 0x03
121+
#define FKEY_STEP 0x04
122+
#define FKEY_VFOCHANGE 0x05
123+
#define FKEY_SPLIT 0x06
124+
#define FKEY_TXOFF 0x07
125+
#define FKEY_SDRMODE 0x08
126+
#define FKEY_RIT 0x09
127+
128+
#define FKEY_ENTER 0x0A
129+
#define FKEY_POINT 0x0B
130+
#define FKEY_DELETE 0x0C
131+
#define FKEY_CANCEL 0x0D
132+
133+
#define FKEY_NUM0 0x10
134+
#define FKEY_NUM1 0x11
135+
#define FKEY_NUM2 0x12
136+
#define FKEY_NUM3 0x13
137+
#define FKEY_NUM4 0x14
138+
#define FKEY_NUM5 0x15
139+
#define FKEY_NUM6 0x16
140+
#define FKEY_NUM7 0x17
141+
#define FKEY_NUM8 0x18
142+
#define FKEY_NUM9 0x19
143+
144+
#define FKEY_TYPE_MAX 0x1F
108145

109146
extern unsigned long frequency;
110147
extern byte WsprMSGCount;
111148
extern byte sMeterLevels[9];
112-
extern int KeyValues[16][2]; //ADC value Ranges for Extend Key
149+
extern byte KeyValues[16][3]; //Set : Start Value, End Value, Key Type, 16 Set (3 * 16 = 48)
113150

114151
extern void printLine1(const char *c);
115152
extern void printLine2(const char *c);

ubitx_20/ubitx_20.ino

+108-59
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// So I put + in the sense that it was improved one by one based on Original Firmware.
77
// This firmware has been gradually changed based on the original firmware created by Farhan, Jack, Jerry and others.
88

9-
#define FIRMWARE_VERSION_INFO F("+v1.072")
9+
#define FIRMWARE_VERSION_INFO F("+v1.073")
1010
#define FIRMWARE_VERSION_NUM 0x02 //1st Complete Project : 1 (Version 1.061), 2st Project : 2
1111

1212
/**
@@ -182,30 +182,10 @@ byte line2DisplayStatus = 0; //0:Clear, 1 : menu, 1: DisplayFrom Idle,
182182
char lcdMeter[17];
183183
byte sMeterLevels[9];
184184

185-
int KeyValues[16][2];
186-
/*= {
187-
{1023, 1025}, //1
188-
{707, 711}, //5
189-
{570, 574}, //9
190-
{493, 500}, //13
191-
192-
{932, 936}, //2
193-
{860, 864}, //3
194-
{800, 805}, //4
195-
196-
{672, 676}, //6
197-
{642, 646}, //7
198-
{616, 620}, //8
199-
200-
{552, 556}, //10
201-
{535, 539}, //11
202-
{520, 524}, //12
203-
204-
{438, 442}, //14
205-
{403, 407}, //15
206-
{378, 382} //16
207-
};
208-
*/
185+
byte I2C_LCD_MASTER_ADDRESS; //0x27 //if Set I2C Address by uBITX Manager, read from EEProm
186+
byte I2C_LCD_SECOND_ADDRESS; //only using Dual LCD Mode
187+
188+
byte KeyValues[16][3];
209189

210190
byte isIFShift = 0; //1 = ifShift, 2 extend
211191
int ifShiftValue = 0; //
@@ -422,7 +402,7 @@ void setFrequency(unsigned long f){
422402
// Offset Frequency : 30Mhz and current Frequncy is 14.074 => 34.074Mhz
423403
moveFrequency = (f % 10000000);
424404
}
425-
else if (sdrOption == 3) //Khzz move
405+
else if (sdrOption == 3) //Khz move
426406
{
427407
//Offset Frequency + Khz,
428408
//Example : Offset Frequency : 30Mhz and current Frequncy is 7.080 => 30.080Mhz
@@ -454,31 +434,6 @@ void setFrequency(unsigned long f){
454434
}
455435
}
456436

457-
/*
458-
if (cwMode == 0)
459-
{
460-
if (isUSB){
461-
si5351bx_setfreq(2, SECOND_OSC_USB - appliedCarrier + f);
462-
si5351bx_setfreq(1, SECOND_OSC_USB);
463-
}
464-
else{
465-
si5351bx_setfreq(2, SECOND_OSC_LSB + appliedCarrier + f);
466-
si5351bx_setfreq(1, SECOND_OSC_LSB);
467-
}
468-
}
469-
else
470-
{
471-
if (cwMode == 1){ //CWL
472-
si5351bx_setfreq(2, SECOND_OSC_LSB + appliedCarrier + f);
473-
si5351bx_setfreq(1, SECOND_OSC_LSB);
474-
}
475-
else{ //CWU
476-
si5351bx_setfreq(2, SECOND_OSC_USB - appliedCarrier + f);
477-
si5351bx_setfreq(1, SECOND_OSC_USB);
478-
}
479-
}
480-
*/
481-
482437
frequency = f;
483438
}
484439

@@ -630,6 +585,8 @@ void checkPTT(){
630585
}
631586
#ifdef EXTEND_KEY_GROUP1
632587
void checkButton(){
588+
char currentBandIndex = -1;
589+
633590
//only if the button is pressed
634591
int keyStatus = getBtnStatus();
635592
if (keyStatus == -1)
@@ -642,8 +599,69 @@ void checkButton(){
642599

643600
if (keyStatus == FKEY_PRESS) //Menu Key
644601
doMenu();
645-
else if (keyStatus <= FKEY_STEP) //EXTEND KEY GROUP #1
602+
else if (keyStatus <= FKEY_TYPE_MAX) //EXTEND KEY GROUP #1
646603
{
604+
605+
switch(keyStatus)
606+
{
607+
case FKEY_MODE :
608+
if (cwMode == 1)
609+
{
610+
cwMode = 2;
611+
}
612+
else if (cwMode == 2)
613+
{
614+
cwMode = 0;
615+
isUSB = 0;
616+
}
617+
else if (isUSB == 0)
618+
{
619+
isUSB = 1;
620+
}
621+
else
622+
{
623+
cwMode = 1;
624+
}
625+
break;
626+
case FKEY_BANDUP :
627+
case FKEY_BANDDOWN :
628+
//Save Band Information
629+
if (tuneTXType == 2 || tuneTXType == 3 || tuneTXType == 102 || tuneTXType == 103) { //only ham band move
630+
currentBandIndex = getIndexHambanBbyFreq(frequency);
631+
632+
if (currentBandIndex >= 0) {
633+
saveBandFreqByIndex(frequency, modeToByte(), currentBandIndex);
634+
}
635+
}
636+
setNextHamBandFreq(frequency, keyStatus == FKEY_BANDDOWN ? -1 : 1); //Prior Band
637+
break;
638+
639+
case FKEY_STEP :
640+
if (++tuneStepIndex > 5)
641+
tuneStepIndex = 1;
642+
643+
EEPROM.put(TUNING_STEP, tuneStepIndex);
644+
printLine2ClearAndUpdate();
645+
break;
646+
647+
case FKEY_VFOCHANGE :
648+
menuVfoToggle(1); //Vfo Toggle
649+
break;
650+
651+
case FKEY_SPLIT :
652+
menuSplitOnOff(1);
653+
break;
654+
case FKEY_TXOFF:
655+
menuTxOnOff(1, 0x01);
656+
break;
657+
case FKEY_SDRMODE :
658+
menuSDROnOff(1);
659+
break;
660+
case FKEY_RIT :
661+
menuRitToggle(1);
662+
break;
663+
}
664+
/*
647665
if (keyStatus == FKEY_MODE) //Press Mode Key
648666
{
649667
if (cwMode == 1)
@@ -664,10 +682,6 @@ void checkButton(){
664682
cwMode = 1;
665683
}
666684
}
667-
//else if (keyStatus == FKEY_BANDDOWN) //Press Mode Key
668-
//{
669-
// setNextHamBandFreq(frequency, -1); //Prior Band
670-
//}
671685
else if (keyStatus == FKEY_BANDUP || keyStatus == FKEY_BANDDOWN) //Press Mode Key
672686
{
673687
@@ -692,6 +706,28 @@ void checkButton(){
692706
EEPROM.put(TUNING_STEP, tuneStepIndex);
693707
printLine2ClearAndUpdate();
694708
}
709+
710+
else if (keyStatus == FKEY_VFOCHANGE)
711+
{
712+
menuVfoToggle(1); //Vfo Toggle
713+
}
714+
else if (keyStatus == FKEY_SPLIT)
715+
{
716+
menuSplitOnOff(1);
717+
}
718+
else if (keyStatus == FKEY_TXOFF)
719+
{
720+
menuTxOnOff(1, 0x01);
721+
}
722+
else if (keyStatus == FKEY_SDRMODE)
723+
{
724+
menuSDROnOff(1);
725+
}
726+
else if (keyStatus == FKEY_RIT)
727+
{
728+
menuRitToggle(1);
729+
}
730+
*/
695731

696732
FrequencyToVFO(1);
697733
SetCarrierFreq();
@@ -927,7 +963,6 @@ void initSettings(){
927963
else
928964
keyerControl |= IAMBICB;
929965
}
930-
931966

932967
EEPROM.get(COMMON_OPTION0, commonOption0);
933968
EEPROM.get(DISPLAY_OPTION1, displayOption1);
@@ -939,8 +974,9 @@ void initSettings(){
939974

940975
//KeyValues
941976
for (byte i = 0; i < 16; i++) {
942-
KeyValues[i][0] = EEPROM.read(EXTENDED_KEY_RANGE + (i * 2));
943-
KeyValues[i][1] = EEPROM.read(EXTENDED_KEY_RANGE + (i * 2) + 1);
977+
KeyValues[i][0] = EEPROM.read(EXTENDED_KEY_RANGE + (i * 3)); //RANGE : Start Value
978+
KeyValues[i][1] = EEPROM.read(EXTENDED_KEY_RANGE + (i * 3) + 1); //RANGE : End Value
979+
KeyValues[i][2] = EEPROM.read(EXTENDED_KEY_RANGE + (i * 3) + 2); //KEY TYPE
944980
}
945981

946982
//User callsign information
@@ -1190,6 +1226,19 @@ void setup()
11901226
//while(1);
11911227
//end section of test
11921228
*/
1229+
1230+
//Load I2C LCD Address for I2C LCD
1231+
//I2C LCD Parametere
1232+
#ifdef USE_I2C_LCD
1233+
EEPROM.get(I2C_LCD_MASTER, I2C_LCD_MASTER_ADDRESS);
1234+
EEPROM.get(I2C_LCD_SECOND, I2C_LCD_SECOND_ADDRESS);
1235+
1236+
if (I2C_LCD_MASTER_ADDRESS < 0x10 || I2C_LCD_MASTER_ADDRESS > 0xF0)
1237+
I2C_LCD_MASTER_ADDRESS = I2C_LCD_MASTER_ADDRESS_DEFAULT;
1238+
1239+
if (I2C_LCD_SECOND_ADDRESS < 0x10 || I2C_LCD_SECOND_ADDRESS > 0xF0)
1240+
I2C_LCD_SECOND_ADDRESS = I2C_LCD_SECOND_ADDRESS_DEFAULT;
1241+
#endif
11931242

11941243
//Serial.begin(9600);
11951244
LCD_Init();

ubitx_20/ubitx_eemap.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,13 @@
5050
// 256 ~ 1023 (EEProm Section #1)
5151
// 255 ~ 101 (EEProm Section #2)
5252
//==============================================================================
53-
#define EXTENDED_KEY_RANGE 196 //Extended Key, KEY RANGE (MODE, BAND+, BAND-, TUNE_STEP, NUM0~NUM9, POINT, ENTER
53+
54+
//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
55+
#define EXTENDED_KEY_RANGE 140 //Extended Key => Set : Start Value, End Value, Key Type, 16 Set (3 * 16 = 48)
56+
57+
#define I2C_LCD_MASTER 190
58+
#define I2C_LCD_SECOND 191
59+
5460
#define S_METER_LEVELS 230 //LEVEL0 ~ LEVEL7
5561

5662
#define ADVANCED_FREQ_OPTION1 240 //Bit0: use IFTune_Value, Bit1 : use Stored enabled SDR Mode, Bit2 : dynamic sdr frequency

0 commit comments

Comments
 (0)