Skip to content

Commit

Permalink
Merge branch 'fagci:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
RE3CON committed Oct 29, 2023
2 parents 163da48 + c8ae8a5 commit 031f2f0
Show file tree
Hide file tree
Showing 12 changed files with 137 additions and 104 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ TARGET = firmware

ENABLE_AIRCOPY := 0
ENABLE_AM_FIX := 1
ENABLE_FMRADIO := 0
ENABLE_FMRADIO := 1
ENABLE_OVERLAY := 0
ENABLE_SPECTRUM := 1
ENABLE_SWD := 1
ENABLE_TX1750 := 1
ENABLE_UART := 1
ENABLE_NOSCANTIMEOUT := 1
ENABLE_KEEPNAMEONSAVE := 1
ENABLE_ALL_REGISTERS := 1
ENABLE_ALL_REGISTERS := 0
ENABLE_FASTER_CHANNEL_SCAN := 1
ENABLE_UART_CAT := 1

Expand Down
6 changes: 3 additions & 3 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,12 +361,12 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool resetAmFix) {
AM_fix_10ms(chan);

} else { // FM RX mode
BK4819_SetAGC(1); // normalize gain
BK4819_SetAGC(0); // normalize gain
/* BK4819_WriteRegister(BK4819_REG_13, (lnaShort << 8) | (lna << 5) |
(mixer << 3) | (pga << 0)); */
}
#else
BK4819_SetAGC(1); // normalize gain
BK4819_SetAGC(0); // normalize gain
/* BK4819_WriteRegister(BK4819_REG_13, (lnaShort << 8) | (lna << 5) |
(mixer << 3) | (pga << 0)); */
#endif
Expand Down Expand Up @@ -431,7 +431,7 @@ void APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t Step) {
pInfo->ConfigRX.Frequency = Frequency;
}

BK4819_TuneTo(Frequency);
BK4819_TuneTo(Frequency, false);
}

static void FREQ_NextChannel(void) {
Expand Down
10 changes: 8 additions & 2 deletions app/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ int MENU_GetLimits(uint8_t Cursor, uint8_t *pMin, uint8_t *pMax) {
*pMin = 0;
*pMax = 50;
break;
case MENU_W_N:
case MENU_BCL:
case MENU_BEEP:
case MENU_AUTOLK:
Expand All @@ -106,7 +105,6 @@ int MENU_GetLimits(uint8_t Cursor, uint8_t *pMin, uint8_t *pMax) {
case MENU_STE:
case MENU_D_ST:
case MENU_D_DCD:
case MENU_AM:
case MENU_RESET:
case MENU_350TX:
case MENU_200TX:
Expand All @@ -115,6 +113,14 @@ int MENU_GetLimits(uint8_t Cursor, uint8_t *pMin, uint8_t *pMax) {
*pMin = 0;
*pMax = 1;
break;
case MENU_W_N:
*pMin = 0;
*pMax = ARRAY_SIZE(bwNames) - 1;
break;
case MENU_AM:
*pMin = 0;
*pMax = ARRAY_SIZE(modulationTypeOptions) - 1;
break;
case MENU_SCR:
case MENU_VOX:
case MENU_TOT:
Expand Down
34 changes: 19 additions & 15 deletions app/spectrum.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,10 @@ static void RestoreRegisters() {
}
}

static void SetF(uint32_t f) { BK4819_TuneTo(fMeasure = f); }
static void SetTxF(uint32_t f) { BK4819_TuneTo(fTx = f); }
static void SetF(uint32_t f, bool precise) {
BK4819_TuneTo(fMeasure = f, precise);
}
static void SetTxF(uint32_t f) { BK4819_TuneTo(fTx = f, true); }

// Spectrum related

Expand Down Expand Up @@ -225,7 +227,7 @@ static void TuneToPeak() {
scanInfo.f = peak.f;
scanInfo.rssi = peak.rssi;
scanInfo.i = peak.i;
SetF(scanInfo.f);
SetF(scanInfo.f, true);
}

uint16_t GetBWRegValueForScan() { return 0b0000000110111100; }
Expand Down Expand Up @@ -345,7 +347,7 @@ static void ToggleTX(bool on) {
RegRestore(BK4819_REG_7E);
RegRestore(BK4819_REG_47);

SetF(fMeasure);
SetF(fMeasure, true);
}
BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2, !on);
BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1, on);
Expand Down Expand Up @@ -417,10 +419,12 @@ static void UpdatePeakInfo() {

static void Measure() {
// rm harmonics using blacklist for now
/* if (scanInfo.f % 1300000 == 0) {
#ifndef ENABLE_ALL_REGISTERS
if (scanInfo.f % 1300000 == 0) {
blacklist[scanInfo.i] = true;
return;
} */
}
#endif
rssiHistory[scanInfo.i] = scanInfo.rssi = GetRssi();
}

Expand Down Expand Up @@ -506,7 +510,7 @@ static void UpdateCurrentFreqStill(bool inc) {
} else if (!inc && f > F_MIN) {
f -= offset;
}
SetF(f);
SetF(f, false);
SYSTEM_DelayMs(10);
redrawScreen = true;
}
Expand Down Expand Up @@ -640,9 +644,9 @@ static void DrawStatus() {
}

static void DrawF(uint32_t f) {
UI_PrintStringSmallest(modulationTypeOptions[settings.modulationType], 116, 1,
UI_PrintStringSmallest(modulationTypeOptions[settings.modulationType], 116, 2,
false, true);
UI_PrintStringSmallest(bwOptions[settings.listenBw], 108, 7, false, true);
UI_PrintStringSmallest(bwOptions[settings.listenBw], 108, 8, false, true);

if (currentState == SPECTRUM && !f) {
return;
Expand All @@ -653,7 +657,7 @@ static void DrawF(uint32_t f) {
sprintf(String, "R%03u S%03u A%03u", scanInfo.rssi,
BK4819_GetRegValue((RegisterSpec){"snr_out", 0x61, 8, 0xFF, 1}),
BK4819_GetRegValue((RegisterSpec){"agc_rssi", 0x62, 8, 0xFF, 1}));
UI_PrintStringSmallest(String, 26, 8, false, true);
UI_PrintStringSmallest(String, 36, 8, false, true);
}
#endif

Expand All @@ -673,9 +677,9 @@ static void DrawF(uint32_t f) {
static void DrawNums() {
if (currentState == SPECTRUM) {
sprintf(String, "%ux", GetStepsCount());
UI_PrintStringSmallest(String, 0, 1, false, true);
UI_PrintStringSmallest(String, 0, 2, false, true);
sprintf(String, "%u.%02uk", GetScanStep() / 100, GetScanStep() % 100);
UI_PrintStringSmallest(String, 0, 7, false, true);
UI_PrintStringSmallest(String, 0, 8, false, true);
}

if (IsCenterMode()) {
Expand Down Expand Up @@ -747,7 +751,7 @@ static void DrawArrow(uint8_t x) {
}

static void DeInitSpectrum() {
SetF(initialFreq);
SetF(initialFreq, true);
ToggleRX(false);
RestoreRegisters();
isInitialized = false;
Expand Down Expand Up @@ -923,7 +927,7 @@ static void OnKeyDownFreqInput(uint8_t key) {
ResetBlacklist();
RelaunchScan();
} else {
SetF(currentFreq);
SetF(currentFreq, true);
}
redrawScreen = true;
break;
Expand Down Expand Up @@ -1217,7 +1221,7 @@ static void Scan() {
if (blacklist[scanInfo.i]) {
return;
}
SetF(scanInfo.f);
SetF(scanInfo.f, true);
Measure();
UpdateScanInfo();
}
Expand Down
11 changes: 7 additions & 4 deletions driver/bk4819.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void BK4819_Init(void) {
BK4819_WriteRegister(BK4819_REG_00, 0x0000);
BK4819_WriteRegister(BK4819_REG_37, 0x1D0F);
BK4819_WriteRegister(BK4819_REG_36, 0x0022);
BK4819_SetAGC(1);
BK4819_SetAGC(0);
BK4819_WriteRegister(BK4819_REG_19, 0x1041);
BK4819_WriteRegister(BK4819_REG_7D, 0xE94F);
BK4819_WriteRegister(BK4819_REG_48, 0xB3A8);
Expand Down Expand Up @@ -963,11 +963,14 @@ void BK4819_ToggleAFDAC(bool on) {
BK4819_WriteRegister(BK4819_REG_30, Reg);
}

void BK4819_TuneTo(uint32_t f) {
void BK4819_TuneTo(uint32_t f, bool precise) {
BK4819_PickRXFilterPathBasedOnFrequency(f);
BK4819_SetFrequency(f);
uint16_t reg = BK4819_ReadRegister(BK4819_REG_30);
// BK4819_WriteRegister(BK4819_REG_30, reg & ~BK4819_REG_30_ENABLE_VCO_CALIB);
BK4819_WriteRegister(BK4819_REG_30, 0);
if (precise) {
BK4819_WriteRegister(BK4819_REG_30, 0);
} else {
BK4819_WriteRegister(BK4819_REG_30, reg & ~BK4819_REG_30_ENABLE_VCO_CALIB);
}
BK4819_WriteRegister(BK4819_REG_30, reg);
}
2 changes: 1 addition & 1 deletion driver/bk4819.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,6 @@ void BK4819_ToggleAFDAC(bool on);
uint16_t BK4819_GetRegValue(RegisterSpec s);
void BK4819_SetRegValue(RegisterSpec s, uint16_t v);
void BK4819_SetModulation(ModulationType type);
void BK4819_TuneTo(uint32_t f);
void BK4819_TuneTo(uint32_t f, bool precise);

#endif
16 changes: 14 additions & 2 deletions font.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "font.h"

const uint8_t gFontBigDigits[11][26] = {
{0x00, 0xE0, 0xF0, 0xF0, 0x38, 0x18, 0x18, 0x18, 0x18, 0x38, 0xF0, 0xF0, 0xE0, 0x00, 0x1F, 0x3F, 0x3F, 0x70, 0x60, 0x60, 0x60, 0x60, 0x70, 0x3F, 0x3F, 0x1F, },
/* {0x00, 0xE0, 0xF0, 0xF0, 0x38, 0x18, 0x18, 0x18, 0x18, 0x38, 0xF0, 0xF0, 0xE0, 0x00, 0x1F, 0x3F, 0x3F, 0x70, 0x60, 0x60, 0x60, 0x60, 0x70, 0x3F, 0x3F, 0x1F, },
{0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0xF8, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x7F, 0x7F, 0x7F, 0x60, 0x60, 0x00, 0x00, },
{0x00, 0x60, 0x70, 0x70, 0x38, 0x18, 0x18, 0x18, 0x18, 0xB8, 0xF0, 0xF0, 0xE0, 0x00, 0x70, 0x78, 0x7C, 0x7C, 0x6E, 0x66, 0x67, 0x63, 0x63, 0x61, 0x61, 0x60, },
{0x00, 0x60, 0x70, 0x70, 0x38, 0x18, 0x18, 0x18, 0x18, 0xB8, 0xF0, 0xF0, 0x60, 0x00, 0x18, 0x38, 0x38, 0x70, 0x60, 0x63, 0x63, 0x63, 0x77, 0x3F, 0x3E, 0x1C, },
Expand All @@ -27,7 +27,19 @@ const uint8_t gFontBigDigits[11][26] = {
{0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x98, 0xF8, 0xF8, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x7C, 0x7E, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, },
{0x00, 0x60, 0xF0, 0xF0, 0xB8, 0x18, 0x18, 0x18, 0x18, 0xB8, 0xF0, 0xF0, 0x60, 0x00, 0x1C, 0x3E, 0x3F, 0x77, 0x63, 0x63, 0x63, 0x63, 0x77, 0x3F, 0x3E, 0x1C, },
{0x00, 0xE0, 0xF0, 0xF0, 0x38, 0x18, 0x18, 0x18, 0x18, 0x38, 0xF0, 0xF0, 0xE0, 0x00, 0x11, 0x33, 0x77, 0x67, 0x66, 0x66, 0x66, 0x66, 0x77, 0x7F, 0x3F, 0x1F, },
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00, },
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00, }, */

{0x00, 0xE0, 0xF0, 0xF0, 0x38, 0x18, 0x18, 0x18, 0x38, 0xF0, 0xF0, 0xE0, 0x00, 0x00, 0x1F, 0x3F, 0x3F, 0x70, 0x60, 0x60, 0x60, 0x70, 0x3F, 0x3F, 0x1F, 0x00, },
{0x00, 0x00, 0x00, 0x60, 0x60, 0xF8, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x7F, 0x7F, 0x7F, 0x60, 0x60, 0x00, 0x00, 0x00, },
{0x00, 0x60, 0x70, 0x70, 0x38, 0x18, 0x18, 0x18, 0xB8, 0xF0, 0xF0, 0xE0, 0x00, 0x00, 0x70, 0x78, 0x7C, 0x7C, 0x6E, 0x66, 0x67, 0x63, 0x61, 0x61, 0x60, 0x00, },
{0x00, 0x60, 0x70, 0x70, 0x38, 0x18, 0x18, 0x18, 0xB8, 0xF0, 0xF0, 0x60, 0x00, 0x00, 0x18, 0x38, 0x38, 0x70, 0x60, 0x63, 0x63, 0x77, 0x3F, 0x3E, 0x1C, 0x00, },
{0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0x70, 0xF8, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x1C, 0x1E, 0x1F, 0x1B, 0x19, 0x18, 0x18, 0x7F, 0x7F, 0x7F, 0x18, 0x00, },
{0x00, 0xF8, 0xF8, 0xF8, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x18, 0x18, 0x00, 0x00, 0x19, 0x39, 0x39, 0x71, 0x61, 0x61, 0x61, 0x73, 0x3F, 0x3F, 0x1E, 0x00, },
{0x00, 0xE0, 0xF0, 0xF0, 0xB8, 0x98, 0x98, 0x98, 0xB8, 0xB0, 0x30, 0x20, 0x00, 0x00, 0x1F, 0x3F, 0x3F, 0x73, 0x61, 0x61, 0x61, 0x73, 0x3F, 0x3F, 0x1E, 0x00, },
{0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x98, 0xF8, 0xF8, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x7C, 0x7E, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, },
{0x00, 0x60, 0xF0, 0xF0, 0xB8, 0x18, 0x18, 0x18, 0xB8, 0xF0, 0xF0, 0x60, 0x00, 0x00, 0x1C, 0x3E, 0x3F, 0x77, 0x63, 0x63, 0x63, 0x77, 0x3F, 0x3E, 0x1C, 0x00, },
{0x00, 0xE0, 0xF0, 0xF0, 0x38, 0x18, 0x18, 0x18, 0x38, 0xF0, 0xF0, 0xE0, 0x00, 0x00, 0x11, 0x33, 0x77, 0x67, 0x66, 0x66, 0x66, 0x77, 0x7F, 0x3F, 0x1F, 0x00, },
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, },
};

const uint8_t gFontBig[95][16] = {
Expand Down
4 changes: 2 additions & 2 deletions radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ STEP_Setting_t gStepSetting;

VfoState_t VfoState[2];

const char *modulationTypeOptions[] = {" FM", " AM", "SSB", "BYP", "RAW"};
const char *modulationTypeOptions[5] = {" FM", " AM", "SSB", "BYP", "RAW"};
const char *vfoStateNames[] = {
"NORMAL", "BUSY", "BAT LOW", "DISABLE", "TIMEOUT", "ALARM", "VOL HIGH",
};
const char *powerNames[] = {"LOW", "MID", "HIGH"};
const char *bwNames[] = {" 25k", "12.5k", "6.25k"};
const char *bwNames[3] = {" 25k", "12.5k", "6.25k"};
const char *deviationNames[] = {"", "+", "-"};

bool RADIO_CheckValidChannel(uint16_t Channel, bool bCheckScanList,
Expand Down
4 changes: 2 additions & 2 deletions radio.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ enum STEP_Setting_t {
STEP_100_0kHz,
};

extern const char *modulationTypeOptions[];
extern const char *modulationTypeOptions[5];
extern const char *vfoStateNames[];
extern const char *powerNames[];
extern const char *bwNames[];
extern const char *bwNames[3];
extern const char *deviationNames[];

typedef enum ModulationType {
Expand Down
14 changes: 12 additions & 2 deletions ui/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,20 @@ void UI_DisplayMain(void) {
if (IS_MR_CHANNEL(screenCH)) {
const uint8_t ATTR = gMR_ChannelAttributes[screenCH];
if (ATTR & MR_CH_SCANLIST1) {
UI_PrintStringSmallest("s1", 112, lineSubY, false, true);
gFrameBuffer[Line+2][116] = 0b00001111;
gFrameBuffer[Line+2][117] = 0b00001111;
gFrameBuffer[Line+2][118] = 0b00001111;
gFrameBuffer[Line+2][119] = 0b00001111;
gFrameBuffer[Line+2][120] = 0b00001111;
// UI_PrintStringSmallest("s1", 112, lineSubY, false, true);
}
if (ATTR & MR_CH_SCANLIST2) {
UI_PrintStringSmallest("s2", 120, lineSubY, false, true);
gFrameBuffer[Line+2][122] = 0b00001111;
gFrameBuffer[Line+2][123] = 0b00001111;
gFrameBuffer[Line+2][124] = 0b00001111;
gFrameBuffer[Line+2][125] = 0b00001111;
gFrameBuffer[Line+2][126] = 0b00001111;
// UI_PrintStringSmallest("s2", 120, lineSubY, false, true);
}
}

Expand Down
Loading

0 comments on commit 031f2f0

Please sign in to comment.