Do some stuff
All checks were successful
Build Firmware / build (push) Successful in 2m19s

This commit is contained in:
2025-03-28 22:07:50 +01:00
parent 4fe99744e1
commit 85fb527020
23 changed files with 258 additions and 658 deletions

View File

@@ -43,6 +43,7 @@
#include "ui/inputbox.h"
#include "ui/ui.h"
#include "driver/st7565.h"
#include "ui/menu.h"
#ifdef ENABLE_REGA
#include "app/rega.h"
@@ -128,10 +129,8 @@ void (*action_opt_table[])(void) = {
#else
[ACTION_OPT_MUTE] = &FUNCTION_NOP,
#endif
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
[ACTION_OPT_POWER_HIGH] = &ACTION_Power_High,
[ACTION_OPT_REMOVE_OFFSET] = &ACTION_Remove_Offset,
#endif
#else
[ACTION_OPT_RXMODE] = &FUNCTION_NOP,
#endif
@@ -145,8 +144,9 @@ static_assert(ARRAY_SIZE(action_opt_table) == ACTION_OPT_LEN);
void ACTION_Power(void)
{
if (++gTxVfo->OUTPUT_POWER > OUTPUT_POWER_HIGH)
gTxVfo->OUTPUT_POWER = OUTPUT_POWER_LOW1;
gTxVfo->OUTPUT_POWER++;
if (gTxVfo->OUTPUT_POWER >= ARRAY_SIZE(gSubMenu_TXP))
gTxVfo->OUTPUT_POWER = 0;
gRequestSaveChannel = 1;
@@ -561,40 +561,12 @@ void ACTION_Ptt(void)
void ACTION_Wn(void)
{
#ifdef ENABLE_FEAT_F4HWN_NARROWER
bool narrower = 0;
if (FUNCTION_IsRx())
{
gRxVfo->CHANNEL_BANDWIDTH = (gRxVfo->CHANNEL_BANDWIDTH == 0) ? 1: 0;
if(gRxVfo->CHANNEL_BANDWIDTH == BANDWIDTH_NARROW && gSetting_set_nfm == 1)
{
narrower = 1;
gRxVfo->CHANNEL_BANDWIDTH++;
if (gRxVfo->CHANNEL_BANDWIDTH > BK4819_FILTER_BW_NARROWER) {
gRxVfo->CHANNEL_BANDWIDTH = BK4819_FILTER_BW_WIDE;
}
#ifdef ENABLE_AM_FIX
BK4819_SetFilterBandwidth(gRxVfo->CHANNEL_BANDWIDTH + narrower, true);
#else
BK4819_SetFilterBandwidth(gRxVfo->CHANNEL_BANDWIDTH + narrower, false);
#endif
}
else
{
gTxVfo->CHANNEL_BANDWIDTH = (gTxVfo->CHANNEL_BANDWIDTH == 0) ? 1: 0;
if(gTxVfo->CHANNEL_BANDWIDTH == BANDWIDTH_NARROW && gSetting_set_nfm == 1)
{
narrower = 1;
}
#ifdef ENABLE_AM_FIX
BK4819_SetFilterBandwidth(gTxVfo->CHANNEL_BANDWIDTH, true);
#else
BK4819_SetFilterBandwidth(gTxVfo->CHANNEL_BANDWIDTH, false);
#endif
}
#else
if (FUNCTION_IsRx())
{
gRxVfo->CHANNEL_BANDWIDTH = (gRxVfo->CHANNEL_BANDWIDTH == 0) ? 1: 0;
#ifdef ENABLE_AM_FIX
BK4819_SetFilterBandwidth(gRxVfo->CHANNEL_BANDWIDTH, true);
#else
@@ -603,14 +575,16 @@ void ACTION_Wn(void)
}
else
{
gTxVfo->CHANNEL_BANDWIDTH = (gTxVfo->CHANNEL_BANDWIDTH == 0) ? 1: 0;
gRxVfo->CHANNEL_BANDWIDTH++;
if (gRxVfo->CHANNEL_BANDWIDTH > BK4819_FILTER_BW_NARROWER) {
gRxVfo->CHANNEL_BANDWIDTH = BK4819_FILTER_BW_WIDE;
}
#ifdef ENABLE_AM_FIX
BK4819_SetFilterBandwidth(gTxVfo->CHANNEL_BANDWIDTH, true);
#else
BK4819_SetFilterBandwidth(gTxVfo->CHANNEL_BANDWIDTH, false);
#endif
}
#endif
}
void ACTION_BackLight(void)
@@ -667,7 +641,6 @@ void ACTION_BackLightOnDemand(void)
}
#endif
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
void ACTION_Power_High(void)
{
gPowerHigh = !gPowerHigh;
@@ -679,5 +652,4 @@ void ACTION_BackLightOnDemand(void)
gRemoveOffset = !gRemoveOffset;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
}
#endif
#endif

View File

@@ -45,10 +45,8 @@ void ACTION_SwitchDemodul(void);
#if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO)
void ACTION_Mute(void);
#endif
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
void ACTION_Power_High(void);
void ACTION_Remove_Offset(void);
#endif
#endif
void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld);

View File

@@ -850,43 +850,6 @@ void APP_Update(void) {
}
#endif
#ifdef ENABLE_FEAT_F4HWN
if (gCurrentFunction == FUNCTION_TRANSMIT && (gTxTimeoutReachedAlert || SerialConfigInProgress())) {
if (gSetting_set_tot >= 2) {
if (gEeprom.BACKLIGHT_TIME == 0) {
if (gBlinkCounter == 0 || gBlinkCounter == 250) {
GPIO_FlipBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
}
} else {
if (gBlinkCounter == 0) {
//BACKLIGHT_TurnOn();
BACKLIGHT_SetBrightness(gEeprom.BACKLIGHT_MAX);
} else if (gBlinkCounter == 15000) {
//BACKLIGHT_TurnOff();
BACKLIGHT_SetBrightness(gEeprom.BACKLIGHT_MIN);
}
}
}
gBlinkCounter++;
if (
(gSetting_set_tot == 3 && gEeprom.BACKLIGHT_TIME != 0 && gBlinkCounter > 74000) ||
(gSetting_set_tot == 3 && gEeprom.BACKLIGHT_TIME == 0 && gBlinkCounter > 79000) ||
(gSetting_set_tot != 3 && gBlinkCounter > 76000)
) // try to calibrate 10 times
{
gBlinkCounter = 0;
if (gSetting_set_tot == 1 || gSetting_set_tot == 3) {
BK4819_DisableScramble();
BK4819_PlaySingleTone(gTxTimeoutToneAlert, 30, 1, true);
gTxTimeoutToneAlert += 100;
}
}
}
#endif
if (gCurrentFunction == FUNCTION_TRANSMIT &&
(gTxTimeoutReached || SerialConfigInProgress())) { // transmitter timed out or must de-key
gTxTimeoutReached = false;
@@ -1310,11 +1273,9 @@ void APP_TimeSlice10ms(void) {
return;
#endif
#if !defined(ENABLE_FEAT_F4HWN) || defined(ENABLE_FEAT_F4HWN_RESCUE_OPS)
#ifdef ENABLE_FLASHLIGHT
FlashlightTimeSlice();
#endif
#endif
#ifdef ENABLE_VOX
if (gVoxResumeCountdown > 0)
@@ -1932,10 +1893,7 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) {
BK4819_ExitDTMF_TX(false);
if (gCurrentVfo->SCRAMBLING_TYPE == 0)
BK4819_DisableScramble();
else
BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1);
BK4819_SetScramble(gCurrentVfo->SCRAMBLING_TYPE);
}
} else {
@@ -1944,7 +1902,7 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) {
gEnableSpeaker = true;
}
BK4819_DisableScramble();
BK4819_SetScramble(0);
if (Code == 0xFE)
BK4819_TransmitTone(gEeprom.DTMF_SIDE_TONE, 1750);

View File

@@ -5,79 +5,60 @@
#include "flashlight.h"
#if !defined(ENABLE_FEAT_F4HWN) || defined(ENABLE_FEAT_F4HWN_RESCUE_OPS)
enum FlashlightMode_t gFlashLightState;
enum FlashlightMode_t gFlashLightState;
void FlashlightTimeSlice()
{
if (gFlashLightState == FLASHLIGHT_BLINK && (gFlashLightBlinkCounter & 15u) == 0) {
GPIO_FlipBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
void FlashlightTimeSlice() {
if (gFlashLightState == FLASHLIGHT_BLINK && (gFlashLightBlinkCounter & 15u) == 0) {
GPIO_FlipBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
return;
}
if (gFlashLightState == FLASHLIGHT_SOS) {
const uint16_t u = 15;
static uint8_t c;
static uint16_t next;
if (gFlashLightBlinkCounter - next > 7 * u) {
c = 0;
next = gFlashLightBlinkCounter + 1;
return;
}
if (gFlashLightState == FLASHLIGHT_SOS) {
const uint16_t u = 15;
static uint8_t c;
static uint16_t next;
if (gFlashLightBlinkCounter - next > 7 * u) {
c = 0;
next = gFlashLightBlinkCounter + 1;
return;
}
if (gFlashLightBlinkCounter == next) {
if (c==0) {
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
} else {
GPIO_FlipBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
}
if (c >= 18) {
next = gFlashLightBlinkCounter + 7 * u;
c = 0;
} else if(c==7 || c==9 || c==11) {
next = gFlashLightBlinkCounter + 3 * u;
} else {
next = gFlashLightBlinkCounter + u;
}
c++;
}
}
}
void ACTION_FlashLight(void)
{
switch (gFlashLightState) {
case FLASHLIGHT_OFF:
gFlashLightState++;
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
break;
case FLASHLIGHT_ON:
case FLASHLIGHT_BLINK:
gFlashLightState++;
break;
case FLASHLIGHT_SOS:
default:
gFlashLightState = 0;
if (gFlashLightBlinkCounter == next) {
if (c == 0) {
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
} else {
GPIO_FlipBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
}
if (c >= 18) {
next = gFlashLightBlinkCounter + 7 * u;
c = 0;
} else if (c == 7 || c == 9 || c == 11) {
next = gFlashLightBlinkCounter + 3 * u;
} else {
next = gFlashLightBlinkCounter + u;
}
c++;
}
}
#else
void ACTION_FlashLight(void)
{
static bool gFlashLightState = false;
}
if(gFlashLightState)
{
void ACTION_FlashLight(void) {
switch (gFlashLightState) {
case FLASHLIGHT_OFF:
gFlashLightState++;
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
break;
case FLASHLIGHT_ON:
case FLASHLIGHT_BLINK:
gFlashLightState++;
break;
case FLASHLIGHT_SOS:
default:
gFlashLightState = 0;
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
}
else
{
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
}
gFlashLightState = (gFlashLightState) ? false : true;
}
#endif
#endif
}
#endif

View File

@@ -5,7 +5,6 @@
#include <stdint.h>
#if !defined(ENABLE_FEAT_F4HWN) || defined(ENABLE_FEAT_F4HWN_RESCUE_OPS)
enum FlashlightMode_t {
FLASHLIGHT_OFF = 0,
FLASHLIGHT_ON,
@@ -17,7 +16,6 @@
extern volatile uint16_t gFlashLightBlinkCounter;
void FlashlightTimeSlice(void);
#endif
void ACTION_FlashLight(void);
#endif

View File

@@ -270,7 +270,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) {
break;
case KEY_8:
gTxVfo->FrequencyReverse = gTxVfo->FrequencyReverse == false;
gTxVfo->FrequencyReverse = !gTxVfo->FrequencyReverse;
gRequestSaveChannel = 1;
break;
@@ -360,10 +360,8 @@ void channelMove(uint16_t Channel) {
//gRequestSaveVFO = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
gRemoveOffset = false;
gPowerHigh = false;
#endif
RADIO_ConfigureChannel(gEeprom.TX_VFO, gVfoConfigureMode);
@@ -825,10 +823,8 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
}
#endif
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
gRemoveOffset = false;
gPowerHigh = false;
#endif
uint8_t Channel = gEeprom.ScreenChannel[gEeprom.TX_VFO];
@@ -970,10 +966,7 @@ void MAIN_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) {
if (VfoState[vfo] == VFO_STATE_NORMAL && !TX_freq_check(gCurrentVfo->freq_config_TX.Frequency)) {
RADIO_PrepareTX();
if (gCurrentVfo->SCRAMBLING_TYPE > 0)
BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1);
else
BK4819_DisableScramble();
BK4819_SetScramble(gCurrentVfo->SCRAMBLING_TYPE);
BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, true);
MSG_FSKSendData(&dataPacket);
BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, false);

View File

@@ -121,6 +121,11 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) {
*pMax = 9;
break;
case MENU_TOT:
*pMin = 0;
*pMax = 179;
break;
case MENU_STEP:
//*pMin = 0;
*pMax = STEP_N_ELEM - 1;
@@ -259,7 +264,7 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) {
case MENU_SCR:
//*pMin = 0;
*pMax = 10;
*pMax = 65535;
break;
case MENU_AUTOLK:
@@ -271,11 +276,6 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) {
*pMin = 0;
break;
case MENU_TOT:
//*pMin = 0;
*pMin = 5;
*pMax = 179;
break;
#ifdef ENABLE_VOX
case MENU_VOX:
@@ -385,35 +385,18 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) {
//*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_SET_PTT) - 1;
break;
case MENU_SET_TOT:
case MENU_SET_EOT:
//*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_SET_TOT) - 1;
break;
#ifdef ENABLE_FEAT_F4HWN_INV
case MENU_SET_INV:
//*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_OFF_ON) - 1;
break;
#endif
#ifdef ENABLE_FEAT_F4HWN_NARROWER
case MENU_SET_NFM:
//*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_SET_NFM) - 1;
break;
#endif
#ifdef ENABLE_FEAT_F4HWN_VOL
case MENU_SET_VOL:
//*pMin = 0;
*pMax = 63;
break;
#endif
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
case MENU_SET_KEY:
//*pMin = 0;
*pMax = 4;
break;
#endif
#endif
default:
@@ -512,10 +495,7 @@ void MENU_AcceptSetting(void) {
case MENU_SCR:
gTxVfo->SCRAMBLING_TYPE = gSubMenuSelection;
if (gSubMenuSelection > 0)
BK4819_EnableScramble(gSubMenuSelection - 1);
else
BK4819_DisableScramble();
BK4819_SetScramble(gSubMenuSelection);
gRequestSaveChannel = 1;
return;
@@ -524,6 +504,10 @@ void MENU_AcceptSetting(void) {
gRequestSaveChannel = 1;
return;
case MENU_TOT:
gEeprom.TX_TIMEOUT_TIMER = gSubMenuSelection;
break;
case MENU_MEM_CH:
gTxVfo->CHANNEL_SAVE = gSubMenuSelection;
#if 0
@@ -600,10 +584,6 @@ void MENU_AcceptSetting(void) {
gEeprom.BEEP_CONTROL = gSubMenuSelection;
break;
case MENU_TOT:
gEeprom.TX_TIMEOUT_TIMER = gSubMenuSelection;
break;
#ifdef ENABLE_VOICE
case MENU_VOICE:
gEeprom.VOICE_PROMPT = gSubMenuSelection;
@@ -843,31 +823,13 @@ void MENU_AcceptSetting(void) {
gSetting_set_ptt = gSubMenuSelection;
gSetting_set_ptt_session = gSetting_set_ptt; // Special for action
break;
case MENU_SET_TOT:
gSetting_set_tot = gSubMenuSelection;
break;
case MENU_SET_EOT:
gSetting_set_eot = gSubMenuSelection;
break;
case MENU_SET_INV:
gSetting_set_inv = gSubMenuSelection;
break;
#ifdef ENABLE_FEAT_F4HWN_NARROWER
case MENU_SET_NFM:
gSetting_set_nfm = gSubMenuSelection;
RADIO_SetTxParameters();
RADIO_SetupRegisters(true);
break;
#endif
#ifdef ENABLE_FEAT_F4HWN_VOL
case MENU_SET_VOL:
gEeprom.VOLUME_GAIN = gSubMenuSelection;
break;
#endif
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
case MENU_SET_KEY:
gEeprom.SET_KEY = gSubMenuSelection;
break;
#endif
case MENU_SET_TMR:
gSetting_set_tmr = gSubMenuSelection;
@@ -978,6 +940,10 @@ void MENU_ShowCurrentSetting(void) {
gSubMenuSelection = gTxVfo->BUSY_CHANNEL_LOCK;
break;
case MENU_TOT:
gSubMenuSelection = gEeprom.TX_TIMEOUT_TIMER;
break;
case MENU_MEM_CH:
#if 0
gSubMenuSelection = gEeprom.MrChannel[0];
@@ -1032,11 +998,6 @@ void MENU_ShowCurrentSetting(void) {
case MENU_BEEP:
gSubMenuSelection = gEeprom.BEEP_CONTROL;
break;
case MENU_TOT:
gSubMenuSelection = gEeprom.TX_TIMEOUT_TIMER;
break;
#ifdef ENABLE_VOICE
case MENU_VOICE:
gSubMenuSelection = gEeprom.VOICE_PROMPT;
@@ -1242,29 +1203,13 @@ void MENU_ShowCurrentSetting(void) {
case MENU_SET_PTT:
gSubMenuSelection = gSetting_set_ptt_session;
break;
case MENU_SET_TOT:
gSubMenuSelection = gSetting_set_tot;
break;
case MENU_SET_EOT:
gSubMenuSelection = gSetting_set_eot;
break;
case MENU_SET_INV:
gSubMenuSelection = gSetting_set_inv;
break;
#ifdef ENABLE_FEAT_F4HWN_NARROWER
case MENU_SET_NFM:
gSubMenuSelection = gSetting_set_nfm;
break;
#endif
#ifdef ENABLE_FEAT_F4HWN_VOL
case MENU_SET_VOL:
gSubMenuSelection = gEeprom.VOLUME_GAIN;
break;
#endif
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
case MENU_SET_KEY:
gSubMenuSelection = gEeprom.SET_KEY;
break;
#endif
case MENU_SET_TMR:
gSubMenuSelection = gSetting_set_tmr;
@@ -1400,7 +1345,15 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) {
return;
}
Offset = (Max >= 100) ? 3 : (Max >= 10) ? 2 : 1;
Offset = (Max >= 1000000000) ? 10 :
(Max >= 100000000) ? 9 :
(Max >= 10000000) ? 8 :
(Max >= 1000000) ? 7 :
(Max >= 100000) ? 6 :
(Max >= 10000) ? 5 :
(Max >= 1000) ? 4 :
(Max >= 100) ? 3 :
(Max >= 10) ? 2 : 1;
/*
switch (gInputBoxIndex)