Refactor, merge #186
This commit is contained in:
committed by
Krzysiek Egzmont
parent
ed395ab638
commit
52bdd408c4
25
Makefile
25
Makefile
@@ -184,17 +184,15 @@ else # unix
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
AS = arm-none-eabi-gcc
|
AS = arm-none-eabi-gcc
|
||||||
|
|
||||||
CC =
|
|
||||||
LD = arm-none-eabi-gcc
|
LD = arm-none-eabi-gcc
|
||||||
|
|
||||||
ifeq ($(ENABLE_CLANG),0)
|
ifeq ($(ENABLE_CLANG),0)
|
||||||
CC += arm-none-eabi-gcc
|
CC = arm-none-eabi-gcc
|
||||||
# Use GCC's linker to avoid undefined symbol errors
|
# Use GCC's linker to avoid undefined symbol errors
|
||||||
# LD += arm-none-eabi-gcc
|
# LD += arm-none-eabi-gcc
|
||||||
else
|
else
|
||||||
# May need to adjust this to match your system
|
# May need to adjust this to match your system
|
||||||
CC += clang --sysroot=/usr/arm-none-eabi --target=arm-none-eabi
|
CC = clang --sysroot=/usr/arm-none-eabi --target=arm-none-eabi
|
||||||
# Bloats binaries to 512MB
|
# Bloats binaries to 512MB
|
||||||
# LD = ld.lld
|
# LD = ld.lld
|
||||||
endif
|
endif
|
||||||
@@ -221,17 +219,18 @@ endif
|
|||||||
|
|
||||||
CFLAGS =
|
CFLAGS =
|
||||||
ifeq ($(ENABLE_CLANG),0)
|
ifeq ($(ENABLE_CLANG),0)
|
||||||
CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD
|
CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c2x -MMD
|
||||||
|
#CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD
|
||||||
#CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c99 -MMD
|
#CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c99 -MMD
|
||||||
#CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=gnu99 -MMD
|
#CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=gnu99 -MMD
|
||||||
#CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=gnu11 -MMD
|
#CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=gnu11 -MMD
|
||||||
else
|
else
|
||||||
# Oz needed to make it fit on flash
|
# Oz needed to make it fit on flash
|
||||||
CFLAGS += -Oz -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD
|
CFLAGS += -Oz -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c2x -MMD
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(ENABLE_LTO),1)
|
ifeq ($(ENABLE_LTO),1)
|
||||||
CFLAGS += -flto=2
|
CFLAGS += -flto=auto
|
||||||
else
|
else
|
||||||
# We get most of the space savings if LTO creates problems
|
# We get most of the space savings if LTO creates problems
|
||||||
CFLAGS += -ffunction-sections -fdata-sections
|
CFLAGS += -ffunction-sections -fdata-sections
|
||||||
@@ -366,21 +365,11 @@ ifeq ($(ENABLE_AGC_SHOW_DATA),1)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
LDFLAGS =
|
LDFLAGS =
|
||||||
ifeq ($(ENABLE_CLANG),0)
|
LDFLAGS += -z noexecstack -mcpu=cortex-m0 -nostartfiles -Wl,-T,firmware.ld -Wl,--gc-sections
|
||||||
LDFLAGS += -mcpu=cortex-m0 -nostartfiles -Wl,-T,firmware.ld
|
|
||||||
else
|
|
||||||
# Fix warning about implied executable stack
|
|
||||||
LDFLAGS += -z noexecstack -mcpu=cortex-m0 -nostartfiles -Wl,-T,firmware.ld
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Use newlib-nano instead of newlib
|
# Use newlib-nano instead of newlib
|
||||||
LDFLAGS += --specs=nano.specs
|
LDFLAGS += --specs=nano.specs
|
||||||
|
|
||||||
ifeq ($(ENABLE_LTO),0)
|
|
||||||
# Throw away unneeded func/data sections like LTO does
|
|
||||||
LDFLAGS += -Wl,--gc-sections
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(DEBUG),1)
|
ifeq ($(DEBUG),1)
|
||||||
ASFLAGS += -g
|
ASFLAGS += -g
|
||||||
CFLAGS += -g
|
CFLAGS += -g
|
||||||
|
87
app/main.c
87
app/main.c
@@ -56,19 +56,10 @@ void toggle_chan_scanlist(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gTxVfo->SCANLIST1_PARTICIPATION)
|
if (gTxVfo->SCANLIST1_PARTICIPATION ^ gTxVfo->SCANLIST2_PARTICIPATION){
|
||||||
{
|
gTxVfo->SCANLIST2_PARTICIPATION = gTxVfo->SCANLIST1_PARTICIPATION;
|
||||||
if (gTxVfo->SCANLIST2_PARTICIPATION)
|
} else {
|
||||||
gTxVfo->SCANLIST1_PARTICIPATION = 0;
|
gTxVfo->SCANLIST1_PARTICIPATION = !gTxVfo->SCANLIST1_PARTICIPATION;
|
||||||
else
|
|
||||||
gTxVfo->SCANLIST2_PARTICIPATION = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (gTxVfo->SCANLIST2_PARTICIPATION)
|
|
||||||
gTxVfo->SCANLIST2_PARTICIPATION = 0;
|
|
||||||
else
|
|
||||||
gTxVfo->SCANLIST1_PARTICIPATION = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true);
|
SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true);
|
||||||
@@ -79,7 +70,6 @@ void toggle_chan_scanlist(void)
|
|||||||
|
|
||||||
static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
|
static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
|
||||||
{
|
{
|
||||||
uint8_t Band;
|
|
||||||
uint8_t Vfo = gEeprom.TX_VFO;
|
uint8_t Vfo = gEeprom.TX_VFO;
|
||||||
|
|
||||||
if (gScreenToDisplay == DISPLAY_MENU)
|
if (gScreenToDisplay == DISPLAY_MENU)
|
||||||
@@ -113,8 +103,11 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
|
|||||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||||
|
|
||||||
#ifdef ENABLE_COPY_CHAN_TO_VFO
|
#ifdef ENABLE_COPY_CHAN_TO_VFO
|
||||||
if (gEeprom.VFO_OPEN && !gCssBackgroundScan)
|
if (!gEeprom.VFO_OPEN || gCssBackgroundScan)
|
||||||
{
|
{
|
||||||
|
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (gScanStateDir != SCAN_OFF)
|
if (gScanStateDir != SCAN_OFF)
|
||||||
{
|
{
|
||||||
@@ -131,10 +124,8 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
|
|||||||
if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo]))
|
if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo]))
|
||||||
{ // copy channel to VFO, then swap to the VFO
|
{ // copy channel to VFO, then swap to the VFO
|
||||||
|
|
||||||
const unsigned int channel = FREQ_CHANNEL_FIRST + gEeprom.VfoInfo[vfo].Band;
|
gEeprom.ScreenChannel[vfo] = FREQ_CHANNEL_FIRST + gEeprom.VfoInfo[vfo].Band;
|
||||||
|
gEeprom.VfoInfo[vfo].CHANNEL_SAVE = gEeprom.ScreenChannel[vfo];
|
||||||
gEeprom.ScreenChannel[vfo] = channel;
|
|
||||||
gEeprom.VfoInfo[vfo].CHANNEL_SAVE = channel;
|
|
||||||
|
|
||||||
RADIO_SelectVfos();
|
RADIO_SelectVfos();
|
||||||
RADIO_ApplyOffset(gRxVfo);
|
RADIO_ApplyOffset(gRxVfo);
|
||||||
@@ -145,37 +136,30 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
|
|||||||
|
|
||||||
gUpdateDisplay = true;
|
gUpdateDisplay = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_WIDE_RX
|
#ifdef ENABLE_WIDE_RX
|
||||||
if(gTxVfo->Band == 6 && gTxVfo->pRX->Frequency < 100000000) {
|
if(gTxVfo->Band == BAND7_470MHz && gTxVfo->pRX->Frequency < _1GHz_in_KHz) {
|
||||||
gTxVfo->pRX->Frequency = 100000000;
|
gTxVfo->pRX->Frequency = _1GHz_in_KHz;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
#endif
|
#endif
|
||||||
{
|
|
||||||
Band = gTxVfo->Band + 1;
|
|
||||||
if (gSetting_350EN || Band != BAND5_350MHz) {
|
|
||||||
if (Band > BAND7_470MHz)
|
|
||||||
Band = BAND1_50MHz;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Band = BAND6_400MHz;
|
|
||||||
|
|
||||||
gTxVfo->Band = Band;
|
gTxVfo->Band += 1;
|
||||||
|
|
||||||
gEeprom.ScreenChannel[Vfo] = FREQ_CHANNEL_FIRST + Band;
|
if (gTxVfo->Band == BAND5_350MHz && !gSetting_350EN) {
|
||||||
gEeprom.FreqChannel[Vfo] = FREQ_CHANNEL_FIRST + Band;
|
// skip if not enabled
|
||||||
|
gTxVfo->Band += 1;
|
||||||
|
} else if (gTxVfo->Band >= BAND_LAST_ELEMENT){
|
||||||
|
// go arround if overflowed
|
||||||
|
gTxVfo->Band = BAND1_50MHz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gEeprom.ScreenChannel[Vfo] = FREQ_CHANNEL_FIRST + gTxVfo->Band;
|
||||||
|
gEeprom.FreqChannel[Vfo] = FREQ_CHANNEL_FIRST + gTxVfo->Band;
|
||||||
|
|
||||||
gRequestSaveVFO = true;
|
gRequestSaveVFO = true;
|
||||||
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
|
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
|
||||||
|
|
||||||
@@ -335,8 +319,6 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE))
|
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE))
|
||||||
{ // user is entering channel number
|
{ // user is entering channel number
|
||||||
|
|
||||||
uint16_t Channel;
|
|
||||||
|
|
||||||
if (gInputBoxIndex != 3)
|
if (gInputBoxIndex != 3)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
@@ -348,7 +330,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
|
|
||||||
gInputBoxIndex = 0;
|
gInputBoxIndex = 0;
|
||||||
|
|
||||||
Channel = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1;
|
const uint16_t Channel = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1;
|
||||||
|
|
||||||
if (!RADIO_CheckValidChannel(Channel, false, 0))
|
if (!RADIO_CheckValidChannel(Channel, false, 0))
|
||||||
{
|
{
|
||||||
@@ -374,19 +356,17 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
if (IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE))
|
if (IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE))
|
||||||
{ // user is entering a frequency
|
{ // user is entering a frequency
|
||||||
|
|
||||||
uint32_t Frequency;
|
|
||||||
bool isGigaF = gTxVfo->pRX->Frequency >= 100000000;
|
|
||||||
if (gInputBoxIndex < 6 + isGigaF)
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||||
#endif
|
#endif
|
||||||
|
bool isGigaF = gTxVfo->pRX->Frequency >= _1GHz_in_KHz;
|
||||||
|
if (gInputBoxIndex < 6 + isGigaF)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gInputBoxIndex = 0;
|
gInputBoxIndex = 0;
|
||||||
Frequency = StrToUL(INPUTBOX_GetAscii()) * 100;
|
uint32_t Frequency = StrToUL(INPUTBOX_GetAscii()) * 100;
|
||||||
|
|
||||||
// clamp the frequency entered to some valid value
|
// clamp the frequency entered to some valid value
|
||||||
if (Frequency < frequencyBandTable[0].lower)
|
if (Frequency < frequencyBandTable[0].lower)
|
||||||
@@ -405,13 +385,8 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
Frequency = frequencyBandTable[ARRAY_SIZE(frequencyBandTable) - 1].upper;
|
Frequency = frequencyBandTable[ARRAY_SIZE(frequencyBandTable) - 1].upper;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
const FREQUENCY_Band_t band = FREQUENCY_GetBand(Frequency);
|
const FREQUENCY_Band_t band = FREQUENCY_GetBand(Frequency);
|
||||||
|
|
||||||
#ifdef ENABLE_VOICE
|
|
||||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (gTxVfo->Band != band)
|
if (gTxVfo->Band != band)
|
||||||
{
|
{
|
||||||
gTxVfo->Band = band;
|
gTxVfo->Band = band;
|
||||||
@@ -435,16 +410,12 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
|
|
||||||
gRequestSaveChannel = 1;
|
gRequestSaveChannel = 1;
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
else
|
else
|
||||||
if (IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
|
if (IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
|
||||||
{ // user is entering NOAA channel
|
{ // user is entering NOAA channel
|
||||||
|
|
||||||
uint8_t Channel;
|
|
||||||
|
|
||||||
if (gInputBoxIndex != 2)
|
if (gInputBoxIndex != 2)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
@@ -456,7 +427,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
|
|
||||||
gInputBoxIndex = 0;
|
gInputBoxIndex = 0;
|
||||||
|
|
||||||
Channel = (gInputBox[0] * 10) + gInputBox[1];
|
uint8_t Channel = (gInputBox[0] * 10) + gInputBox[1];
|
||||||
if (Channel >= 1 && Channel <= ARRAY_SIZE(NoaaFrequencyTable))
|
if (Channel >= 1 && Channel <= ARRAY_SIZE(NoaaFrequencyTable))
|
||||||
{
|
{
|
||||||
Channel += NOAA_CHANNEL_FIRST;
|
Channel += NOAA_CHANNEL_FIRST;
|
||||||
@@ -586,7 +557,7 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
|
|||||||
|
|
||||||
if (!bKeyPressed && !gDTMF_InputMode)
|
if (!bKeyPressed && !gDTMF_InputMode)
|
||||||
{ // menu key released
|
{ // menu key released
|
||||||
const bool bFlag = (gInputBoxIndex == 0);
|
const bool bFlag = !gInputBoxIndex;
|
||||||
gInputBoxIndex = 0;
|
gInputBoxIndex = 0;
|
||||||
|
|
||||||
if (bFlag)
|
if (bFlag)
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "app/spectrum.h"
|
#include "app/spectrum.h"
|
||||||
#include "driver/backlight.h"
|
|
||||||
#include "audio.h"
|
|
||||||
#include "ui/helper.h"
|
|
||||||
#include "am_fix.h"
|
#include "am_fix.h"
|
||||||
|
#include "audio.h"
|
||||||
|
#include "driver/backlight.h"
|
||||||
|
#include "ui/helper.h"
|
||||||
#include "ui/main.h"
|
#include "ui/main.h"
|
||||||
|
|
||||||
struct FrequencyBandInfo {
|
struct FrequencyBandInfo {
|
||||||
@@ -32,7 +32,6 @@ struct FrequencyBandInfo {
|
|||||||
|
|
||||||
const uint16_t RSSI_MAX_VALUE = 65535;
|
const uint16_t RSSI_MAX_VALUE = 65535;
|
||||||
|
|
||||||
|
|
||||||
static uint16_t R30, R37, R3D, R43, R47, R48, R7E;
|
static uint16_t R30, R37, R3D, R43, R47, R48, R7E;
|
||||||
static uint32_t initialFreq;
|
static uint32_t initialFreq;
|
||||||
static char String[32];
|
static char String[32];
|
||||||
@@ -57,17 +56,17 @@ const char *bwOptions[] = {" 25k", "12.5k", "6.25k"};
|
|||||||
const uint8_t modulationTypeTuneSteps[] = {100, 50, 10};
|
const uint8_t modulationTypeTuneSteps[] = {100, 50, 10};
|
||||||
const uint8_t modTypeReg47Values[] = {1, 7, 5};
|
const uint8_t modTypeReg47Values[] = {1, 7, 5};
|
||||||
|
|
||||||
SpectrumSettings settings = {stepsCount: STEPS_64,
|
SpectrumSettings settings = {.stepsCount = STEPS_64,
|
||||||
scanStepIndex: S_STEP_25_0kHz,
|
.scanStepIndex = S_STEP_25_0kHz,
|
||||||
frequencyChangeStep: 80000,
|
.frequencyChangeStep = 80000,
|
||||||
scanDelay: 3200,
|
.scanDelay = 3200,
|
||||||
rssiTriggerLevel: 150,
|
.rssiTriggerLevel = 150,
|
||||||
backlightState: true,
|
.backlightState = true,
|
||||||
bw: BK4819_FILTER_BW_WIDE,
|
.bw = BK4819_FILTER_BW_WIDE,
|
||||||
listenBw: BK4819_FILTER_BW_WIDE,
|
.listenBw = BK4819_FILTER_BW_WIDE,
|
||||||
modulationType: false,
|
.modulationType = false,
|
||||||
dbMin: -130,
|
.dbMin = -130,
|
||||||
dbMax: -50};
|
.dbMax = -50};
|
||||||
|
|
||||||
uint32_t fMeasure = 0;
|
uint32_t fMeasure = 0;
|
||||||
uint32_t currentFreq, tempFreq;
|
uint32_t currentFreq, tempFreq;
|
||||||
@@ -103,8 +102,7 @@ static uint8_t DBm2S(int dbm) {
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int Rssi2DBm(uint16_t rssi)
|
static int Rssi2DBm(uint16_t rssi) {
|
||||||
{
|
|
||||||
return (rssi / 2) - 160 + dBmCorrTable[gRxVfo->Band];
|
return (rssi / 2) - 160 + dBmCorrTable[gRxVfo->Band];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,17 +292,11 @@ uint16_t GetRssi() {
|
|||||||
SYSTICK_DelayUs(100);
|
SYSTICK_DelayUs(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return BK4819_GetRSSI()
|
||||||
#ifdef ENABLE_AM_FIX
|
#ifdef ENABLE_AM_FIX
|
||||||
if(settings.modulationType == MODULATION_AM) {
|
- ((settings.modulationType == MODULATION_AM) ? AM_fix_get_rssi_gain_diff(vfo) : 0)
|
||||||
//return the corrected RSSI to allow for AM_Fixs AGC action.
|
|
||||||
return BK4819_GetRSSI() - AM_fix_get_rssi_gain_diff(vfo);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
#endif
|
||||||
{
|
;
|
||||||
return BK4819_GetRSSI();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ToggleAudio(bool on) {
|
static void ToggleAudio(bool on) {
|
||||||
@@ -409,14 +401,14 @@ static void Measure() { rssiHistory[scanInfo.i] = scanInfo.rssi = GetRssi(); }
|
|||||||
|
|
||||||
// Update things by keypress
|
// Update things by keypress
|
||||||
|
|
||||||
static uint16_t dbm2rssi(int dBm)
|
static uint16_t dbm2rssi(int dBm) {
|
||||||
{
|
|
||||||
return (dBm + 160 - dBmCorrTable[gRxVfo->Band]) * 2;
|
return (dBm + 160 - dBmCorrTable[gRxVfo->Band]) * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ClampRssiTriggerLevel()
|
static void ClampRssiTriggerLevel() {
|
||||||
{
|
settings.rssiTriggerLevel =
|
||||||
settings.rssiTriggerLevel = clamp(settings.rssiTriggerLevel, dbm2rssi(settings.dbMin), dbm2rssi(settings.dbMax));
|
clamp(settings.rssiTriggerLevel, dbm2rssi(settings.dbMin),
|
||||||
|
dbm2rssi(settings.dbMax));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void UpdateRssiTriggerLevel(bool inc) {
|
static void UpdateRssiTriggerLevel(bool inc) {
|
||||||
@@ -648,10 +640,11 @@ static void DrawStatus() {
|
|||||||
#endif
|
#endif
|
||||||
GUI_DisplaySmallest(String, 0, 1, true, true);
|
GUI_DisplaySmallest(String, 0, 1, true, true);
|
||||||
|
|
||||||
BOARD_ADC_GetBatteryInfo(&gBatteryVoltages[gBatteryCheckCounter++ % 4], &gBatteryCurrent);
|
BOARD_ADC_GetBatteryInfo(&gBatteryVoltages[gBatteryCheckCounter++ % 4],
|
||||||
|
&gBatteryCurrent);
|
||||||
|
|
||||||
uint16_t voltage = (gBatteryVoltages[0] + gBatteryVoltages[1] + gBatteryVoltages[2] +
|
uint16_t voltage = (gBatteryVoltages[0] + gBatteryVoltages[1] +
|
||||||
gBatteryVoltages[3]) /
|
gBatteryVoltages[2] + gBatteryVoltages[3]) /
|
||||||
4 * 760 / gBatteryCalibration[3];
|
4 * 760 / gBatteryCalibration[3];
|
||||||
|
|
||||||
unsigned perc = BATTERY_VoltsToPercent(voltage);
|
unsigned perc = BATTERY_VoltsToPercent(voltage);
|
||||||
@@ -931,9 +924,7 @@ void OnKeyDownStill(KEY_Code_t key) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void RenderFreqInput() {
|
static void RenderFreqInput() { UI_PrintString(freqInputString, 2, 127, 0, 8); }
|
||||||
UI_PrintString(freqInputString, 2, 127, 0, 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void RenderStatus() {
|
static void RenderStatus() {
|
||||||
memset(gStatusLine, 0, sizeof(gStatusLine));
|
memset(gStatusLine, 0, sizeof(gStatusLine));
|
||||||
@@ -1038,8 +1029,7 @@ bool HandleUserInput() {
|
|||||||
else
|
else
|
||||||
kbd.counter -= 3;
|
kbd.counter -= 3;
|
||||||
SYSTEM_DelayMs(20);
|
SYSTEM_DelayMs(20);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
kbd.counter = 0;
|
kbd.counter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1175,7 +1165,8 @@ void APP_RunSpectrum() {
|
|||||||
// TX here coz it always? set to active VFO
|
// TX here coz it always? set to active VFO
|
||||||
vfo = gEeprom.TX_VFO;
|
vfo = gEeprom.TX_VFO;
|
||||||
// set the current frequency in the middle of the display
|
// set the current frequency in the middle of the display
|
||||||
currentFreq = initialFreq = gEeprom.VfoInfo[vfo].pRX->Frequency - ((GetStepsCount()/2) * GetScanStep());
|
currentFreq = initialFreq = gEeprom.VfoInfo[vfo].pRX->Frequency -
|
||||||
|
((GetStepsCount() / 2) * GetScanStep());
|
||||||
|
|
||||||
BackupRegisters();
|
BackupRegisters();
|
||||||
|
|
||||||
|
@@ -19,30 +19,29 @@
|
|||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
// the BK4819 has 2 bands it covers, 18MHz ~ 630MHz and 760MHz ~ 1300MHz
|
// the BK4819 has 2 bands it covers, 18MHz ~ 630MHz and 760MHz ~ 1300MHz
|
||||||
const freq_band_table_t BX4819_band1 = { 1800000, 63000000};
|
|
||||||
const freq_band_table_t BX4819_band2 = {84000000, 130000000};
|
|
||||||
|
|
||||||
const freq_band_table_t frequencyBandTable[7] =
|
#define BX4819_band1_lower 1800000
|
||||||
|
#define BX4819_band2_upper 130000000
|
||||||
|
|
||||||
|
const freq_band_table_t BX4819_band1 = {BX4819_band1_lower, 63000000};
|
||||||
|
const freq_band_table_t BX4819_band2 = {84000000, BX4819_band2_upper};
|
||||||
|
|
||||||
|
const freq_band_table_t frequencyBandTable[] =
|
||||||
{
|
{
|
||||||
#ifndef ENABLE_WIDE_RX
|
#ifndef ENABLE_WIDE_RX
|
||||||
// QS original
|
// QS original
|
||||||
{.lower = 5000000, .upper = 7600000},
|
[BAND1_50MHz ]={.lower = 5000000, .upper = 7600000},
|
||||||
{.lower = 10800000, .upper = 13700000},
|
[BAND7_470MHz]={.lower = 47000000, .upper = 60000000},
|
||||||
{.lower = 13700000, .upper = 17400000},
|
|
||||||
{.lower = 17400000, .upper = 35000000},
|
|
||||||
{.lower = 35000000, .upper = 40000000},
|
|
||||||
{.lower = 40000000, .upper = 47000000},
|
|
||||||
{.lower = 47000000, .upper = 60000000}
|
|
||||||
#else
|
#else
|
||||||
// extended range
|
// extended range
|
||||||
{.lower = BX4819_band1.lower, .upper = 10800000},
|
[BAND1_50MHz ]={.lower = BX4819_band1_lower, .upper = 10800000},
|
||||||
{.lower = 10800000, .upper = 13700000},
|
[BAND7_470MHz]={.lower = 47000000, .upper = BX4819_band2_upper},
|
||||||
{.lower = 13700000, .upper = 17400000},
|
|
||||||
{.lower = 17400000, .upper = 35000000},
|
|
||||||
{.lower = 35000000, .upper = 40000000},
|
|
||||||
{.lower = 40000000, .upper = 47000000},
|
|
||||||
{.lower = 47000000, .upper = BX4819_band2.upper}
|
|
||||||
#endif
|
#endif
|
||||||
|
[BAND2_108MHz]={.lower = 10800000, .upper = 13700000},
|
||||||
|
[BAND3_137MHz]={.lower = 13700000, .upper = 17400000},
|
||||||
|
[BAND4_174MHz]={.lower = 17400000, .upper = 35000000},
|
||||||
|
[BAND5_350MHz]={.lower = 35000000, .upper = 40000000},
|
||||||
|
[BAND6_400MHz]={.lower = 40000000, .upper = 47000000}
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
@@ -68,16 +67,18 @@ const uint16_t gStepFrequencyTable[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const uint8_t StepSortedIndexes[] = {
|
const STEP_Setting_t StepSortedIndexes[] = {
|
||||||
STEP_0_01kHz, STEP_0_05kHz, STEP_0_1kHz, STEP_0_25kHz, STEP_0_5kHz, STEP_1kHz, STEP_1_25kHz, STEP_2_5kHz, STEP_5kHz, STEP_6_25kHz,
|
STEP_0_01kHz, STEP_0_05kHz, STEP_0_1kHz, STEP_0_25kHz, STEP_0_5kHz, STEP_1kHz, STEP_1_25kHz, STEP_2_5kHz, STEP_5kHz, STEP_6_25kHz,
|
||||||
STEP_8_33kHz, STEP_10kHz, STEP_12_5kHz, STEP_15kHz, STEP_25kHz, STEP_30kHz, STEP_50kHz, STEP_100kHz,
|
STEP_8_33kHz, STEP_10kHz, STEP_12_5kHz, STEP_15kHz, STEP_25kHz, STEP_30kHz, STEP_50kHz, STEP_100kHz,
|
||||||
STEP_125kHz, STEP_250kHz, STEP_500kHz
|
STEP_125kHz, STEP_250kHz, STEP_500kHz
|
||||||
};
|
};
|
||||||
uint8_t FREQUENCY_GetStepIdxFromSortedIdx(uint8_t sortedIdx)
|
|
||||||
|
STEP_Setting_t FREQUENCY_GetStepIdxFromSortedIdx(uint8_t sortedIdx)
|
||||||
{
|
{
|
||||||
return StepSortedIndexes[sortedIdx];
|
return StepSortedIndexes[sortedIdx];
|
||||||
}
|
}
|
||||||
uint8_t FREQUENCY_GetSortedIdxFromStepIdx(uint8_t stepIdx)
|
|
||||||
|
uint32_t FREQUENCY_GetSortedIdxFromStepIdx(uint8_t stepIdx)
|
||||||
{
|
{
|
||||||
for(uint8_t i = 0; i < ARRAY_SIZE(gStepFrequencyTable); i++)
|
for(uint8_t i = 0; i < ARRAY_SIZE(gStepFrequencyTable); i++)
|
||||||
if(StepSortedIndexes[i] == stepIdx)
|
if(StepSortedIndexes[i] == stepIdx)
|
||||||
@@ -87,8 +88,7 @@ uint8_t FREQUENCY_GetSortedIdxFromStepIdx(uint8_t stepIdx)
|
|||||||
|
|
||||||
FREQUENCY_Band_t FREQUENCY_GetBand(uint32_t Frequency)
|
FREQUENCY_Band_t FREQUENCY_GetBand(uint32_t Frequency)
|
||||||
{
|
{
|
||||||
int band;
|
for (int band = ARRAY_SIZE(frequencyBandTable) - 1; band >= 0; band--)
|
||||||
for (band = ARRAY_SIZE(frequencyBandTable) - 1; band >= 0; band--)
|
|
||||||
if (Frequency >= frequencyBandTable[band].lower)
|
if (Frequency >= frequencyBandTable[band].lower)
|
||||||
// if (Frequency < frequencyBandTable[band].upper)
|
// if (Frequency < frequencyBandTable[band].upper)
|
||||||
return (FREQUENCY_Band_t)band;
|
return (FREQUENCY_Band_t)band;
|
||||||
@@ -129,7 +129,7 @@ uint32_t FREQUENCY_RoundToStep(uint32_t freq, uint16_t step)
|
|||||||
return (freq + (step + 1) / 2) / step * step;
|
return (freq + (step + 1) / 2) / step * step;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TX_freq_check(const uint32_t Frequency)
|
int32_t TX_freq_check(const uint32_t Frequency)
|
||||||
{ // return '0' if TX frequency is allowed
|
{ // return '0' if TX frequency is allowed
|
||||||
// otherwise return '-1'
|
// otherwise return '-1'
|
||||||
|
|
||||||
@@ -206,7 +206,7 @@ int TX_freq_check(const uint32_t Frequency)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RX_freq_check(const uint32_t Frequency)
|
int32_t RX_freq_check(const uint32_t Frequency)
|
||||||
{ // return '0' if RX frequency is allowed
|
{ // return '0' if RX frequency is allowed
|
||||||
// otherwise return '-1'
|
// otherwise return '-1'
|
||||||
|
|
||||||
|
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#define _1GHz_in_KHz 100000000
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const uint32_t lower;
|
const uint32_t lower;
|
||||||
const uint32_t upper;
|
const uint32_t upper;
|
||||||
@@ -37,7 +39,8 @@ typedef enum {
|
|||||||
BAND4_174MHz,
|
BAND4_174MHz,
|
||||||
BAND5_350MHz,
|
BAND5_350MHz,
|
||||||
BAND6_400MHz,
|
BAND6_400MHz,
|
||||||
BAND7_470MHz
|
BAND7_470MHz,
|
||||||
|
BAND_LAST_ELEMENT //keep this guard as last element
|
||||||
} FREQUENCY_Band_t;
|
} FREQUENCY_Band_t;
|
||||||
|
|
||||||
|
|
||||||
@@ -76,10 +79,10 @@ FREQUENCY_Band_t FREQUENCY_GetBand(uint32_t Frequency);
|
|||||||
uint8_t FREQUENCY_CalculateOutputPower(uint8_t TxpLow, uint8_t TxpMid, uint8_t TxpHigh, int32_t LowerLimit, int32_t Middle, int32_t UpperLimit, int32_t Frequency);
|
uint8_t FREQUENCY_CalculateOutputPower(uint8_t TxpLow, uint8_t TxpMid, uint8_t TxpHigh, int32_t LowerLimit, int32_t Middle, int32_t UpperLimit, int32_t Frequency);
|
||||||
uint32_t FREQUENCY_RoundToStep(uint32_t freq, uint16_t step);
|
uint32_t FREQUENCY_RoundToStep(uint32_t freq, uint16_t step);
|
||||||
|
|
||||||
uint8_t FREQUENCY_GetStepIdxFromSortedIdx(uint8_t sortedIdx);
|
STEP_Setting_t FREQUENCY_GetStepIdxFromSortedIdx(uint8_t sortedIdx);
|
||||||
uint8_t FREQUENCY_GetSortedIdxFromStepIdx(uint8_t step);
|
uint32_t FREQUENCY_GetSortedIdxFromStepIdx(uint8_t step);
|
||||||
|
|
||||||
int TX_freq_check(const uint32_t Frequency);
|
int32_t TX_freq_check(const uint32_t Frequency);
|
||||||
int RX_freq_check(const uint32_t Frequency);
|
int32_t RX_freq_check(const uint32_t Frequency);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
5
radio.c
5
radio.c
@@ -352,8 +352,9 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
|
|||||||
else
|
else
|
||||||
pVfo->freq_config_RX.Frequency = info.Frequency;
|
pVfo->freq_config_RX.Frequency = info.Frequency;
|
||||||
|
|
||||||
if (info.Offset >= 100000000)
|
if (info.Offset >= _1GHz_in_KHz)
|
||||||
info.Offset = 1000000;
|
info.Offset = _1GHz_in_KHz / 100;
|
||||||
|
|
||||||
pVfo->TX_OFFSET_FREQUENCY = info.Offset;
|
pVfo->TX_OFFSET_FREQUENCY = info.Offset;
|
||||||
|
|
||||||
// ***************
|
// ***************
|
||||||
|
29
settings.c
29
settings.c
@@ -609,29 +609,32 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO,
|
|||||||
if (Mode >= 2 || !IS_MR_CHANNEL(Channel))
|
if (Mode >= 2 || !IS_MR_CHANNEL(Channel))
|
||||||
{ // copy VFO to a channel
|
{ // copy VFO to a channel
|
||||||
|
|
||||||
uint8_t State[8];
|
union {
|
||||||
|
uint8_t _8[8];
|
||||||
|
uint32_t _32[2];
|
||||||
|
} State;
|
||||||
|
|
||||||
((uint32_t *)State)[0] = pVFO->freq_config_RX.Frequency;
|
State._32[0] = pVFO->freq_config_RX.Frequency;
|
||||||
((uint32_t *)State)[1] = pVFO->TX_OFFSET_FREQUENCY;
|
State._32[1] = pVFO->TX_OFFSET_FREQUENCY;
|
||||||
EEPROM_WriteBuffer(OffsetVFO + 0, State);
|
EEPROM_WriteBuffer(OffsetVFO + 0, State._32);
|
||||||
|
|
||||||
State[0] = pVFO->freq_config_RX.Code;
|
State._8[0] = pVFO->freq_config_RX.Code;
|
||||||
State[1] = pVFO->freq_config_TX.Code;
|
State._8[1] = pVFO->freq_config_TX.Code;
|
||||||
State[2] = (pVFO->freq_config_TX.CodeType << 4) | pVFO->freq_config_RX.CodeType;
|
State._8[2] = (pVFO->freq_config_TX.CodeType << 4) | pVFO->freq_config_RX.CodeType;
|
||||||
State[3] = (pVFO->Modulation << 4) | pVFO->TX_OFFSET_FREQUENCY_DIRECTION;
|
State._8[3] = (pVFO->Modulation << 4) | pVFO->TX_OFFSET_FREQUENCY_DIRECTION;
|
||||||
State[4] = 0
|
State._8[4] = 0
|
||||||
| (pVFO->BUSY_CHANNEL_LOCK << 4)
|
| (pVFO->BUSY_CHANNEL_LOCK << 4)
|
||||||
| (pVFO->OUTPUT_POWER << 2)
|
| (pVFO->OUTPUT_POWER << 2)
|
||||||
| (pVFO->CHANNEL_BANDWIDTH << 1)
|
| (pVFO->CHANNEL_BANDWIDTH << 1)
|
||||||
| (pVFO->FrequencyReverse << 0);
|
| (pVFO->FrequencyReverse << 0);
|
||||||
State[5] = ((pVFO->DTMF_PTT_ID_TX_MODE & 7u) << 1)
|
State._8[5] = ((pVFO->DTMF_PTT_ID_TX_MODE & 7u) << 1)
|
||||||
#ifdef ENABLE_DTMF_CALLING
|
#ifdef ENABLE_DTMF_CALLING
|
||||||
| ((pVFO->DTMF_DECODING_ENABLE & 1u) << 0)
|
| ((pVFO->DTMF_DECODING_ENABLE & 1u) << 0)
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
State[6] = pVFO->STEP_SETTING;
|
State._8[6] = pVFO->STEP_SETTING;
|
||||||
State[7] = pVFO->SCRAMBLING_TYPE;
|
State._8[7] = pVFO->SCRAMBLING_TYPE;
|
||||||
EEPROM_WriteBuffer(OffsetVFO + 8, State);
|
EEPROM_WriteBuffer(OffsetVFO + 8, State._8);
|
||||||
|
|
||||||
SETTINGS_UpdateChannel(Channel, pVFO, true);
|
SETTINGS_UpdateChannel(Channel, pVFO, true);
|
||||||
|
|
||||||
|
@@ -459,7 +459,7 @@ void UI_DisplayMain(void)
|
|||||||
{ // frequency mode
|
{ // frequency mode
|
||||||
// show the frequency band number
|
// show the frequency band number
|
||||||
const unsigned int x = 2;
|
const unsigned int x = 2;
|
||||||
char * buf = gEeprom.VfoInfo[vfo_num].pRX->Frequency < 100000000 ? "" : "+";
|
char * buf = gEeprom.VfoInfo[vfo_num].pRX->Frequency < _1GHz_in_KHz ? "" : "+";
|
||||||
sprintf(String, "F%u%s", 1 + gEeprom.ScreenChannel[vfo_num] - FREQ_CHANNEL_FIRST, buf);
|
sprintf(String, "F%u%s", 1 + gEeprom.ScreenChannel[vfo_num] - FREQ_CHANNEL_FIRST, buf);
|
||||||
UI_PrintStringSmall(String, x, 0, line + 1);
|
UI_PrintStringSmall(String, x, 0, line + 1);
|
||||||
}
|
}
|
||||||
@@ -500,7 +500,7 @@ void UI_DisplayMain(void)
|
|||||||
else if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_VFO == vfo_num)
|
else if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_VFO == vfo_num)
|
||||||
{ // user entering a frequency
|
{ // user entering a frequency
|
||||||
const char * ascii = INPUTBOX_GetAscii();
|
const char * ascii = INPUTBOX_GetAscii();
|
||||||
bool isGigaF = frequency>=100000000;
|
bool isGigaF = frequency>=_1GHz_in_KHz;
|
||||||
sprintf(String, "%.*s.%.3s", 3 + isGigaF, ascii, ascii + 3 + isGigaF);
|
sprintf(String, "%.*s.%.3s", 3 + isGigaF, ascii, ascii + 3 + isGigaF);
|
||||||
#ifdef ENABLE_BIG_FREQ
|
#ifdef ENABLE_BIG_FREQ
|
||||||
if(!isGigaF) {
|
if(!isGigaF) {
|
||||||
@@ -550,7 +550,7 @@ void UI_DisplayMain(void)
|
|||||||
case MDF_FREQUENCY: // show the channel frequency
|
case MDF_FREQUENCY: // show the channel frequency
|
||||||
sprintf(String, "%3u.%05u", frequency / 100000, frequency % 100000);
|
sprintf(String, "%3u.%05u", frequency / 100000, frequency % 100000);
|
||||||
#ifdef ENABLE_BIG_FREQ
|
#ifdef ENABLE_BIG_FREQ
|
||||||
if(frequency < 100000000) {
|
if(frequency < _1GHz_in_KHz) {
|
||||||
// show the remaining 2 small frequency digits
|
// show the remaining 2 small frequency digits
|
||||||
UI_PrintStringSmall(String + 7, 113, 0, line + 1);
|
UI_PrintStringSmall(String + 7, 113, 0, line + 1);
|
||||||
String[7] = 0;
|
String[7] = 0;
|
||||||
@@ -602,7 +602,7 @@ void UI_DisplayMain(void)
|
|||||||
sprintf(String, "%3u.%05u", frequency / 100000, frequency % 100000);
|
sprintf(String, "%3u.%05u", frequency / 100000, frequency % 100000);
|
||||||
|
|
||||||
#ifdef ENABLE_BIG_FREQ
|
#ifdef ENABLE_BIG_FREQ
|
||||||
if(frequency < 100000000) {
|
if(frequency < _1GHz_in_KHz) {
|
||||||
// show the remaining 2 small frequency digits
|
// show the remaining 2 small frequency digits
|
||||||
UI_PrintStringSmall(String + 7, 113, 0, line + 1);
|
UI_PrintStringSmall(String + 7, 113, 0, line + 1);
|
||||||
String[7] = 0;
|
String[7] = 0;
|
||||||
|
Reference in New Issue
Block a user