SSB, BYP, RAW demodulation modes added #64
This commit is contained in:
19
app/app.c
19
app/app.c
@@ -71,7 +71,7 @@ static void UpdateRSSI(const int vfo)
|
||||
|
||||
#ifdef ENABLE_AM_FIX
|
||||
// add RF gain adjust compensation
|
||||
if (gEeprom.VfoInfo[vfo].AM_mode && gSetting_AM_fix)
|
||||
if (gEeprom.VfoInfo[vfo].Modulation != MODULATION_FM && gSetting_AM_fix)
|
||||
rssi -= rssi_gain_diff[vfo];
|
||||
#endif
|
||||
|
||||
@@ -526,7 +526,7 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
|
||||
const uint8_t orig_pga = 6; // -3dB
|
||||
|
||||
#ifdef ENABLE_AM_FIX
|
||||
if (gRxVfo->AM_mode && gSetting_AM_fix) { // AM RX mode
|
||||
if (gRxVfo->Modulation != MODULATION_FM && gSetting_AM_fix) { // AM RX mode
|
||||
if (reset_am_fix)
|
||||
AM_fix_reset(chan); // TODO: only reset it when moving channel/frequency
|
||||
AM_fix_10ms(chan);
|
||||
@@ -540,10 +540,11 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
|
||||
}
|
||||
|
||||
// AF gain - original QS values
|
||||
if (gRxVfo->AM_mode){
|
||||
BK4819_WriteRegister(BK4819_REG_48, 0xB3A8);
|
||||
}
|
||||
else {
|
||||
// if (gRxVfo->Modulation != MODULATION_FM){
|
||||
// BK4819_WriteRegister(BK4819_REG_48, 0xB3A8);
|
||||
// }
|
||||
// else
|
||||
{
|
||||
BK4819_WriteRegister(BK4819_REG_48,
|
||||
(11u << 12) | // ??? .. 0 to 15, doesn't seem to make any difference
|
||||
( 0u << 10) | // AF Rx Gain-1
|
||||
@@ -554,7 +555,7 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
|
||||
#ifdef ENABLE_VOICE
|
||||
if (gVoiceWriteIndex == 0) // AM/FM RX mode will be set when the voice has finished
|
||||
#endif
|
||||
BK4819_SetAF(gRxVfo->AM_mode ? BK4819_AF_AM : BK4819_AF_FM); // no need, set it now
|
||||
RADIO_SetModulation(gRxVfo->Modulation); // no need, set it now
|
||||
|
||||
FUNCTION_Select(Function);
|
||||
|
||||
@@ -1209,8 +1210,8 @@ void APP_TimeSlice10ms(void)
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_AM_FIX
|
||||
// if (gEeprom.VfoInfo[gEeprom.RX_VFO].AM_mode && gSetting_AM_fix)
|
||||
if (gRxVfo->AM_mode && gSetting_AM_fix)
|
||||
// if (gEeprom.VfoInfo[gEeprom.RX_VFO].Modulation != MODULATION_FM && gSetting_AM_fix)
|
||||
if (gRxVfo->Modulation != MODULATION_FM && gSetting_AM_fix)
|
||||
AM_fix_10ms(gEeprom.RX_VFO);
|
||||
#endif
|
||||
|
||||
|
14
app/menu.c
14
app/menu.c
@@ -232,7 +232,6 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax)
|
||||
case MENU_D_ST:
|
||||
case MENU_D_DCD:
|
||||
case MENU_D_LIVE_DEC:
|
||||
case MENU_AM:
|
||||
#ifdef ENABLE_NOAA
|
||||
case MENU_NOAA_S:
|
||||
#endif
|
||||
@@ -246,6 +245,11 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax)
|
||||
*pMax = ARRAY_SIZE(gSubMenu_OFF_ON) - 1;
|
||||
break;
|
||||
|
||||
case MENU_AM:
|
||||
*pMin = 0;
|
||||
*pMax = ARRAY_SIZE(gModulationStr) - 1;
|
||||
break;
|
||||
|
||||
case MENU_SCR:
|
||||
*pMin = 0;
|
||||
*pMax = ARRAY_SIZE(gSubMenu_SCRAMBLER) - 1;
|
||||
@@ -702,7 +706,7 @@ void MENU_AcceptSetting(void)
|
||||
break;
|
||||
|
||||
case MENU_AM:
|
||||
gTxVfo->AM_mode = gSubMenuSelection;
|
||||
gTxVfo->Modulation = gSubMenuSelection;
|
||||
gRequestSaveChannel = 1;
|
||||
return;
|
||||
|
||||
@@ -1112,7 +1116,7 @@ void MENU_ShowCurrentSetting(void)
|
||||
break;
|
||||
|
||||
case MENU_AM:
|
||||
gSubMenuSelection = gTxVfo->AM_mode;
|
||||
gSubMenuSelection = gTxVfo->Modulation;
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_AM_FIX
|
||||
@@ -1603,9 +1607,9 @@ static void MENU_Key_STAR(const bool bKeyPressed, const bool bKeyHeld)
|
||||
RADIO_SelectVfos();
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
if (!IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && gRxVfo->AM_mode == 0)
|
||||
if (!IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && gRxVfo->Modulation == MODULATION_FM)
|
||||
#else
|
||||
if (gRxVfo->AM_mode == 0)
|
||||
if (gRxVfo->Modulation == MODULATION_FM)
|
||||
#endif
|
||||
{
|
||||
if (GetCurrentMenuId() == MENU_R_CTCS || GetCurrentMenuId() == MENU_R_DCS)
|
||||
|
@@ -49,7 +49,6 @@ ScanInfo scanInfo;
|
||||
KeyboardState kbd = {KEY_INVALID, KEY_INVALID, 0};
|
||||
|
||||
const char *bwOptions[] = {" 25k", "12.5k", "6.25k"};
|
||||
const char *modulationTypeOptions[] = {" FM", " AM", "USB"};
|
||||
const uint8_t modulationTypeTuneSteps[] = {100, 50, 10};
|
||||
const uint8_t modTypeReg47Values[] = {1, 7, 5};
|
||||
|
||||
@@ -103,7 +102,7 @@ static int Rssi2DBm(uint16_t rssi) { return (rssi >> 1) - 160; }
|
||||
|
||||
static uint16_t GetRegMenuValue(uint8_t st) {
|
||||
RegisterSpec s = registerSpecs[st];
|
||||
return (BK4819_ReadRegister(s.num) >> s.offset) & s.maxValue;
|
||||
return (BK4819_ReadRegister(s.num) >> s.offset) & s.mask;
|
||||
}
|
||||
|
||||
static void SetRegMenuValue(uint8_t st, bool add) {
|
||||
@@ -111,14 +110,14 @@ static void SetRegMenuValue(uint8_t st, bool add) {
|
||||
RegisterSpec s = registerSpecs[st];
|
||||
|
||||
uint16_t reg = BK4819_ReadRegister(s.num);
|
||||
if (add && v <= s.maxValue - s.inc) {
|
||||
if (add && v <= s.mask - s.inc) {
|
||||
v += s.inc;
|
||||
} else if (!add && v >= 0 + s.inc) {
|
||||
v -= s.inc;
|
||||
}
|
||||
// TODO: use max value for bits count in max value, or reset by additional
|
||||
// mask in spec
|
||||
reg &= ~(s.maxValue << s.offset);
|
||||
reg &= ~(s.mask << s.offset);
|
||||
BK4819_WriteRegister(s.num, reg | (v << s.offset));
|
||||
redrawScreen = true;
|
||||
}
|
||||
@@ -225,18 +224,6 @@ static void RestoreRegisters() {
|
||||
BK4819_WriteRegister(BK4819_REG_7E, R7E);
|
||||
}
|
||||
|
||||
static void SetModulation(ModulationType type) {
|
||||
RestoreRegisters();
|
||||
uint16_t reg = BK4819_ReadRegister(BK4819_REG_47);
|
||||
reg &= ~(0b111 << 8);
|
||||
BK4819_WriteRegister(BK4819_REG_47, reg | (modTypeReg47Values[type] << 8));
|
||||
if (type == MOD_USB) {
|
||||
BK4819_WriteRegister(BK4819_REG_3D, 0b0010101101000101);
|
||||
BK4819_WriteRegister(BK4819_REG_37, 0x160F);
|
||||
BK4819_WriteRegister(BK4819_REG_48, 0b0000001110101000);
|
||||
}
|
||||
}
|
||||
|
||||
static void ToggleAFDAC(bool on) {
|
||||
uint32_t Reg = BK4819_ReadRegister(BK4819_REG_30);
|
||||
Reg &= ~(1 << 9);
|
||||
@@ -489,12 +476,12 @@ static void UpdateFreqChangeStep(bool inc) {
|
||||
}
|
||||
|
||||
static void ToggleModulation() {
|
||||
if (settings.modulationType < MOD_USB) {
|
||||
if (settings.modulationType < MODULATION_UKNOWN - 1) {
|
||||
settings.modulationType++;
|
||||
} else {
|
||||
settings.modulationType = MOD_FM;
|
||||
settings.modulationType = MODULATION_FM;
|
||||
}
|
||||
SetModulation(settings.modulationType);
|
||||
RADIO_SetModulation(settings.modulationType);
|
||||
redrawScreen = true;
|
||||
}
|
||||
|
||||
@@ -669,7 +656,7 @@ static void DrawF(uint32_t f) {
|
||||
sprintf(String, "%u.%05u", f / 100000, f % 100000);
|
||||
UI_PrintStringSmall(String, 8, 127, 0);
|
||||
|
||||
sprintf(String, "%s", modulationTypeOptions[settings.modulationType]);
|
||||
sprintf(String, "%3s", gModulationStr[settings.modulationType]);
|
||||
GUI_DisplaySmallest(String, 116, 1, false, true);
|
||||
sprintf(String, "%s", bwOptions[settings.listenBw]);
|
||||
GUI_DisplaySmallest(String, 108, 7, false, true);
|
||||
@@ -1175,7 +1162,7 @@ void APP_RunSpectrum() {
|
||||
newScanStart = true;
|
||||
|
||||
ToggleRX(true), ToggleRX(false); // hack to prevent noise when squelch off
|
||||
SetModulation(settings.modulationType = MOD_FM);
|
||||
RADIO_SetModulation(settings.modulationType = MODULATION_FM);
|
||||
BK4819_SetFilterBandwidth(settings.listenBw = BK4819_FILTER_BW_WIDE, false);
|
||||
|
||||
RelaunchScan();
|
||||
|
@@ -99,12 +99,6 @@ typedef enum StepsCount {
|
||||
STEPS_16,
|
||||
} StepsCount;
|
||||
|
||||
typedef enum ModulationType {
|
||||
MOD_FM,
|
||||
MOD_AM,
|
||||
MOD_USB,
|
||||
} ModulationType;
|
||||
|
||||
typedef enum ScanStep {
|
||||
S_STEP_0_01kHz,
|
||||
S_STEP_0_1kHz,
|
||||
@@ -131,7 +125,7 @@ typedef struct SpectrumSettings {
|
||||
BK4819_FilterBandwidth_t listenBw;
|
||||
int dbMin;
|
||||
int dbMax;
|
||||
ModulationType modulationType;
|
||||
ModulationMode_t modulationType;
|
||||
bool backlightState;
|
||||
} SpectrumSettings;
|
||||
|
||||
@@ -149,14 +143,6 @@ typedef struct ScanInfo {
|
||||
uint8_t measurementsCount;
|
||||
} ScanInfo;
|
||||
|
||||
typedef struct RegisterSpec {
|
||||
char *name;
|
||||
uint8_t num;
|
||||
uint8_t offset;
|
||||
uint16_t maxValue;
|
||||
uint16_t inc;
|
||||
} RegisterSpec;
|
||||
|
||||
typedef struct PeakInfo {
|
||||
uint16_t t;
|
||||
uint16_t rssi;
|
||||
|
Reference in New Issue
Block a user