mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-13 21:18:35 -07:00
Allow desktop clock with no battery icon
This commit is contained in:
@@ -20,6 +20,8 @@ static void xtreme_app_scene_interface_statusbar_battery_icon_changed(VariableIt
|
|||||||
variable_item_set_current_value_text(item, battery_icon_names[index]);
|
variable_item_set_current_value_text(item, battery_icon_names[index]);
|
||||||
XTREME_SETTINGS()->battery_icon = index;
|
XTREME_SETTINGS()->battery_icon = index;
|
||||||
app->save_settings = true;
|
app->save_settings = true;
|
||||||
|
power_set_battery_icon_enabled(furi_record_open(RECORD_POWER), index != BatteryIconOff);
|
||||||
|
furi_record_close(RECORD_POWER);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xtreme_app_scene_interface_statusbar_status_icons_changed(VariableItem* item) {
|
static void xtreme_app_scene_interface_statusbar_status_icons_changed(VariableItem* item) {
|
||||||
|
|||||||
@@ -100,75 +100,67 @@ static void gui_redraw_status_bar(Gui* gui, bool need_attention) {
|
|||||||
}
|
}
|
||||||
canvas_set_bitmap_mode(gui->canvas, 0);
|
canvas_set_bitmap_mode(gui->canvas, 0);
|
||||||
|
|
||||||
uint8_t x;
|
|
||||||
|
|
||||||
// Right side
|
// Right side
|
||||||
if(xtreme_settings->battery_icon != BatteryIconOff) {
|
uint8_t x = GUI_DISPLAY_WIDTH - 1;
|
||||||
x = GUI_DISPLAY_WIDTH - 1;
|
ViewPortArray_it(it, gui->layers[GuiLayerStatusBarRight]);
|
||||||
ViewPortArray_it(it, gui->layers[GuiLayerStatusBarRight]);
|
while(!ViewPortArray_end_p(it) && right_used < GUI_STATUS_BAR_WIDTH) {
|
||||||
while(!ViewPortArray_end_p(it) && right_used < GUI_STATUS_BAR_WIDTH) {
|
ViewPort* view_port = *ViewPortArray_ref(it);
|
||||||
ViewPort* view_port = *ViewPortArray_ref(it);
|
if(view_port_is_enabled(view_port)) {
|
||||||
if(view_port_is_enabled(view_port)) {
|
width = view_port_get_width(view_port);
|
||||||
width = view_port_get_width(view_port);
|
if(!width) width = 8;
|
||||||
if(!width) width = 8;
|
// Recalculate next position
|
||||||
// Recalculate next position
|
right_used += (width + 2);
|
||||||
right_used += (width + 2);
|
x -= (width + 2);
|
||||||
x -= (width + 2);
|
// Prepare work area background
|
||||||
// Prepare work area background
|
|
||||||
canvas_frame_set(
|
|
||||||
gui->canvas,
|
|
||||||
x - 1,
|
|
||||||
GUI_STATUS_BAR_Y + 1,
|
|
||||||
width + 2,
|
|
||||||
GUI_STATUS_BAR_WORKAREA_HEIGHT + 2);
|
|
||||||
// Hide battery background
|
|
||||||
if(xtreme_settings->bar_borders) {
|
|
||||||
canvas_set_color(gui->canvas, ColorWhite);
|
|
||||||
canvas_draw_box(
|
|
||||||
gui->canvas,
|
|
||||||
-1,
|
|
||||||
0,
|
|
||||||
canvas_width(gui->canvas) + 1,
|
|
||||||
canvas_height(gui->canvas));
|
|
||||||
}
|
|
||||||
canvas_set_color(gui->canvas, ColorBlack);
|
|
||||||
// ViewPort draw
|
|
||||||
canvas_frame_set(
|
|
||||||
gui->canvas,
|
|
||||||
x - xtreme_settings->bar_borders,
|
|
||||||
GUI_STATUS_BAR_Y + 2,
|
|
||||||
width,
|
|
||||||
GUI_STATUS_BAR_WORKAREA_HEIGHT);
|
|
||||||
view_port_draw(view_port, gui->canvas);
|
|
||||||
}
|
|
||||||
ViewPortArray_next(it);
|
|
||||||
}
|
|
||||||
// Draw frame around icons on the right
|
|
||||||
if(right_used) {
|
|
||||||
canvas_frame_set(
|
canvas_frame_set(
|
||||||
gui->canvas,
|
gui->canvas,
|
||||||
GUI_DISPLAY_WIDTH - 4 - right_used,
|
x - 1,
|
||||||
GUI_STATUS_BAR_Y,
|
GUI_STATUS_BAR_Y + 1,
|
||||||
right_used + 4,
|
width + 2,
|
||||||
GUI_STATUS_BAR_HEIGHT);
|
GUI_STATUS_BAR_WORKAREA_HEIGHT + 2);
|
||||||
// Disable battery border
|
// Hide battery background
|
||||||
if(xtreme_settings->bar_borders) {
|
if(xtreme_settings->bar_borders) {
|
||||||
canvas_set_color(gui->canvas, ColorBlack);
|
canvas_set_color(gui->canvas, ColorWhite);
|
||||||
canvas_draw_rframe(
|
canvas_draw_box(
|
||||||
gui->canvas, 0, 0, canvas_width(gui->canvas), canvas_height(gui->canvas), 1);
|
gui->canvas, -1, 0, canvas_width(gui->canvas) + 1, canvas_height(gui->canvas));
|
||||||
canvas_draw_line(
|
|
||||||
gui->canvas,
|
|
||||||
canvas_width(gui->canvas) - 2,
|
|
||||||
1,
|
|
||||||
canvas_width(gui->canvas) - 2,
|
|
||||||
canvas_height(gui->canvas) - 2);
|
|
||||||
canvas_draw_line(
|
|
||||||
gui->canvas,
|
|
||||||
1,
|
|
||||||
canvas_height(gui->canvas) - 2,
|
|
||||||
canvas_width(gui->canvas) - 2,
|
|
||||||
canvas_height(gui->canvas) - 2);
|
|
||||||
}
|
}
|
||||||
|
canvas_set_color(gui->canvas, ColorBlack);
|
||||||
|
// ViewPort draw
|
||||||
|
canvas_frame_set(
|
||||||
|
gui->canvas,
|
||||||
|
x - xtreme_settings->bar_borders,
|
||||||
|
GUI_STATUS_BAR_Y + 2,
|
||||||
|
width,
|
||||||
|
GUI_STATUS_BAR_WORKAREA_HEIGHT);
|
||||||
|
view_port_draw(view_port, gui->canvas);
|
||||||
|
}
|
||||||
|
ViewPortArray_next(it);
|
||||||
|
}
|
||||||
|
// Draw frame around icons on the right
|
||||||
|
if(right_used) {
|
||||||
|
canvas_frame_set(
|
||||||
|
gui->canvas,
|
||||||
|
GUI_DISPLAY_WIDTH - 4 - right_used,
|
||||||
|
GUI_STATUS_BAR_Y,
|
||||||
|
right_used + 4,
|
||||||
|
GUI_STATUS_BAR_HEIGHT);
|
||||||
|
// Disable battery border
|
||||||
|
if(xtreme_settings->bar_borders) {
|
||||||
|
canvas_set_color(gui->canvas, ColorBlack);
|
||||||
|
canvas_draw_rframe(
|
||||||
|
gui->canvas, 0, 0, canvas_width(gui->canvas), canvas_height(gui->canvas), 1);
|
||||||
|
canvas_draw_line(
|
||||||
|
gui->canvas,
|
||||||
|
canvas_width(gui->canvas) - 2,
|
||||||
|
1,
|
||||||
|
canvas_width(gui->canvas) - 2,
|
||||||
|
canvas_height(gui->canvas) - 2);
|
||||||
|
canvas_draw_line(
|
||||||
|
gui->canvas,
|
||||||
|
1,
|
||||||
|
canvas_height(gui->canvas) - 2,
|
||||||
|
canvas_width(gui->canvas) - 2,
|
||||||
|
canvas_height(gui->canvas) - 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,12 @@
|
|||||||
#define POWER_OFF_TIMEOUT 90
|
#define POWER_OFF_TIMEOUT 90
|
||||||
#define TAG "Power"
|
#define TAG "Power"
|
||||||
|
|
||||||
|
void power_set_battery_icon_enabled(Power* power, bool is_enabled) {
|
||||||
|
furi_assert(power);
|
||||||
|
|
||||||
|
view_port_enabled_set(power->battery_view_port, is_enabled);
|
||||||
|
}
|
||||||
|
|
||||||
void power_draw_battery_callback(Canvas* canvas, void* context) {
|
void power_draw_battery_callback(Canvas* canvas, void* context) {
|
||||||
furi_assert(context);
|
furi_assert(context);
|
||||||
Power* power = context;
|
Power* power = context;
|
||||||
@@ -356,6 +362,7 @@ Power* power_alloc() {
|
|||||||
|
|
||||||
// Battery view port
|
// Battery view port
|
||||||
power->battery_view_port = power_battery_view_port_alloc(power);
|
power->battery_view_port = power_battery_view_port_alloc(power);
|
||||||
|
power_set_battery_icon_enabled(power, XTREME_SETTINGS()->battery_icon != BatteryIconOff);
|
||||||
power->show_low_bat_level_message = true;
|
power->show_low_bat_level_message = true;
|
||||||
|
|
||||||
//Auto shutdown timer
|
//Auto shutdown timer
|
||||||
|
|||||||
@@ -120,6 +120,13 @@ void power_enable_low_battery_level_notification(Power* power, bool enable);
|
|||||||
*/
|
*/
|
||||||
void power_trigger_ui_update(Power* power);
|
void power_trigger_ui_update(Power* power);
|
||||||
|
|
||||||
|
/** Enable or disable battery icon
|
||||||
|
*
|
||||||
|
* @param power Power instance
|
||||||
|
* @param is_enabled Show battery or not
|
||||||
|
*/
|
||||||
|
void power_set_battery_icon_enabled(Power* power, bool is_enabled);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2276,6 +2276,7 @@ Function,+,power_get_settings_events_pubsub,FuriPubSub*,Power*
|
|||||||
Function,+,power_is_battery_healthy,_Bool,Power*
|
Function,+,power_is_battery_healthy,_Bool,Power*
|
||||||
Function,+,power_off,void,Power*
|
Function,+,power_off,void,Power*
|
||||||
Function,+,power_reboot,void,PowerBootMode
|
Function,+,power_reboot,void,PowerBootMode
|
||||||
|
Function,+,power_set_battery_icon_enabled,void,"Power*, _Bool"
|
||||||
Function,-,power_trigger_ui_update,void,Power*
|
Function,-,power_trigger_ui_update,void,Power*
|
||||||
Function,+,powf,float,"float, float"
|
Function,+,powf,float,"float, float"
|
||||||
Function,-,powl,long double,"long double, long double"
|
Function,-,powl,long double,"long double, long double"
|
||||||
|
|||||||
|
Reference in New Issue
Block a user