diff --git a/Makefile b/Makefile index 3b59c09..9c3e0bf 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,8 @@ ENABLE_BOOT_BEEPS := 0 ENABLE_DTMF_DECODER := 1 ENABLE_COMPANDER := 1 ENABLE_SHOW_CHARGE_LEVEL := 1 +ENABLE_STATUSBAR_VOLTAGE := 0 +ENABLE_STATUSBAR_PERCENTAGE := 1 #ENABLE_SINGLE_VFO_CHAN := 1 #ENABLE_BAND_SCOPE := 1 @@ -193,6 +195,12 @@ endif ifeq ($(ENABLE_SHOW_CHARGE_LEVEL),1) CFLAGS += -DENABLE_SHOW_CHARGE_LEVEL endif +ifeq ($(ENABLE_STATUSBAR_VOLTAGE),1) + CFLAGS += -DENABLE_STATUSBAR_VOLTAGE +endif +ifeq ($(ENABLE_STATUSBAR_PERCENTAGE),1) + CFLAGS += -DENABLE_STATUSBAR_PERCENTAGE +endif ifeq ($(ENABLE_DTMF_DECODER),1) CFLAGS += -DENABLE_DTMF_DECODER endif diff --git a/README.md b/README.md index 2b00b90..b1eb7cd 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,8 @@ ENABLE_BOOT_BEEPS := 0 give user audio feedback on volume knob ENABLE_DTMF_DECODER := 1 live on-screen DTMF decoder ENABLE_COMPANDER := 1 compander option - setting not yet saved ENABLE_SHOW_CHARGE_LEVEL := 1 show the charge level when the radio is on charge +ENABLE_STATUSBAR_VOLTAGE := 0 show the battery voltage on the top status bar - when possible +ENABLE_STATUSBAR_PERCENTAGE := 1 show the battery percentage on the top status bar - when possible #ENABLE_SINGLE_VFO_CHAN := 1 not yet implemented - single VFO on display when possible #ENABLE_BAND_SCOPE := 1 not yet implemented - spectrum/pan-adapter ``` diff --git a/driver/bk4819.c b/driver/bk4819.c index 47f70f7..dd7861c 100644 --- a/driver/bk4819.c +++ b/driver/bk4819.c @@ -80,17 +80,19 @@ void BK4819_Init(void) ( 0u << 10) | // AF Rx Gain-1 (58u << 4) | // AF Rx Gain-2 ( 8u << 0)); // AF DAC Gain (after Gain-1 and Gain-2) - -// const uint8_t dtmf_coeffs[] = {0x6F,0x6B,0x67,0x62,0x50,0x47,0x3A,0x2C,0x41,0x37,0x25,0x17,0xE4,0xCB,0xB5,0x9F}; -// for (unsigned int i = 0; i < ARRAY_SIZE(dtmf_coeffs); i++) -// BK4819_WriteRegister(BK4819_REG_09, (i << 12) | dtmf_coeffs[i]); - + +#if 1 + const uint8_t dtmf_coeffs[] = {111, 107, 103, 98, 80, 71, 58, 44, 65, 55, 37, 23, 228, 203, 181, 159}; + for (unsigned int i = 0; i < ARRAY_SIZE(dtmf_coeffs); i++) + BK4819_WriteRegister(BK4819_REG_09, (i << 12) | dtmf_coeffs[i]); +#else + // original code BK4819_WriteRegister(BK4819_REG_09, 0x006F); // 6F BK4819_WriteRegister(BK4819_REG_09, 0x106B); // 6B BK4819_WriteRegister(BK4819_REG_09, 0x2067); // 67 BK4819_WriteRegister(BK4819_REG_09, 0x3062); // 62 BK4819_WriteRegister(BK4819_REG_09, 0x4050); // 50 - BK4819_WriteRegister(BK4819_REG_09, 0x5046); // 47 ** + BK4819_WriteRegister(BK4819_REG_09, 0x5047); // 47 BK4819_WriteRegister(BK4819_REG_09, 0x603A); // 3A BK4819_WriteRegister(BK4819_REG_09, 0x702C); // 2C BK4819_WriteRegister(BK4819_REG_09, 0x8041); // 41 @@ -101,6 +103,7 @@ void BK4819_Init(void) BK4819_WriteRegister(BK4819_REG_09, 0xD0CB); // CB BK4819_WriteRegister(BK4819_REG_09, 0xE0B5); // B5 BK4819_WriteRegister(BK4819_REG_09, 0xF09F); // 9F +#endif BK4819_WriteRegister(BK4819_REG_1F, 0x5454); BK4819_WriteRegister(BK4819_REG_3E, 0xA037); diff --git a/firmware b/firmware index 0bc01d8..7223312 100644 Binary files a/firmware and b/firmware differ diff --git a/firmware.bin b/firmware.bin index f90f8e0..88bc89c 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index 8236ecf..485eebe 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/ui/helper.c b/ui/helper.c index 83b3b43..4410cfd 100644 --- a/ui/helper.c +++ b/ui/helper.c @@ -104,6 +104,22 @@ void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_ } } +void UI_PrintStringSmallBuffer(const char *pString, uint8_t *buffer) +{ + size_t i; + const unsigned int char_width = ARRAY_SIZE(gFontSmall[0]); + const unsigned int char_spacing = char_width + 0; + for (i = 0; i < strlen(pString); i++) + { + if (pString[i] >= 32) + { + const unsigned int Index = (unsigned int)pString[i] - 32; + if (Index < ARRAY_SIZE(gFontSmall)) + memmove(buffer + (i * char_spacing), &gFontSmall[Index], char_width); + } + } +} + void UI_DisplayFrequency(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero, bool bFlag) { const unsigned int char_width = 13; diff --git a/ui/helper.h b/ui/helper.h index 213b149..3a93d84 100644 --- a/ui/helper.h +++ b/ui/helper.h @@ -24,6 +24,7 @@ void UI_GenerateChannelString(char *pString, const uint8_t Channel); void UI_GenerateChannelStringEx(char *pString, const bool bShowPrefix, const uint8_t ChannelNumber); void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t Width); void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_t Line); +void UI_PrintStringSmallBuffer(const char *pString, uint8_t *buffer); void UI_DisplayFrequency(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero, bool bFlag); void UI_DisplayFrequencySmall(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero); void UI_DisplaySmallDigits(const uint8_t size, const char *str, const uint8_t x, const uint8_t y, const bool display_leading_zeros); diff --git a/ui/status.c b/ui/status.c index 732b6a6..d767e1a 100644 --- a/ui/status.c +++ b/ui/status.c @@ -23,10 +23,12 @@ #include "bitmaps.h" #include "driver/keyboard.h" #include "driver/st7565.h" +#include "external/printf/printf.h" #include "functions.h" #include "helper/battery.h" #include "misc.h" #include "settings.h" +#include "ui/helper.h" #include "ui/ui.h" #include "ui/status.h" @@ -100,12 +102,34 @@ void UI_DisplayStatus(const bool test_display) // KEY-LOCK indicator if (gEeprom.KEY_LOCK || test_display) + { memmove(line, BITMAP_KeyLock, sizeof(BITMAP_KeyLock)); + line += sizeof(BITMAP_KeyLock); + } else if (gWasFKeyPressed) + { memmove(line, BITMAP_F_Key, sizeof(BITMAP_F_Key)); - line += sizeof(BITMAP_F_Key); + line += sizeof(BITMAP_F_Key); + } + else + if (!gChargingWithTypeC) + { // battery voltage/percentage + #if defined(ENABLE_STATUSBAR_VOLTAGE) + char s[6]; + sprintf(s, "%u.%02u", gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100); + UI_PrintStringSmallBuffer(s, line); + #elif defined(ENABLE_STATUSBAR_PERCENTAGE) + char s[6]; + const uint16_t volts = (gBatteryVoltageAverage < gMin_bat_v) ? gMin_bat_v : + (gBatteryVoltageAverage > gMax_bat_v) ? gMax_bat_v : + gBatteryVoltageAverage; + sprintf(s, "%u%%", (100 * (volts - gMin_bat_v)) / (gMax_bat_v - gMin_bat_v)); + UI_PrintStringSmallBuffer(s, line); + #endif + } + // USB-C charge indicator if (gChargingWithTypeC || test_display) memmove(line, BITMAP_USB_C, sizeof(BITMAP_USB_C));