Merge branch 'feature_update_v4' into REGA

This commit is contained in:
Armel FAUVEAU
2025-02-12 02:43:31 +01:00
committed by GitHub
30 changed files with 350 additions and 128 deletions

View File

@@ -114,6 +114,11 @@ void (*action_opt_table[])(void) = {
[ACTION_OPT_PTT] = &ACTION_Ptt,
[ACTION_OPT_WN] = &ACTION_Wn,
[ACTION_OPT_BACKLIGHT] = &ACTION_BackLight,
#if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO)
[ACTION_OPT_MUTE] = &ACTION_Mute,
#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,
@@ -632,6 +637,27 @@ void ACTION_BackLightOnDemand(void)
BACKLIGHT_TurnOn();
}
#if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO)
void ACTION_Mute(void)
{
// Toggle mute state
gMute = !gMute;
// Update the registers
#ifdef ENABLE_FMRADIO
BK1080_WriteRegister(BK1080_REG_05_SYSTEM_CONFIGURATION2, gMute ? 0x0A10 : 0x0A1F);
#endif
gEeprom.VOLUME_GAIN = gMute ? 0 : gEeprom.VOLUME_GAIN_BACKUP;
BK4819_WriteRegister(BK4819_REG_48,
(11u << 12) | // ??? .. 0 ~ 15, doesn't seem to make any difference
(0u << 10) | // AF Rx Gain-1
(gEeprom.VOLUME_GAIN << 4) | // AF Rx Gain-2
(gEeprom.DAC_GAIN << 0)); // AF DAC Gain (after Gain-1 and Gain-2)
gUpdateStatus = true;
}
#endif
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
void ACTION_Power_High(void)
{

View File

@@ -42,6 +42,9 @@ void ACTION_SwitchDemodul(void);
void ACTION_Wn(void);
void ACTION_BackLightOnDemand(void);
void ACTION_BackLight(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);

View File

@@ -103,7 +103,6 @@ static_assert(ARRAY_SIZE(ProcessKeysFunctions) == DISPLAY_N_ELEM-1);
static_assert(ARRAY_SIZE(ProcessKeysFunctions) == DISPLAY_N_ELEM);
#endif
static void CheckForIncoming(void)
{
if (!g_SquelchLost)

View File

@@ -78,6 +78,7 @@ void CHFRSCANNER_Start(const bool storeBackupSettings, const int8_t scan_directi
gScanPauseMode = false;
}
/*
void CHFRSCANNER_ContinueScanning(void)
{
if (IS_FREQ_CHANNEL(gNextMrChannel))
@@ -99,6 +100,24 @@ void CHFRSCANNER_ContinueScanning(void)
gRxReceptionMode = RX_MODE_NONE;
gScheduleScanListen = false;
}
*/
void CHFRSCANNER_ContinueScanning(void)
{
if (gCurrentFunction == FUNCTION_INCOMING &&
(IS_FREQ_CHANNEL(gNextMrChannel) || gCurrentCodeType == CODE_TYPE_OFF))
{
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE);
}
else
{
IS_FREQ_CHANNEL(gNextMrChannel) ? NextFreqChannel() : NextMemChannel();
}
gScanPauseMode = false;
gRxReceptionMode = RX_MODE_NONE;
gScheduleScanListen = false;
}
void CHFRSCANNER_Found(void)
{

View File

@@ -363,6 +363,7 @@ void channelMoveSwitch(void) {
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) { // user is entering channel number
uint16_t Channel = 0;
/*
switch (gInputBoxIndex)
{
case 1:
@@ -375,6 +376,11 @@ void channelMoveSwitch(void) {
Channel = (gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2];
break;
}
*/
for (uint8_t i = 0; i < gInputBoxIndex; i++) {
Channel = (Channel * 10) + gInputBox[i];
}
if ((Channel == 0) && (gInputBoxIndex != 3)) {
return;

View File

@@ -1567,6 +1567,7 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
Offset = (Max >= 100) ? 3 : (Max >= 10) ? 2 : 1;
/*
switch (gInputBoxIndex)
{
case 1:
@@ -1579,6 +1580,11 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
Value = (gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2];
break;
}
*/
for (uint8_t i = 0; i < gInputBoxIndex; i++) {
Value = (Value * 10) + gInputBox[i];
}
if (Offset == gInputBoxIndex)
gInputBoxIndex = 0;
@@ -1937,8 +1943,8 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
VFO = 2;
break;
case MENU_SLIST1:
VFO = 1;
bCheckScanList = true;
VFO = 1;
break;
default:

View File

@@ -870,13 +870,20 @@ uint8_t Rssi2Y(uint16_t rssi)
#ifdef ENABLE_FEAT_F4HWN_SPECTRUM
static void DrawSpectrum()
{
uint16_t steps = GetStepsCount();
// max bars at 128 to correctly draw larger numbers of samples
uint8_t bars = (steps > 128) ? 128 : steps;
// shift to center bar on freq marker
uint8_t shift_graph = 64 / steps + 1;
uint8_t ox = 0;
for (uint8_t i = 0; i < 128; ++i)
{
uint16_t rssi = rssiHistory[i >> settings.stepsCount];
if (rssi != RSSI_MAX_VALUE)
{
uint8_t x = i * 128 / GetStepsCount();
// stretch bars to fill the screen width
uint8_t x = i * 128 / bars + shift_graph;
for (uint8_t xx = ox; xx < x; xx++)
{
DrawVLine(Rssi2Y(rssi), DrawingEndY, xx, true);

View File

@@ -210,29 +210,26 @@ static void SendVersion(void)
SendReply(&Reply, sizeof(Reply));
}
#ifndef ENABLE_FEAT_F4HWN
static bool IsBadChallenge(const uint32_t *pKey, const uint32_t *pIn, const uint32_t *pResponse)
{
#ifdef ENABLE_FEAT_F4HWN
UNUSED(pKey);
UNUSED(pIn);
UNUSED(pResponse);
#else
unsigned int i;
uint32_t IV[4];
unsigned int i;
uint32_t IV[4];
IV[0] = 0;
IV[1] = 0;
IV[2] = 0;
IV[3] = 0;
IV[0] = 0;
IV[1] = 0;
IV[2] = 0;
IV[3] = 0;
AES_Encrypt(pKey, IV, pIn, IV, true);
AES_Encrypt(pKey, IV, pIn, IV, true);
for (i = 0; i < 4; i++)
if (IV[i] != pResponse[i])
return true;
for (i = 0; i < 4; i++)
if (IV[i] != pResponse[i])
return true;
#endif
return false;
}
#endif
// session init, sends back version info and state
// timestamp is a session id really
@@ -360,6 +357,7 @@ static void CMD_0529(void)
SendReply(&Reply, sizeof(Reply));
}
#ifndef ENABLE_FEAT_F4HWN
static void CMD_052D(const uint8_t *pBuffer)
{
const CMD_052D_t *pCmd = (const CMD_052D_t *)pBuffer;
@@ -400,6 +398,7 @@ static void CMD_052D(const uint8_t *pBuffer)
SendReply(&Reply, sizeof(Reply));
}
#endif
// session init, sends back version info and state
// timestamp is a session id really
@@ -600,10 +599,12 @@ void UART_HandleCommand(void)
case 0x0529:
CMD_0529();
break;
case 0x052D:
CMD_052D(UART_Command.Buffer);
break;
#ifndef ENABLE_FEAT_F4HWN
case 0x052D:
CMD_052D(UART_Command.Buffer);
break;
#endif
case 0x052F:
CMD_052F(UART_Command.Buffer);