mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-04-28 22:31:25 +03:00
Merge pull request #143 from egzumer/battery_fix
BUG FIX #139: always 4 battery bars
This commit is contained in:
commit
8b552e6e97
15
ui/battery.c
15
ui/battery.c
@ -22,16 +22,15 @@
|
||||
#include "functions.h"
|
||||
#include "ui/battery.h"
|
||||
|
||||
void UI_DisplayBattery(const unsigned int level, const unsigned int blink)
|
||||
void UI_DrawBattery(uint8_t* bitmap, const unsigned int level, const unsigned int blink)
|
||||
{
|
||||
uint8_t bitmap[sizeof(BITMAP_BATTERY_LEVEL)];
|
||||
|
||||
memmove(bitmap, BITMAP_BATTERY_LEVEL, sizeof(BITMAP_BATTERY_LEVEL));
|
||||
|
||||
if (level >= 1)
|
||||
{
|
||||
unsigned int i;
|
||||
const uint8_t bars = (level <= 5) - 1 ? level - 1 : 5 - 1;
|
||||
uint8_t bars = level > 0 ? level - 1 : 0;
|
||||
if(bars>4) bars = 4;
|
||||
for (i = 0; i < bars; i++)
|
||||
{
|
||||
#ifndef ENABLE_REVERSE_BAT_SYMBOL
|
||||
@ -46,7 +45,13 @@ void UI_DisplayBattery(const unsigned int level, const unsigned int blink)
|
||||
else
|
||||
if (blink == 0)
|
||||
memset(bitmap, 0, sizeof(bitmap));
|
||||
}
|
||||
|
||||
// col lne, siz, bm
|
||||
void UI_DisplayBattery(const unsigned int level, const unsigned int blink)
|
||||
{
|
||||
uint8_t bitmap[sizeof(BITMAP_BATTERY_LEVEL)];
|
||||
|
||||
UI_DrawBattery(bitmap, level, blink);
|
||||
memmove(bitmap, BITMAP_BATTERY_LEVEL, sizeof(BITMAP_BATTERY_LEVEL));
|
||||
ST7565_DrawLine(LCD_WIDTH - sizeof(bitmap), 0, sizeof(bitmap), bitmap);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
#define UI_BATTERY_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void UI_DrawBattery(uint8_t* bitmap, const unsigned int level, const unsigned int blink);
|
||||
void UI_DisplayBattery(const unsigned int Level, const unsigned int blink);
|
||||
|
||||
#endif
|
||||
|
29
ui/status.c
29
ui/status.c
@ -28,6 +28,7 @@
|
||||
#include "helper/battery.h"
|
||||
#include "misc.h"
|
||||
#include "settings.h"
|
||||
#include "ui/battery.h"
|
||||
#include "ui/helper.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/status.h"
|
||||
@ -216,32 +217,8 @@ void UI_DisplayStatus(const bool test_display)
|
||||
memmove(line + x, BITMAP_USB_C, sizeof(BITMAP_USB_C));
|
||||
x += sizeof(BITMAP_USB_C);
|
||||
|
||||
{ // BATTERY LEVEL indicator
|
||||
uint8_t bitmap[sizeof(BITMAP_BATTERY_LEVEL)];
|
||||
unsigned int i = g_battery_display_level;
|
||||
|
||||
memmove(bitmap, BITMAP_BATTERY_LEVEL, sizeof(BITMAP_BATTERY_LEVEL));
|
||||
|
||||
if (i >= 1)
|
||||
{
|
||||
const uint8_t bars = (i <= 5) - 1 ? i - 1 : 5 - 1;
|
||||
for (i = 0; i < bars; i++)
|
||||
{
|
||||
#ifndef ENABLE_REVERSE_BAT_SYMBOL
|
||||
bitmap[sizeof(bitmap) - 3 - (i * 3) - 0] = 0b01011101;
|
||||
bitmap[sizeof(bitmap) - 3 - (i * 3) - 1] = 0b01011101;
|
||||
#else
|
||||
bitmap[3 + (i * 3) + 0] = 0b01011101;
|
||||
bitmap[3 + (i * 3) + 1] = 0b01011101;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
if (g_low_battery)
|
||||
memset(bitmap, 0, sizeof(bitmap));
|
||||
|
||||
memmove(line + x, bitmap, sizeof(bitmap));
|
||||
}
|
||||
// BATTERY LEVEL indicator
|
||||
UI_DrawBattery(line + x, g_battery_display_level, g_low_battery);
|
||||
|
||||
// **************
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user