Battery symbol fix
This commit is contained in:
80
ui/battery.c
80
ui/battery.c
@@ -22,66 +22,36 @@
|
|||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
#include "ui/battery.h"
|
#include "ui/battery.h"
|
||||||
|
|
||||||
void UI_DisplayBattery(const uint8_t level, const uint8_t blink)
|
void UI_DrawBattery(uint8_t* bitmap, uint8_t level, uint8_t blink)
|
||||||
{
|
{
|
||||||
// if (gCurrentFunction != FUNCTION_TRANSMIT)
|
memmove(bitmap, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
|
||||||
|
|
||||||
|
if (level >= 1)
|
||||||
{
|
{
|
||||||
|
unsigned int i;
|
||||||
|
uint8_t bars = level > 0 ? level - 1 : 0;
|
||||||
|
if(bars>4) bars = 4;
|
||||||
|
for (i = 0; i < bars; i++)
|
||||||
|
{
|
||||||
|
#ifndef ENABLE_REVERSE_BAT_SYMBOL
|
||||||
|
memcpy(bitmap + sizeof(bitmap) - 4 - (i * 3), BITMAP_BatteryLevel, 2);
|
||||||
|
#else
|
||||||
|
memcpy(bitmap + 3 + (i * 3) + 0, BITMAP_BatteryLevel, 2);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (blink == 0)
|
||||||
|
memset(bitmap, 0, sizeof(bitmap));
|
||||||
|
}
|
||||||
|
|
||||||
|
void UI_DisplayBattery(uint8_t level, uint8_t blink)
|
||||||
|
{
|
||||||
|
if (gCurrentFunction != FUNCTION_TRANSMIT) {
|
||||||
uint8_t bitmap[sizeof(BITMAP_BatteryLevel1)];
|
uint8_t bitmap[sizeof(BITMAP_BatteryLevel1)];
|
||||||
|
|
||||||
#if 1
|
UI_DrawBattery(bitmap, level, blink);
|
||||||
|
|
||||||
if (level >= 2)
|
|
||||||
{
|
|
||||||
memmove(bitmap, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
|
memmove(bitmap, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
|
||||||
#ifndef ENABLE_REVERSE_BAT_SYMBOL
|
|
||||||
uint8_t *pb = bitmap + sizeof(BITMAP_BatteryLevel1);
|
|
||||||
if (level >= 2)
|
|
||||||
memmove(pb - 4, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
|
||||||
if (level >= 5)
|
|
||||||
memmove(pb - 7, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
|
||||||
if (level >= 7)
|
|
||||||
memmove(pb - 10, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
|
||||||
if (level >= 9)
|
|
||||||
memmove(pb - 13, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
|
||||||
#else
|
|
||||||
if (level >= 2)
|
|
||||||
memmove(bitmap + 3, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
|
||||||
if (level >= 5)
|
|
||||||
memmove(bitmap + 6, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
|
||||||
if (level >= 7)
|
|
||||||
memmove(bitmap + 9, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
|
||||||
if (level >= 9)
|
|
||||||
memmove(bitmap + 12, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (blink == 1)
|
|
||||||
memmove(bitmap, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
|
|
||||||
else
|
|
||||||
memset(bitmap, 0, sizeof(bitmap));
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
if (level > 0)
|
|
||||||
{
|
|
||||||
const uint8_t lev = (level <= 11) ? level : 11;
|
|
||||||
|
|
||||||
memmove(bitmap, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
|
|
||||||
|
|
||||||
#ifdef ENABLE_REVERSE_BAT_SYMBOL
|
|
||||||
for (uint8_t i = 0; i < lev; i++)
|
|
||||||
bitmap[3 + i] = (i & 1u) ? 0b01011101 : 0b01011101;
|
|
||||||
#else
|
|
||||||
for (uint8_t i = 0; i < lev; i++)
|
|
||||||
bitmap[sizeof(bitmap) - 3 - i] = (i & 1u) ? 0b01011101 : 0b01011101;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
memset(bitmap, 0, sizeof(bitmap));
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// col lne, siz, bm
|
|
||||||
ST7565_DrawLine(LCD_WIDTH - sizeof(bitmap), 0, sizeof(bitmap), bitmap);
|
ST7565_DrawLine(LCD_WIDTH - sizeof(bitmap), 0, sizeof(bitmap), bitmap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
#define UI_BATTERY_H
|
#define UI_BATTERY_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
void UI_DrawBattery(uint8_t* bitmap, uint8_t level, uint8_t blink);
|
||||||
void UI_DisplayBattery(const uint8_t Level, const uint8_t blink);
|
void UI_DisplayBattery(uint8_t Level, uint8_t blink);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
45
ui/status.c
45
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"
|
||||||
@@ -217,49 +218,7 @@ void UI_DisplayStatus(const bool test_display)
|
|||||||
x += sizeof(BITMAP_USB_C);
|
x += sizeof(BITMAP_USB_C);
|
||||||
|
|
||||||
// BATTERY LEVEL indicator
|
// BATTERY LEVEL indicator
|
||||||
if (gBatteryDisplayLevel >= 2 && !gLowBattery)
|
UI_DrawBattery(line + x, gBatteryDisplayLevel, gLowBattery);
|
||||||
{
|
|
||||||
line += x;
|
|
||||||
memmove(line, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
|
|
||||||
|
|
||||||
#ifndef ENABLE_REVERSE_BAT_SYMBOL
|
|
||||||
line += sizeof(BITMAP_BatteryLevel1);
|
|
||||||
{
|
|
||||||
const int8_t pos[] = {-4, -7, -10, 13};
|
|
||||||
for (unsigned int i = 0; i < ARRAY_SIZE(pos); i++)
|
|
||||||
if (gBatteryDisplayLevel >= (2 + i))
|
|
||||||
memmove(line + pos[i], BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
|
||||||
|
|
||||||
/* switch (gBatteryDisplayLevel)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
case 5: memmove(line - 13, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
|
||||||
case 4: memmove(line - 10, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
|
||||||
case 3: memmove(line - 7, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
|
||||||
case 2: memmove(line - 4, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
|
||||||
}
|
|
||||||
*/ }
|
|
||||||
#else
|
|
||||||
{
|
|
||||||
const int8_t pos[] = {3, 6, 9, 12};
|
|
||||||
for (unsigned int i = 0; i < ARRAY_SIZE(pos); i++)
|
|
||||||
if (gBatteryDisplayLevel >= (2 + i))
|
|
||||||
memmove(line + pos[i], BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
|
||||||
/*
|
|
||||||
switch (gBatteryDisplayLevel)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
case 5: memmove(line + 12, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
|
||||||
case 4: memmove(line + 9, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
|
||||||
case 3: memmove(line + 6, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
|
||||||
case 2: memmove(line + 3, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
|
||||||
}
|
|
||||||
*/ }
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (gLowBatteryBlink == 1)
|
|
||||||
memmove(line + x, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
|
|
||||||
|
|
||||||
// **************
|
// **************
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user