Bargraph level resolution fix

This commit is contained in:
OneOfEleven 2023-09-17 15:36:23 +01:00
parent 628f00a939
commit 71375f31b2
9 changed files with 105 additions and 40 deletions

View File

@ -452,7 +452,7 @@ void APP_StartListening(FUNCTION_Type_t Function)
// help improve AM RX audio by reducing the PGA gain // help improve AM RX audio by reducing the PGA gain
// //
// I think the solution is to set the RX AGC to limit the front end gain // I think the solution is to set the RX AGC to limit the front end/I.F gain
// //
// LNA_SHORT .. 0dB // LNA_SHORT .. 0dB
// LNA ........ 14dB // LNA ........ 14dB

View File

@ -24,30 +24,39 @@
enum BK4819_AF_Type_t enum BK4819_AF_Type_t
{ {
BK4819_AF_MUTE = 0U, BK4819_AF_MUTE = 0u,
BK4819_AF_OPEN = 1U, BK4819_AF_OPEN = 1u,
BK4819_AF_ALAM = 2U, BK4819_AF_ALAM = 2u,
BK4819_AF_BEEP = 3U, BK4819_AF_BEEP = 3u,
BK4819_AF_CTCO = 6U, BK4819_AF_UNKNOWN1 = 4u,
BK4819_AF_AM = 7U, BK4819_AF_UNKNOWN2 = 5u,
BK4819_AF_FSKO = 8U, BK4819_AF_CTCO = 6u,
BK4819_AF_AM = 7u,
BK4819_AF_FSKO = 8u,
BK4819_AF_UNKNOWN3 = 9u,
BK4819_AF_UNKNOWN4 = 10u,
BK4819_AF_UNKNOWN5 = 11u,
BK4819_AF_UNKNOWN6 = 12u,
BK4819_AF_UNKNOWN7 = 13u,
BK4819_AF_UNKNOWN8 = 14u,
BK4819_AF_UNKNOWN9 = 15u
}; };
typedef enum BK4819_AF_Type_t BK4819_AF_Type_t; typedef enum BK4819_AF_Type_t BK4819_AF_Type_t;
enum BK4819_FilterBandwidth_t enum BK4819_FilterBandwidth_t
{ {
BK4819_FILTER_BW_WIDE = 0U, BK4819_FILTER_BW_WIDE = 0,
BK4819_FILTER_BW_NARROW = 1U, BK4819_FILTER_BW_NARROW
}; };
typedef enum BK4819_FilterBandwidth_t BK4819_FilterBandwidth_t; typedef enum BK4819_FilterBandwidth_t BK4819_FilterBandwidth_t;
enum BK4819_CssScanResult_t enum BK4819_CssScanResult_t
{ {
BK4819_CSS_RESULT_NOT_FOUND = 0U, BK4819_CSS_RESULT_NOT_FOUND = 0,
BK4819_CSS_RESULT_CTCSS = 1U, BK4819_CSS_RESULT_CTCSS,
BK4819_CSS_RESULT_CDCSS = 2U, BK4819_CSS_RESULT_CDCSS
}; };
typedef enum BK4819_CssScanResult_t BK4819_CssScanResult_t; typedef enum BK4819_CssScanResult_t BK4819_CssScanResult_t;

BIN
firmware

Binary file not shown.

Binary file not shown.

Binary file not shown.

3
misc.c
View File

@ -99,7 +99,10 @@ uint8_t gUpdateStatus;
uint8_t gFoundCTCSS; uint8_t gFoundCTCSS;
uint8_t gFoundCDCSS; uint8_t gFoundCDCSS;
bool gEndOfRxDetectedMaybe; bool gEndOfRxDetectedMaybe;
uint16_t gVFO_RSSI[2];
uint8_t gVFO_RSSI_Level[2]; uint8_t gVFO_RSSI_Level[2];
uint8_t gReducedService; uint8_t gReducedService;
uint8_t gBatteryVoltageIndex; uint8_t gBatteryVoltageIndex;
CssScanMode_t gCssScanMode; CssScanMode_t gCssScanMode;

3
misc.h
View File

@ -159,7 +159,10 @@ extern uint8_t gUpdateStatus;
extern uint8_t gFoundCTCSS; extern uint8_t gFoundCTCSS;
extern uint8_t gFoundCDCSS; extern uint8_t gFoundCDCSS;
extern bool gEndOfRxDetectedMaybe; extern bool gEndOfRxDetectedMaybe;
extern uint16_t gVFO_RSSI[2];
extern uint8_t gVFO_RSSI_Level[2]; extern uint8_t gVFO_RSSI_Level[2];
extern uint8_t gReducedService; extern uint8_t gReducedService;
extern uint8_t gBatteryVoltageIndex; extern uint8_t gBatteryVoltageIndex;
extern CssScanMode_t gCssScanMode; extern CssScanMode_t gCssScanMode;

View File

@ -57,7 +57,7 @@ void UI_DisplayMain(void)
#ifdef ENABLE_DTMF_DECODER #ifdef ENABLE_DTMF_DECODER
bool show_dtmf_rx = true; bool show_dtmf_rx = true;
#endif #endif
for (vfo_num = 0; vfo_num < 2; vfo_num++) for (vfo_num = 0; vfo_num < 2; vfo_num++)
{ {
uint8_t Channel = gEeprom.TX_CHANNEL; uint8_t Channel = gEeprom.TX_CHANNEL;
@ -131,7 +131,7 @@ void UI_DisplayMain(void)
#ifdef ENABLE_DTMF_DECODER #ifdef ENABLE_DTMF_DECODER
show_dtmf_rx = false; show_dtmf_rx = false;
#endif #endif
continue; continue;
} }
@ -354,32 +354,49 @@ void UI_DisplayMain(void)
else else
if (SomeValue == 2) if (SomeValue == 2)
{ // RX signal level { // RX signal level
if (gVFO_RSSI_Level[vfo_num]) #ifdef ENABLE_DBM
Level = gVFO_RSSI_Level[vfo_num]; // dBm
//
// this doesn't yet quite fit into the available screen space
const uint16_t rssi = gVFO_RSSI[vfo_num];
if (rssi > 0)
{
const int16_t dBm = (int16_t)(rssi / 2) - 160;
sprintf(String, "%-3d", dBm);
UI_PrintStringSmall(String, 2, 0, Line + 2);
}
#else
// bar graph
if (gVFO_RSSI_Level[vfo_num] > 0)
Level = gVFO_RSSI_Level[vfo_num];
#endif
} }
if (Level >= 1) if (Level >= 1)
{ {
memmove(pLine1 + display_width + 0, BITMAP_Antenna, sizeof(BITMAP_Antenna)); uint8_t *pLine = pLine1 + display_width;
memmove(pLine1 + display_width + 5, BITMAP_AntennaLevel1, sizeof(BITMAP_AntennaLevel1)); memmove(pLine + 0, BITMAP_Antenna, sizeof(BITMAP_Antenna));
if (Level >= 2) if (Level >= 2)
memmove(pLine1 + display_width + 8, BITMAP_AntennaLevel2, sizeof(BITMAP_AntennaLevel2)); memmove(pLine + 5, BITMAP_AntennaLevel1, sizeof(BITMAP_AntennaLevel1));
if (Level >= 3) if (Level >= 3)
memmove(pLine1 + display_width + 11, BITMAP_AntennaLevel3, sizeof(BITMAP_AntennaLevel3)); memmove(pLine + 8, BITMAP_AntennaLevel2, sizeof(BITMAP_AntennaLevel2));
if (Level >= 4) if (Level >= 4)
memmove(pLine1 + display_width + 14, BITMAP_AntennaLevel4, sizeof(BITMAP_AntennaLevel4)); memmove(pLine + 11, BITMAP_AntennaLevel3, sizeof(BITMAP_AntennaLevel3));
if (Level >= 5) if (Level >= 5)
memmove(pLine1 + display_width + 17, BITMAP_AntennaLevel5, sizeof(BITMAP_AntennaLevel5)); memmove(pLine + 14, BITMAP_AntennaLevel4, sizeof(BITMAP_AntennaLevel4));
if (Level >= 6) if (Level >= 6)
memmove(pLine1 + display_width + 20, BITMAP_AntennaLevel6, sizeof(BITMAP_AntennaLevel6)); memmove(pLine + 17, BITMAP_AntennaLevel5, sizeof(BITMAP_AntennaLevel5));
if (Level >= 7)
memmove(pLine + 20, BITMAP_AntennaLevel6, sizeof(BITMAP_AntennaLevel6));
} }
} }
// ************ // ************
String[0] = '\0';
if (gEeprom.VfoInfo[vfo_num].IsAM) if (gEeprom.VfoInfo[vfo_num].IsAM)
{ // show the AM symbol { // show the AM symbol
UI_PrintStringSmall("AM", display_width + 27, 0, Line + 1); strcpy(String, "AM");
} }
else else
{ // show the CTCSS/DCS symbol { // show the CTCSS/DCS symbol
@ -387,8 +404,9 @@ void UI_DisplayMain(void)
const unsigned int code_type = pConfig->CodeType; const unsigned int code_type = pConfig->CodeType;
const char *code_list[] = {"", "CT", "DCS", "DCR"}; const char *code_list[] = {"", "CT", "DCS", "DCR"};
if (code_type >= 0 && code_type < ARRAY_SIZE(code_list)) if (code_type >= 0 && code_type < ARRAY_SIZE(code_list))
UI_PrintStringSmall(code_list[code_type], display_width + 24, 0, Line + 1); strcpy(String, code_list[code_type]);
} }
UI_PrintStringSmall(String, display_width + 24, 0, Line + 1);
{ // show the TX power { // show the TX power
const char pwr_list[] = "LMH"; const char pwr_list[] = "LMH";
@ -423,7 +441,7 @@ void UI_DisplayMain(void)
UI_PrintStringSmall("DTMF", display_width + 78, 0, Line + 1); UI_PrintStringSmall("DTMF", display_width + 78, 0, Line + 1);
// show the audio scramble symbol // show the audio scramble symbol
if (gEeprom.VfoInfo[vfo_num].SCRAMBLING_TYPE && gSetting_ScrambleEnable) if (gEeprom.VfoInfo[vfo_num].SCRAMBLING_TYPE > 0 && gSetting_ScrambleEnable)
UI_PrintStringSmall("SCR", display_width + 106, 0, Line + 1); UI_PrintStringSmall("SCR", display_width + 106, 0, Line + 1);
} }
@ -433,6 +451,6 @@ void UI_DisplayMain(void)
UI_PrintStringSmall(gDTMF_ReceivedSaved, 8, 0, 3); UI_PrintStringSmall(gDTMF_ReceivedSaved, 8, 0, 3);
} }
#endif #endif
ST7565_BlitFullScreen(); ST7565_BlitFullScreen();
} }

View File

@ -15,19 +15,48 @@
*/ */
#include <string.h> #include <string.h>
#include "bitmaps.h" #include "bitmaps.h"
#include "driver/st7565.h" #include "driver/st7565.h"
#include "external/printf/printf.h"
#include "functions.h" #include "functions.h"
#include "misc.h" #include "misc.h"
#include "settings.h" #include "settings.h"
#include "ui/helper.h"
#include "ui/rssi.h" #include "ui/rssi.h"
#include "ui/ui.h" #include "ui/ui.h"
static void Render(uint8_t RssiLevel, uint8_t VFO) #ifdef ENABLE_DBM
{
void UI_UpdateRSSI(uint16_t RSSI)
{ // dBm
//
// this doesn't yet quite fit into the available screen space
char s[8];
const uint8_t line = (gEeprom.RX_CHANNEL == 0) ? 3 : 7;
gVFO_RSSI[gEeprom.RX_CHANNEL] = RSSI;
gVFO_RSSI_Level[gEeprom.RX_CHANNEL] = 0;
if (RSSI > 0)
{ // drop the '.5'
const int16_t dBm = (int16_t)(RSSI / 2) - 160;
sprintf(s, "%-3d", dBm);
}
else
strcpy(s, " ");
UI_PrintStringSmall(s, 2, 0, line);
}
#else
void Render(const uint8_t rssi, const uint8_t RssiLevel, const uint8_t VFO)
{ // bar graph
uint8_t *pLine; uint8_t *pLine;
uint8_t Line; uint8_t Line;
bool bIsClearMode = false;
if (gCurrentFunction == FUNCTION_TRANSMIT || gScreenToDisplay != DISPLAY_MAIN) if (gCurrentFunction == FUNCTION_TRANSMIT || gScreenToDisplay != DISPLAY_MAIN)
return; return;
@ -36,7 +65,6 @@ static void Render(uint8_t RssiLevel, uint8_t VFO)
{ {
pLine = gFrameBuffer[2]; pLine = gFrameBuffer[2];
Line = 3; Line = 3;
// Line = 4;
} }
else else
{ {
@ -45,15 +73,15 @@ static void Render(uint8_t RssiLevel, uint8_t VFO)
} }
memset(pLine, 0, 23); memset(pLine, 0, 23);
if (RssiLevel == 0) if (RssiLevel == 0)
{ {
pLine = NULL; pLine = NULL;
bIsClearMode = true;
} }
else else
{ {
memmove(pLine, BITMAP_Antenna, 5); //if (RssiLevel >= 1)
memmove(pLine, BITMAP_Antenna, 5);
if (RssiLevel >= 2) if (RssiLevel >= 2)
memmove(pLine + 5, BITMAP_AntennaLevel1, sizeof(BITMAP_AntennaLevel1)); memmove(pLine + 5, BITMAP_AntennaLevel1, sizeof(BITMAP_AntennaLevel1));
if (RssiLevel >= 3) if (RssiLevel >= 3)
@ -68,14 +96,16 @@ static void Render(uint8_t RssiLevel, uint8_t VFO)
memmove(pLine + 20, BITMAP_AntennaLevel6, sizeof(BITMAP_AntennaLevel6)); memmove(pLine + 20, BITMAP_AntennaLevel6, sizeof(BITMAP_AntennaLevel6));
} }
ST7565_DrawLine(0, Line, 23 , pLine, bIsClearMode); ST7565_DrawLine(0, Line, 23, pLine, (pLine == NULL) ? true : false);
} }
void UI_UpdateRSSI(uint16_t RSSI) void UI_UpdateRSSI(uint16_t RSSI)
{ {
//const int16_t dB = (int16_t)(RSSI / 2) - 160; gVFO_RSSI[gEeprom.RX_CHANNEL] = RSSI;
//const int16_t dBm = (int16_t)(RSSI / 2) - 160;
// const unsigned int band = gRxVfo->Band; //const unsigned int band = gRxVfo->Band;
const unsigned int band = 0; const unsigned int band = 0;
const uint16_t level0 = gEEPROM_RSSI_CALIB[band][0]; const uint16_t level0 = gEEPROM_RSSI_CALIB[band][0];
@ -105,6 +135,8 @@ void UI_UpdateRSSI(uint16_t RSSI)
if (gVFO_RSSI_Level[gEeprom.RX_CHANNEL] != Level) if (gVFO_RSSI_Level[gEeprom.RX_CHANNEL] != Level)
{ {
gVFO_RSSI_Level[gEeprom.RX_CHANNEL] = Level; gVFO_RSSI_Level[gEeprom.RX_CHANNEL] = Level;
Render(Level, gEeprom.RX_CHANNEL); Render(RSSI, Level, gEeprom.RX_CHANNEL);
} }
} }
#endif