0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-28 22:31:25 +03:00

RSSI/Mic bar update

This commit is contained in:
OneOfEleven 2023-09-29 09:58:32 +01:00
parent 604d42c766
commit 74b597a6ce
5 changed files with 93 additions and 63 deletions

View File

@ -27,7 +27,7 @@ ENABLE_AM_FIX := 1
ENABLE_AM_FIX_SHOW_DATA := 1 ENABLE_AM_FIX_SHOW_DATA := 1
ENABLE_SQUELCH1_LOWER := 0 ENABLE_SQUELCH1_LOWER := 0
ENABLE_RSSI_BAR := 1 ENABLE_RSSI_BAR := 1
ENABLE_AUDIO_BAR := 0 ENABLE_AUDIO_BAR := 1
#ENABLE_COPY_CHAN_TO_VFO := 1 #ENABLE_COPY_CHAN_TO_VFO := 1
#ENABLE_SINGLE_VFO_CHAN := 1 #ENABLE_SINGLE_VFO_CHAN := 1
#ENABLE_BAND_SCOPE := 1 #ENABLE_BAND_SCOPE := 1

View File

@ -114,7 +114,8 @@ static void APP_CheckForIncoming(void)
if (gCurrentFunction != FUNCTION_INCOMING) if (gCurrentFunction != FUNCTION_INCOMING)
{ {
FUNCTION_Select(FUNCTION_INCOMING); FUNCTION_Select(FUNCTION_INCOMING);
gUpdateDisplay = true; //gUpdateDisplay = true;
gUpdateRSSI = true;
} }
return; return;
@ -127,7 +128,8 @@ static void APP_CheckForIncoming(void)
if (gCurrentFunction != FUNCTION_INCOMING) if (gCurrentFunction != FUNCTION_INCOMING)
{ {
FUNCTION_Select(FUNCTION_INCOMING); FUNCTION_Select(FUNCTION_INCOMING);
gUpdateDisplay = true; //gUpdateDisplay = true;
gUpdateRSSI = true;
} }
return; return;
} }
@ -146,7 +148,8 @@ static void APP_CheckForIncoming(void)
if (gCurrentFunction != FUNCTION_INCOMING) if (gCurrentFunction != FUNCTION_INCOMING)
{ {
FUNCTION_Select(FUNCTION_INCOMING); FUNCTION_Select(FUNCTION_INCOMING);
gUpdateDisplay = true; //gUpdateDisplay = true;
gUpdateRSSI = true;
} }
return; return;
} }
@ -160,7 +163,8 @@ static void APP_CheckForIncoming(void)
if (gCurrentFunction != FUNCTION_INCOMING) if (gCurrentFunction != FUNCTION_INCOMING)
{ {
FUNCTION_Select(FUNCTION_INCOMING); FUNCTION_Select(FUNCTION_INCOMING);
gUpdateDisplay = true; //gUpdateDisplay = true;
gUpdateRSSI = true;
} }
} }
@ -937,7 +941,8 @@ static void APP_HandleVox(void)
{ {
if (gFlagEndTransmission) if (gFlagEndTransmission)
{ {
FUNCTION_Select(FUNCTION_FOREGROUND); //if (gCurrentFunction != FUNCTION_FOREGROUND)
FUNCTION_Select(FUNCTION_FOREGROUND);
} }
else else
{ {
@ -945,12 +950,14 @@ static void APP_HandleVox(void)
if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0) if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0)
{ {
FUNCTION_Select(FUNCTION_FOREGROUND); //if (gCurrentFunction != FUNCTION_FOREGROUND)
FUNCTION_Select(FUNCTION_FOREGROUND);
} }
else else
gRTTECountdown = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10; gRTTECountdown = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10;
} }
gUpdateStatus = true;
gUpdateDisplay = true; gUpdateDisplay = true;
gFlagEndTransmission = false; gFlagEndTransmission = false;
} }
@ -1128,7 +1135,8 @@ void APP_Update(void)
else else
if ((IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) && IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) || !gIsNoaaMode) if ((IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) && IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) || !gIsNoaaMode)
{ {
FUNCTION_Select(FUNCTION_POWER_SAVE); //if (gCurrentFunction != FUNCTION_POWER_SAVE)
FUNCTION_Select(FUNCTION_POWER_SAVE);
} }
else else
{ {
@ -1151,7 +1159,8 @@ void APP_Update(void)
} }
else else
{ {
FUNCTION_Select(FUNCTION_POWER_SAVE); //if (gCurrentFunction != FUNCTION_POWER_SAVE)
FUNCTION_Select(FUNCTION_POWER_SAVE);
} }
gSchedulePowerSave = false; gSchedulePowerSave = false;
@ -1490,8 +1499,10 @@ void APP_TimeSlice10ms(void)
{ {
if (--gRTTECountdown == 0) if (--gRTTECountdown == 0)
{ {
FUNCTION_Select(FUNCTION_FOREGROUND); //if (gCurrentFunction != FUNCTION_FOREGROUND)
FUNCTION_Select(FUNCTION_FOREGROUND);
gUpdateStatus = true;
gUpdateDisplay = true; gUpdateDisplay = true;
} }
} }
@ -1843,7 +1854,8 @@ void APP_TimeSlice500ms(void)
gReducedService = true; gReducedService = true;
FUNCTION_Select(FUNCTION_POWER_SAVE); //if (gCurrentFunction != FUNCTION_POWER_SAVE)
FUNCTION_Select(FUNCTION_POWER_SAVE);
ST7565_Configure_GPIO_B11(); ST7565_Configure_GPIO_B11();
@ -2203,7 +2215,10 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
ALARM_Off(); ALARM_Off();
if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0) if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0)
FUNCTION_Select(FUNCTION_FOREGROUND); {
//if (gCurrentFunction != FUNCTION_FOREGROUND)
FUNCTION_Select(FUNCTION_FOREGROUND);
}
else else
gRTTECountdown = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10; gRTTECountdown = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10;

Binary file not shown.

Binary file not shown.

101
ui/main.c
View File

@ -62,8 +62,10 @@
{ {
if (gSetting_mic_bar) if (gSetting_mic_bar)
{ {
const unsigned int line = 3; const unsigned int line = 3;
const unsigned int lcd_width = sizeof(gFrameBuffer[line]) - 2; const unsigned int bar_x = 2;
const unsigned int bar_width = LCD_WIDTH - 2 - bar_x;
unsigned int i;
#if 1 #if 1
// TX audio level // TX audio level
@ -74,34 +76,37 @@
const unsigned int voice_amp = BK4819_GetVoiceAmplitudeOut(); // 15:0 const unsigned int voice_amp = BK4819_GetVoiceAmplitudeOut(); // 15:0
// const unsigned int max = 65535; // const unsigned int max = 65535;
// const unsigned int level = ((voice_amp * lcd_width) + (max / 2)) / max; // with rounding // const unsigned int level = ((voice_amp * bar_width) + (max / 2)) / max; // with rounding
// const unsigned int len = (level <= lcd_width) ? level : lcd_width; // const unsigned int len = (level <= bar_width) ? level : bar_width;
// make non-linear to make more sensitive at low values // make non-linear to make more sensitive at low values
const unsigned int level = voice_amp * 8; const unsigned int level = voice_amp * 8;
const unsigned int sqrt_level = sqrt16((level < 65535) ? level : 65535); const unsigned int sqrt_level = sqrt16((level < 65535) ? level : 65535);
const unsigned int len = (sqrt_level <= lcd_width) ? sqrt_level : lcd_width; const unsigned int len = (sqrt_level <= bar_width) ? sqrt_level : bar_width;
#else #else
// TX/RX AF input level (dB) // TX/RX AF input level (dB)
const uint8_t af_tx_rx = BK4819_GetAfTxRx(); // 6:0 const uint8_t af_tx_rx = BK4819_GetAfTxRx(); // 6:0
const unsigned int max = 63; const unsigned int max = 63;
const unsigned int level = (((uint16_t)af_tx_rx * lcd_width) + (max / 2)) / max; // with rounding const unsigned int level = (((uint16_t)af_tx_rx * bar_width) + (max / 2)) / max; // with rounding
const unsigned int len = (level <= lcd_width) ? level : lcd_width; const unsigned int len = (level <= bar_width) ? level : bar_width;
#endif #endif
uint8_t *pLine = gFrameBuffer[line]; uint8_t *pLine = gFrameBuffer[line];
memset(pLine, 0, lcd_width);
#if 0
// solid bar
memset(pLine, 0x3e, len);
#else
for (unsigned int i = 0; i < len; i += 2)
pLine[i] = 0x3e;
#endif
memset(pLine, 0, LCD_WIDTH);
#if 1
// solid bar
for (i = 0; i < bar_width; i++)
pLine[bar_x + i] = (i <= len) ? 0x7f : ((i & 1) == 0) ? 0x41 : 0x00;
#else
// knuled bar
for (i = 0; i < bar_width; i += 2)
pLine[bar_x + i] = (i <= len) ? 0x7f : 0x41;
#endif
if (gCurrentFunction == FUNCTION_TRANSMIT) if (gCurrentFunction == FUNCTION_TRANSMIT)
ST7565_BlitFullScreen(); ST7565_BlitFullScreen();
@ -152,8 +157,15 @@
sprintf(s, "%-4d +%2u", dBm, s_level); // S9+ sprintf(s, "%-4d +%2u", dBm, s_level); // S9+
UI_PrintStringSmall(s, 2, 0, line); UI_PrintStringSmall(s, 2, 0, line);
for (i = 0; i < bar_width; i += 2) #if 1
pLine[bar_x + i] = ((i & 1) == 0 && i <= len) ? 0x7f : 0x41; // solid bar
for (i = 0; i < bar_width; i++)
pLine[bar_x + i] = (i <= len) ? 0x7f : ((i & 1) == 0) ? 0x41 : 0x00;
#else
// knuled bar
for (i = 0; i < bar_width; i += 2)
pLine[bar_x + i] = (i <= len) ? 0x7f : 0x41;
#endif
if (now) if (now)
ST7565_BlitFullScreen(); ST7565_BlitFullScreen();
@ -670,10 +682,13 @@ void UI_DisplayMain(void)
gCurrentFunction == FUNCTION_INCOMING); gCurrentFunction == FUNCTION_INCOMING);
#if defined(ENABLE_AM_FIX) && defined(ENABLE_AM_FIX_SHOW_DATA) #if defined(ENABLE_AM_FIX) && defined(ENABLE_AM_FIX_SHOW_DATA)
if (rx && gEeprom.VfoInfo[gEeprom.RX_CHANNEL].AM_mode && gSetting_AM_fix) if (gEeprom.VfoInfo[gEeprom.RX_CHANNEL].AM_mode && gSetting_AM_fix)
{ {
AM_fix_print_data(gEeprom.RX_CHANNEL, String); if (rx)
UI_PrintStringSmall(String, 0, 0, 3); {
AM_fix_print_data(gEeprom.RX_CHANNEL, String);
UI_PrintStringSmall(String, 0, 0, 3);
}
} }
else else
#endif #endif
@ -684,35 +699,35 @@ void UI_DisplayMain(void)
else else
#endif #endif
{ #ifdef ENABLE_AUDIO_BAR
#ifdef ENABLE_AUDIO_BAR if (gSetting_mic_bar && gCurrentFunction == FUNCTION_TRANSMIT)
UI_DisplayAudioBar(); UI_DisplayAudioBar();
else
#endif
// if (!gSetting_mic_bar) if (rx || gCurrentFunction == FUNCTION_FOREGROUND)
#endif {
if (rx || gCurrentFunction == FUNCTION_FOREGROUND) if (gSetting_live_DTMF_decoder && gDTMF_ReceivedSaved[0] >= 32)
{ { // show live DTMF decode
if (gSetting_live_DTMF_decoder && gDTMF_ReceivedSaved[0] >= 32) const unsigned int len = strlen(gDTMF_ReceivedSaved);
{ // show live DTMF decode unsigned int idx = 0;
const unsigned int len = strlen(gDTMF_ReceivedSaved); while ((len - idx) > (17 - 5)) // display the last 'n' on-screen fittable chars
unsigned int idx = 0; idx++;
while ((len - idx) > (17 - 5)) // display the last 'n' on-screen fittable chars strcpy(String, "DTMF ");
idx++; strcat(String, gDTMF_ReceivedSaved + idx);
strcpy(String, "DTMF "); UI_PrintStringSmall(String, 2, 0, 3);
strcat(String, gDTMF_ReceivedSaved + idx); }
UI_PrintStringSmall(String, 2, 0, 3);
} #ifdef ENABLE_SHOW_CHARGE_LEVEL
else else
if (gChargingWithTypeC) if (gChargingWithTypeC)
{ // charging .. show the battery state { // charging .. show the battery state
#ifdef ENABLE_SHOW_CHARGE_LEVEL const uint16_t volts = (gBatteryVoltageAverage < gMin_bat_v) ? gMin_bat_v : gBatteryVoltageAverage;
const uint16_t volts = (gBatteryVoltageAverage < gMin_bat_v) ? gMin_bat_v : gBatteryVoltageAverage; const uint16_t percent = (100 * (volts - gMin_bat_v)) / (gMax_bat_v - gMin_bat_v);
const uint16_t percent = (100 * (volts - gMin_bat_v)) / (gMax_bat_v - gMin_bat_v); sprintf(String, "Charge %u.%02uV %u%%", gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100, percent);
sprintf(String, "Charge %u.%02uV %u%%", gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100, percent); UI_PrintStringSmall(String, 2, 0, 3);
UI_PrintStringSmall(String, 2, 0, 3);
#endif
} }
} #endif
} }
} }