mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-07-16 00:18:11 -07:00
Rename batt style to icon and improve value logic
This commit is contained in:
@@ -42,7 +42,7 @@ We wrote a powerful yet easy-to-use application specifically for our Firmware, t
|
||||
<br><code>Anim Speed:</code> Speed in which the animations play
|
||||
<br><code>Cycle Anims:</code> Duration of how long animations are played before switching to next
|
||||
<br><code>Unlock Anims:</code> Custom setting just for NSFW fallback animations. Figure it out ;)
|
||||
<br><code>Battery style:</code> Classic Firmware battery style toggle, just at a more convenient place
|
||||
<br><code>Battery Icon:</code> Classic Firmware battery style toggle, just at a more convenient place
|
||||
<br><code>XP Level:</code> Changes your Flippers level
|
||||
<br><code>SubGhz Extend:</code> Allows you to extend the subghz range beyond what FZ devs planned
|
||||
<br><code>SubGhz Bypass:</code> Allows you to bypass the subghz region locks of the Flipper
|
||||
|
||||
@@ -93,7 +93,7 @@ static void gui_redraw_status_bar(Gui* gui, bool need_attention) {
|
||||
width + 2,
|
||||
GUI_STATUS_BAR_WORKAREA_HEIGHT + 2);
|
||||
// Hide battery background
|
||||
if(xtreme_settings->status_bar && xtreme_settings->battery_style != BatteryStyleOff) {
|
||||
if(xtreme_settings->status_bar && xtreme_settings->battery_icon != BatteryIconOff) {
|
||||
canvas_set_color(gui->canvas, ColorWhite);
|
||||
canvas_draw_box(
|
||||
gui->canvas, -1, 0, canvas_width(gui->canvas) + 1, canvas_height(gui->canvas));
|
||||
@@ -119,7 +119,7 @@ static void gui_redraw_status_bar(Gui* gui, bool need_attention) {
|
||||
right_used + 4,
|
||||
GUI_STATUS_BAR_HEIGHT);
|
||||
// Disable battery border
|
||||
if(xtreme_settings->status_bar && xtreme_settings->battery_style != BatteryStyleOff) {
|
||||
if(xtreme_settings->status_bar && xtreme_settings->battery_icon != BatteryIconOff) {
|
||||
canvas_set_color(gui->canvas, ColorBlack);
|
||||
canvas_draw_rframe(
|
||||
gui->canvas, 0, 0, canvas_width(gui->canvas), canvas_height(gui->canvas), 1);
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
void power_draw_battery_callback(Canvas* canvas, void* context) {
|
||||
furi_assert(context);
|
||||
Power* power = context;
|
||||
BatteryStyle battery_style = XTREME_SETTINGS()->battery_style;
|
||||
if(battery_style == BatteryStyleOff) return;
|
||||
BatteryIcon battery_icon = XTREME_SETTINGS()->battery_icon;
|
||||
if(battery_icon == BatteryIconOff) return;
|
||||
|
||||
canvas_draw_icon(canvas, 0, 0, &I_Battery_25x8);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
@@ -25,7 +25,7 @@ void power_draw_battery_callback(Canvas* canvas, void* context) {
|
||||
char batteryPercentile[4];
|
||||
snprintf(batteryPercentile, sizeof(batteryPercentile), "%d", power->info.charge);
|
||||
|
||||
if((battery_style == BatteryStylePercent) &&
|
||||
if((battery_icon == BatteryIconPercent) &&
|
||||
(power->state !=
|
||||
PowerStateCharging)) { //if display battery percentage, black background white text
|
||||
canvas_set_font(canvas, FontBatteryPercent);
|
||||
@@ -34,14 +34,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(
|
||||
(battery_style == BatteryStyleInvertedPercent) &&
|
||||
(battery_icon == BatteryIconInvertedPercent) &&
|
||||
(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(
|
||||
(battery_style == BatteryStyleRetro3) &&
|
||||
(battery_icon == BatteryIconRetro3) &&
|
||||
(power->state != PowerStateCharging)) { //Retro style segmented display, 3 parts
|
||||
if(power->info.charge > 25) {
|
||||
canvas_draw_box(canvas, 2, 2, 6, 4);
|
||||
@@ -53,7 +53,7 @@ void power_draw_battery_callback(Canvas* canvas, void* context) {
|
||||
canvas_draw_box(canvas, 16, 2, 6, 4);
|
||||
}
|
||||
} else if(
|
||||
(battery_style == BatteryStyleRetro5) &&
|
||||
(battery_icon == BatteryIconRetro5) &&
|
||||
(power->state != PowerStateCharging)) { //Retro style segmented display, 5 parts
|
||||
if(power->info.charge > 10) {
|
||||
canvas_draw_box(canvas, 2, 2, 3, 4);
|
||||
@@ -71,7 +71,7 @@ void power_draw_battery_callback(Canvas* canvas, void* context) {
|
||||
canvas_draw_box(canvas, 18, 2, 3, 4);
|
||||
}
|
||||
} else if(
|
||||
(battery_style == BatteryStyleBarPercent) &&
|
||||
(battery_icon == BatteryIconBarPercent) &&
|
||||
(power->state != PowerStateCharging) && // Default bar display with percentage
|
||||
(power->info.voltage_battery_charging >=
|
||||
4.2)) { // not looking nice with low voltage indicator
|
||||
@@ -145,7 +145,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(battery_style == BatteryStylePercent || battery_style == BatteryStyleBarPercent) {
|
||||
if(battery_icon == BatteryIconPercent || battery_icon == BatteryIconBarPercent) {
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_draw_box(canvas, 1, 1, 22, 6);
|
||||
canvas_draw_icon(canvas, 2, -1, &I_Charging_lightning_9x10);
|
||||
@@ -154,7 +154,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(battery_style == BatteryStyleInvertedPercent) {
|
||||
} else if(battery_icon == BatteryIconInvertedPercent) {
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
canvas_draw_box(canvas, 1, 1, 22, 6);
|
||||
canvas_draw_icon(canvas, 2, -1, &I_Charging_lightning_9x10);
|
||||
|
||||
@@ -26,14 +26,15 @@ typedef enum {
|
||||
} PowerEventType;
|
||||
|
||||
typedef enum {
|
||||
BatteryStyleOff = 1,
|
||||
BatteryStyleBar = 2,
|
||||
BatteryStylePercent = 3,
|
||||
BatteryStyleInvertedPercent = 4,
|
||||
BatteryStyleRetro3 = 5,
|
||||
BatteryStyleRetro5 = 6,
|
||||
BatteryStyleBarPercent = 0,
|
||||
} BatteryStyle;
|
||||
BatteryIconOff,
|
||||
BatteryIconBar,
|
||||
BatteryIconPercent,
|
||||
BatteryIconInvertedPercent,
|
||||
BatteryIconRetro3,
|
||||
BatteryIconRetro5,
|
||||
BatteryIconBarPercent,
|
||||
BatteryIconCount,
|
||||
} BatteryIcon;
|
||||
|
||||
typedef union {
|
||||
uint8_t battery_level;
|
||||
|
||||
@@ -19,7 +19,7 @@ typedef struct {
|
||||
int32_t cycle_anims;
|
||||
bool unlock_anims;
|
||||
char asset_pack[MAX_PACK_NAME_LEN];
|
||||
BatteryStyle battery_style;
|
||||
BatteryIcon battery_icon;
|
||||
uint16_t anim_speed;
|
||||
bool sort_ignore_dirs;
|
||||
bool status_bar;
|
||||
|
||||
@@ -60,21 +60,13 @@ static void xtreme_app_scene_main_unlock_anims_changed(VariableItem* item) {
|
||||
app->settings_changed = true;
|
||||
}
|
||||
|
||||
const char* const battery_style_names[] =
|
||||
const char* const battery_icon_names[] =
|
||||
{"OFF", "Bar", "%", "Inv. %", "Retro 3", "Retro 5", "Bar %"};
|
||||
const int32_t battery_style_values[COUNT_OF(battery_style_names)] = {
|
||||
BatteryStyleOff,
|
||||
BatteryStyleBar,
|
||||
BatteryStylePercent,
|
||||
BatteryStyleInvertedPercent,
|
||||
BatteryStyleRetro3,
|
||||
BatteryStyleRetro5,
|
||||
BatteryStyleBarPercent};
|
||||
static void xtreme_app_scene_main_battery_style_changed(VariableItem* item) {
|
||||
static void xtreme_app_scene_main_battery_icon_changed(VariableItem* item) {
|
||||
XtremeApp* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
variable_item_set_current_value_text(item, battery_style_names[index]);
|
||||
XTREME_SETTINGS()->battery_style = battery_style_values[index];
|
||||
variable_item_set_current_value_text(item, battery_icon_names[index]);
|
||||
XTREME_SETTINGS()->battery_icon = battery_icon_values[index];
|
||||
app->settings_changed = true;
|
||||
}
|
||||
|
||||
@@ -212,14 +204,14 @@ void xtreme_app_scene_main_on_enter(void* context) {
|
||||
|
||||
item = variable_item_list_add(
|
||||
var_item_list,
|
||||
"Battery Style",
|
||||
COUNT_OF(battery_style_names),
|
||||
xtreme_app_scene_main_battery_style_changed,
|
||||
"Battery Icon",
|
||||
BatteryIconCount,
|
||||
xtreme_app_scene_main_battery_icon_changed,
|
||||
app);
|
||||
value_index = value_index_int32(
|
||||
xtreme_settings->battery_style, battery_style_values, COUNT_OF(battery_style_names));
|
||||
xtreme_settings->battery_icon, battery_icon_values, BatteryIconCount);
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, battery_style_names[value_index]);
|
||||
variable_item_set_current_value_text(item, battery_icon_names[value_index]);
|
||||
|
||||
item = variable_item_list_add(
|
||||
var_item_list, "Status Bar", 2, xtreme_app_scene_main_status_bar_changed, app);
|
||||
|
||||
Reference in New Issue
Block a user