Skip to content

Commit

Permalink
Add Custom LPF Filter and Changed Version Number
Browse files Browse the repository at this point in the history
  • Loading branch information
phdlee committed Sep 7, 2018
1 parent e79dbdb commit 9ff8365
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 6 deletions.
9 changes: 6 additions & 3 deletions ubitx_20/ubitx.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,22 @@
//#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
#define I2C_LCD_SECOND_ADDRESS_DEFAULT 0x3F //0x27 //only using Dual LCD Mode

//Select betwen Analog S-Meter and DSP (I2C) Meter
#define USE_I2CSMETER
//#define USE_I2CSMETER

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

//Custom LPF Filter Mod
//#define USE_CUSTOM_LPF_FILTER //LPF FILTER MOD

//#define ENABLE_FACTORYALIGN
#define FACTORY_RECOVERY_BOOTUP //Whether to enter Factory Recovery mode by pressing FKey and turning on power
#define ENABLE_ADCMONITOR //Starting with Version 1.07, you can read ADC values directly from uBITX Manager. So this function is not necessary.
Expand Down
48 changes: 46 additions & 2 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.097")
#define FIRMWARE_VERSION_INFO F("+v1.100")
#define FIRMWARE_VERSION_NUM 0x04 //1st Complete Project : 1 (Version 1.061), 2st Project : 2, 1.08: 3, 1.09 : 4

/**
Expand Down Expand Up @@ -195,6 +195,13 @@ byte isIFShift = 0; //1 = ifShift, 2 extend
int ifShiftValue = 0; //

byte TriggerBySW = 0; //Action Start from Nextion LCD, Other MCU

//Use Custom Filter
//#define CUST_LPF_ENABLED 48
//#define CUST_LPF_START 49
char isCustomFilter = 0;
char isCustomFilter_A7 = 0;
char CustFilters[7][2];

/**
* Below are the basic functions that control the uBitx. Understanding the functions before
Expand Down Expand Up @@ -317,7 +324,24 @@ byte delay_background(unsigned delayTime, byte fromType){ //fromType : 4 autoCWK
*/

void setTXFilters(unsigned long freq){

#ifdef USE_CUSTOM_LPF_FILTER
freq = freq / 1000000UL;
for (byte i = 0; i < 7; i++) {
if (freq > CustFilters[i][0])
{
char aIn = CustFilters[i][1];
digitalWrite(TX_LPF_A, aIn & 0x01);
digitalWrite(TX_LPF_B, aIn & 0x02);
digitalWrite(TX_LPF_C, aIn & 0x04);

if (isCustomFilter_A7 == 1)
{
digitalWrite(A7, aIn & 0x08);
}
return;
}
} //end of for
#else
if (freq > 21000000L){ // the default filter is with 35 MHz cut-off
digitalWrite(TX_LPF_A, 0);
digitalWrite(TX_LPF_B, 0);
Expand All @@ -338,6 +362,8 @@ void setTXFilters(unsigned long freq){
digitalWrite(TX_LPF_B, 1);
digitalWrite(TX_LPF_C, 1);
}

#endif
}

/**
Expand Down Expand Up @@ -951,6 +977,24 @@ void initSettings(){
KeyValues[i][2] = EEPROM.read(EXTENDED_KEY_RANGE + (i * 3) + 2); //KEY TYPE
}

#ifdef USE_CUSTOM_LPF_FILTER
//Custom Filters
EEPROM.get(CUST_LPF_ENABLED, isCustomFilter);
if (isCustomFilter == 0x58)
{
isCustomFilter_A7 = 1;
}
isCustomFilter = (isCustomFilter == 0x58 || isCustomFilter == 0x57);

for (byte i = 0; i < 7; i++) {
CustFilters[i][0] = EEPROM.read(CUST_LPF_START + (i * 2)); //LPF (To) Mhz
CustFilters[i][1] = EEPROM.read(CUST_LPF_START + (i * 2) + 1); //Enabled I/O
}
//char isCustomFilter = 0;
//char isCustomFilter_A7 = 0;
//char CustFilters[2][7];
#endif

//User callsign information
if (EEPROM.read(USER_CALLSIGN_KEY) == 0x59)
userCallsignLength = EEPROM.read(USER_CALLSIGN_LEN); //MAXIMUM 18 LENGTH
Expand Down
14 changes: 14 additions & 0 deletions ubitx_20/ubitx_eemap.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,20 @@
//==============================================================================
#define RESERVE_FOR_FACTORY1 32

//==============================================================================
// custom LPF Filter
// 48 : Using Custom LPF Filter (48 = 0x57 or 0x58 => Using Custom LPF Filter, 0x58 = using A7 IO
// 49, 50 : LPF1 (49 : MHz (~ Mhz), 50 : Enabled PIN
// 51, 52 : LPF2
// 53, 54 : LPF3
// 55, 56 : LPF4
// 57, 58 : LPF5
// 59, 60 : LPF6
// 61, 62 : LPF7
//==============================================================================
#define CUST_LPF_ENABLED 48
#define CUST_LPF_START 49

//SI5351 I2C Address (Version 1.097)
#define I2C_ADDR_SI5351 63

Expand Down
2 changes: 1 addition & 1 deletion ubitx_20/ubitx_lcd_nextion.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ void SendUbitxData(void)
EEPROM.get(EXTERNAL_DEVICE_OPT1, nextionDisplayOption);
SendCommandUL(CMD_DISP_OPTION2, nextionDisplayOption);

SendCommandStr(CMD_VERSION, (char *)("+v1.097")); //Version
SendCommandStr(CMD_VERSION, (char *)("+v1.100")); //Version
SendEEPromData(CMD_CALLSIGN, 0, userCallsignLength -1, 0);

/*
Expand Down

0 comments on commit 9ff8365

Please sign in to comment.