mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-17 04:34:44 -07:00
battery off switch
This commit is contained in:
@@ -36,12 +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 DISPLAY_BATTERY_NO 0
|
||||
#define DISPLAY_BATTERY_BAR 1
|
||||
#define DISPLAY_BATTERY_PERCENT 2
|
||||
#define DISPLAY_BATTERY_INVERTED_PERCENT 3
|
||||
#define DISPLAY_BATTERY_RETRO_3 4
|
||||
#define DISPLAY_BATTERY_RETRO_5 5
|
||||
#define DISPLAY_BATTERY_BAR_PERCENT 6
|
||||
|
||||
#define FAP_LOADER_APP_NAME "Applications"
|
||||
|
||||
|
||||
@@ -9,6 +9,10 @@
|
||||
void power_draw_battery_callback(Canvas* canvas, void* context) {
|
||||
furi_assert(context);
|
||||
Power* power = context;
|
||||
if(power->displayBatteryPercentage == DISPLAY_BATTERY_NO) {
|
||||
// no draw
|
||||
} else {
|
||||
|
||||
canvas_draw_icon(canvas, 0, 0, &I_Battery_25x8);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
canvas_draw_box(canvas, -1, 0, 1, 8);
|
||||
@@ -21,6 +25,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 == DISPLAY_BATTERY_PERCENT) &&
|
||||
(power->state !=
|
||||
PowerStateCharging)) { //if display battery percentage, black background white text
|
||||
@@ -172,12 +177,17 @@ void power_draw_battery_callback(Canvas* canvas, void* context) {
|
||||
canvas_draw_box(canvas, 8, 3, 8, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static ViewPort* power_battery_view_port_alloc(Power* power) {
|
||||
ViewPort* battery_view_port = view_port_alloc();
|
||||
if(power->displayBatteryPercentage == DISPLAY_BATTERY_NO) {
|
||||
// no draw
|
||||
} else {
|
||||
view_port_set_width(battery_view_port, icon_get_width(&I_Battery_25x8));
|
||||
view_port_draw_callback_set(battery_view_port, power_draw_battery_callback, power);
|
||||
gui_add_view_port(power->gui, battery_view_port, GuiLayerStatusBarRight);
|
||||
}
|
||||
return battery_view_port;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,10 +26,11 @@ 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 6
|
||||
#define BATTERY_VIEW_COUNT 7
|
||||
const char* const battery_view_count_text[BATTERY_VIEW_COUNT] =
|
||||
{"Bar", "%", "Inv. %", "Retro 3", "Retro 5", "Bar %"};
|
||||
{"Off", "Bar", "%", "Inv. %", "Retro 3", "Retro 5", "Bar %"};
|
||||
const uint32_t displayBatteryPercentage_value[BATTERY_VIEW_COUNT] = {
|
||||
DISPLAY_BATTERY_NO,
|
||||
DISPLAY_BATTERY_BAR,
|
||||
DISPLAY_BATTERY_PERCENT,
|
||||
DISPLAY_BATTERY_INVERTED_PERCENT,
|
||||
|
||||
Reference in New Issue
Block a user