Skip to content

Commit

Permalink
Merge pull request #31 from phdlee/version1.073
Browse files Browse the repository at this point in the history
Version1.073
  • Loading branch information
phdlee authored Apr 24, 2018
2 parents 3b4bdaf + 6add092 commit 5c40718
Show file tree
Hide file tree
Showing 11 changed files with 996 additions and 111 deletions.
14 changes: 13 additions & 1 deletion ubitx_20/cat_libs.ino
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,19 @@ void WriteEEPRom(void) //for remove warning
}
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(ACK);
}
Expand Down
59 changes: 48 additions & 11 deletions ubitx_20/ubitx.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,34 @@
//==============================================================================
//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
#define UBITX_DISPLAY_LCD1602P //LCD mounted on unmodified uBITX
//#define UBITX_DISPLAY_LCD1602I //I2C type 16 x 02 LCD
#define UBITX_DISPLAY_LCD2004P //24 x 04 LCD (Parallel)
//#define UBITX_DISPLAY_LCD1602I_DUAL
//#define UBITX_DISPLAY_LCD2004P //24 x 04 LCD (Parallel)
//#define UBITX_DISPLAY_LCD2004I //I2C type 24 x 04 LCD

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

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

#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_SECOND_ADDRESS; //only using Dual LCD Mode

#define SMeterLatency 3 //1 is 0.25 sec

#ifdef UBITX_DISPLAY_LCD1602I
#define USE_I2C_LCD
#elif defined(UBITX_DISPLAY_LCD1602I_DUAL)
#define USE_I2C_LCD
#elif defined(UBITX_DISPLAY_LCD2004I)
#define USE_I2C_LCD
#endif

//==============================================================================
// Hardware, Define PIN Usage
//==============================================================================
Expand Down Expand Up @@ -99,17 +112,41 @@
#define printLineF1(x) (printLineF(1, 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 FKEY_PRESS 120
#define FKEY_MODE 0
#define FKEY_BANDUP 1
#define FKEY_BANDDOWN 2
#define FKEY_STEP 3
#define FKEY_PRESS 0x78
#define FKEY_MODE 0x01
#define FKEY_BANDUP 0x02
#define FKEY_BANDDOWN 0x03
#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 byte WsprMSGCount;
extern byte sMeterLevels[9];
extern int 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 printLine2(const char *c);
Expand Down
167 changes: 108 additions & 59 deletions ubitx_20/ubitx_20.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// So I put + in the sense that it was improved one by one based on Original Firmware.
// This firmware has been gradually changed based on the original firmware created by Farhan, Jack, Jerry and others.

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

/**
Expand Down Expand Up @@ -182,30 +182,10 @@ byte line2DisplayStatus = 0; //0:Clear, 1 : menu, 1: DisplayFrom Idle,
char lcdMeter[17];
byte sMeterLevels[9];

int 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 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 KeyValues[16][3];

byte isIFShift = 0; //1 = ifShift, 2 extend
int ifShiftValue = 0; //
Expand Down Expand Up @@ -422,7 +402,7 @@ void setFrequency(unsigned long f){
// Offset Frequency : 30Mhz and current Frequncy is 14.074 => 34.074Mhz
moveFrequency = (f % 10000000);
}
else if (sdrOption == 3) //Khzz move
else if (sdrOption == 3) //Khz move
{
//Offset Frequency + Khz,
//Example : Offset Frequency : 30Mhz and current Frequncy is 7.080 => 30.080Mhz
Expand Down Expand Up @@ -454,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;
}

Expand Down Expand Up @@ -630,6 +585,8 @@ void checkPTT(){
}
#ifdef EXTEND_KEY_GROUP1
void checkButton(){
char currentBandIndex = -1;

//only if the button is pressed
int keyStatus = getBtnStatus();
if (keyStatus == -1)
Expand All @@ -642,8 +599,69 @@ void checkButton(){

if (keyStatus == FKEY_PRESS) //Menu Key
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 (cwMode == 1)
Expand All @@ -664,10 +682,6 @@ void checkButton(){
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
{
Expand All @@ -692,6 +706,28 @@ void checkButton(){
EEPROM.put(TUNING_STEP, tuneStepIndex);
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);
SetCarrierFreq();
Expand Down Expand Up @@ -927,7 +963,6 @@ void initSettings(){
else
keyerControl |= IAMBICB;
}


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

//KeyValues
for (byte i = 0; i < 16; i++) {
KeyValues[i][0] = EEPROM.read(EXTENDED_KEY_RANGE + (i * 2));
KeyValues[i][1] = EEPROM.read(EXTENDED_KEY_RANGE + (i * 2) + 1);
KeyValues[i][0] = EEPROM.read(EXTENDED_KEY_RANGE + (i * 3)); //RANGE : Start Value
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
Expand Down Expand Up @@ -1190,6 +1226,19 @@ void setup()
//while(1);
//end section of test
*/

//Load I2C LCD Address for I2C LCD
//I2C LCD Parametere
#ifdef USE_I2C_LCD
EEPROM.get(I2C_LCD_MASTER, I2C_LCD_MASTER_ADDRESS);
EEPROM.get(I2C_LCD_SECOND, I2C_LCD_SECOND_ADDRESS);

if (I2C_LCD_MASTER_ADDRESS < 0x10 || I2C_LCD_MASTER_ADDRESS > 0xF0)
I2C_LCD_MASTER_ADDRESS = I2C_LCD_MASTER_ADDRESS_DEFAULT;

if (I2C_LCD_SECOND_ADDRESS < 0x10 || I2C_LCD_SECOND_ADDRESS > 0xF0)
I2C_LCD_SECOND_ADDRESS = I2C_LCD_SECOND_ADDRESS_DEFAULT;
#endif

//Serial.begin(9600);
LCD_Init();
Expand Down
8 changes: 7 additions & 1 deletion ubitx_20/ubitx_eemap.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@
// 256 ~ 1023 (EEProm Section #1)
// 255 ~ 101 (EEProm Section #2)
//==============================================================================
#define EXTENDED_KEY_RANGE 196 //Extended Key, KEY RANGE (MODE, BAND+, BAND-, TUNE_STEP, NUM0~NUM9, POINT, ENTER

//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_SECOND 191

#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
Expand Down
Loading

0 comments on commit 5c40718

Please sign in to comment.