Skip to content

Commit

Permalink
Added IF Tune, ATT, SDR Functions
Browse files Browse the repository at this point in the history
  • Loading branch information
phdlee committed Apr 6, 2018
1 parent d4ed058 commit 23f1b7c
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 35 deletions.
38 changes: 36 additions & 2 deletions ubitx_20/ubitx_20.ino
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,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
#define UBITX_DISPLAY_LCD1602I //I2C type 16 x 02 LCD
#define UBITX_DISPLAY_LCD1602P //LCD mounted on unmodified uBITX
//#define UBITX_DISPLAY_LCD1602I //I2C type 16 x 02 LCD
//#define UBITX_DISPLAY_LCD2404P //24 x 04 LCD
//#define UBITX_DISPLAY_LCD2404I //I2C type 24 x 04 LCD

//#define ENABLE_FACTORYALIGN


/**
Expand Down Expand Up @@ -326,6 +327,11 @@ unsigned char txFilter = 0; //which of the four transmit filters are in use
boolean modeCalibrate = false;//this mode of menus shows extended menus to calibrate the oscillators and choose the proper
//beat frequency

byte attLevel = 0; //ATT : RF Gain Control (Receive) <-- IF1 Shift, 0 : Off, ShiftValue is attLevel * 100; attLevel 150 = 15K
char if1TuneValue = 0; //0 : OFF, IF1 + if1TuneValue * 100; // + - 12500;
byte sdrModeOn = 0; //SDR MODE ON / OFF
unsigned long SDR_Center_Freq = 32000000;

unsigned long beforeIdle_ProcessTime = 0; //for check Idle time
byte line2DisplayStatus = 0; //0:Clear, 1 : menu, 1: DisplayFrom Idle,
char lcdMeter[17];
Expand Down Expand Up @@ -495,7 +501,32 @@ void setFrequency(unsigned long f){
setTXFilters(f);

unsigned long appliedCarrier = ((cwMode == 0 ? usbCarrier : cwmCarrier) + (isIFShift && (inTx == 0) ? ifShiftValue : 0));
long if1AdjustValue = ((inTx == 0) ? (attLevel * 200) : 0) + (if1TuneValue * 50); //if1Tune RX, TX Enabled, ATT : only RX Mode

if (sdrModeOn && (inTx == 0)) //IF SDR
{
si5351bx_setfreq(2, 44999500 + if1AdjustValue + f);
si5351bx_setfreq(1, 44999500 + if1AdjustValue + SDR_Center_Freq + 2390);
}
else
{
if (cwMode == 1 || (cwMode == 0 && (!isUSB)))
{
//CWL(cwMode == 1) or LSB (cwMode == 0 && (!isUSB))
si5351bx_setfreq(2, SECOND_OSC_LSB + if1AdjustValue + appliedCarrier + f);
//si5351bx_setfreq(1, SECOND_OSC_LSB + if1AdjustValue - (sdrModeOn ? (SDR_Center_Freq- usbCarrier) : 0));
si5351bx_setfreq(1, SECOND_OSC_LSB + if1AdjustValue);
}
else
{
//CWU (cwMode == 2) or LSB (cwMode == 0 and isUSB)
si5351bx_setfreq(2, SECOND_OSC_USB + if1AdjustValue - appliedCarrier + f);
//si5351bx_setfreq(1, SECOND_OSC_USB + if1AdjustValue + (sdrModeOn ? (SDR_Center_Freq- usbCarrier) : 0)); //Increase LO Frequency => 1198500 -> 32Mhz
si5351bx_setfreq(1, SECOND_OSC_USB + if1AdjustValue); //Increase LO Frequency => 1198500 -> 32Mhz
}
}

/*
if (cwMode == 0)
{
if (isUSB){
Expand All @@ -518,6 +549,7 @@ void setFrequency(unsigned long f){
si5351bx_setfreq(1, SECOND_OSC_USB);
}
}
*/

frequency = f;
}
Expand Down Expand Up @@ -1150,8 +1182,10 @@ void setup()
setFrequency(vfoA);
updateDisplay();

#ifdef ENABLE_FACTORYALIGN
if (btnDown())
factory_alignment();
#endif
}

//Auto save Frequency and Mode with Protected eeprom life by KD8CEC
Expand Down
129 changes: 97 additions & 32 deletions ubitx_20/ubitx_menu.ino
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,37 @@ void menuTxOnOff(int btn, byte optionType){
}
}

//Toggle SDR MODE
void menuSDROnOff(int btn)
{
if (!btn){
if (sdrModeOn == 0)
printLineF2(F("SDR Mode On?"));
else
printLineF2(F("SDR Mode Off?"));
}
else {
if (sdrModeOn == 1){
sdrModeOn = 0;
printLineF2(F("[OFF]"));
}
else {
sdrModeOn = 1;

if (ritOn == 1)
ritOn = 0;

if (splitOn == 1)
splitOn = 0;

printLineF2(F("[ON]"));
}

setFrequency(frequency);
menuClearExit(500);
}
}

void displayEmptyData(void){
printLineF2(F("Empty data"));
delay_background(2000, 0);
Expand Down Expand Up @@ -548,17 +579,18 @@ void menuSetupCWCarrier(int btn){
//valueType 0 : Normal
// 1 : CW Change -> Generate Tone
// 2 : IF Shift Setup -> SetFrequency, Set SideTone
// 3 : Select Mode (different display type)
// 5 : ATT
// 11 : Select Mode (different display type)
//knobSensitivity : 1 ~
int getValueByKnob(int valueType, int targetValue, int minKnobValue, int maxKnobValue, int incStep, char* displayTitle, int knobSensitivity)
int getValueByKnob(int valueType, int targetValue, int minKnobValue, int maxKnobValue, int incStep, const char* displayTitle, int knobSensitivity)
{
int knob;
int moveDetectStep = 0;
int negativeSensitivity;
char isInitDisplay = 1;
delay_background(300, 0); //Default Delay

if (valueType < 3)
if (valueType < 10)
{
strcpy(b, "Press, set ");
strcat(b, displayTitle);
Expand Down Expand Up @@ -597,7 +629,7 @@ int getValueByKnob(int valueType, int targetValue, int minKnobValue, int maxKnob

strcpy(b, displayTitle);

if (valueType == 3) //Mode Select
if (valueType == 11) //Mode Select
{
b[targetValue * 4] = '>';
}
Expand Down Expand Up @@ -625,9 +657,13 @@ int getValueByKnob(int valueType, int targetValue, int minKnobValue, int maxKnob
{
tone(CW_TONE, targetValue);
}
else if (valueType == 2)
else if (valueType == 2 || valueType == 5 ) // 2:IFS, 5:ATT
{
ifShiftValue = targetValue;
if (valueType == 2)
ifShiftValue = targetValue;
else
attLevel = targetValue;

setFrequency(frequency);
SetCarrierFreq();
}
Expand Down Expand Up @@ -912,6 +948,31 @@ void menuIFSSetup(int btn){
}
}

//ATT SETUP (IF1(45MHZ) SHIFT), by KD8CEC
void menuATTSetup(int btn){
int knob = 0;
char needApplyChangeValue = 1;

if (!btn){
if (isIFShift == 1)
printLineF2(F("ATT Change?"));
else
printLineF2(F("ATT On?"));
}
else
{
attLevel = getValueByKnob(5, attLevel, 0, 200, 5, "ATT", 2); //2 : (SetFrequency), targetValue, minKnobValue, maxKnobValue, stepSize
delay_background(500, 0); //for check Long Press function key

if (btnDown() || attLevel == 0)
{
attLevel = 0;
setFrequency(frequency);
//SetCarrierFreq();
}
menuClearExit(0);
}
}

//Functions for CWL and CWU by KD8CEC
void menuSelectMode(int btn){
Expand Down Expand Up @@ -939,7 +1000,7 @@ void menuSelectMode(int btn){

//delay_background(500, 0);

selectModeType = getValueByKnob(3, selectModeType, 0, 3, 1, " LSB USB CWL CWU", 4); //3 : Select Mode, targetValue, minKnobValue, maxKnobValue, stepSize
selectModeType = getValueByKnob(11, selectModeType, 0, 3, 1, " LSB USB CWL CWU", 4); //3 : Select Mode, targetValue, minKnobValue, maxKnobValue, stepSize

/*
while(!btnDown()){
Expand Down Expand Up @@ -1011,8 +1072,8 @@ void menuSetupKeyType(int btn){
//delay_background(500, 0);
selectedKeyType = cwKeyType;

//selectedKeyType = getValueByKnob(4, selectedKeyType, 0, 2, 1, " KEY:", 5); //4 : Select Key Type, targetValue, minKnobValue, maxKnobValue, stepSize
selectedKeyType = getValueByKnob(3, selectedKeyType, 0, 2, 1, " ST IA IB", 5); //4 : Select Key Type, targetValue, minKnobValue, maxKnobValue, stepSize
//selectedKeyType = getValueByKnob(12, selectedKeyType, 0, 2, 1, " KEY:", 5); //4 : Select Key Type, targetValue, minKnobValue, maxKnobValue, stepSize
selectedKeyType = getValueByKnob(11, selectedKeyType, 0, 2, 1, " ST IA IB", 5); //4 : Select Key Type, targetValue, minKnobValue, maxKnobValue, stepSize

/*
while(!btnDown()){
Expand Down Expand Up @@ -1170,14 +1231,13 @@ void doMenu(){
if (i > 0){
if (modeCalibrate && select + i < 240)
select += i;
if (!modeCalibrate && select + i < 130)
else if (!modeCalibrate && select + i < 150)
select += i;
}
else if (i < 0 && select - i >= -10)
select += i;

if (i < 0 && select - i >= -10)
select += i; //caught ya, i is already -ve here, so you add it

//if -> switch reduce program memory 200byte
//if -> switch : reduce program memory 200byte
switch (select / 10)
{
case 0 :
Expand All @@ -1196,60 +1256,65 @@ void doMenu(){
menuIFSSetup(btnState);
break;
case 5 :
menuCWSpeed(btnState);
menuATTSetup(btnState);
break;
case 6 :
menuSplitOnOff(btnState); //SplitOn / off
menuCWSpeed(btnState);
break;
case 7 :
menuCHMemory(btnState, 0); //VFO to Memroy
menuSplitOnOff(btnState); //SplitOn / off
break;
case 8 :
menuCHMemory(btnState, 1); //Memory to VFO
menuCHMemory(btnState, 0); //VFO to Memroy
break;
case 9 :
menuCWAutoKey(btnState);
menuCHMemory(btnState, 1); //Memory to VFO
break;
case 10 :
menuWSPRSend(btnState);
menuCWAutoKey(btnState);
break;
case 11 :
menuSetup(btnState);
menuWSPRSend(btnState);
break;
case 12 :
menuExit(btnState);
menuSDROnOff(btnState);
break;
case 13 :
menuSetupCalibration(btnState); //crystal
menuSetup(btnState);
break;
case 14 :
menuSetupCarrier(btnState); //lsb
menuExit(btnState);
break;
case 15 :
menuSetupCWCarrier(btnState); //lsb
menuSetupCalibration(btnState); //crystal
break;
case 16 :
menuSetupCwTone(btnState);
menuSetupCarrier(btnState); //ssb
break;
case 17 :
menuSetupCwDelay(btnState);
menuSetupCWCarrier(btnState); //cw
break;
case 18 :
menuSetupCwTone(btnState);
break;
case 19 :
menuSetupCwDelay(btnState);
break;
case 20 :
menuSetupTXCWInterval(btnState);
break;
case 19 :
case 21 :
menuSetupKeyType(btnState);
break;
case 20 :
case 22 :
menuADCMonitor(btnState);
break;
case 21 :
case 23 :
menuTxOnOff(btnState, 0x01); //TX OFF / ON
break;
default :
menuExit(btnState); break;
}

}
Check_Cat(0); //To prevent disconnections
}
}
Expand Down
2 changes: 1 addition & 1 deletion ubitx_20/ubitx_si5351.ino
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void si5351_set_calibration(int32_t cal){
void SetCarrierFreq()
{
unsigned long appliedCarrier = ((cwMode == 0 ? usbCarrier : cwmCarrier) + (isIFShift && (inTx == 0) ? ifShiftValue : 0));
si5351bx_setfreq(0, appliedCarrier);
si5351bx_setfreq(0, (sdrModeOn ? 0 : appliedCarrier));

/*
if (cwMode == 0)
Expand Down

0 comments on commit 23f1b7c

Please sign in to comment.