mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-12 14:28:36 -07:00
Allow desktop clock with no battery icon
This commit is contained in:
@@ -100,75 +100,67 @@ static void gui_redraw_status_bar(Gui* gui, bool need_attention) {
|
||||
}
|
||||
canvas_set_bitmap_mode(gui->canvas, 0);
|
||||
|
||||
uint8_t x;
|
||||
|
||||
// Right side
|
||||
if(xtreme_settings->battery_icon != BatteryIconOff) {
|
||||
x = GUI_DISPLAY_WIDTH - 1;
|
||||
ViewPortArray_it(it, gui->layers[GuiLayerStatusBarRight]);
|
||||
while(!ViewPortArray_end_p(it) && right_used < GUI_STATUS_BAR_WIDTH) {
|
||||
ViewPort* view_port = *ViewPortArray_ref(it);
|
||||
if(view_port_is_enabled(view_port)) {
|
||||
width = view_port_get_width(view_port);
|
||||
if(!width) width = 8;
|
||||
// Recalculate next position
|
||||
right_used += (width + 2);
|
||||
x -= (width + 2);
|
||||
// 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) {
|
||||
uint8_t x = GUI_DISPLAY_WIDTH - 1;
|
||||
ViewPortArray_it(it, gui->layers[GuiLayerStatusBarRight]);
|
||||
while(!ViewPortArray_end_p(it) && right_used < GUI_STATUS_BAR_WIDTH) {
|
||||
ViewPort* view_port = *ViewPortArray_ref(it);
|
||||
if(view_port_is_enabled(view_port)) {
|
||||
width = view_port_get_width(view_port);
|
||||
if(!width) width = 8;
|
||||
// Recalculate next position
|
||||
right_used += (width + 2);
|
||||
x -= (width + 2);
|
||||
// Prepare work area background
|
||||
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
|
||||
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, 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);
|
||||
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(
|
||||
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 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) {
|
||||
furi_assert(context);
|
||||
Power* power = context;
|
||||
@@ -356,6 +362,7 @@ Power* power_alloc() {
|
||||
|
||||
// Battery view port
|
||||
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;
|
||||
|
||||
//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);
|
||||
|
||||
/** 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
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user