Add Support SDR Receiver and improve ATT
This commit is contained in:
parent
23f1b7cd5c
commit
689cfda09e
@ -611,6 +611,34 @@ void WriteEEPRom_FT817(byte fromType)
|
||||
Serial.write(ACK);
|
||||
}
|
||||
|
||||
const byte anlogPinIndex[6] = {A0, A1, A2, A3, A6, A7};
|
||||
|
||||
//Read ADC Value by uBITX Manager Software
|
||||
void ReadADCValue(void)
|
||||
{
|
||||
//ADC MAP for uBITX
|
||||
int readedADCValue;
|
||||
//5BYTES
|
||||
//CAT_BUFF[0] [1] [2] [3] [4] //4 COMMAND
|
||||
//0 READ ADDRESS
|
||||
readedADCValue = analogRead(anlogPinIndex[CAT_BUFF[0]]);
|
||||
CAT_BUFF[0] = readedADCValue >> 8;
|
||||
CAT_BUFF[1] = readedADCValue;
|
||||
SendCatData(2);
|
||||
Serial.write(ACK);
|
||||
}
|
||||
|
||||
void SetIFSValue(void)
|
||||
{
|
||||
//Set IFShift Value
|
||||
isIFShift = CAT_BUFF[0];
|
||||
ifShiftValue = CAT_BUFF[1] + CAT_BUFF[2] * 256;
|
||||
setFrequency(frequency);
|
||||
SetCarrierFreq();
|
||||
updateLine2Buffer(1); //option, perhap not need
|
||||
Serial.write(ACK);
|
||||
}
|
||||
|
||||
//void CatRxStatus(byte fromType)
|
||||
void CatRxStatus(void) //for remove warning
|
||||
{
|
||||
@ -768,6 +796,14 @@ void Check_Cat(byte fromType)
|
||||
WriteEEPRom_FT817(fromType);
|
||||
break;
|
||||
|
||||
case 0xDD: //Read uBITX ADC Data
|
||||
ReadADCValue(); //Call by uBITX Manager Program
|
||||
break;
|
||||
|
||||
case 0xDE: //IF-Shift Control by CAT
|
||||
SetIFSValue(); //
|
||||
break;
|
||||
|
||||
case 0xE7 : //Read RX Status
|
||||
CatRxStatus();
|
||||
break;
|
||||
|
@ -10,7 +10,9 @@
|
||||
//#define UBITX_DISPLAY_LCD2404P //24 x 04 LCD
|
||||
//#define UBITX_DISPLAY_LCD2404I //I2C type 24 x 04 LCD
|
||||
|
||||
//#define ENABLE_FACTORYALIGN
|
||||
//Compile Option
|
||||
#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.
|
||||
|
||||
|
||||
/**
|
||||
@ -145,7 +147,12 @@ int count = 0; //to generally count ticks, loops, etc
|
||||
#define CW_SIDETONE 24
|
||||
#define CW_SPEED 28
|
||||
|
||||
//AT328 has 1KBytes EEPROM
|
||||
//KD8CEC EEPROM MAP
|
||||
#define ADVANCED_FREQ_OPTION1 240 //Bit0: use IFTune_Value, Bit1 : use Stored enabled SDR Mode, Bit2 : dynamic sdr frequency
|
||||
#define IF1_CAL 241
|
||||
#define ENABLE_SDR 242
|
||||
#define SDR_FREQUNCY 243
|
||||
|
||||
#define CW_CAL 252
|
||||
#define VFO_A_MODE 256
|
||||
#define VFO_B_MODE 257
|
||||
@ -327,10 +334,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 advancedFreqOption1; //255 : Bit0: use IFTune_Value, Bit1 : use Stored enabled SDR Mode, Bit2 : dynamic sdr 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 SDR_Center_Freq; //DEFAULT Frequency : 32000000
|
||||
|
||||
unsigned long beforeIdle_ProcessTime = 0; //for check Idle time
|
||||
byte line2DisplayStatus = 0; //0:Clear, 1 : menu, 1: DisplayFrom Idle,
|
||||
@ -501,12 +509,30 @@ 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
|
||||
long if1AdjustValue = ((inTx == 0) ? (attLevel * 100) : 0) + (if1TuneValue * 100); //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);
|
||||
//Fixed Frequency SDR (Default Frequency : 32Mhz, available change sdr Frequency by uBITX Manager)
|
||||
//Dynamic Frequency is for SWL without cat
|
||||
//Offset Frequency + Mhz,
|
||||
//Example : Offset Frequency : 30Mhz and current Frequncy is 7.080 => 37.080Mhz
|
||||
// Offset Frequency : 30Mhz and current Frequncy is 14.074 => 34.074Mhz
|
||||
|
||||
//Dynamic Frequency
|
||||
//if (advancedFreqOption1 & 0x04 != 0x00)
|
||||
// if1AdjustValue += (f % 10000000);
|
||||
|
||||
si5351bx_setfreq(2, 44991500 + if1AdjustValue + f);
|
||||
si5351bx_setfreq(1, 44991500
|
||||
+ if1AdjustValue
|
||||
+ SDR_Center_Freq
|
||||
+ ((advancedFreqOption1 & 0x04) == 0x00 ? 0 : (f % 10000000))
|
||||
+ 2390);
|
||||
/*
|
||||
si5351bx_setfreq(2, 44999500 + f);
|
||||
si5351bx_setfreq(1, 44999500 + SDR_Center_Freq + 2390);
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -880,7 +906,7 @@ void initSettings(){
|
||||
|
||||
printLineF(1, F("Init EEProm..."));
|
||||
//initial all eeprom
|
||||
for (unsigned int i = 32; i < 1024; i++) //protect Master_cal, usb_cal
|
||||
for (unsigned int i = 64; i < 1024; i++) //protect Master_cal, usb_cal
|
||||
EEPROM.write(i, 0);
|
||||
|
||||
//Write Firmware ID
|
||||
@ -1033,6 +1059,25 @@ void initSettings(){
|
||||
isIFShift = ifShiftValue != 0;
|
||||
}
|
||||
|
||||
//Advanced Freq control
|
||||
EEPROM.get(ADVANCED_FREQ_OPTION1, advancedFreqOption1);
|
||||
|
||||
//use Advanced Frequency Control
|
||||
if (advancedFreqOption1 & 0x01 != 0x00)
|
||||
{
|
||||
EEPROM.get(IF1_CAL, if1TuneValue);
|
||||
|
||||
//Stored Enabled SDR Mode
|
||||
if (advancedFreqOption1 & 0x02 != 0x00)
|
||||
{
|
||||
EEPROM.get(ENABLE_SDR, sdrModeOn);
|
||||
}
|
||||
}
|
||||
|
||||
EEPROM.get(SDR_FREQUNCY, SDR_Center_Freq);
|
||||
if (SDR_Center_Freq == 0)
|
||||
SDR_Center_Freq = 32000000;
|
||||
|
||||
//default Value (for original hardware)
|
||||
if (cwAdcSTFrom >= cwAdcSTTo)
|
||||
{
|
||||
|
@ -290,6 +290,7 @@ void menuCHMemory(int btn, byte isMemoryToVfo){
|
||||
|
||||
//Analog pin monitoring with CW Key and function keys connected.
|
||||
//by KD8CEC
|
||||
#ifdef ENABLE_ADCMONITOR
|
||||
void menuADCMonitor(int btn){
|
||||
int adcPinA0 = 0; //A0(BLACK, EncoderA)
|
||||
int adcPinA1 = 0; //A1(BROWN, EncoderB)
|
||||
@ -359,6 +360,7 @@ void menuADCMonitor(int btn){
|
||||
|
||||
menuClearExit(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
//VFO Toggle and save VFO Information, modified by KD8CEC
|
||||
void menuVfoToggle(int btn)
|
||||
@ -467,6 +469,7 @@ void menuSDROnOff(int btn)
|
||||
printLineF2(F("[ON]"));
|
||||
}
|
||||
|
||||
EEPROM.put(ENABLE_SDR, sdrModeOn);
|
||||
setFrequency(frequency);
|
||||
menuClearExit(500);
|
||||
}
|
||||
@ -954,14 +957,14 @@ void menuATTSetup(int btn){
|
||||
char needApplyChangeValue = 1;
|
||||
|
||||
if (!btn){
|
||||
if (isIFShift == 1)
|
||||
if (attLevel != 0)
|
||||
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
|
||||
attLevel = getValueByKnob(5, attLevel, 0, 250, 5, "ATT", 2); //2 : (SetFrequency), targetValue, minKnobValue, maxKnobValue, stepSize
|
||||
delay_background(500, 0); //for check Long Press function key
|
||||
|
||||
if (btnDown() || attLevel == 0)
|
||||
@ -1229,7 +1232,7 @@ void doMenu(){
|
||||
btnState = btnDown();
|
||||
|
||||
if (i > 0){
|
||||
if (modeCalibrate && select + i < 240)
|
||||
if (modeCalibrate && select + i < 250)
|
||||
select += i;
|
||||
else if (!modeCalibrate && select + i < 150)
|
||||
select += i;
|
||||
@ -1306,10 +1309,14 @@ void doMenu(){
|
||||
case 21 :
|
||||
menuSetupKeyType(btnState);
|
||||
break;
|
||||
#ifdef ENABLE_ADCMONITOR
|
||||
case 22 :
|
||||
menuADCMonitor(btnState);
|
||||
break;
|
||||
case 23 :
|
||||
#else
|
||||
case 22 :
|
||||
#endif
|
||||
menuTxOnOff(btnState, 0x01); //TX OFF / ON
|
||||
break;
|
||||
default :
|
||||
|
Loading…
Reference in New Issue
Block a user