2023-09-09 08:03:56 +01:00
|
|
|
/* Copyright 2023 Dual Tachyon
|
|
|
|
* https://github.com/DualTachyon
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stddef.h>
|
2023-09-25 07:12:08 +01:00
|
|
|
#include <string.h>
|
|
|
|
|
2023-09-09 08:03:56 +01:00
|
|
|
#include "bitmaps.h"
|
|
|
|
#include "driver/st7565.h"
|
|
|
|
#include "functions.h"
|
|
|
|
#include "ui/battery.h"
|
|
|
|
|
2023-10-06 22:16:03 +01:00
|
|
|
void UI_DisplayBattery(const unsigned int level, const unsigned int blink)
|
2023-09-09 08:03:56 +01:00
|
|
|
{
|
2023-10-06 22:16:03 +01:00
|
|
|
uint8_t bitmap[sizeof(BITMAP_BATTERY_LEVEL)];
|
2023-09-25 07:12:08 +01:00
|
|
|
|
2023-10-06 22:16:03 +01:00
|
|
|
memmove(bitmap, BITMAP_BATTERY_LEVEL, sizeof(BITMAP_BATTERY_LEVEL));
|
2023-09-25 07:12:08 +01:00
|
|
|
|
2023-10-06 22:16:03 +01:00
|
|
|
if (level >= 1)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
const uint8_t bars = (level <= 5) - 1 ? level - 1 : 5 - 1;
|
|
|
|
for (i = 0; i < bars; i++)
|
2023-09-25 07:12:08 +01:00
|
|
|
{
|
2023-10-06 22:16:03 +01:00
|
|
|
#ifndef ENABLE_REVERSE_BAT_SYMBOL
|
|
|
|
bitmap[sizeof(bitmap) - 3 - (i * 3) - 0] = 0b01011101;
|
|
|
|
bitmap[sizeof(bitmap) - 3 - (i * 3) - 1] = 0b01011101;
|
2023-09-25 07:12:08 +01:00
|
|
|
#else
|
2023-10-06 22:16:03 +01:00
|
|
|
bitmap[3 + (i * 3) + 0] = 0b01011101;
|
|
|
|
bitmap[3 + (i * 3) + 1] = 0b01011101;
|
2023-09-25 07:12:08 +01:00
|
|
|
#endif
|
|
|
|
}
|
2023-09-09 08:03:56 +01:00
|
|
|
}
|
2023-10-06 22:16:03 +01:00
|
|
|
else
|
|
|
|
if (blink == 0)
|
|
|
|
memset(bitmap, 0, sizeof(bitmap));
|
|
|
|
|
|
|
|
// col lne, siz, bm
|
|
|
|
ST7565_DrawLine(LCD_WIDTH - sizeof(bitmap), 0, sizeof(bitmap), bitmap);
|
2023-09-09 08:03:56 +01:00
|
|
|
}
|