0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-29 23:01:26 +03:00

Fix RSSI bars

This commit is contained in:
OneOfEleven 2023-09-24 20:16:56 +01:00
parent 9cc84bd00b
commit e266409efe
5 changed files with 35 additions and 35 deletions

View File

@ -1134,14 +1134,14 @@ void APP_Update(void)
{ // dual watch mode, go back to sleep { // dual watch mode, go back to sleep
// sample the RSSI // sample the RSSI
gCurrentRSSI[gEeprom.RX_CHANNEL] = (int16_t)BK4819_GetRSSI(); gCurrentRSSI[gEeprom.RX_CHANNEL] = BK4819_GetRSSI();
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
// with compensation // with compensation
if (gSetting_AM_fix) if (gRxVfo->IsAM && gSetting_AM_fix)
gCurrentRSSI[gEeprom.RX_CHANNEL] -= rssi_db_gain_diff * 2; gCurrentRSSI[gEeprom.RX_CHANNEL] -= rssi_db_gain_diff * 2;
#endif #endif
UI_UpdateRSSI(gCurrentRSSI[gEeprom.RX_CHANNEL]); UI_UpdateRSSI(gCurrentRSSI[gEeprom.RX_CHANNEL], gEeprom.RX_CHANNEL);
// go back to sleep // go back to sleep
@ -1663,11 +1663,11 @@ void APP_TimeSlice500ms(void)
gCurrentRSSI[gEeprom.RX_CHANNEL] = (int16_t)BK4819_GetRSSI(); gCurrentRSSI[gEeprom.RX_CHANNEL] = (int16_t)BK4819_GetRSSI();
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
// with compensation // with compensation
if (gSetting_AM_fix) if (gRxVfo->IsAM && gSetting_AM_fix)
gCurrentRSSI[gEeprom.RX_CHANNEL] -= rssi_db_gain_diff * 2; gCurrentRSSI[gEeprom.RX_CHANNEL] -= rssi_db_gain_diff * 2;
#endif #endif
UI_UpdateRSSI(gCurrentRSSI[gEeprom.RX_CHANNEL]); UI_UpdateRSSI(gCurrentRSSI[gEeprom.RX_CHANNEL], gEeprom.RX_CHANNEL);
} }
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO

Binary file not shown.

Binary file not shown.

View File

@ -28,22 +28,22 @@
#ifdef ENABLE_DBM #ifdef ENABLE_DBM
void UI_UpdateRSSI(const int16_t RSSI) void UI_UpdateRSSI(const int16_t rssi, const int vfo)
{ // dBm { // dBm
// //
// this doesn't yet quite fit into the available screen space // this doesn't yet quite fit into the available screen space
char s[8]; char s[8];
const uint8_t line = (gEeprom.RX_CHANNEL == 0) ? 3 : 7; const uint8_t line = (vfo == 0) ? 3 : 7;
if (gEeprom.KEY_LOCK && gKeypadLocked > 0) if (gEeprom.KEY_LOCK && gKeypadLocked > 0)
return; // the screen is currently in use return; // the screen is currently in use
gVFO_RSSI[gEeprom.RX_CHANNEL] = RSSI; gVFO_RSSI[vfo] = rssi;
gVFO_RSSI_bar_level[gEeprom.RX_CHANNEL] = 0; gVFO_RSSI_bar_level[vfo] = 0;
{ // drop the '.5' { // drop the '.5'
const int16_t dBm = (RSSI / 2) - 160; const int16_t dBm = (rssi / 2) - 160;
sprintf(s, "%-3d", dBm); sprintf(s, "%-3d", dBm);
} }
else else
@ -54,7 +54,7 @@ void UI_UpdateRSSI(const int16_t RSSI)
#else #else
void Render(const uint8_t rssi, const uint8_t RssiLevel, const uint8_t VFO) void render(const int16_t rssi, const uint8_t rssi_level, const int vfo)
{ // bar graph { // bar graph
uint8_t *pLine; uint8_t *pLine;
@ -66,7 +66,7 @@ void Render(const uint8_t rssi, const uint8_t RssiLevel, const uint8_t VFO)
if (gCurrentFunction == FUNCTION_TRANSMIT || gScreenToDisplay != DISPLAY_MAIN) if (gCurrentFunction == FUNCTION_TRANSMIT || gScreenToDisplay != DISPLAY_MAIN)
return; // it's still in use return; // it's still in use
if (VFO == 0) if (vfo == 0)
{ {
pLine = gFrameBuffer[2]; pLine = gFrameBuffer[2];
Line = 3; Line = 3;
@ -79,36 +79,36 @@ void Render(const uint8_t rssi, const uint8_t RssiLevel, const uint8_t VFO)
memset(pLine, 0, 23); memset(pLine, 0, 23);
if (RssiLevel == 0) if (rssi_level == 0)
{ {
pLine = NULL; pLine = NULL;
} }
else else
{ {
//if (RssiLevel >= 1) //if (rssi_level >= 1)
memmove(pLine, BITMAP_Antenna, 5); memmove(pLine, BITMAP_Antenna, 5);
if (RssiLevel >= 2) if (rssi_level >= 2)
memmove(pLine + 5, BITMAP_AntennaLevel1, sizeof(BITMAP_AntennaLevel1)); memmove(pLine + 5, BITMAP_AntennaLevel1, sizeof(BITMAP_AntennaLevel1));
if (RssiLevel >= 3) if (rssi_level >= 3)
memmove(pLine + 8, BITMAP_AntennaLevel2, sizeof(BITMAP_AntennaLevel2)); memmove(pLine + 8, BITMAP_AntennaLevel2, sizeof(BITMAP_AntennaLevel2));
if (RssiLevel >= 4) if (rssi_level >= 4)
memmove(pLine + 11, BITMAP_AntennaLevel3, sizeof(BITMAP_AntennaLevel3)); memmove(pLine + 11, BITMAP_AntennaLevel3, sizeof(BITMAP_AntennaLevel3));
if (RssiLevel >= 5) if (rssi_level >= 5)
memmove(pLine + 14, BITMAP_AntennaLevel4, sizeof(BITMAP_AntennaLevel4)); memmove(pLine + 14, BITMAP_AntennaLevel4, sizeof(BITMAP_AntennaLevel4));
if (RssiLevel >= 6) if (rssi_level >= 6)
memmove(pLine + 17, BITMAP_AntennaLevel5, sizeof(BITMAP_AntennaLevel5)); memmove(pLine + 17, BITMAP_AntennaLevel5, sizeof(BITMAP_AntennaLevel5));
if (RssiLevel >= 7) if (rssi_level >= 7)
memmove(pLine + 20, BITMAP_AntennaLevel6, sizeof(BITMAP_AntennaLevel6)); memmove(pLine + 20, BITMAP_AntennaLevel6, sizeof(BITMAP_AntennaLevel6));
} }
ST7565_DrawLine(0, Line, 23, pLine); ST7565_DrawLine(0, Line, 23, pLine);
} }
void UI_UpdateRSSI(const int16_t RSSI) void UI_UpdateRSSI(const int16_t rssi, const int vfo)
{ {
gVFO_RSSI[gEeprom.RX_CHANNEL] = RSSI; gVFO_RSSI[vfo] = rssi;
//const int16_t dBm = (RSSI / 2) - 160; //const int16_t dBm = (rssi / 2) - 160;
#if 0 #if 0
//const unsigned int band = gRxVfo->Band; //const unsigned int band = gRxVfo->Band;
@ -129,24 +129,24 @@ void UI_UpdateRSSI(const int16_t RSSI)
uint8_t Level = 0; uint8_t Level = 0;
if (RSSI >= level3) Level = 7; if (rssi >= level3) Level = 7;
else else
if (RSSI >= level23) Level = 6; if (rssi >= level23) Level = 6;
else else
if (RSSI >= level2) Level = 5; if (rssi >= level2) Level = 5;
else else
if (RSSI >= level12) Level = 4; if (rssi >= level12) Level = 4;
else else
if (RSSI >= level1) Level = 3; if (rssi >= level1) Level = 3;
else else
if (RSSI >= level01) Level = 2; if (rssi >= level01) Level = 2;
else else
if (RSSI >= level0) Level = 1; if (rssi >= level0) Level = 1;
if (gVFO_RSSI_bar_level[gEeprom.RX_CHANNEL] != Level) if (gVFO_RSSI_bar_level[vfo] != Level)
{ {
gVFO_RSSI_bar_level[gEeprom.RX_CHANNEL] = Level; gVFO_RSSI_bar_level[vfo] = Level;
Render(RSSI, Level, gEeprom.RX_CHANNEL); render(rssi, Level, vfo);
} }
} }

View File

@ -17,7 +17,7 @@
#ifndef UI_RSSI_H #ifndef UI_RSSI_H
#define UI_RSSI_H #define UI_RSSI_H
void UI_UpdateRSSI(const int16_t RSSI); void UI_UpdateRSSI(const int16_t RSSI, const int vfo);
#endif #endif