Add Mute action

This commit is contained in:
Armel FAUVEAU
2025-01-24 03:54:26 +01:00
parent c27c02eaef
commit e35eac6835
11 changed files with 84 additions and 14 deletions

View File

@@ -111,6 +111,7 @@ void (*action_opt_table[])(void) = {
[ACTION_OPT_PTT] = &ACTION_Ptt,
[ACTION_OPT_WN] = &ACTION_Wn,
[ACTION_OPT_BACKLIGHT] = &ACTION_BackLight,
[ACTION_OPT_MUTE] = &ACTION_Mute,
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
[ACTION_OPT_POWER_HIGH] = &ACTION_Power_High,
[ACTION_OPT_REMOVE_OFFSET] = &ACTION_Remove_Offset,
@@ -625,6 +626,25 @@ void ACTION_BackLightOnDemand(void)
BACKLIGHT_TurnOn();
}
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;
}
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
void ACTION_Power_High(void)
{

View File

@@ -42,6 +42,7 @@ void ACTION_SwitchDemodul(void);
void ACTION_Wn(void);
void ACTION_BackLightOnDemand(void);
void ACTION_BackLight(void);
void ACTION_Mute(void);
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
void ACTION_Power_High(void);
void ACTION_Remove_Offset(void);

View File

@@ -57,6 +57,22 @@ const uint8_t gFontLight[9] =
0b00001100,
};
const uint8_t gFontSound[12] =
{
0b00011100,
0b00011100,
0b00010100,
0b00100010,
0b01000001,
0b01111111,
0b00000000,
0b00100010,
0b00010100,
0b00001000,
0b00010100,
0b00100010,
};
const uint8_t gFontXB[2][6] =
{ // "XB"
{0x00, 0x63, 0x14, 0x8, 0x14, 0x63},

View File

@@ -12,6 +12,7 @@ extern const uint8_t gFontS[6];
extern const uint8_t gFontKeyLock[9];
extern const uint8_t gFontLight[9];
extern const uint8_t gFontSound[12];
extern const uint8_t gFontXB[2][6];
extern const uint8_t gFontMO[2][6];

View File

@@ -68,7 +68,11 @@ void BK1080_Init(uint16_t freq, uint8_t band/*, uint8_t space*/)
BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, 0x0201);
}
BK1080_WriteRegister(BK1080_REG_05_SYSTEM_CONFIGURATION2, 0x0A1F);
#ifdef ENABLE_FEAT_F4HWN
BK1080_WriteRegister(BK1080_REG_05_SYSTEM_CONFIGURATION2, gMute ? 0x0A10 : 0x0A1F);
#else
BK1080_WriteRegister(BK1080_REG_05_SYSTEM_CONFIGURATION2, 0x0A1F);
#endif
BK1080_SetFrequency(freq, band/*, space*/);
}
else {

1
misc.c
View File

@@ -308,6 +308,7 @@ uint8_t gIsLocked = 0xFF;
#ifdef ENABLE_FEAT_F4HWN
bool gK5startup = true;
bool gBackLight = false;
bool gMute = false;
uint8_t gBacklightTimeOriginal;
uint8_t gBacklightBrightnessOld;
uint8_t gPttOnePushCounter = 0;

1
misc.h
View File

@@ -377,6 +377,7 @@ extern volatile uint8_t boot_counter_10ms;
#ifdef ENABLE_FEAT_F4HWN
extern bool gK5startup;
extern bool gBackLight;
extern bool gMute;
extern uint8_t gBacklightTimeOriginal;
extern uint8_t gBacklightBrightnessOld;
extern uint8_t gPttOnePushCounter;

View File

@@ -434,6 +434,10 @@ void SETTINGS_LoadCalibration(void)
gEeprom.VOLUME_GAIN = (Misc.VOLUME_GAIN < 64) ? Misc.VOLUME_GAIN : 58;
gEeprom.DAC_GAIN = (Misc.DAC_GAIN < 16) ? Misc.DAC_GAIN : 8;
#ifdef ENABLE_FEAT_F4HWN
gEeprom.VOLUME_GAIN_BACKUP = gEeprom.VOLUME_GAIN;
#endif
BK4819_WriteRegister(BK4819_REG_3B, 22656 + gEeprom.BK4819_XTAL_FREQ_LOW);
// BK4819_WriteRegister(BK4819_REG_3C, gEeprom.BK4819_XTAL_FREQ_HIGH);
}

View File

@@ -117,6 +117,7 @@ enum ACTION_OPT_t {
ACTION_OPT_PTT,
ACTION_OPT_WN,
ACTION_OPT_BACKLIGHT,
ACTION_OPT_MUTE,
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
ACTION_OPT_POWER_HIGH,
ACTION_OPT_REMOVE_OFFSET,
@@ -272,6 +273,9 @@ typedef struct {
bool NOAA_AUTO_SCAN;
#endif
uint8_t VOLUME_GAIN;
#ifdef ENABLE_FEAT_F4HWN
uint8_t VOLUME_GAIN_BACKUP;
#endif
uint8_t DAC_GAIN;
VFO_Info_t VfoInfo[2];

View File

@@ -451,6 +451,7 @@ const t_sidefunction gSubMenu_SIDEFUNCTIONS[] =
{"MAIN ONLY", ACTION_OPT_MAINONLY},
{"PTT", ACTION_OPT_PTT},
{"WIDE\nNARROW", ACTION_OPT_WN},
{"MUTE", ACTION_OPT_MUTE},
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
{"POWER\nHIGH", ACTION_OPT_POWER_HIGH},
{"REMOVE\nOFFSET", ACTION_OPT_REMOVE_OFFSET},

View File

@@ -212,30 +212,47 @@ void UI_DisplayStatus()
x = MAX(x1, 69u);
// KEY-LOCK indicator
const void *src = NULL; // Pointer to the font/bitmap to copy
size_t size = 0; // Size of the font/bitmap
// Determine the source and size based on conditions
if (gEeprom.KEY_LOCK) {
memcpy(line + x + 1, gFontKeyLock, sizeof(gFontKeyLock));
src = gFontKeyLock;
size = sizeof(gFontKeyLock);
}
else if (gWasFKeyPressed) {
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
if(gEeprom.MENU_LOCK == false) {
memcpy(line + x + 1, gFontF, sizeof(gFontF));
}
if (!gEeprom.MENU_LOCK) {
src = gFontF;
size = sizeof(gFontF);
}
#else
memcpy(line + x + 1, gFontF, sizeof(gFontF));
src = gFontF;
size = sizeof(gFontF);
#endif
}
else if (gBackLight)
{
memcpy(line + x + 1, gFontLight, sizeof(gFontLight));
#ifdef ENABLE_FEAT_F4HWN
else if (gMute) {
src = gFontSound;
size = sizeof(gFontSound);
}
#endif
else if (gBackLight) {
src = gFontLight;
size = sizeof(gFontLight);
}
#ifdef ENABLE_FEAT_F4HWN_CHARGING_C
else if (gChargingWithTypeC)
{
memcpy(line + x + 1, BITMAP_USB_C, sizeof(BITMAP_USB_C));
else if (gChargingWithTypeC) {
src = BITMAP_USB_C;
size = sizeof(BITMAP_USB_C);
}
#endif
// Perform the memcpy if a source was selected
if (src) {
memcpy(line + x + 1, src, size);
}
// Battery
unsigned int x2 = LCD_WIDTH - sizeof(BITMAP_BatteryLevel1) - 0;