mirror of
https://github.com/egzumer/uv-k5-firmware-custom
synced 2024-11-21 17:19:57 +00:00
Battery volt/percent now has menu setting instead of compile option
This commit is contained in:
parent
93f6866c87
commit
0b676d29e3
8
Makefile
8
Makefile
@ -19,8 +19,6 @@ ENABLE_BOOT_BEEPS := 0
|
||||
ENABLE_COMPANDER := 1
|
||||
ENABLE_SHOW_CHARGE_LEVEL := 0
|
||||
ENABLE_REVERSE_BAT_SYMBOL := 1
|
||||
ENABLE_STATUSBAR_VOLTAGE := 1
|
||||
ENABLE_STATUSBAR_PERCENTAGE := 1
|
||||
#ENABLE_SINGLE_VFO_CHAN := 1
|
||||
#ENABLE_BAND_SCOPE := 1
|
||||
|
||||
@ -194,12 +192,6 @@ endif
|
||||
ifeq ($(ENABLE_REVERSE_BAT_SYMBOL),1)
|
||||
CFLAGS += -DENABLE_REVERSE_BAT_SYMBOL
|
||||
endif
|
||||
ifeq ($(ENABLE_STATUSBAR_VOLTAGE),1)
|
||||
CFLAGS += -DENABLE_STATUSBAR_VOLTAGE
|
||||
endif
|
||||
ifeq ($(ENABLE_STATUSBAR_PERCENTAGE),1)
|
||||
CFLAGS += -DENABLE_STATUSBAR_PERCENTAGE
|
||||
endif
|
||||
ifeq ($(ENABLE_SINGLE_VFO_CHAN),1)
|
||||
CFLAGS += -DENABLE_SINGLE_VFO_CHAN
|
||||
endif
|
||||
|
@ -30,8 +30,6 @@ ENABLE_BOOT_BEEPS := 0 give user audio feedback on volume knob
|
||||
ENABLE_COMPANDER := 1 compander option (per channel)
|
||||
ENABLE_SHOW_CHARGE_LEVEL := 1 show the charge level when the radio is on charge
|
||||
ENABLE_REVERSE_BAT_SYMBOL := 1 mirror the battery symbol on the status bar (+ pole on the right)
|
||||
ENABLE_STATUSBAR_VOLTAGE := 0 show the battery voltage on the top status bar - when possible
|
||||
ENABLE_STATUSBAR_PERCENTAGE := 1 or 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
|
||||
```
|
||||
|
32
app/app.c
32
app/app.c
@ -654,6 +654,7 @@ void APP_StartListening(FUNCTION_Type_t Function)
|
||||
uint16_t lna;
|
||||
uint16_t mixer;
|
||||
uint16_t pga;
|
||||
|
||||
// seems the RX gain abrutly reduces above this frequency, why ?
|
||||
if (rx_frequency <= 22640000)
|
||||
{
|
||||
@ -663,7 +664,7 @@ void APP_StartListening(FUNCTION_Type_t Function)
|
||||
pga = 3; // reduced - seems to help reduce the AM demodulation distortion
|
||||
}
|
||||
else
|
||||
{
|
||||
{ // increasing the front ends gain decreases the dynamic range
|
||||
lna_short = 3; // original
|
||||
lna = 4; // increased
|
||||
mixer = 3; // original
|
||||
@ -679,16 +680,32 @@ void APP_StartListening(FUNCTION_Type_t Function)
|
||||
//BK4819_WriteRegister(BK4819_REG_10, 0x007A); // 000000 00 011 11 010
|
||||
//BK4819_WriteRegister(BK4819_REG_14, 0x0019); // 000000 00 000 11 001
|
||||
}
|
||||
|
||||
BK4819_WriteRegister(BK4819_REG_48,
|
||||
// max RX AF gain
|
||||
(11u << 12) | // ???
|
||||
( 0u << 10) | // AF Rx Gain-1
|
||||
(63u << 4) | // AF Rx Gain-2
|
||||
(15u << 0)); // AF DAC Gain (after Gain-1 and Gain-2)
|
||||
|
||||
gNeverUsed = 0;
|
||||
}
|
||||
else
|
||||
{ // FM
|
||||
|
||||
uint16_t lna_short; // whats "LNA SHORT" mean ?
|
||||
uint16_t lna;
|
||||
uint16_t mixer;
|
||||
uint16_t pga;
|
||||
|
||||
// original
|
||||
lna_short = 3;
|
||||
lna = 2;
|
||||
mixer = 3;
|
||||
pga = 6;
|
||||
|
||||
BK4819_WriteRegister(BK4819_REG_13, (lna_short << 8) | (lna << 5) | (mixer << 3) | (pga << 0));
|
||||
|
||||
BK4819_WriteRegister(BK4819_REG_48,
|
||||
(11u << 12) | // ???
|
||||
( 0u << 10) | // AF Rx Gain-1
|
||||
@ -1788,16 +1805,13 @@ void APP_TimeSlice500ms(void)
|
||||
gBatteryVoltageIndex = 0;
|
||||
|
||||
BATTERY_GetReadings(true);
|
||||
|
||||
#if defined(ENABLE_STATUSBAR_VOLTAGE) || defined(ENABLE_STATUSBAR_PERCENTAGE)
|
||||
// regular statusbar updates (once per sec) if battery voltage or percentage is enabled
|
||||
gUpdateStatus = true;
|
||||
#else
|
||||
if (gChargingWithTypeC)
|
||||
gUpdateDisplay = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
// regular statusbar updates (once every 2 sec) if need be
|
||||
if ((gBatteryCheckCounter & 3) == 0)
|
||||
if (gChargingWithTypeC || gSetting_battery_text > 0)
|
||||
gUpdateStatus = true;
|
||||
|
||||
if (gCurrentFunction != FUNCTION_POWER_SAVE)
|
||||
{
|
||||
gCurrentRSSI = BK4819_GetRSSI();
|
||||
|
55
app/menu.c
55
app/menu.c
@ -104,6 +104,7 @@
|
||||
VOICE_ID_INVALID, // PONMSG
|
||||
VOICE_ID_INVALID, // ROGER
|
||||
VOICE_ID_INVALID, // BATVOL
|
||||
VOICE_ID_INVALID, // BATTXT
|
||||
VOICE_ID_INVALID, // MODE
|
||||
#ifdef ENABLE_NOAA
|
||||
VOICE_ID_INVALID, // NOAA-S
|
||||
@ -322,6 +323,11 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
|
||||
*pMax = ARRAY_SIZE(gSubMenu_PTT_ID) - 1;
|
||||
break;
|
||||
|
||||
case MENU_BAT_TXT:
|
||||
*pMin = 0;
|
||||
*pMax = ARRAY_SIZE(gSubMenu_BAT_TXT) - 1;
|
||||
break;
|
||||
|
||||
case MENU_D_HOLD:
|
||||
*pMin = 5;
|
||||
*pMax = 60;
|
||||
@ -365,11 +371,13 @@ void MENU_AcceptSetting(void)
|
||||
|
||||
switch (gMenuCursor)
|
||||
{
|
||||
default:
|
||||
return;
|
||||
|
||||
case MENU_SQL:
|
||||
gEeprom.SQUELCH_LEVEL = gSubMenuSelection;
|
||||
gRequestSaveSettings = true;
|
||||
gVfoConfigureMode = VFO_CONFIGURE_1;
|
||||
return;
|
||||
break;
|
||||
|
||||
case MENU_STEP:
|
||||
if (IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE))
|
||||
@ -484,9 +492,8 @@ void MENU_AcceptSetting(void)
|
||||
gEeprom.VOX_LEVEL = gSubMenuSelection - 1;
|
||||
BOARD_EEPROM_LoadMoreSettings();
|
||||
gFlagReconfigureVfos = true;
|
||||
gRequestSaveSettings = true;
|
||||
gUpdateStatus = true;
|
||||
return;
|
||||
break;
|
||||
|
||||
case MENU_ABR:
|
||||
gEeprom.BACKLIGHT = gSubMenuSelection;
|
||||
@ -499,9 +506,8 @@ void MENU_AcceptSetting(void)
|
||||
case MENU_TDR:
|
||||
gEeprom.DUAL_WATCH = gSubMenuSelection;
|
||||
gFlagReconfigureVfos = true;
|
||||
gRequestSaveSettings = true;
|
||||
gUpdateStatus = true;
|
||||
return;
|
||||
break;
|
||||
|
||||
case MENU_XB:
|
||||
#ifdef ENABLE_NOAA
|
||||
@ -513,9 +519,8 @@ void MENU_AcceptSetting(void)
|
||||
|
||||
gEeprom.CROSS_BAND_RX_TX = gSubMenuSelection;
|
||||
gFlagReconfigureVfos = true;
|
||||
gRequestSaveSettings = true;
|
||||
gUpdateStatus = true;
|
||||
return;
|
||||
break;
|
||||
|
||||
case MENU_BEEP:
|
||||
gEeprom.BEEP_CONTROL = gSubMenuSelection;
|
||||
@ -528,9 +533,8 @@ void MENU_AcceptSetting(void)
|
||||
#ifdef ENABLE_VOICE
|
||||
case MENU_VOICE:
|
||||
gEeprom.VOICE_PROMPT = gSubMenuSelection;
|
||||
gRequestSaveSettings = true;
|
||||
gUpdateStatus = true;
|
||||
return;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case MENU_SC_REV:
|
||||
@ -571,9 +575,8 @@ void MENU_AcceptSetting(void)
|
||||
case MENU_MIC:
|
||||
gEeprom.MIC_SENSITIVITY = gSubMenuSelection;
|
||||
BOARD_EEPROM_LoadMoreSettings();
|
||||
gRequestSaveSettings = true;
|
||||
gFlagReconfigureVfos = true;
|
||||
return;
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_COMPANDER
|
||||
case MENU_COMPAND:
|
||||
@ -617,6 +620,10 @@ void MENU_AcceptSetting(void)
|
||||
gRequestSaveChannel = 1;
|
||||
return;
|
||||
|
||||
case MENU_BAT_TXT:
|
||||
gSetting_battery_text = gSubMenuSelection;
|
||||
break;
|
||||
|
||||
case MENU_D_DCD:
|
||||
gTxVfo->DTMF_DECODING_ENABLE = gSubMenuSelection;
|
||||
gRequestSaveChannel = 1;
|
||||
@ -624,8 +631,7 @@ void MENU_AcceptSetting(void)
|
||||
|
||||
case MENU_D_LIVE_DEC:
|
||||
gSetting_live_DTMF_decoder = gSubMenuSelection;
|
||||
gRequestSaveSettings = true;
|
||||
return;
|
||||
break;
|
||||
|
||||
case MENU_D_LIST:
|
||||
gDTMFChosenContact = gSubMenuSelection - 1;
|
||||
@ -655,9 +661,8 @@ void MENU_AcceptSetting(void)
|
||||
#ifdef ENABLE_NOAA
|
||||
case MENU_NOAA_S:
|
||||
gEeprom.NOAA_AUTO_SCAN = gSubMenuSelection;
|
||||
gRequestSaveSettings = true;
|
||||
gFlagReconfigureVfos = true;
|
||||
return;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case MENU_DEL_CH:
|
||||
@ -688,21 +693,18 @@ void MENU_AcceptSetting(void)
|
||||
|
||||
case MENU_350EN:
|
||||
gSetting_350EN = gSubMenuSelection;
|
||||
gRequestSaveSettings = true;
|
||||
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
|
||||
gFlagResetVfos = true;
|
||||
return;
|
||||
break;
|
||||
|
||||
case MENU_SCREN:
|
||||
gSetting_ScrambleEnable = gSubMenuSelection;
|
||||
gRequestSaveSettings = true;
|
||||
gFlagReconfigureVfos = true;
|
||||
return;
|
||||
break;
|
||||
|
||||
case MENU_TX_EN:
|
||||
gSetting_TX_EN = gSubMenuSelection;
|
||||
gRequestSaveSettings = true;
|
||||
return;
|
||||
gSetting_TX_EN = gSubMenuSelection;
|
||||
break;
|
||||
|
||||
case MENU_F_CALI:
|
||||
gEeprom.BK4819_XTAL_FREQ_LOW = gSubMenuSelection;
|
||||
@ -724,9 +726,6 @@ void MENU_AcceptSetting(void)
|
||||
EEPROM_WriteBuffer(0x1F88, &Misc);
|
||||
}
|
||||
return;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
gRequestSaveSettings = true;
|
||||
@ -988,6 +987,10 @@ void MENU_ShowCurrentSetting(void)
|
||||
gSubMenuSelection = gTxVfo->DTMF_PTT_ID_TX_MODE;
|
||||
break;
|
||||
|
||||
case MENU_BAT_TXT:
|
||||
gSubMenuSelection = gSetting_battery_text;
|
||||
return;
|
||||
|
||||
case MENU_D_DCD:
|
||||
gSubMenuSelection = gTxVfo->DTMF_DECODING_ENABLE;
|
||||
break;
|
||||
|
24
bitmaps.c
24
bitmaps.c
@ -256,30 +256,24 @@ const uint8_t BITMAP_USB_C[9] =
|
||||
0b00011100
|
||||
};
|
||||
|
||||
const uint8_t BITMAP_KeyLock[9] =
|
||||
{ // padlock symbol
|
||||
const uint8_t BITMAP_KeyLock[6] =
|
||||
{ // teeny padlock symbol
|
||||
0b00000000,
|
||||
0b01111100,
|
||||
0b01000110,
|
||||
0b01000101,
|
||||
0b01000101,
|
||||
0b01000101,
|
||||
0b01000101,
|
||||
0b01000110,
|
||||
0b01111100
|
||||
};
|
||||
|
||||
const uint8_t BITMAP_F_Key[9] =
|
||||
const uint8_t BITMAP_F_Key[6] =
|
||||
{ // F-Key symbol
|
||||
0b11111111,
|
||||
0b10000001,
|
||||
0b10111101,
|
||||
0b10010101,
|
||||
0b10010101,
|
||||
0b10010101,
|
||||
0b10000101,
|
||||
0b10000001,
|
||||
0b11111111
|
||||
0b00000000,
|
||||
0b01011111,
|
||||
0b01000101,
|
||||
0b01000101,
|
||||
0b01000101,
|
||||
0b01000001
|
||||
};
|
||||
|
||||
const uint8_t BITMAP_VOX[18] =
|
||||
|
@ -14,9 +14,9 @@ extern const uint8_t BITMAP_BatteryLevel5[17];
|
||||
|
||||
extern const uint8_t BITMAP_USB_C[9];
|
||||
|
||||
extern const uint8_t BITMAP_KeyLock[9];
|
||||
extern const uint8_t BITMAP_KeyLock[6];
|
||||
|
||||
extern const uint8_t BITMAP_F_Key[9];
|
||||
extern const uint8_t BITMAP_F_Key[6];
|
||||
|
||||
extern const uint8_t BITMAP_VOX[18];
|
||||
|
||||
|
1
board.c
1
board.c
@ -711,6 +711,7 @@ void BOARD_EEPROM_Init(void)
|
||||
gSetting_ScrambleEnable = (Data[6] < 2) ? Data[6] : true;
|
||||
gSetting_TX_EN = (Data[7] & (1u << 0)) ? true : false;
|
||||
gSetting_live_DTMF_decoder = (Data[7] & (1u << 1)) ? true : false;
|
||||
gSetting_battery_text = (((Data[7] >> 2) & 3u) <= 2) ? (Data[7] >> 2) & 3: 2;
|
||||
|
||||
if (!gEeprom.VFO_OPEN)
|
||||
{
|
||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
1
misc.c
1
misc.c
@ -66,6 +66,7 @@ uint8_t gSetting_F_LOCK;
|
||||
bool gSetting_ScrambleEnable;
|
||||
|
||||
bool gSetting_live_DTMF_decoder;
|
||||
uint8_t gSetting_battery_text;
|
||||
|
||||
uint32_t gCustomAesKey[4];
|
||||
bool bHasCustomAesKey;
|
||||
|
1
misc.h
1
misc.h
@ -123,6 +123,7 @@ extern uint8_t gSetting_F_LOCK;
|
||||
extern bool gSetting_ScrambleEnable;
|
||||
|
||||
extern bool gSetting_live_DTMF_decoder;
|
||||
extern uint8_t gSetting_battery_text;
|
||||
|
||||
extern const uint32_t gDefaultAesKey[4];
|
||||
extern uint32_t gCustomAesKey[4];
|
||||
|
@ -172,6 +172,7 @@ void SETTINGS_SaveSettings(void)
|
||||
State[6] = gSetting_ScrambleEnable;
|
||||
if (!gSetting_TX_EN) State[7] &= ~(1u << 0);
|
||||
if (!gSetting_live_DTMF_decoder) State[7] &= ~(1u << 1);
|
||||
State[7] = (State[7] & ~(3u << 2)) | ((gSetting_battery_text & 3u) << 2);
|
||||
EEPROM_WriteBuffer(0x0F40, State);
|
||||
}
|
||||
|
||||
|
12
ui/menu.c
12
ui/menu.c
@ -95,6 +95,7 @@ const char MenuList[][7] =
|
||||
"PONMSG",
|
||||
"ROGER",
|
||||
"BATVOL", // was "VOL"
|
||||
"BATTXT",
|
||||
"MODE", // was "AM"
|
||||
#ifdef ENABLE_NOAA
|
||||
"NOAA-S",
|
||||
@ -248,6 +249,13 @@ const char gSubMenu_F_LOCK[6][4] =
|
||||
};
|
||||
#endif
|
||||
|
||||
const char gSubMenu_BAT_TXT[3][8] =
|
||||
{
|
||||
"NONE",
|
||||
"VOLTAGE",
|
||||
"PERCENT"
|
||||
};
|
||||
|
||||
bool gIsInSubMenu;
|
||||
uint8_t gMenuCursor;
|
||||
int8_t gMenuScrollDirection;
|
||||
@ -523,6 +531,10 @@ void UI_DisplayMenu(void)
|
||||
strcpy(String, gSubMenu_PTT_ID[gSubMenuSelection]);
|
||||
break;
|
||||
|
||||
case MENU_BAT_TXT:
|
||||
strcpy(String, gSubMenu_BAT_TXT[gSubMenuSelection]);
|
||||
break;
|
||||
|
||||
case MENU_D_LIST:
|
||||
gIsDtmfContactValid = DTMF_GetContact((int)gSubMenuSelection - 1, Contact);
|
||||
if (!gIsDtmfContactValid)
|
||||
|
@ -78,6 +78,7 @@ enum
|
||||
MENU_PONMSG,
|
||||
MENU_ROGER,
|
||||
MENU_VOL,
|
||||
MENU_BAT_TXT,
|
||||
MENU_AM,
|
||||
#ifdef ENABLE_NOAA
|
||||
MENU_NOAA_S,
|
||||
@ -122,6 +123,7 @@ extern const char gSubMenu_F_LOCK[6][4];
|
||||
#ifdef ENABLE_COMPANDER
|
||||
extern const char gSubMenu_Compand[4][6];
|
||||
#endif
|
||||
extern const char gSubMenu_BAT_TXT[3][8];
|
||||
|
||||
extern bool gIsInSubMenu;
|
||||
|
||||
|
156
ui/status.c
156
ui/status.c
@ -34,133 +34,177 @@
|
||||
|
||||
void UI_DisplayStatus(const bool test_display)
|
||||
{
|
||||
uint8_t *line = gStatusLine;
|
||||
uint8_t *line = gStatusLine;
|
||||
unsigned int x = 0;
|
||||
unsigned int x1 = 0;
|
||||
|
||||
gUpdateStatus = false;
|
||||
|
||||
memset(gStatusLine, 0, sizeof(gStatusLine));
|
||||
|
||||
// line += 2;
|
||||
// **************
|
||||
|
||||
// POWER-SAVE indicator
|
||||
if (gCurrentFunction == FUNCTION_POWER_SAVE || test_display)
|
||||
memmove(line, BITMAP_PowerSave, sizeof(BITMAP_PowerSave));
|
||||
line += sizeof(BITMAP_PowerSave);
|
||||
{
|
||||
memmove(line + x, BITMAP_PowerSave, sizeof(BITMAP_PowerSave));
|
||||
x1 = x + sizeof(BITMAP_PowerSave);
|
||||
}
|
||||
x += sizeof(BITMAP_PowerSave);
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
// NOASS SCAN indicator
|
||||
if (gIsNoaaMode || test_display)
|
||||
memmove(line, BITMAP_NOAA, sizeof(BITMAP_NOAA));
|
||||
line += sizeof(BITMAP_NOAA);
|
||||
{
|
||||
memmove(line + x, BITMAP_NOAA, sizeof(BITMAP_NOAA));
|
||||
x1 = x + sizeof(BITMAP_NOAA);
|
||||
}
|
||||
x += sizeof(BITMAP_NOAA);
|
||||
#else
|
||||
line += 12;
|
||||
// hmmm, what to put in it's place
|
||||
#endif
|
||||
|
||||
if (gSetting_KILLED)
|
||||
memset(line, 0xFF, 10);
|
||||
{
|
||||
memset(line + x, 0xFF, 10);
|
||||
x1 = x + 10;
|
||||
}
|
||||
else
|
||||
#ifdef ENABLE_FMRADIO
|
||||
// FM indicator
|
||||
if (gFmRadioMode || test_display)
|
||||
memmove(line, BITMAP_FM, sizeof(BITMAP_FM));
|
||||
{
|
||||
memmove(line + x, BITMAP_FM, sizeof(BITMAP_FM));
|
||||
x1 = x + sizeof(BITMAP_FM);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
// SCAN indicator
|
||||
if (gScanState != SCAN_OFF || gScreenToDisplay == DISPLAY_SCANNER || test_display)
|
||||
memmove(line, BITMAP_SC, sizeof(BITMAP_SC));
|
||||
line += sizeof(BITMAP_SC);
|
||||
{
|
||||
memmove(line + x, BITMAP_SC, sizeof(BITMAP_SC));
|
||||
x1 = x + sizeof(BITMAP_SC);
|
||||
}
|
||||
x += sizeof(BITMAP_SC);
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
// VOICE indicator
|
||||
if (gEeprom.VOICE_PROMPT != VOICE_PROMPT_OFF || test_display)
|
||||
memmove(line, BITMAP_VoicePrompt, sizeof(BITMAP_VoicePrompt));
|
||||
{
|
||||
memmove(line + x, BITMAP_VoicePrompt, sizeof(BITMAP_VoicePrompt));
|
||||
x1 = x + sizeof(BITMAP_VoicePrompt);
|
||||
}
|
||||
x += sizeof(BITMAP_VoicePrompt);
|
||||
#else
|
||||
if (test_display)
|
||||
memset(line, 0xFF, 8);
|
||||
// hmmm, what to put in it's place
|
||||
#endif
|
||||
line += 9;
|
||||
|
||||
// DUAL-WATCH indicator
|
||||
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF || test_display)
|
||||
{
|
||||
if (gDualWatchActive || test_display)
|
||||
memmove(line, BITMAP_TDR1, sizeof(BITMAP_TDR1));
|
||||
memmove(line + x, BITMAP_TDR1, sizeof(BITMAP_TDR1));
|
||||
else
|
||||
memmove(line, BITMAP_TDR2, sizeof(BITMAP_TDR2));
|
||||
memmove(line + x, BITMAP_TDR2, sizeof(BITMAP_TDR2));
|
||||
}
|
||||
line += sizeof(BITMAP_TDR1);
|
||||
x += sizeof(BITMAP_TDR1);
|
||||
|
||||
// CROSS-VFO indicator
|
||||
if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF || test_display)
|
||||
memmove(line, BITMAP_XB, sizeof(BITMAP_XB));
|
||||
line += sizeof(BITMAP_XB);
|
||||
|
||||
{
|
||||
memmove(line + x, BITMAP_XB, sizeof(BITMAP_XB));
|
||||
x1 = x + sizeof(BITMAP_XB);
|
||||
}
|
||||
x += sizeof(BITMAP_XB);
|
||||
|
||||
// VOX indicator
|
||||
if (gEeprom.VOX_SWITCH || test_display)
|
||||
memmove(line, BITMAP_VOX, sizeof(BITMAP_VOX));
|
||||
line += sizeof(BITMAP_VOX);
|
||||
{
|
||||
memmove(line + x, BITMAP_VOX, sizeof(BITMAP_VOX));
|
||||
x1 = x + sizeof(BITMAP_VOX);
|
||||
}
|
||||
x += sizeof(BITMAP_VOX);
|
||||
|
||||
// KEY-LOCK indicator
|
||||
if (gEeprom.KEY_LOCK || test_display)
|
||||
{
|
||||
memmove(line, BITMAP_KeyLock, sizeof(BITMAP_KeyLock));
|
||||
line += sizeof(BITMAP_KeyLock);
|
||||
memmove(line + x, BITMAP_KeyLock, sizeof(BITMAP_KeyLock));
|
||||
x += sizeof(BITMAP_KeyLock);
|
||||
x1 = x;
|
||||
}
|
||||
else
|
||||
if (gWasFKeyPressed)
|
||||
{
|
||||
memmove(line, BITMAP_F_Key, sizeof(BITMAP_F_Key));
|
||||
line += sizeof(BITMAP_F_Key);
|
||||
memmove(line + x, BITMAP_F_Key, sizeof(BITMAP_F_Key));
|
||||
x += sizeof(BITMAP_F_Key);
|
||||
x1 = x;
|
||||
}
|
||||
else
|
||||
if (!gChargingWithTypeC)
|
||||
|
||||
{ // battery voltage or percentage
|
||||
char s[8];
|
||||
char s[8];
|
||||
unsigned int space_needed;
|
||||
|
||||
unsigned int x2 = LCD_WIDTH - sizeof(BITMAP_BatteryLevel5) - 3;
|
||||
|
||||
#ifdef ENABLE_STATUSBAR_VOLTAGE
|
||||
if (gChargingWithTypeC)
|
||||
x2 -= sizeof(BITMAP_USB_C); // the radio is on charge
|
||||
|
||||
const char *fmt[] = {"%u.%02u", "%2u.%02uV"};
|
||||
unsigned int i = gEeprom.VOX_SWITCH ? 0 : 1; // add a 'V' and shift the text left a bit if the VOX is not showing
|
||||
sprintf(s, fmt[i], gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100);
|
||||
UI_PrintStringSmallBuffer(s, line - (i ? 20 : 0));
|
||||
|
||||
#elif defined(ENABLE_STATUSBAR_PERCENTAGE)
|
||||
|
||||
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 unsigned int x = (percent >= 100) ? 0 : 4; // move to the right a bit
|
||||
sprintf(s, "%u%%", percent);
|
||||
UI_PrintStringSmallBuffer(s, line + x);
|
||||
|
||||
#endif
|
||||
switch (gSetting_battery_text)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
break;
|
||||
|
||||
case 1: // voltage
|
||||
{
|
||||
const uint16_t voltage = (gBatteryVoltageAverage <= 999) ? gBatteryVoltageAverage : 999; // limit to 9.99V
|
||||
sprintf(s, "%u.%02uV", voltage / 100, voltage % 100);
|
||||
space_needed = (7 * strlen(s));
|
||||
if (x2 >= (x1 + space_needed))
|
||||
{
|
||||
UI_PrintStringSmallBuffer(s, line + x2 - space_needed);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 2: // percentage
|
||||
{
|
||||
const uint16_t voltage = (gBatteryVoltageAverage < gMin_bat_v) ? gMin_bat_v : gBatteryVoltageAverage;
|
||||
const uint16_t percent = (100 * (voltage - gMin_bat_v)) / (gMax_bat_v - gMin_bat_v);
|
||||
sprintf(s, "%u%%", percent);
|
||||
space_needed = (7 * strlen(s));
|
||||
if (x2 >= (x1 + space_needed))
|
||||
UI_PrintStringSmallBuffer(s, line + x2 - space_needed);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// move to right side of the screen
|
||||
line = gStatusLine + LCD_WIDTH - sizeof(BITMAP_BatteryLevel5) - sizeof(BITMAP_USB_C);
|
||||
x = LCD_WIDTH - sizeof(BITMAP_BatteryLevel5) - sizeof(BITMAP_USB_C);
|
||||
|
||||
// USB-C charge indicator
|
||||
if (gChargingWithTypeC || test_display)
|
||||
memmove(line, BITMAP_USB_C, sizeof(BITMAP_USB_C));
|
||||
line += sizeof(BITMAP_USB_C);
|
||||
memmove(line + x, BITMAP_USB_C, sizeof(BITMAP_USB_C));
|
||||
x += sizeof(BITMAP_USB_C);
|
||||
|
||||
// BATTERY LEVEL indicator
|
||||
if (gBatteryDisplayLevel >= 5 || test_display)
|
||||
memmove(line, BITMAP_BatteryLevel5, sizeof(BITMAP_BatteryLevel5));
|
||||
memmove(line + x, BITMAP_BatteryLevel5, sizeof(BITMAP_BatteryLevel5));
|
||||
else
|
||||
if (gBatteryDisplayLevel >= 4)
|
||||
memmove(line, BITMAP_BatteryLevel4, sizeof(BITMAP_BatteryLevel4));
|
||||
memmove(line + x, BITMAP_BatteryLevel4, sizeof(BITMAP_BatteryLevel4));
|
||||
else
|
||||
if (gBatteryDisplayLevel >= 3)
|
||||
memmove(line, BITMAP_BatteryLevel3, sizeof(BITMAP_BatteryLevel3));
|
||||
memmove(line + x, BITMAP_BatteryLevel3, sizeof(BITMAP_BatteryLevel3));
|
||||
else
|
||||
if (gBatteryDisplayLevel >= 2)
|
||||
memmove(line, BITMAP_BatteryLevel2, sizeof(BITMAP_BatteryLevel2));
|
||||
memmove(line + x, BITMAP_BatteryLevel2, sizeof(BITMAP_BatteryLevel2));
|
||||
else
|
||||
if (gLowBatteryBlink == 1)
|
||||
memmove(line, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
|
||||
memmove(line + x, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
|
||||
|
||||
// **************
|
||||
|
||||
ST7565_BlitStatusLine();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user