mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-11-28 02:45:45 +03:00
commit
24c12ab852
@ -36,6 +36,13 @@
|
||||
#define MIN_PIN_SIZE 4
|
||||
#define MAX_APP_LENGTH 128
|
||||
|
||||
#define DISPLAY_BATTERY_BAR 0
|
||||
#define DISPLAY_BATTERY_PERCENT 1
|
||||
#define DISPLAY_BATTERY_INVERTED_PERCENT 2
|
||||
#define DISPLAY_BATTERY_RETRO_3 3
|
||||
#define DISPLAY_BATTERY_RETRO_5 4
|
||||
#define DISPLAY_BATTERY_BAR_PERCENT 5
|
||||
|
||||
#define FAP_LOADER_APP_NAME "Applications"
|
||||
|
||||
typedef struct {
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "power_i.h"
|
||||
#include "desktop/desktop_settings.h"
|
||||
#include "power_i.h"
|
||||
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
@ -14,7 +14,7 @@ void power_draw_battery_callback(Canvas* canvas, void* context) {
|
||||
if(power->info.gauge_is_ok) {
|
||||
char batteryPercentile[4];
|
||||
snprintf(batteryPercentile, sizeof(batteryPercentile), "%d", power->info.charge);
|
||||
if((power->displayBatteryPercentage == 1) &&
|
||||
if((power->displayBatteryPercentage == DISPLAY_BATTERY_PERCENT) &&
|
||||
(power->state !=
|
||||
PowerStateCharging)) { //if display battery percentage, black background white text
|
||||
canvas_set_font(canvas, FontBatteryPercent);
|
||||
@ -23,14 +23,14 @@ void power_draw_battery_callback(Canvas* canvas, void* context) {
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
canvas_draw_str_aligned(canvas, 11, 4, AlignCenter, AlignCenter, batteryPercentile);
|
||||
} else if(
|
||||
(power->displayBatteryPercentage == 2) &&
|
||||
(power->displayBatteryPercentage == DISPLAY_BATTERY_INVERTED_PERCENT) &&
|
||||
(power->state !=
|
||||
PowerStateCharging)) { //if display inverted percentage, white background black text
|
||||
canvas_set_font(canvas, FontBatteryPercent);
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_draw_str_aligned(canvas, 11, 4, AlignCenter, AlignCenter, batteryPercentile);
|
||||
} else if(
|
||||
(power->displayBatteryPercentage == 3) &&
|
||||
(power->displayBatteryPercentage == DISPLAY_BATTERY_RETRO_3) &&
|
||||
(power->state != PowerStateCharging)) { //Retro style segmented display, 3 parts
|
||||
if(power->info.charge > 25) {
|
||||
canvas_draw_box(canvas, 2, 2, 6, 4);
|
||||
@ -42,7 +42,7 @@ void power_draw_battery_callback(Canvas* canvas, void* context) {
|
||||
canvas_draw_box(canvas, 16, 2, 6, 4);
|
||||
}
|
||||
} else if(
|
||||
(power->displayBatteryPercentage == 4) &&
|
||||
(power->displayBatteryPercentage == DISPLAY_BATTERY_RETRO_5) &&
|
||||
(power->state != PowerStateCharging)) { //Retro style segmented display, 5 parts
|
||||
if(power->info.charge > 10) {
|
||||
canvas_draw_box(canvas, 2, 2, 3, 4);
|
||||
@ -59,6 +59,58 @@ void power_draw_battery_callback(Canvas* canvas, void* context) {
|
||||
if(power->info.charge > 90) {
|
||||
canvas_draw_box(canvas, 18, 2, 3, 4);
|
||||
}
|
||||
} else if(
|
||||
(power->displayBatteryPercentage == DISPLAY_BATTERY_BAR_PERCENT) &&
|
||||
(power->state != PowerStateCharging) && // Default bar display with percentage
|
||||
(power->info.voltage_battery_charging >= 4.2)) { // not looking nice with low voltage indicator
|
||||
canvas_set_font(canvas, FontBatteryPercent);
|
||||
|
||||
// align charge dispaly value with digits to draw
|
||||
uint8_t bar_charge = power->info.charge;
|
||||
if(bar_charge > 23 && bar_charge < 38) {
|
||||
bar_charge = 23;
|
||||
} else if(bar_charge >= 38 && bar_charge < 62) {
|
||||
bar_charge = 50;
|
||||
} else if(bar_charge >= 62 && bar_charge < 74) {
|
||||
bar_charge = 74;
|
||||
}
|
||||
|
||||
// drawing digits
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_draw_box(canvas, 1, 1, (bar_charge * 22) / 100, 6);
|
||||
if(bar_charge < 38) { // both digits are black
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_draw_str_aligned(
|
||||
canvas, 11, 4, AlignCenter, AlignCenter, batteryPercentile);
|
||||
} else if(bar_charge >= 38 && bar_charge < 74) { // first digit is white
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
|
||||
// first
|
||||
char batteryPercentileFirstDigit[2];
|
||||
snprintf(
|
||||
batteryPercentileFirstDigit,
|
||||
sizeof(batteryPercentileFirstDigit),
|
||||
"%c",
|
||||
batteryPercentile[0]);
|
||||
canvas_draw_str_aligned(
|
||||
canvas, 9, 4, AlignCenter, AlignCenter, batteryPercentileFirstDigit);
|
||||
|
||||
// second
|
||||
char batteryPercentileSecondDigit[2];
|
||||
snprintf(
|
||||
batteryPercentileSecondDigit,
|
||||
sizeof(batteryPercentileSecondDigit),
|
||||
"%c",
|
||||
batteryPercentile[1]);
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_draw_str_aligned(
|
||||
canvas, 15, 4, AlignCenter, AlignCenter, batteryPercentileSecondDigit);
|
||||
} else { // charge >= 74, both digits are white
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
canvas_draw_str_aligned(
|
||||
canvas, 11, 4, AlignCenter, AlignCenter, batteryPercentile);
|
||||
}
|
||||
|
||||
} else { //default bar display, added here to serve as fallback/default behaviour.
|
||||
canvas_draw_box(canvas, 2, 2, (power->info.charge + 4) / 5, 4);
|
||||
}
|
||||
@ -82,7 +134,7 @@ void power_draw_battery_callback(Canvas* canvas, void* context) {
|
||||
if(power->state == PowerStateCharging) {
|
||||
canvas_set_bitmap_mode(canvas, 1);
|
||||
// TODO: replace -1 magic for uint8_t with re-framing
|
||||
if(power->displayBatteryPercentage == 1) {
|
||||
if(power->displayBatteryPercentage == DISPLAY_BATTERY_PERCENT) {
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_draw_box(canvas, 1, 1, 22, 6);
|
||||
canvas_draw_icon(canvas, 2, -1, &I_Charging_lightning_9x10);
|
||||
@ -91,7 +143,7 @@ void power_draw_battery_callback(Canvas* canvas, void* context) {
|
||||
canvas_set_font(canvas, FontBatteryPercent);
|
||||
canvas_draw_str_aligned(
|
||||
canvas, 16, 4, AlignCenter, AlignCenter, batteryPercentile);
|
||||
} else if(power->displayBatteryPercentage == 2) {
|
||||
} else if(power->displayBatteryPercentage == DISPLAY_BATTERY_INVERTED_PERCENT) {
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
canvas_draw_box(canvas, 1, 1, 22, 6);
|
||||
canvas_draw_icon(canvas, 2, -1, &I_Charging_lightning_9x10);
|
||||
@ -100,6 +152,64 @@ void power_draw_battery_callback(Canvas* canvas, void* context) {
|
||||
canvas_set_font(canvas, FontBatteryPercent);
|
||||
canvas_draw_str_aligned(
|
||||
canvas, 16, 4, AlignCenter, AlignCenter, batteryPercentile);
|
||||
} else if(power->displayBatteryPercentage == DISPLAY_BATTERY_BAR_PERCENT) {
|
||||
|
||||
// clean-up default charging bar display
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
canvas_draw_box(canvas, 1, 1, 22, 6);
|
||||
|
||||
// align charge dispaly value with digits to draw
|
||||
uint8_t bar_charge = power->info.charge;
|
||||
|
||||
if(bar_charge > 48 && bar_charge < 63) {
|
||||
bar_charge = 48;
|
||||
} else if(bar_charge >= 63 && bar_charge < 84) {
|
||||
bar_charge = 75;
|
||||
} else if(bar_charge >= 84 && bar_charge < 96) {
|
||||
bar_charge = 96;
|
||||
}
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_draw_box(canvas, 1, 1, (bar_charge * 22) / 100, 6);
|
||||
|
||||
// drawing charge icon
|
||||
canvas_draw_icon(canvas, 2, -1, &I_Charging_lightning_9x10);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
canvas_draw_icon(canvas, 2, -1, &I_Charging_lightning_mask_9x10);
|
||||
|
||||
// drawing digits
|
||||
canvas_set_font(canvas, FontBatteryPercent);
|
||||
if(bar_charge < 64) { // both digits are black
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_draw_str_aligned(
|
||||
canvas, 16, 4, AlignCenter, AlignCenter, batteryPercentile);
|
||||
} else if(bar_charge >= 64 && bar_charge < 84) { // first digit is white
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
|
||||
// first
|
||||
char batteryPercentileFirstDigit[2];
|
||||
snprintf(
|
||||
batteryPercentileFirstDigit,
|
||||
sizeof(batteryPercentileFirstDigit),
|
||||
"%c",
|
||||
batteryPercentile[0]);
|
||||
canvas_draw_str_aligned(
|
||||
canvas, 14, 4, AlignCenter, AlignCenter, batteryPercentileFirstDigit);
|
||||
|
||||
// second
|
||||
char batteryPercentileSecondDigit[2];
|
||||
snprintf(
|
||||
batteryPercentileSecondDigit,
|
||||
sizeof(batteryPercentileSecondDigit),
|
||||
"%c",
|
||||
batteryPercentile[1]);
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_draw_str_aligned(
|
||||
canvas, 20, 4, AlignCenter, AlignCenter, batteryPercentileSecondDigit);
|
||||
} else { // charge >= 84, both digits are white
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
canvas_draw_str_aligned(
|
||||
canvas, 16, 4, AlignCenter, AlignCenter, batteryPercentile);
|
||||
}
|
||||
} else {
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
canvas_draw_icon(canvas, 8, -1, &I_Charging_lightning_mask_9x10);
|
||||
|
@ -26,7 +26,7 @@ const char* const auto_lock_delay_text[AUTO_LOCK_DELAY_COUNT] = {
|
||||
const uint32_t auto_lock_delay_value[AUTO_LOCK_DELAY_COUNT] =
|
||||
{0, 10000, 15000, 30000, 60000, 90000, 120000, 300000, 600000};
|
||||
|
||||
#define BATTERY_VIEW_COUNT 5
|
||||
#define BATTERY_VIEW_COUNT 6
|
||||
|
||||
const char* const battery_view_count_text[BATTERY_VIEW_COUNT] = {
|
||||
"Bar",
|
||||
@ -34,9 +34,17 @@ const char* const battery_view_count_text[BATTERY_VIEW_COUNT] = {
|
||||
"Inv. %",
|
||||
"Retro 3",
|
||||
"Retro 5",
|
||||
"Bar %"
|
||||
};
|
||||
|
||||
const uint32_t displayBatteryPercentage_value[BATTERY_VIEW_COUNT] = {0, 1, 2, 3, 4};
|
||||
const uint32_t displayBatteryPercentage_value[BATTERY_VIEW_COUNT] = {
|
||||
DISPLAY_BATTERY_BAR,
|
||||
DISPLAY_BATTERY_PERCENT,
|
||||
DISPLAY_BATTERY_INVERTED_PERCENT,
|
||||
DISPLAY_BATTERY_RETRO_3,
|
||||
DISPLAY_BATTERY_RETRO_5,
|
||||
DISPLAY_BATTERY_BAR_PERCENT
|
||||
};
|
||||
|
||||
static void desktop_settings_scene_start_var_list_enter_callback(void* context, uint32_t index) {
|
||||
DesktopSettingsApp* app = context;
|
||||
|
Loading…
Reference in New Issue
Block a user