mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-04-29 14:51:26 +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 "functions.h"
|
||||||
#include "ui/battery.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));
|
memmove(bitmap, BITMAP_BATTERY_LEVEL, sizeof(BITMAP_BATTERY_LEVEL));
|
||||||
|
|
||||||
if (level >= 1)
|
if (level >= 1)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
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++)
|
for (i = 0; i < bars; i++)
|
||||||
{
|
{
|
||||||
#ifndef ENABLE_REVERSE_BAT_SYMBOL
|
#ifndef ENABLE_REVERSE_BAT_SYMBOL
|
||||||
@ -46,7 +45,13 @@ void UI_DisplayBattery(const unsigned int level, const unsigned int blink)
|
|||||||
else
|
else
|
||||||
if (blink == 0)
|
if (blink == 0)
|
||||||
memset(bitmap, 0, sizeof(bitmap));
|
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);
|
ST7565_DrawLine(LCD_WIDTH - sizeof(bitmap), 0, sizeof(bitmap), bitmap);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#define UI_BATTERY_H
|
#define UI_BATTERY_H
|
||||||
|
|
||||||
#include <stdint.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);
|
void UI_DisplayBattery(const unsigned int Level, const unsigned int blink);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
29
ui/status.c
29
ui/status.c
@ -28,6 +28,7 @@
|
|||||||
#include "helper/battery.h"
|
#include "helper/battery.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
#include "ui/battery.h"
|
||||||
#include "ui/helper.h"
|
#include "ui/helper.h"
|
||||||
#include "ui/ui.h"
|
#include "ui/ui.h"
|
||||||
#include "ui/status.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));
|
memmove(line + x, BITMAP_USB_C, sizeof(BITMAP_USB_C));
|
||||||
x += sizeof(BITMAP_USB_C);
|
x += sizeof(BITMAP_USB_C);
|
||||||
|
|
||||||
{ // BATTERY LEVEL indicator
|
// BATTERY LEVEL indicator
|
||||||
uint8_t bitmap[sizeof(BITMAP_BATTERY_LEVEL)];
|
UI_DrawBattery(line + x, g_battery_display_level, g_low_battery);
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
// **************
|
// **************
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user