Xtreme app (#106)

This commit is contained in:
WillyJL
2023-01-20 20:26:10 +00:00
committed by GitHub
856 changed files with 2064 additions and 1425 deletions
@@ -1,5 +1,5 @@
#include "../bad_usb_app_i.h"
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_settings.h"
typedef enum {
BadUsbCustomEventErrorBack,
@@ -17,8 +17,6 @@ static void
void bad_usb_scene_error_on_enter(void* context) {
BadUsbApp* app = context;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
if(app->error == BadUsbAppErrorNoFiles) {
widget_add_icon_element(app->widget, 0, 0, &I_SDQuestion_35x43);
@@ -34,7 +32,7 @@ void bad_usb_scene_error_on_enter(void* context) {
app->widget, GuiButtonTypeLeft, "Back", bad_usb_scene_error_event_callback, app);
} else if(app->error == BadUsbAppErrorCloseRpc) {
widget_add_icon_element(app->widget, 78, 0, &I_ActiveConnection_50x64);
if(settings->sfw_mode) {
if(XTREME_SETTINGS()->sfw_mode) {
widget_add_string_multiline_element(
app->widget, 3, 2, AlignLeft, AlignTop, FontPrimary, "Connection\nis active!");
widget_add_string_multiline_element(
@@ -60,7 +58,6 @@ void bad_usb_scene_error_on_enter(void* context) {
}
view_dispatcher_switch_to_view(app->view_dispatcher, BadUsbAppViewError);
free(settings);
}
bool bad_usb_scene_error_on_event(void* context, SceneManagerEvent event) {
@@ -3,7 +3,7 @@
#include <toolbox/path.h>
#include <gui/elements.h>
#include <assets_icons.h>
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_settings.h"
#define MAX_NAME_LEN 64
@@ -28,8 +28,7 @@ static void bad_usb_draw_callback(Canvas* canvas, void* _model) {
elements_string_fit_width(canvas, disp_str, 128 - 2);
canvas_set_font(canvas, FontSecondary);
canvas_draw_str(canvas, 2, 8, furi_string_get_cstr(disp_str));
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
XtremeSettings* xtreme_settings = XTREME_SETTINGS();
if(strlen(model->layout) == 0) {
furi_string_set(disp_str, "(default)");
@@ -50,7 +49,7 @@ static void bad_usb_draw_callback(Canvas* canvas, void* _model) {
if((model->state.state == BadUsbStateIdle) || (model->state.state == BadUsbStateDone) ||
(model->state.state == BadUsbStateNotConnected)) {
if(settings->sfw_mode) {
if(xtreme_settings->sfw_mode) {
elements_button_center(canvas, "Start");
} else {
elements_button_center(canvas, "Cum");
@@ -69,7 +68,7 @@ static void bad_usb_draw_callback(Canvas* canvas, void* _model) {
if(model->state.state == BadUsbStateNotConnected) {
canvas_draw_icon(canvas, 4, 26, &I_Clock_18x18);
canvas_set_font(canvas, FontPrimary);
if(settings->sfw_mode) {
if(xtreme_settings->sfw_mode) {
canvas_draw_str_aligned(canvas, 127, 31, AlignRight, AlignBottom, "Connect to");
canvas_draw_str_aligned(canvas, 127, 43, AlignRight, AlignBottom, "a device");
} else {
@@ -79,7 +78,7 @@ static void bad_usb_draw_callback(Canvas* canvas, void* _model) {
} else if(model->state.state == BadUsbStateWillRun) {
canvas_draw_icon(canvas, 4, 26, &I_Clock_18x18);
canvas_set_font(canvas, FontPrimary);
if(settings->sfw_mode) {
if(xtreme_settings->sfw_mode) {
canvas_draw_str_aligned(canvas, 127, 31, AlignRight, AlignBottom, "Will run");
} else {
canvas_draw_str_aligned(canvas, 127, 31, AlignRight, AlignBottom, "Will cum");
@@ -147,7 +146,6 @@ static void bad_usb_draw_callback(Canvas* canvas, void* _model) {
}
furi_string_free(disp_str);
free(settings);
}
static bool bad_usb_input_callback(InputEvent* event, void* context) {
@@ -1,5 +1,5 @@
#include "../ibutton_i.h"
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
static void ibutton_scene_delete_success_popup_callback(void* context) {
iButton* ibutton = context;
@@ -9,14 +9,8 @@ static void ibutton_scene_delete_success_popup_callback(void* context) {
void ibutton_scene_delete_success_on_enter(void* context) {
iButton* ibutton = context;
Popup* popup = ibutton->popup;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
if(settings->sfw_mode) {
popup_set_icon(popup, 0, 2, &I_DolphinMafia_115x62_sfw);
} else {
popup_set_icon(popup, 0, 2, &I_DolphinMafia_115x62);
}
popup_set_icon(popup, 0, 2, XTREME_ASSETS()->dolphin_mafia);
popup_set_header(popup, "Deleted", 83, 19, AlignLeft, AlignBottom);
popup_set_callback(popup, ibutton_scene_delete_success_popup_callback);
@@ -25,7 +19,6 @@ void ibutton_scene_delete_success_on_enter(void* context) {
popup_enable_timeout(popup);
view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewPopup);
free(settings);
}
bool ibutton_scene_delete_success_on_event(void* context, SceneManagerEvent event) {
@@ -1,6 +1,6 @@
#include "../ibutton_i.h"
#include <dolphin/dolphin.h>
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
static void ibutton_scene_read_callback(void* context) {
iButton* ibutton = context;
@@ -12,16 +12,10 @@ void ibutton_scene_read_on_enter(void* context) {
Popup* popup = ibutton->popup;
iButtonKey* key = ibutton->key;
iButtonWorker* worker = ibutton->key_worker;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
popup_set_header(popup, "iButton", 95, 26, AlignCenter, AlignBottom);
popup_set_text(popup, "Waiting\nfor key ...", 95, 30, AlignCenter, AlignTop);
if(settings->sfw_mode) {
popup_set_icon(popup, 0, 5, &I_DolphinWait_61x59_sfw);
} else {
popup_set_icon(popup, 0, 5, &I_DolphinWait_61x59);
}
popup_set_icon(popup, 0, 5, XTREME_ASSETS()->dolphin_wait);
view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewPopup);
furi_string_set(ibutton->file_path, IBUTTON_APP_FOLDER);
@@ -30,7 +24,6 @@ void ibutton_scene_read_on_enter(void* context) {
ibutton_worker_read_start(worker, key);
ibutton_notification_message(ibutton, iButtonNotificationMessageReadStart);
free(settings);
}
bool ibutton_scene_read_on_event(void* context, SceneManagerEvent event) {
@@ -1,5 +1,5 @@
#include "../ibutton_i.h"
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
static void ibutton_scene_save_success_popup_callback(void* context) {
iButton* ibutton = context;
@@ -9,14 +9,8 @@ static void ibutton_scene_save_success_popup_callback(void* context) {
void ibutton_scene_save_success_on_enter(void* context) {
iButton* ibutton = context;
Popup* popup = ibutton->popup;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
if(settings->sfw_mode) {
popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59_sfw);
} else {
popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59);
}
popup_set_icon(popup, 32, 5, XTREME_ASSETS()->dolphin_nice);
popup_set_header(popup, "Saved!", 5, 7, AlignLeft, AlignTop);
popup_set_callback(popup, ibutton_scene_save_success_popup_callback);
@@ -25,7 +19,6 @@ void ibutton_scene_save_success_on_enter(void* context) {
popup_enable_timeout(popup);
view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewPopup);
free(settings);
}
bool ibutton_scene_save_success_on_event(void* context, SceneManagerEvent event) {
@@ -1,5 +1,5 @@
#include "../ibutton_i.h"
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
static void ibutton_scene_write_success_popup_callback(void* context) {
iButton* ibutton = context;
@@ -10,14 +10,8 @@ static void ibutton_scene_write_success_popup_callback(void* context) {
void ibutton_scene_write_success_on_enter(void* context) {
iButton* ibutton = context;
Popup* popup = ibutton->popup;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
if(settings->sfw_mode) {
popup_set_icon(popup, 0, 12, &I_iButtonDolphinVerySuccess_108x52_sfw);
} else {
popup_set_icon(popup, 0, 12, &I_iButtonDolphinVerySuccess_108x52);
}
popup_set_icon(popup, 0, 12, XTREME_ASSETS()->ibutton_success);
popup_set_text(popup, "Successfully written!", 40, 12, AlignLeft, AlignBottom);
popup_set_callback(popup, ibutton_scene_write_success_popup_callback);
@@ -28,7 +22,6 @@ void ibutton_scene_write_success_on_enter(void* context) {
view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewPopup);
ibutton_notification_message(ibutton, iButtonNotificationMessageSuccess);
ibutton_notification_message(ibutton, iButtonNotificationMessageGreenOn);
free(settings);
}
bool ibutton_scene_write_success_on_event(void* context, SceneManagerEvent event) {
@@ -1,17 +1,11 @@
#include "../infrared_i.h"
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
void infrared_scene_edit_rename_done_on_enter(void* context) {
Infrared* infrared = context;
Popup* popup = infrared->popup;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
if(settings->sfw_mode) {
popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59_sfw);
} else {
popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59);
}
popup_set_icon(popup, 32, 5, XTREME_ASSETS()->dolphin_nice);
popup_set_header(popup, "Saved!", 5, 7, AlignLeft, AlignTop);
popup_set_callback(popup, infrared_popup_closed_callback);
@@ -20,7 +14,6 @@ void infrared_scene_edit_rename_done_on_enter(void* context) {
popup_enable_timeout(popup);
view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewPopup);
free(settings);
}
bool infrared_scene_edit_rename_done_on_event(void* context, SceneManagerEvent event) {
@@ -1,21 +1,15 @@
#include "../infrared_i.h"
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
void infrared_scene_learn_done_on_enter(void* context) {
Infrared* infrared = context;
Popup* popup = infrared->popup;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
if(settings->sfw_mode) {
popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59_sfw);
if(infrared->app_state.is_learning_new_remote) {
popup_set_header(popup, "New remote\ncreated!", 0, 0, AlignLeft, AlignTop);
} else {
popup_set_header(popup, "Saved!", 5, 7, AlignLeft, AlignTop);
}
popup_set_icon(popup, 32, 5, XTREME_ASSETS()->dolphin_nice);
if(infrared->app_state.is_learning_new_remote) {
popup_set_header(popup, "New remote\ncreated!", 0, 0, AlignLeft, AlignTop);
} else {
popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59);
popup_set_header(popup, "Saved!", 5, 7, AlignLeft, AlignTop);
}
popup_set_callback(popup, infrared_popup_closed_callback);
@@ -24,7 +18,6 @@ void infrared_scene_learn_done_on_enter(void* context) {
popup_enable_timeout(popup);
view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewPopup);
free(settings);
}
bool infrared_scene_learn_done_on_event(void* context, SceneManagerEvent event) {
@@ -1,5 +1,5 @@
#include "../infrared_i.h"
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
static void
infrared_scene_learn_success_dialog_result_callback(DialogExResult result, void* context) {
@@ -11,8 +11,6 @@ void infrared_scene_learn_success_on_enter(void* context) {
Infrared* infrared = context;
DialogEx* dialog_ex = infrared->dialog_ex;
InfraredSignal* signal = infrared->received_signal;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
infrared_play_notification_message(infrared, InfraredNotificationMessageGreenOn);
@@ -50,17 +48,12 @@ void infrared_scene_learn_success_on_enter(void* context) {
dialog_ex_set_left_button_text(dialog_ex, "Retry");
dialog_ex_set_right_button_text(dialog_ex, "Save");
dialog_ex_set_center_button_text(dialog_ex, "Send");
if(settings->sfw_mode) {
dialog_ex_set_icon(dialog_ex, 0, 1, &I_DolphinReadingSuccess_59x63_sfw);
} else {
dialog_ex_set_icon(dialog_ex, 0, 1, &I_DolphinReadingSuccess_59x63);
}
dialog_ex_set_icon(dialog_ex, 0, 1, XTREME_ASSETS()->ir_success);
dialog_ex_set_result_callback(dialog_ex, infrared_scene_learn_success_dialog_result_callback);
dialog_ex_set_context(dialog_ex, context);
dialog_ex_enable_extended_events(dialog_ex);
view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewDialogEx);
free(settings);
}
bool infrared_scene_learn_success_on_event(void* context, SceneManagerEvent event) {
@@ -1,6 +1,6 @@
#include "../lfrfid_i.h"
#include "../helpers/rfid_writer.h"
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
static void writer_initialize(T55xxTiming* t55xxtiming) {
t55xxtiming->wait_time = 400;
@@ -15,8 +15,6 @@ static void lfrfid_clear_t5577_password_and_config_to_EM(LfRfid* app) {
T55xxTiming* t55xxtiming = malloc(sizeof(T55xxTiming));
Popup* popup = app->popup;
char curr_buf[32] = {};
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
//TODO: use .txt file in resourses for passwords.
const uint32_t default_passwords[] = {
@@ -45,11 +43,7 @@ static void lfrfid_clear_t5577_password_and_config_to_EM(LfRfid* app) {
writer_initialize(t55xxtiming);
popup_set_header(popup, "Removing\npassword", 90, 36, AlignCenter, AlignCenter);
if(settings->sfw_mode) {
popup_set_icon(popup, 0, 3, &I_RFIDDolphinSend_97x61_sfw);
} else {
popup_set_icon(popup, 0, 3, &I_RFIDDolphinSend_97x61);
}
popup_set_icon(popup, 0, 3, XTREME_ASSETS()->rfid_send);
popup_set_text(popup, curr_buf, 90, 56, AlignCenter, AlignCenter);
notification_message(app->notifications, &sequence_blink_start_magenta);
@@ -67,24 +61,17 @@ static void lfrfid_clear_t5577_password_and_config_to_EM(LfRfid* app) {
notification_message(app->notifications, &sequence_blink_stop);
popup_reset(app->popup);
free(t55xxtiming);
free(settings);
}
void lfrfid_scene_clear_t5577_on_enter(void* context) {
LfRfid* app = context;
Popup* popup = app->popup;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
lfrfid_clear_t5577_password_and_config_to_EM(app);
notification_message(app->notifications, &sequence_success);
popup_set_header(popup, "Done!", 94, 10, AlignCenter, AlignTop);
if(settings->sfw_mode) {
popup_set_icon(popup, 0, 7, &I_RFIDDolphinSuccess_108x57_sfw);
} else {
popup_set_icon(popup, 0, 7, &I_RFIDDolphinSuccess_108x57);
}
popup_set_icon(popup, 0, 7, XTREME_ASSETS()->rfid_success);
popup_set_context(popup, app);
popup_set_callback(popup, lfrfid_popup_timeout_callback);
popup_set_timeout(popup, 1500);
@@ -92,7 +79,6 @@ void lfrfid_scene_clear_t5577_on_enter(void* context) {
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup);
notification_message_block(app->notifications, &sequence_set_green_255);
free(settings);
}
bool lfrfid_scene_clear_t5577_on_event(void* context, SceneManagerEvent event) {
@@ -1,17 +1,11 @@
#include "../lfrfid_i.h"
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
void lfrfid_scene_delete_success_on_enter(void* context) {
LfRfid* app = context;
Popup* popup = app->popup;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
if(settings->sfw_mode) {
popup_set_icon(popup, 0, 2, &I_DolphinMafia_115x62_sfw);
} else {
popup_set_icon(popup, 0, 2, &I_DolphinMafia_115x62);
}
popup_set_icon(popup, 0, 2, XTREME_ASSETS()->dolphin_mafia);
popup_set_header(popup, "Deleted", 83, 19, AlignLeft, AlignBottom);
popup_set_context(popup, app);
popup_set_callback(popup, lfrfid_popup_timeout_callback);
@@ -19,7 +13,6 @@ void lfrfid_scene_delete_success_on_enter(void* context) {
popup_enable_timeout(popup);
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup);
free(settings);
}
bool lfrfid_scene_delete_success_on_event(void* context, SceneManagerEvent event) {
@@ -1,11 +1,9 @@
#include "../lfrfid_i.h"
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
void lfrfid_scene_emulate_on_enter(void* context) {
LfRfid* app = context;
Popup* popup = app->popup;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
popup_set_header(popup, "Emulating", 89, 30, AlignCenter, AlignTop);
if(!furi_string_empty(app->file_name)) {
@@ -19,18 +17,13 @@ void lfrfid_scene_emulate_on_enter(void* context) {
AlignCenter,
AlignTop);
}
if(settings->sfw_mode) {
popup_set_icon(popup, 0, 3, &I_RFIDDolphinSend_97x61_sfw);
} else {
popup_set_icon(popup, 0, 3, &I_RFIDDolphinSend_97x61);
}
popup_set_icon(popup, 0, 3, XTREME_ASSETS()->rfid_send);
lfrfid_worker_start_thread(app->lfworker);
lfrfid_worker_emulate_start(app->lfworker, (LFRFIDProtocol)app->protocol_id);
notification_message(app->notifications, &sequence_blink_start_magenta);
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup);
free(settings);
}
bool lfrfid_scene_emulate_on_event(void* context, SceneManagerEvent event) {
@@ -1,5 +1,5 @@
#include "../lfrfid_i.h"
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
#define RAW_READ_TIME 5000
@@ -29,17 +29,11 @@ static void timer_callback(void* context) {
void lfrfid_scene_raw_read_on_enter(void* context) {
LfRfid* app = context;
Popup* popup = app->popup;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
LfRfidReadRawState* state = malloc(sizeof(LfRfidReadRawState));
scene_manager_set_scene_state(app->scene_manager, LfRfidSceneRawRead, (uint32_t)state);
state->string_file_name = furi_string_alloc();
if(settings->sfw_mode) {
popup_set_icon(popup, 0, 3, &I_RFIDDolphinReceive_97x61_sfw);
} else {
popup_set_icon(popup, 0, 3, &I_RFIDDolphinReceive_97x61);
}
popup_set_icon(popup, 0, 3, XTREME_ASSETS()->rfid_receive);
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup);
lfrfid_worker_start_thread(app->lfworker);
lfrfid_make_app_folder(app);
@@ -64,7 +58,6 @@ void lfrfid_scene_raw_read_on_enter(void* context) {
state->is_psk = false;
state->error = false;
free(settings);
}
bool lfrfid_scene_raw_read_on_event(void* context, SceneManagerEvent event) {
@@ -1,26 +1,19 @@
#include "../lfrfid_i.h"
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
void lfrfid_scene_rpc_on_enter(void* context) {
LfRfid* app = context;
Popup* popup = app->popup;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
popup_set_header(popup, "LF RFID", 89, 42, AlignCenter, AlignBottom);
popup_set_text(popup, "RPC mode", 89, 44, AlignCenter, AlignTop);
if(settings->sfw_mode) {
popup_set_icon(popup, 0, 12, &I_RFIDDolphinSend_97x61_sfw);
} else {
popup_set_icon(popup, 0, 12, &I_RFIDDolphinSend_97x61);
}
popup_set_icon(popup, 0, 12, XTREME_ASSETS()->rfid_send);
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup);
notification_message(app->notifications, &sequence_display_backlight_on);
app->rpc_state = LfRfidRpcStateIdle;
free(settings);
}
bool lfrfid_scene_rpc_on_event(void* context, SceneManagerEvent event) {
@@ -1,19 +1,13 @@
#include "../lfrfid_i.h"
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
void lfrfid_scene_save_success_on_enter(void* context) {
LfRfid* app = context;
Popup* popup = app->popup;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
// Clear state of data enter scene
scene_manager_set_scene_state(app->scene_manager, LfRfidSceneSaveData, 0);
if(settings->sfw_mode) {
popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59_sfw);
} else {
popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59);
}
popup_set_icon(popup, 32, 5, XTREME_ASSETS()->dolphin_nice);
popup_set_header(popup, "Saved!", 5, 7, AlignLeft, AlignTop);
popup_set_context(popup, app);
popup_set_callback(popup, lfrfid_popup_timeout_callback);
@@ -21,7 +15,6 @@ void lfrfid_scene_save_success_on_enter(void* context) {
popup_enable_timeout(popup);
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup);
free(settings);
}
bool lfrfid_scene_save_success_on_event(void* context, SceneManagerEvent event) {
@@ -1,5 +1,5 @@
#include "../lfrfid_i.h"
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
static void lfrfid_write_callback(LFRFIDWorkerWriteResult result, void* context) {
LfRfid* app = context;
@@ -21,8 +21,6 @@ static void lfrfid_write_callback(LFRFIDWorkerWriteResult result, void* context)
void lfrfid_scene_write_on_enter(void* context) {
LfRfid* app = context;
Popup* popup = app->popup;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
popup_set_header(popup, "Writing", 89, 30, AlignCenter, AlignTop);
if(!furi_string_empty(app->file_name)) {
@@ -36,11 +34,7 @@ void lfrfid_scene_write_on_enter(void* context) {
AlignCenter,
AlignTop);
}
if(settings->sfw_mode) {
popup_set_icon(popup, 0, 3, &I_RFIDDolphinSend_97x61_sfw);
} else {
popup_set_icon(popup, 0, 3, &I_RFIDDolphinSend_97x61);
}
popup_set_icon(popup, 0, 3, XTREME_ASSETS()->rfid_send);
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup);
@@ -51,7 +45,6 @@ void lfrfid_scene_write_on_enter(void* context) {
lfrfid_worker_write_start(
app->lfworker, (LFRFIDProtocol)app->protocol_id, lfrfid_write_callback, app);
notification_message(app->notifications, &sequence_blink_start_magenta);
free(settings);
}
bool lfrfid_scene_write_on_event(void* context, SceneManagerEvent event) {
@@ -1,18 +1,12 @@
#include "../lfrfid_i.h"
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
void lfrfid_scene_write_success_on_enter(void* context) {
LfRfid* app = context;
Popup* popup = app->popup;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
popup_set_header(popup, "Successfully\nwritten!", 94, 3, AlignCenter, AlignTop);
if(settings->sfw_mode) {
popup_set_icon(popup, 0, 6, &I_RFIDDolphinSuccess_108x57_sfw);
} else {
popup_set_icon(popup, 0, 6, &I_RFIDDolphinSuccess_108x57);
}
popup_set_icon(popup, 0, 6, XTREME_ASSETS()->rfid_success);
popup_set_context(popup, app);
popup_set_callback(popup, lfrfid_popup_timeout_callback);
popup_set_timeout(popup, 1500);
@@ -20,7 +14,6 @@ void lfrfid_scene_write_success_on_enter(void* context) {
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup);
notification_message_block(app->notifications, &sequence_set_green_255);
free(settings);
}
bool lfrfid_scene_write_success_on_event(void* context, SceneManagerEvent event) {
@@ -1,5 +1,5 @@
#include "../nfc_i.h"
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
void nfc_scene_delete_success_popup_callback(void* context) {
Nfc* nfc = context;
@@ -8,23 +8,16 @@ void nfc_scene_delete_success_popup_callback(void* context) {
void nfc_scene_delete_success_on_enter(void* context) {
Nfc* nfc = context;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
// Setup view
Popup* popup = nfc->popup;
if(settings->sfw_mode) {
popup_set_icon(popup, 0, 2, &I_DolphinMafia_115x62_sfw);
} else {
popup_set_icon(popup, 0, 2, &I_DolphinMafia_115x62);
}
popup_set_icon(popup, 0, 2, XTREME_ASSETS()->dolphin_mafia);
popup_set_header(popup, "Deleted", 83, 19, AlignLeft, AlignBottom);
popup_set_timeout(popup, 1500);
popup_set_context(popup, nfc);
popup_set_callback(popup, nfc_scene_delete_success_popup_callback);
popup_enable_timeout(popup);
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewPopup);
free(settings);
}
bool nfc_scene_delete_success_on_event(void* context, SceneManagerEvent event) {
@@ -1,5 +1,5 @@
#include "../nfc_i.h"
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
#define NFC_SCENE_EMULATE_NFCV_LOG_SIZE_MAX (100)
@@ -38,14 +38,7 @@ static void nfc_scene_emulate_nfcv_widget_config(Nfc* nfc, bool data_received) {
FuriString* info_str;
info_str = furi_string_alloc();
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
if(settings->sfw_mode) {
widget_add_icon_element(widget, 0, 3, &I_RFIDDolphinSend_97x61_sfw);
} else {
widget_add_icon_element(widget, 0, 3, &I_RFIDDolphinSend_97x61);
}
widget_add_icon_element(widget, 0, 3, XTREME_ASSETS()->rfid_send);
widget_add_string_element(
widget, 89, 32, AlignCenter, AlignTop, FontPrimary, "Emulating NfcV");
@@ -64,7 +57,6 @@ static void nfc_scene_emulate_nfcv_widget_config(Nfc* nfc, bool data_received) {
widget_add_button_element(
widget, GuiButtonTypeCenter, "Log", nfc_scene_emulate_nfcv_widget_callback, nfc);
}
free(settings);
}
void nfc_scene_emulate_nfcv_on_enter(void* context) {
@@ -1,5 +1,5 @@
#include "../nfc_i.h"
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
#define NFC_SCENE_EMULATE_UID_LOG_SIZE_MAX (200)
@@ -37,14 +37,8 @@ static void nfc_scene_emulate_uid_widget_config(Nfc* nfc, bool data_received) {
widget_reset(widget);
FuriString* info_str;
info_str = furi_string_alloc();
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
if(settings->sfw_mode) {
widget_add_icon_element(widget, 0, 3, &I_NFC_dolphin_emulation_47x61_sfw);
} else {
widget_add_icon_element(widget, 0, 3, &I_NFC_dolphin_emulation_47x61);
}
widget_add_icon_element(widget, 0, 3, XTREME_ASSETS()->nfc_emulation);
widget_add_string_element(widget, 57, 13, AlignLeft, AlignTop, FontPrimary, "Emulating UID");
if(strcmp(nfc->dev->dev_name, "") != 0) {
furi_string_printf(info_str, "%s", nfc->dev->dev_name);
@@ -61,7 +55,6 @@ static void nfc_scene_emulate_uid_widget_config(Nfc* nfc, bool data_received) {
widget_add_button_element(
widget, GuiButtonTypeCenter, "Log", nfc_scene_emulate_uid_widget_callback, nfc);
}
free(settings);
}
void nfc_scene_emulate_uid_on_enter(void* context) {
@@ -1,5 +1,5 @@
#include "../nfc_i.h"
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
#define NFC_MF_CLASSIC_DATA_NOT_CHANGED (0UL)
#define NFC_MF_CLASSIC_DATA_CHANGED (1UL)
@@ -15,8 +15,6 @@ bool nfc_mf_classic_emulate_worker_callback(NfcWorkerEvent event, void* context)
void nfc_scene_mf_classic_emulate_on_enter(void* context) {
Nfc* nfc = context;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
// Setup view
Popup* popup = nfc->popup;
@@ -26,11 +24,7 @@ void nfc_scene_mf_classic_emulate_on_enter(void* context) {
} else {
nfc_text_store_set(nfc, "MIFARE\nClassic");
}
if(settings->sfw_mode) {
popup_set_icon(popup, 0, 3, &I_NFC_dolphin_emulation_47x61_sfw);
} else {
popup_set_icon(popup, 0, 3, &I_NFC_dolphin_emulation_47x61);
}
popup_set_icon(popup, 0, 3, XTREME_ASSETS()->nfc_emulation);
popup_set_text(popup, nfc->text_store, 90, 28, AlignCenter, AlignTop);
// Setup and start worker
@@ -42,7 +36,6 @@ void nfc_scene_mf_classic_emulate_on_enter(void* context) {
nfc_mf_classic_emulate_worker_callback,
nfc);
nfc_blink_emulate_start(nfc);
free(settings);
}
bool nfc_scene_mf_classic_emulate_on_event(void* context, SceneManagerEvent event) {
@@ -1,6 +1,6 @@
#include "../nfc_i.h"
#include <dolphin/dolphin.h>
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
void nfc_scene_mf_classic_update_success_popup_callback(void* context) {
Nfc* nfc = context;
@@ -10,17 +10,11 @@ void nfc_scene_mf_classic_update_success_popup_callback(void* context) {
void nfc_scene_mf_classic_update_success_on_enter(void* context) {
Nfc* nfc = context;
DOLPHIN_DEED(DolphinDeedNfcSave);
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
notification_message(nfc->notifications, &sequence_success);
Popup* popup = nfc->popup;
if(settings->sfw_mode) {
popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59_sfw);
} else {
popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59);
}
popup_set_icon(popup, 32, 5, XTREME_ASSETS()->dolphin_nice);
popup_set_header(popup, "Updated!", 11, 20, AlignLeft, AlignBottom);
popup_set_timeout(popup, 1500);
popup_set_context(popup, nfc);
@@ -28,7 +22,6 @@ void nfc_scene_mf_classic_update_success_on_enter(void* context) {
popup_enable_timeout(popup);
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewPopup);
free(settings);
}
bool nfc_scene_mf_classic_update_success_on_event(void* context, SceneManagerEvent event) {
@@ -1,6 +1,6 @@
#include "../nfc_i.h"
#include <dolphin/dolphin.h>
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
void nfc_scene_mf_classic_write_success_popup_callback(void* context) {
Nfc* nfc = context;
@@ -10,17 +10,11 @@ void nfc_scene_mf_classic_write_success_popup_callback(void* context) {
void nfc_scene_mf_classic_write_success_on_enter(void* context) {
Nfc* nfc = context;
DOLPHIN_DEED(DolphinDeedNfcSave);
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
notification_message(nfc->notifications, &sequence_success);
Popup* popup = nfc->popup;
if(settings->sfw_mode) {
popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59_sfw);
} else {
popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59);
}
popup_set_icon(popup, 32, 5, XTREME_ASSETS()->dolphin_nice);
popup_set_header(popup, "Successfully\nwritten", 13, 22, AlignLeft, AlignBottom);
popup_set_timeout(popup, 1500);
popup_set_context(popup, nfc);
@@ -28,7 +22,6 @@ void nfc_scene_mf_classic_write_success_on_enter(void* context) {
popup_enable_timeout(popup);
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewPopup);
free(settings);
}
bool nfc_scene_mf_classic_write_success_on_event(void* context, SceneManagerEvent event) {
@@ -1,6 +1,6 @@
#include "../nfc_i.h"
#include <lib/nfc/protocols/mifare_ultralight.h>
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
#define NFC_SCENE_MF_ULTRALIGHT_EMULATE_LOG_SIZE_MAX (200)
@@ -66,14 +66,7 @@ void nfc_scene_mf_ultralight_emulate_widget_config(Nfc* nfc, bool auth_attempted
FuriString* info_str;
info_str = furi_string_alloc();
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
if(settings->sfw_mode) {
widget_add_icon_element(widget, 0, 3, &I_NFC_dolphin_emulation_47x61_sfw);
} else {
widget_add_icon_element(widget, 0, 3, &I_NFC_dolphin_emulation_47x61);
}
widget_add_icon_element(widget, 0, 3, XTREME_ASSETS()->nfc_emulation);
if(strcmp(nfc->dev->dev_name, "")) {
furi_string_printf(info_str, "Emulating\n%s", nfc->dev->dev_name);
@@ -92,15 +85,12 @@ void nfc_scene_mf_ultralight_emulate_widget_config(Nfc* nfc, bool auth_attempted
nfc_scene_mf_ultralight_emulate_widget_callback,
nfc);
}
free(settings);
}
void nfc_scene_mf_ultralight_emulate_on_enter(void* context) {
Nfc* nfc = context;
uint32_t state =
scene_manager_get_scene_state(nfc->scene_manager, NfcSceneMfUltralightEmulate);
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
// Setup Widget
nfc_scene_mf_ultralight_emulate_widget_config(nfc, false);
@@ -123,11 +113,7 @@ void nfc_scene_mf_ultralight_emulate_on_enter(void* context) {
} else {
nfc_text_store_set(nfc, "MIFARE\nNTAG");
}
if(settings->sfw_mode) {
popup_set_icon(popup, 0, 3, &I_NFC_dolphin_emulation_47x61_sfw);
} else {
popup_set_icon(popup, 0, 3, &I_NFC_dolphin_emulation_47x61);
}
popup_set_icon(popup, 0, 3, XTREME_ASSETS()->nfc_emulation);
popup_set_text(popup, nfc->text_store, 90, 28, AlignCenter, AlignTop);
// Set Widget state and view
@@ -143,7 +129,6 @@ void nfc_scene_mf_ultralight_emulate_on_enter(void* context) {
nfc_mf_ultralight_emulate_worker_callback,
nfc);
nfc_blink_emulate_start(nfc);
free(settings);
}
bool nfc_scene_mf_ultralight_emulate_on_event(void* context, SceneManagerEvent event) {
@@ -1,5 +1,5 @@
#include "../nfc_i.h"
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
void nfc_scene_restore_original_popup_callback(void* context) {
Nfc* nfc = context;
@@ -8,23 +8,16 @@ void nfc_scene_restore_original_popup_callback(void* context) {
void nfc_scene_restore_original_on_enter(void* context) {
Nfc* nfc = context;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
// Setup view
Popup* popup = nfc->popup;
if(settings->sfw_mode) {
popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59_sfw);
} else {
popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59);
}
popup_set_icon(popup, 32, 5, XTREME_ASSETS()->dolphin_nice);
popup_set_header(popup, "Original file\nrestored", 13, 22, AlignLeft, AlignBottom);
popup_set_timeout(popup, 1500);
popup_set_context(popup, nfc);
popup_set_callback(popup, nfc_scene_restore_original_popup_callback);
popup_enable_timeout(popup);
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewPopup);
free(settings);
}
bool nfc_scene_restore_original_on_event(void* context, SceneManagerEvent event) {
+2 -9
View File
@@ -1,25 +1,18 @@
#include "../nfc_i.h"
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
void nfc_scene_rpc_on_enter(void* context) {
Nfc* nfc = context;
Popup* popup = nfc->popup;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
popup_set_header(popup, "NFC", 89, 42, AlignCenter, AlignBottom);
popup_set_text(popup, "RPC mode", 89, 44, AlignCenter, AlignTop);
if(settings->sfw_mode) {
popup_set_icon(popup, 0, 12, &I_NFC_dolphin_emulation_47x61_sfw);
} else {
popup_set_icon(popup, 0, 12, &I_NFC_dolphin_emulation_47x61);
}
popup_set_icon(popup, 0, 12, XTREME_ASSETS()->nfc_emulation);
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewPopup);
notification_message(nfc->notifications, &sequence_display_backlight_on);
free(settings);
}
static bool nfc_scene_rpc_emulate_callback(NfcWorkerEvent event, void* context) {
@@ -1,5 +1,5 @@
#include "../nfc_i.h"
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
void nfc_scene_save_success_popup_callback(void* context) {
Nfc* nfc = context;
@@ -8,23 +8,16 @@ void nfc_scene_save_success_popup_callback(void* context) {
void nfc_scene_save_success_on_enter(void* context) {
Nfc* nfc = context;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
// Setup view
Popup* popup = nfc->popup;
if(settings->sfw_mode) {
popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59_sfw);
} else {
popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59);
}
popup_set_icon(popup, 32, 5, XTREME_ASSETS()->dolphin_nice);
popup_set_header(popup, "Saved!", 13, 22, AlignLeft, AlignBottom);
popup_set_timeout(popup, 1500);
popup_set_context(popup, nfc);
popup_set_callback(popup, nfc_scene_save_success_popup_callback);
popup_enable_timeout(popup);
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewPopup);
free(settings);
}
bool nfc_scene_save_success_on_event(void* context, SceneManagerEvent event) {
@@ -1,6 +1,6 @@
#include "../subghz_i.h"
#include "../helpers/subghz_custom_event.h"
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
void subghz_scene_delete_success_popup_callback(void* context) {
SubGhz* subghz = context;
@@ -10,23 +10,16 @@ void subghz_scene_delete_success_popup_callback(void* context) {
void subghz_scene_delete_success_on_enter(void* context) {
SubGhz* subghz = context;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
// Setup view
Popup* popup = subghz->popup;
if(settings->sfw_mode) {
popup_set_icon(popup, 0, 2, &I_DolphinMafia_115x62_sfw);
} else {
popup_set_icon(popup, 0, 2, &I_DolphinMafia_115x62);
}
popup_set_icon(popup, 0, 2, XTREME_ASSETS()->dolphin_mafia);
popup_set_header(popup, "Deleted", 83, 19, AlignLeft, AlignBottom);
popup_set_timeout(popup, 1500);
popup_set_context(popup, subghz);
popup_set_callback(popup, subghz_scene_delete_success_popup_callback);
popup_enable_timeout(popup);
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdPopup);
free(settings);
}
bool subghz_scene_delete_success_on_event(void* context, SceneManagerEvent event) {
@@ -1,7 +1,7 @@
#include "../subghz_i.h"
#include <lib/subghz/protocols/keeloq.h>
#include <lib/subghz/protocols/star_line.h>
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
typedef enum {
SubGhzRpcStateIdle,
@@ -11,23 +11,16 @@ typedef enum {
void subghz_scene_rpc_on_enter(void* context) {
SubGhz* subghz = context;
Popup* popup = subghz->popup;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
popup_set_header(popup, "Sub-GHz", 89, 42, AlignCenter, AlignBottom);
popup_set_text(popup, "RPC mode", 89, 44, AlignCenter, AlignTop);
if(settings->sfw_mode) {
popup_set_icon(popup, 0, 12, &I_RFIDDolphinSend_97x61_sfw);
} else {
popup_set_icon(popup, 0, 12, &I_RFIDDolphinSend_97x61);
}
popup_set_icon(popup, 0, 12, XTREME_ASSETS()->rfid_send);
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdPopup);
scene_manager_set_scene_state(subghz->scene_manager, SubGhzSceneRpc, SubGhzRpcStateIdle);
notification_message(subghz->notifications, &sequence_display_backlight_on);
free(settings);
}
bool subghz_scene_rpc_on_event(void* context, SceneManagerEvent event) {
@@ -1,6 +1,6 @@
#include "../subghz_i.h"
#include "../helpers/subghz_custom_event.h"
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
void subghz_scene_save_success_popup_callback(void* context) {
SubGhz* subghz = context;
@@ -9,23 +9,16 @@ void subghz_scene_save_success_popup_callback(void* context) {
void subghz_scene_save_success_on_enter(void* context) {
SubGhz* subghz = context;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
// Setup view
Popup* popup = subghz->popup;
if(settings->sfw_mode) {
popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59_sfw);
} else {
popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59);
}
popup_set_icon(popup, 32, 5, XTREME_ASSETS()->dolphin_nice);
popup_set_header(popup, "Saved!", 13, 22, AlignLeft, AlignBottom);
popup_set_timeout(popup, 1500);
popup_set_context(popup, subghz);
popup_set_callback(popup, subghz_scene_save_success_popup_callback);
popup_enable_timeout(popup);
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdPopup);
free(settings);
}
bool subghz_scene_save_success_on_event(void* context, SceneManagerEvent event) {
+3 -14
View File
@@ -7,7 +7,7 @@
#include <assets_icons.h>
#include <m-array.h>
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
#define FRAME_HEIGHT 12
#define MAX_LEN_PX 111
@@ -195,8 +195,6 @@ void subghz_view_receiver_draw(Canvas* canvas, SubGhzViewReceiverModel* model) {
canvas_clear(canvas);
canvas_set_color(canvas, ColorBlack);
canvas_set_font(canvas, FontSecondary);
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
if(model->mode == SubGhzViewReceiverModeLive) {
elements_button_left(canvas, "Config");
@@ -234,21 +232,13 @@ void subghz_view_receiver_draw(Canvas* canvas, SubGhzViewReceiverModel* model) {
if(model->history_item == 0) {
if(model->mode == SubGhzViewReceiverModeLive) {
if(settings->sfw_mode) {
canvas_draw_icon(canvas, 0, 0, &I_Scanning_123x52_sfw);
} else {
canvas_draw_icon(canvas, 0, 0, &I_Scanning_123x52);
}
canvas_draw_icon(canvas, 0, 0, XTREME_ASSETS()->subghz_scanning);
canvas_set_font(canvas, FontPrimary);
canvas_draw_str(canvas, 63, 46, "Scanning...");
canvas_draw_line(canvas, 46, 51, 125, 51);
canvas_set_font(canvas, FontSecondary);
} else {
if(settings->sfw_mode) {
canvas_draw_icon(canvas, 0, 0, &I_Scanning_123x52_sfw);
} else {
canvas_draw_icon(canvas, 0, 0, &I_Scanning_123x52);
}
canvas_draw_icon(canvas, 0, 0, XTREME_ASSETS()->subghz_scanning);
canvas_set_font(canvas, FontPrimary);
canvas_draw_str(canvas, 63, 46, "Decoding...");
canvas_set_font(canvas, FontSecondary);
@@ -302,7 +292,6 @@ void subghz_view_receiver_draw(Canvas* canvas, SubGhzViewReceiverModel* model) {
canvas_draw_str(canvas, 96, 62, furi_string_get_cstr(model->history_stat_str));
} break;
}
free(settings);
}
static void subghz_view_receiver_timer_callback(void* context) {
@@ -1,5 +1,5 @@
#include "../u2f_app_i.h"
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_settings.h"
static void u2f_scene_error_event_callback(GuiButtonType result, InputType type, void* context) {
furi_assert(context);
@@ -12,8 +12,6 @@ static void u2f_scene_error_event_callback(GuiButtonType result, InputType type,
void u2f_scene_error_on_enter(void* context) {
U2fApp* app = context;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
if(app->error == U2fAppErrorNoFiles) {
widget_add_icon_element(app->widget, 0, 0, &I_SDQuestion_35x43);
@@ -29,7 +27,7 @@ void u2f_scene_error_on_enter(void* context) {
app->widget, GuiButtonTypeLeft, "Back", u2f_scene_error_event_callback, app);
} else if(app->error == U2fAppErrorCloseRpc) {
widget_add_icon_element(app->widget, 78, 0, &I_ActiveConnection_50x64);
if(settings->sfw_mode) {
if(XTREME_SETTINGS()->sfw_mode) {
widget_add_string_multiline_element(
app->widget, 3, 2, AlignLeft, AlignTop, FontPrimary, "Connection\nis active!");
widget_add_string_multiline_element(
@@ -55,7 +53,6 @@ void u2f_scene_error_on_enter(void* context) {
}
view_dispatcher_switch_to_view(app->view_dispatcher, U2fAppViewError);
free(settings);
}
bool u2f_scene_error_on_event(void* context, SceneManagerEvent event) {
+17 -22
View File
@@ -1,7 +1,7 @@
#include "u2f_view.h"
#include <gui/elements.h>
#include <assets_icons.h>
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
struct U2fView {
View* view;
@@ -15,74 +15,69 @@ typedef struct {
static void u2f_view_draw_callback(Canvas* canvas, void* _model) {
U2fModel* model = _model;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
XtremeSettings* xtreme_settings = XTREME_SETTINGS();
XtremeAssets* xtreme_assets = XTREME_ASSETS();
canvas_draw_icon(canvas, 8, 14, &I_Drive_112x35);
canvas_set_font(canvas, FontSecondary);
if(model->display_msg == U2fMsgNotConnected) {
if(settings->sfw_mode) {
canvas_draw_icon(canvas, 22, 15, &I_Connect_me_62x31_sfw);
canvas_draw_icon(canvas, 22, 15, xtreme_assets->connect_me);
if(xtreme_settings->sfw_mode) {
canvas_draw_str_aligned(
canvas, 128 / 2, 3, AlignCenter, AlignTop, "Connect to a device");
} else {
canvas_draw_icon(canvas, 22, 15, &I_Connect_me_62x31);
canvas_draw_str_aligned(
canvas, 128 / 2, 3, AlignCenter, AlignTop, "Plug me in d-daddy");
}
} else if(model->display_msg == U2fMsgIdle) {
if(settings->sfw_mode) {
canvas_draw_icon(canvas, 22, 15, &I_Connected_62x31_sfw);
canvas_draw_icon(canvas, 22, 15, xtreme_assets->connected);
if(xtreme_settings->sfw_mode) {
canvas_draw_str_aligned(canvas, 128 / 2, 3, AlignCenter, AlignTop, "Connected!");
} else {
canvas_draw_icon(canvas, 22, 15, &I_Connected_62x31);
canvas_draw_str_aligned(canvas, 128 / 2, 3, AlignCenter, AlignTop, "Connected!");
}
} else if(model->display_msg == U2fMsgRegister) {
if(settings->sfw_mode) {
if(xtreme_settings->sfw_mode) {
elements_button_center(canvas, "OK");
canvas_draw_icon(canvas, 22, 15, &I_Auth_62x31_sfw);
canvas_draw_icon(canvas, 22, 15, xtreme_assets->authenticate);
canvas_draw_str_aligned(
canvas, 128 / 2, 3, AlignCenter, AlignTop, "Press OK to register");
} else {
elements_button_center(canvas, "CUM");
canvas_draw_icon(canvas, 22, 15, &I_Auth_62x31);
canvas_draw_icon(canvas, 22, 15, xtreme_assets->authenticate);
canvas_draw_str_aligned(
canvas, 128 / 2, 3, AlignCenter, AlignTop, "Press CUM to register");
}
} else if(model->display_msg == U2fMsgAuth) {
if(settings->sfw_mode) {
if(xtreme_settings->sfw_mode) {
elements_button_center(canvas, "OK");
canvas_draw_icon(canvas, 22, 15, &I_Auth_62x31_sfw);
canvas_draw_icon(canvas, 22, 15, xtreme_assets->authenticate);
canvas_draw_str_aligned(
canvas, 128 / 2, 3, AlignCenter, AlignTop, "Press OK to authenticate");
} else {
elements_button_center(canvas, "CUM");
canvas_draw_icon(canvas, 22, 15, &I_Auth_62x31);
canvas_draw_icon(canvas, 22, 15, xtreme_assets->authenticate);
canvas_draw_str_aligned(
canvas, 128 / 2, 3, AlignCenter, AlignTop, "Press CUM to authenticate");
}
} else if(model->display_msg == U2fMsgSuccess) {
if(settings->sfw_mode) {
canvas_draw_icon(canvas, 22, 15, &I_Connected_62x31_sfw);
canvas_draw_icon(canvas, 22, 15, xtreme_assets->connected);
if(xtreme_settings->sfw_mode) {
canvas_draw_str_aligned(
canvas, 128 / 2, 3, AlignCenter, AlignTop, "Authentication successful!");
} else {
canvas_draw_icon(canvas, 22, 15, &I_Connected_62x31);
canvas_draw_str_aligned(canvas, 128 / 2, 3, AlignCenter, AlignTop, "Cum released~");
}
} else if(model->display_msg == U2fMsgError) {
if(settings->sfw_mode) {
canvas_draw_icon(canvas, 22, 15, &I_Error_62x31_sfw);
canvas_draw_icon(canvas, 22, 15, xtreme_assets->error);
if(xtreme_settings->sfw_mode) {
canvas_draw_str_aligned(
canvas, 128 / 2, 3, AlignCenter, AlignTop, "Certificate error");
} else {
canvas_draw_icon(canvas, 22, 15, &I_Error_62x31);
canvas_draw_str_aligned(canvas, 128 / 2, 3, AlignCenter, AlignTop, "Unable to cum");
}
}
free(settings);
}
static bool u2f_view_input_callback(InputEvent* event, void* context) {
+2 -5
View File
@@ -16,7 +16,7 @@
#include <dialogs/dialogs.h>
#include "DAP_Link_icons.h"
#include "../../settings/desktop_settings/desktop_settings_app.h"
#include "../../settings/xtreme_settings/xtreme_settings.h"
/***************************************************************************/
/****************************** DAP COMMON *********************************/
@@ -484,13 +484,11 @@ DapConfig* dap_app_get_config(DapApp* app) {
int32_t dap_link_app(void* p) {
UNUSED(p);
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
if(furi_hal_usb_is_locked()) {
DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
DialogMessage* message = dialog_message_alloc();
if(settings->sfw_mode) {
if(XTREME_SETTINGS()->sfw_mode) {
dialog_message_set_header(
message, "Connection\nis active!", 3, 2, AlignLeft, AlignTop);
dialog_message_set_text(
@@ -514,7 +512,6 @@ int32_t dap_link_app(void* p) {
dialog_message_show(dialogs, message);
dialog_message_free(message);
furi_record_close(RECORD_DIALOGS);
free(settings);
return -1;
}
+5 -7
View File
@@ -5,7 +5,7 @@
#include <gui/gui.h>
#include <input/input.h>
#include <dolphin/dolphin.h>
#include "applications/settings/desktop_settings/desktop_settings_app.h"
#include "applications/settings/xtreme_settings/xtreme_settings.h"
#define TAG "Dice Roller"
@@ -22,7 +22,6 @@ typedef struct {
typedef struct {
FuriMutex* mutex;
FuriMessageQueue* event_queue;
DesktopSettings* desktop_settings;
FuriHalRtcDateTime datetime;
uint8_t diceSelect;
uint8_t diceQty;
@@ -430,7 +429,6 @@ static void dice_state_init(DiceState* const state) {
state->playerOneScore = 0;
state->playerTwoScore = 0;
state->letsRoll = false;
state->desktop_settings = malloc(sizeof(DesktopSettings));
}
static void dice_tick(void* ctx) {
@@ -470,7 +468,6 @@ int32_t dice_app(void* p) {
return 255;
}
DESKTOP_SETTINGS_LOAD(plugin_state->desktop_settings);
ViewPort* view_port = view_port_alloc();
view_port_draw_callback_set(view_port, dice_render_callback, plugin_state);
@@ -480,6 +477,8 @@ int32_t dice_app(void* p) {
gui_add_view_port(gui, view_port, GuiLayerFullscreen);
furi_timer_start(timer, furi_kernel_get_tick_frequency());
XtremeSettings* xtreme_settings = XTREME_SETTINGS();
// Main loop
PluginEvent event;
for(bool processing = true; processing;) {
@@ -510,7 +509,7 @@ int32_t dice_app(void* p) {
} else if(plugin_state->diceSelect == 20) {
plugin_state->diceSelect = 100;
} else if(plugin_state->diceSelect == 100) {
if(plugin_state->desktop_settings->is_sfwmode) {
if(xtreme_settings->sfw_mode) {
plugin_state->diceSelect = 231;
} else {
plugin_state->diceSelect = 230;
@@ -524,7 +523,7 @@ int32_t dice_app(void* p) {
} else if(plugin_state->diceSelect == 229) {
plugin_state->diceSelect = 228;
} else if(plugin_state->diceSelect == 228) {
if(plugin_state->desktop_settings->is_sfwmode) {
if(xtreme_settings->sfw_mode) {
plugin_state->diceSelect = 59;
} else {
plugin_state->diceSelect = 232;
@@ -571,7 +570,6 @@ int32_t dice_app(void* p) {
view_port_free(view_port);
furi_message_queue_free(plugin_state->event_queue);
furi_mutex_free(plugin_state->mutex);
free(plugin_state->desktop_settings);
free(plugin_state);
return 0;
}
@@ -7,7 +7,7 @@
#include <gui/elements.h>
#include <m-array.h>
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
#define FRAME_HEIGHT 12
#define MAX_LEN_PX 112
@@ -181,9 +181,6 @@ void pcsg_view_receiver_draw(Canvas* canvas, PCSGReceiverModel* model) {
FuriString* str_buff;
str_buff = furi_string_alloc();
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
PCSGReceiverMenuItem* item_menu;
for(size_t i = 0; i < MIN(model->history_item, MENU_ITEMS); ++i) {
@@ -209,11 +206,7 @@ void pcsg_view_receiver_draw(Canvas* canvas, PCSGReceiverModel* model) {
canvas_set_color(canvas, ColorBlack);
if(model->history_item == 0) {
if(settings->sfw_mode) {
canvas_draw_icon(canvas, 0, 0, &I_Scanning_123x52_sfw);
} else {
canvas_draw_icon(canvas, 0, 0, &I_Scanning_123x52);
}
canvas_draw_icon(canvas, 0, 0, XTREME_ASSETS()->subghz_scanning);
canvas_set_font(canvas, FontPrimary);
canvas_draw_str(canvas, 63, 46, "Scanning...");
canvas_draw_line(canvas, 46, 51, 125, 51);
@@ -235,7 +228,7 @@ void pcsg_view_receiver_draw(Canvas* canvas, PCSGReceiverModel* model) {
canvas_draw_icon(canvas, 65, 42, &I_Pin_back_arrow_10x8);
canvas_draw_icon(canvas, 80, 42, &I_Pin_back_arrow_10x8);
canvas_draw_icon(canvas, 95, 42, &I_Pin_back_arrow_10x8);
if(settings->sfw_mode) {
if(XTREME_SETTINGS()->sfw_mode) {
canvas_draw_icon(canvas, 16, 13, &I_WarningDolphin_45x42_sfw);
} else {
canvas_draw_icon(canvas, 16, 13, &I_WarningDolphin_45x42);
@@ -252,7 +245,6 @@ void pcsg_view_receiver_draw(Canvas* canvas, PCSGReceiverModel* model) {
canvas_draw_str(canvas, 96, 62, furi_string_get_cstr(model->history_stat_str));
break;
}
free(settings);
}
static void pcsg_view_receiver_timer_callback(void* context) {
@@ -19,7 +19,7 @@
#include "unitemp_icons.h"
#include <assets_icons.h>
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_settings.h"
static View* view;
@@ -170,9 +170,7 @@ static void _draw_singleSensor(Canvas* canvas, Sensor* sensor, const uint8_t pos
}
static void _draw_view_noSensors(Canvas* canvas) {
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
if(settings->sfw_mode) {
if(XTREME_SETTINGS()->sfw_mode) {
canvas_draw_icon(canvas, 7, 17, &I_sherlok_53x45_sfw);
} else {
canvas_draw_icon(canvas, 7, 17, &I_sherlok_53x45);
@@ -191,7 +189,6 @@ static void _draw_view_noSensors(Canvas* canvas) {
canvas_draw_str(canvas, x, y + 18, "press OK");
canvas_draw_icon(canvas, x + 37, y + 10, &I_Ok_btn_9x9);
free(settings);
}
static void _draw_view_sensorsList(Canvas* canvas) {
@@ -7,7 +7,7 @@
#include <gui/elements.h>
#include <m-array.h>
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
#define FRAME_HEIGHT 12
#define MAX_LEN_PX 112
@@ -178,9 +178,6 @@ void ws_view_receiver_draw(Canvas* canvas, WSReceiverModel* model) {
FuriString* str_buff;
str_buff = furi_string_alloc();
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
WSReceiverMenuItem* item_menu;
for(size_t i = 0; i < MIN(model->history_item, MENU_ITEMS); ++i) {
@@ -205,11 +202,7 @@ void ws_view_receiver_draw(Canvas* canvas, WSReceiverModel* model) {
canvas_set_color(canvas, ColorBlack);
if(model->history_item == 0) {
if(settings->sfw_mode) {
canvas_draw_icon(canvas, 0, 0, &I_Scanning_123x52_sfw);
} else {
canvas_draw_icon(canvas, 0, 0, &I_Scanning_123x52);
}
canvas_draw_icon(canvas, 0, 0, XTREME_ASSETS()->subghz_scanning);
canvas_set_font(canvas, FontPrimary);
canvas_draw_str(canvas, 63, 46, "Scanning...");
canvas_draw_line(canvas, 46, 51, 125, 51);
@@ -231,7 +224,7 @@ void ws_view_receiver_draw(Canvas* canvas, WSReceiverModel* model) {
canvas_draw_icon(canvas, 65, 42, &I_Pin_back_arrow_10x8);
canvas_draw_icon(canvas, 80, 42, &I_Pin_back_arrow_10x8);
canvas_draw_icon(canvas, 95, 42, &I_Pin_back_arrow_10x8);
if(settings->sfw_mode) {
if(XTREME_SETTINGS()->sfw_mode) {
canvas_draw_icon(canvas, 16, 13, &I_WarningDolphin_45x42_sfw);
} else {
canvas_draw_icon(canvas, 16, 13, &I_WarningDolphin_45x42);
@@ -248,7 +241,6 @@ void ws_view_receiver_draw(Canvas* canvas, WSReceiverModel* model) {
canvas_draw_str(canvas, 96, 62, furi_string_get_cstr(model->history_stat_str));
break;
}
free(settings);
}
static void ws_view_receiver_timer_callback(void* context) {
+3 -17
View File
@@ -5,7 +5,7 @@
#include <notification/notification_messages.h>
#include <gui/elements.h>
#include <assets_icons.h>
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
#define TAG "BtSrv"
@@ -36,17 +36,10 @@ static void bt_pin_code_view_port_draw_callback(Canvas* canvas, void* context) {
furi_assert(context);
Bt* bt = context;
char pin_code_info[24];
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
if(settings->sfw_mode) {
canvas_draw_icon(canvas, 0, 0, &I_BLE_Pairing_128x64_sfw);
} else {
canvas_draw_icon(canvas, 0, 0, &I_BLE_Pairing_128x64);
}
canvas_draw_icon(canvas, 0, 0, XTREME_ASSETS()->bt_pairing);
snprintf(pin_code_info, sizeof(pin_code_info), "Pairing code\n%06lu", bt->pin_code);
elements_multiline_text_aligned(canvas, 64, 4, AlignCenter, AlignTop, pin_code_info);
elements_button_left(canvas, "Quit");
free(settings);
}
static void bt_pin_code_view_port_input_callback(InputEvent* event, void* context) {
@@ -83,16 +76,10 @@ static void bt_pin_code_hide(Bt* bt) {
static bool bt_pin_code_verify_event_handler(Bt* bt, uint32_t pin) {
furi_assert(bt);
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
notification_message(bt->notification, &sequence_display_backlight_on);
FuriString* pin_str;
if(settings->sfw_mode) {
dialog_message_set_icon(bt->dialog_message, &I_BLE_Pairing_128x64_sfw, 0, 0);
} else {
dialog_message_set_icon(bt->dialog_message, &I_BLE_Pairing_128x64, 0, 0);
}
dialog_message_set_icon(bt->dialog_message, XTREME_ASSETS()->bt_pairing, 0, 0);
pin_str = furi_string_alloc_printf("Verify code\n%06lu", pin);
dialog_message_set_text(
bt->dialog_message, furi_string_get_cstr(pin_str), 64, 4, AlignCenter, AlignTop);
@@ -100,7 +87,6 @@ static bool bt_pin_code_verify_event_handler(Bt* bt, uint32_t pin) {
DialogMessageButton button = dialog_message_show(bt->dialogs, bt->dialog_message);
furi_string_free(pin_str);
return button == DialogMessageButtonCenter;
free(settings);
}
static void bt_battery_level_changed_callback(const void* _event, void* context) {
@@ -13,7 +13,7 @@
#include "animation_storage.h"
#include "animation_manager.h"
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_settings.h"
#define TAG "AnimationManager"
@@ -54,7 +54,6 @@ struct AnimationManager {
FuriString* freezed_animation_name;
int32_t freezed_animation_time_left;
ViewStack* view_stack;
bool sfw_mode;
};
static StorageAnimation*
@@ -66,7 +65,8 @@ static void animation_manager_start_new_idle(AnimationManager* animation_manager
static bool animation_manager_check_blocking(AnimationManager* animation_manager);
static bool animation_manager_is_valid_idle_animation(
const StorageAnimationManifestInfo* info,
const DolphinStats* stats);
const DolphinStats* stats,
const bool unlock);
static void animation_manager_switch_to_one_shot_view(AnimationManager* animation_manager);
static void animation_manager_switch_to_animation_view(AnimationManager* animation_manager);
@@ -145,7 +145,7 @@ void animation_manager_check_blocking_process(AnimationManager* animation_manage
const StorageAnimationManifestInfo* manifest_info =
animation_storage_get_meta(animation_manager->current_animation);
bool valid = animation_manager_is_valid_idle_animation(manifest_info, &stats);
bool valid = animation_manager_is_valid_idle_animation(manifest_info, &stats, XTREME_SETTINGS()->unlock_anims);
if(!valid) {
animation_manager_start_new_idle(animation_manager);
@@ -200,11 +200,9 @@ static void animation_manager_start_new_idle(AnimationManager* animation_manager
const BubbleAnimation* bubble_animation =
animation_storage_get_bubble_animation(animation_manager->current_animation);
animation_manager->state = AnimationManagerStateIdle;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
int32_t duration_s = settings->cycle_animation_s == -1 ? bubble_animation->duration : (settings->cycle_animation_s - 1);
furi_timer_start(animation_manager->idle_animation_timer, duration_s * 1000);
free(settings);
XtremeSettings* xtreme_settings = XTREME_SETTINGS();
int32_t duration = (xtreme_settings->cycle_anims == 0) ? (bubble_animation->duration) : (xtreme_settings->cycle_anims);
furi_timer_start(animation_manager->idle_animation_timer, (duration > 0) ? (duration * 1000) : 0);
}
static bool animation_manager_check_blocking(AnimationManager* animation_manager) {
@@ -336,7 +334,8 @@ View* animation_manager_get_animation_view(AnimationManager* animation_manager)
static bool animation_manager_is_valid_idle_animation(
const StorageAnimationManifestInfo* info,
const DolphinStats* stats) {
const DolphinStats* stats,
const bool unlock) {
furi_assert(info);
furi_assert(info->name);
@@ -356,11 +355,13 @@ static bool animation_manager_is_valid_idle_animation(
result = (sd_status == FSE_NOT_READY);
}
if((stats->butthurt < info->min_butthurt) || (stats->butthurt > info->max_butthurt)) {
result = false;
}
if((stats->level < info->min_level) || (stats->level > info->max_level)) {
result = false;
if (!unlock) {
if((stats->butthurt < info->min_butthurt) || (stats->butthurt > info->max_butthurt)) {
result = false;
}
if((stats->level < info->min_level) || (stats->level > info->max_level)) {
result = false;
}
}
return result;
@@ -368,7 +369,10 @@ static bool animation_manager_is_valid_idle_animation(
static StorageAnimation*
animation_manager_select_idle_animation(AnimationManager* animation_manager) {
UNUSED(animation_manager);
const char* old_animation_name = NULL;
if (animation_manager->current_animation) {
old_animation_name = animation_storage_get_meta(animation_manager->current_animation)->name;
}
StorageAnimationList_t animation_list;
StorageAnimationList_init(animation_list);
@@ -380,11 +384,18 @@ static StorageAnimation*
uint32_t whole_weight = 0;
StorageAnimationList_it_t it;
bool unlock = XTREME_SETTINGS()->unlock_anims;
for(StorageAnimationList_it(it, animation_list); !StorageAnimationList_end_p(it);) {
StorageAnimation* storage_animation = *StorageAnimationList_ref(it);
const StorageAnimationManifestInfo* manifest_info =
animation_storage_get_meta(storage_animation);
bool valid = animation_manager_is_valid_idle_animation(manifest_info, &stats);
bool valid = animation_manager_is_valid_idle_animation(manifest_info, &stats, unlock);
if (old_animation_name != NULL) {
if (strcmp(manifest_info->name, old_animation_name) == 0) {
valid = false;
}
}
if(valid) {
whole_weight += manifest_info->weight;
@@ -501,7 +512,7 @@ void animation_manager_load_and_continue_animation(AnimationManager* animation_m
furi_record_close(RECORD_DOLPHIN);
const StorageAnimationManifestInfo* manifest_info =
animation_storage_get_meta(restore_animation);
bool valid = animation_manager_is_valid_idle_animation(manifest_info, &stats);
bool valid = animation_manager_is_valid_idle_animation(manifest_info, &stats, XTREME_SETTINGS()->unlock_anims);
if(valid) {
animation_manager_replace_current_animation(
animation_manager, restore_animation);
@@ -512,14 +523,12 @@ void animation_manager_load_and_continue_animation(AnimationManager* animation_m
animation_manager->idle_animation_timer,
animation_manager->freezed_animation_time_left);
} else {
const BubbleAnimation* animation = animation_storage_get_bubble_animation(
const BubbleAnimation* bubble_animation = animation_storage_get_bubble_animation(
animation_manager->current_animation);
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
int32_t duration_s = settings->cycle_animation_s == -1 ? animation->duration : (settings->cycle_animation_s - 1);
XtremeSettings* xtreme_settings = XTREME_SETTINGS();
int32_t duration = (xtreme_settings->cycle_anims == 0) ? (bubble_animation->duration) : (xtreme_settings->cycle_anims);
furi_timer_start(
animation_manager->idle_animation_timer, duration_s * 1000);
free(settings);
animation_manager->idle_animation_timer, (duration > 0) ? (duration * 1000) : 0);
}
}
} else {
@@ -554,8 +563,6 @@ static void animation_manager_switch_to_one_shot_view(AnimationManager* animatio
Dolphin* dolphin = furi_record_open(RECORD_DOLPHIN);
DolphinStats stats = dolphin_stats(dolphin);
furi_record_close(RECORD_DOLPHIN);
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
animation_manager->one_shot_view = one_shot_view_alloc();
one_shot_view_set_interact_callback(
@@ -564,7 +571,7 @@ static void animation_manager_switch_to_one_shot_view(AnimationManager* animatio
View* next_view = one_shot_view_get_view(animation_manager->one_shot_view);
view_stack_remove_view(animation_manager->view_stack, prev_view);
view_stack_add_view(animation_manager->view_stack, next_view);
if(settings->sfw_mode) {
if(XTREME_SETTINGS()->sfw_mode) {
if(stats.level <= 20) {
one_shot_view_start_animation(
animation_manager->one_shot_view, &A_Levelup1_128x64_sfw);
@@ -577,7 +584,6 @@ static void animation_manager_switch_to_one_shot_view(AnimationManager* animatio
} else {
one_shot_view_start_animation(animation_manager->one_shot_view, &A_Levelup1_128x64);
}
free(settings);
}
static void animation_manager_switch_to_animation_view(AnimationManager* animation_manager) {
@@ -11,43 +11,51 @@
#include "animation_storage_i.h"
#include <assets_dolphin_internal.h>
#include <assets_dolphin_blocking.h>
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_assets.h"
#define ANIMATION_META_FILE "meta.txt"
#define ANIMATION_DIR EXT_PATH("dolphin")
#define BASE_ANIMATION_DIR EXT_PATH("dolphin")
#define TAG "AnimationStorage"
/* Unused old code, for safe-keeping
#define ANIMATION_MANIFEST_FILE ANIMATION_DIR "/manifest.txt"
*/
char ANIMATION_MANIFEST_FILE[30];
// 59 Max length = strlen("/ext/dolphin_custom//Anims") + MAX_PACK_NAME_LEN + 1 (Null terminator)
char ANIMATION_DIR[59];
// 72 Max length = ANIMATION_DIR + strlen("/manifest.txt")
char ANIMATION_MANIFEST_FILE[72];
static void animation_storage_free_bubbles(BubbleAnimation* animation);
static void animation_storage_free_frames(BubbleAnimation* animation);
static void animation_storage_free_animation(BubbleAnimation** storage_animation);
static BubbleAnimation* animation_storage_load_animation(const char* name);
void animation_handler_beta() {
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
if(settings->sfw_mode) {
snprintf(ANIMATION_MANIFEST_FILE, sizeof(ANIMATION_DIR), "%s", ANIMATION_DIR);
FURI_LOG_I(TAG, "SFW Manifest selected");
strcat(ANIMATION_MANIFEST_FILE, "/sfw/manifest.txt");
void animation_handler_select_manifest() {
XtremeSettings* xtreme_settings = XTREME_SETTINGS();
if (xtreme_settings->asset_pack[0] != '\0') {
snprintf(ANIMATION_DIR, sizeof(PACKS_DIR), "%s", PACKS_DIR);
FURI_LOG_I(TAG, "Custom Manifest selected");
strcat(ANIMATION_DIR, "/");
strcat(ANIMATION_DIR, xtreme_settings->asset_pack);
strcat(ANIMATION_DIR, "/Anims");
} else {
snprintf(ANIMATION_MANIFEST_FILE, sizeof(ANIMATION_DIR), "%s", ANIMATION_DIR);
FURI_LOG_I(TAG, "NSFW Manifest selected");
strcat(ANIMATION_MANIFEST_FILE, "/nsfw/manifest.txt");
snprintf(ANIMATION_DIR, sizeof(BASE_ANIMATION_DIR), "%s", BASE_ANIMATION_DIR);
if(xtreme_settings->sfw_mode) {
FURI_LOG_I(TAG, "SFW Manifest selected");
strcat(ANIMATION_DIR, "/sfw");
} else {
FURI_LOG_I(TAG, "NSFW Manifest selected");
strcat(ANIMATION_DIR, "/nsfw");
}
}
free(settings);
snprintf(ANIMATION_MANIFEST_FILE, sizeof(ANIMATION_MANIFEST_FILE), "%s/manifest.txt", ANIMATION_DIR);
}
static bool animation_storage_load_single_manifest_info(
StorageAnimationManifestInfo* manifest_info,
const char* name) {
furi_assert(manifest_info);
animation_handler_beta();
animation_handler_select_manifest();
bool result = false;
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* file = flipper_format_file_alloc(storage);
@@ -103,7 +111,7 @@ static bool animation_storage_load_single_manifest_info(
void animation_storage_fill_animation_list(StorageAnimationList_t* animation_list) {
furi_assert(sizeof(StorageAnimationList_t) == sizeof(void*));
furi_assert(!StorageAnimationList_size(*animation_list));
animation_handler_beta();
animation_handler_select_manifest();
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* file = flipper_format_file_alloc(storage);
@@ -319,7 +327,7 @@ static bool animation_storage_load_frames(
for(int i = 0; i < icon->frame_count; ++i) {
frames_ok = false;
furi_string_printf(filename, ANIMATION_DIR "/%s/frame_%d.bm", name, i);
furi_string_printf(filename, "%s/%s/frame_%d.bm", ANIMATION_DIR, name, i);
if(storage_common_stat(storage, furi_string_get_cstr(filename), &file_info) != FSE_OK)
break;
@@ -471,7 +479,7 @@ static BubbleAnimation* animation_storage_load_animation(const char* name) {
if(FSE_OK != storage_sd_status(storage)) break;
furi_string_printf(str, ANIMATION_DIR "/%s/" ANIMATION_META_FILE, name);
furi_string_printf(str, "%s/%s/" ANIMATION_META_FILE, ANIMATION_DIR, name);
if(!flipper_format_file_open_existing(ff, furi_string_get_cstr(str))) break;
if(!flipper_format_read_header(ff, str, &u32value)) break;
if(furi_string_cmp_str(str, "Flipper Animation")) break;
-13
View File
@@ -140,12 +140,6 @@ void desktop_unlock(Desktop* desktop) {
desktop_auto_lock_arm(desktop);
}
void desktop_set_sfw_mode_state(Desktop* desktop, bool enabled) {
desktop->settings.sfw_mode = enabled;
DESKTOP_SETTINGS_SAVE(&desktop->settings);
animation_manager_new_idle_process(desktop->animation_manager);
}
Desktop* desktop_alloc() {
Desktop* desktop = malloc(sizeof(Desktop));
@@ -322,13 +316,6 @@ int32_t desktop_srv(void* p) {
DESKTOP_SETTINGS_SAVE(&desktop->settings);
}
if(!desktop->settings.cycle_animation_s) {
desktop->settings.cycle_animation_s = -1;
DESKTOP_SETTINGS_SAVE(&desktop->settings);
}
desktop_main_set_sfw_mode_state(desktop->main_view, desktop->settings.sfw_mode);
scene_manager_next_scene(desktop->scene_manager, DesktopSceneMain);
desktop_pin_lock_init(&desktop->settings);
@@ -75,4 +75,3 @@ Desktop* desktop_alloc();
void desktop_free(Desktop* desktop);
void desktop_lock(Desktop* desktop);
void desktop_unlock(Desktop* desktop);
void desktop_set_sfw_mode_state(Desktop* desktop, bool enabled);
@@ -36,14 +36,6 @@
#define MIN_PIN_SIZE 4
#define MAX_APP_LENGTH 128
#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"
typedef struct {
@@ -62,8 +54,4 @@ typedef struct {
PinCode pin_code;
uint8_t is_locked;
uint32_t auto_lock_delay_ms;
uint8_t displayBatteryPercentage;
bool is_sfwmode;
uint8_t sfw_mode;
int32_t cycle_animation_s;
} DesktopSettings;
@@ -1,7 +1,7 @@
#include <furi_hal.h>
#include "../desktop_i.h"
#include "../../../settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_settings.h"
#define DesktopFaultEventExit 0x00FF00FF
@@ -13,12 +13,9 @@ void desktop_scene_fault_callback(void* context) {
void desktop_scene_fault_on_enter(void* context) {
Desktop* desktop = (Desktop*)context;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
Popup* popup = desktop->hw_mismatch_popup;
popup_set_context(popup, desktop);
if(settings->sfw_mode) {
if(XTREME_SETTINGS()->sfw_mode) {
popup_set_header(
popup,
"Flipper crashed\n but has been rebooted",
@@ -40,7 +37,6 @@ void desktop_scene_fault_on_enter(void* context) {
popup_set_text(popup, message, 60, 37 + STATUS_BAR_Y_SHIFT, AlignCenter, AlignCenter);
popup_set_callback(popup, desktop_scene_fault_callback);
view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewIdHwMismatch);
free(settings);
}
bool desktop_scene_fault_on_event(void* context, SceneManagerEvent event) {
@@ -26,7 +26,6 @@ void desktop_scene_lock_menu_on_enter(void* context) {
scene_manager_set_scene_state(desktop->scene_manager, DesktopSceneLockMenu, 0);
desktop_lock_menu_set_callback(desktop->lock_menu, desktop_scene_lock_menu_callback, desktop);
desktop_lock_menu_set_pin_state(desktop->lock_menu, desktop->settings.pin_code.length > 0);
desktop_lock_menu_set_sfw_mode_state(desktop->lock_menu, desktop->settings.sfw_mode);
desktop_lock_menu_set_idx(desktop->lock_menu, 0);
view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewIdLockMenu);
@@ -90,15 +89,8 @@ bool desktop_scene_lock_menu_on_event(void* context, SceneManagerEvent event) {
furi_record_close(RECORD_POWER);
break;
case DesktopLockMenuEventSFWModeOn:
desktop_set_sfw_mode_state(desktop, true);
scene_manager_search_and_switch_to_previous_scene(
desktop->scene_manager, DesktopSceneMain);
break;
case DesktopLockMenuEventSFWModeOff:
desktop_set_sfw_mode_state(desktop, false);
scene_manager_search_and_switch_to_previous_scene(
desktop->scene_manager, DesktopSceneMain);
case DesktopLockMenuEventXtremeSettings:
loader_start(desktop->loader, "Xtreme FW", NULL);
break;
default:
break;
@@ -111,4 +103,4 @@ bool desktop_scene_lock_menu_on_event(void* context, SceneManagerEvent event) {
void desktop_scene_lock_menu_on_exit(void* context) {
UNUSED(context);
}
}
@@ -43,8 +43,7 @@ typedef enum {
DesktopLockMenuEventPinLock,
DesktopLockMenuEventPinLockShutdown,
DesktopLockMenuEventExit,
DesktopLockMenuEventSFWModeOn,
DesktopLockMenuEventSFWModeOff,
DesktopLockMenuEventXtremeSettings,
DesktopAnimationEventCheckAnimation,
DesktopAnimationEventNewIdleAnimation,
@@ -5,7 +5,7 @@
#include "../desktop_i.h"
#include "desktop_view_lock_menu.h"
#include "applications/settings/desktop_settings/desktop_settings_app.h"
#include "../../../settings/xtreme_settings/xtreme_settings.h"
#define LOCK_MENU_ITEMS_NB 5
@@ -13,7 +13,7 @@ typedef enum {
DesktopLockMenuIndexLock,
DesktopLockMenuIndexPinLock,
DesktopLockMenuIndexPinLockShutdown,
DesktopLockMenuIndexSFW,
DesktopLockMenuIndexXtremeSettings,
DesktopLockMenuIndexTotalCount
} DesktopLockMenuIndex;
@@ -36,11 +36,6 @@ void desktop_lock_menu_set_pin_state(DesktopLockMenuView* lock_menu, bool pin_is
true);
}
void desktop_lock_menu_set_sfw_mode_state(DesktopLockMenuView* lock_menu, bool sfw_mode) {
with_view_model(
lock_menu->view, DesktopLockMenuViewModel * model, { model->sfw_mode = sfw_mode; }, true);
}
void desktop_lock_menu_set_idx(DesktopLockMenuView* lock_menu, uint8_t idx) {
furi_assert(idx < DesktopLockMenuIndexTotalCount);
with_view_model(
@@ -72,12 +67,8 @@ void desktop_lock_menu_draw_callback(Canvas* canvas, void* model) {
} else {
str = "Set PIN + Off";
}
} else if(i == DesktopLockMenuIndexSFW) {
if(m->sfw_mode) {
str = "NSFW Mode";
} else {
str = "SFW Mode";
}
} else if(i == DesktopLockMenuIndexXtremeSettings) {
str = "Xtreme Settings";
}
if(str) //-V547
@@ -100,7 +91,6 @@ bool desktop_lock_menu_input_callback(InputEvent* event, void* context) {
DesktopLockMenuView* lock_menu = context;
uint8_t idx = 0;
bool consumed = false;
bool sfw_mode = false;
bool update = false;
with_view_model(
@@ -127,7 +117,6 @@ bool desktop_lock_menu_input_callback(InputEvent* event, void* context) {
}
}
idx = model->idx;
sfw_mode = model->sfw_mode;
},
update);
@@ -138,17 +127,8 @@ bool desktop_lock_menu_input_callback(InputEvent* event, void* context) {
lock_menu->callback(DesktopLockMenuEventPinLock, lock_menu->context);
} else if((idx == DesktopLockMenuIndexPinLockShutdown) && (event->type == InputTypeShort)) {
lock_menu->callback(DesktopLockMenuEventPinLockShutdown, lock_menu->context);
// } else if((idx == DesktopLockMenuIndexGameMode) && (event->type == InputTypeShort)) {
// desktop_view_lock_menu_sfwmode_changed(1);
// DOLPHIN_DEED(getRandomDeed());
// lock_menu->callback(DesktopLockMenuEventExit, lock_menu->context);
} else if(idx == DesktopLockMenuIndexSFW) {
// DOLPHIN_DEED(getRandomDeed());
if((sfw_mode == false) && (event->type == InputTypeShort)) {
lock_menu->callback(DesktopLockMenuEventSFWModeOn, lock_menu->context);
} else if((sfw_mode == true) && (event->type == InputTypeShort)) {
lock_menu->callback(DesktopLockMenuEventSFWModeOff, lock_menu->context);
}
} else if((idx == DesktopLockMenuIndexXtremeSettings) && (event->type == InputTypeShort)) {
lock_menu->callback(DesktopLockMenuEventXtremeSettings, lock_menu->context);
}
consumed = true;
}
@@ -18,7 +18,6 @@ struct DesktopLockMenuView {
typedef struct {
uint8_t idx;
bool pin_is_set;
bool sfw_mode;
} DesktopLockMenuViewModel;
void desktop_lock_menu_set_callback(
@@ -28,7 +27,6 @@ void desktop_lock_menu_set_callback(
View* desktop_lock_menu_get_view(DesktopLockMenuView* lock_menu);
void desktop_lock_menu_set_pin_state(DesktopLockMenuView* lock_menu, bool pin_is_set);
void desktop_lock_menu_set_sfw_mode_state(DesktopLockMenuView* lock_menu, bool sfw_mode);
void desktop_lock_menu_set_idx(DesktopLockMenuView* lock_menu, uint8_t idx);
DesktopLockMenuView* desktop_lock_menu_alloc();
void desktop_lock_menu_free(DesktopLockMenuView* lock_menu);
@@ -14,7 +14,6 @@ struct DesktopMainView {
DesktopMainViewCallback callback;
void* context;
TimerHandle_t poweroff_timer;
bool sfw_mode;
};
#define DESKTOP_MAIN_VIEW_POWEROFF_TIMEOUT 2000
@@ -39,11 +38,6 @@ View* desktop_main_get_view(DesktopMainView* main_view) {
return main_view->view;
}
void desktop_main_set_sfw_mode_state(DesktopMainView* main_view, bool sfw_mode) {
furi_assert(main_view);
main_view->sfw_mode = sfw_mode;
}
bool desktop_main_input_callback(InputEvent* event, void* context) {
furi_assert(event);
furi_assert(context);
@@ -110,4 +104,4 @@ void desktop_main_free(DesktopMainView* main_view) {
view_free(main_view->view);
furi_timer_free(main_view->poweroff_timer);
free(main_view);
}
}
@@ -13,6 +13,5 @@ void desktop_main_set_callback(
void* context);
View* desktop_main_get_view(DesktopMainView* main_view);
void desktop_main_set_sfw_mode_state(DesktopMainView* main_view, bool sfw_mode);
DesktopMainView* desktop_main_alloc();
void desktop_main_free(DesktopMainView* main_view);
+158 -175
View File
@@ -1,193 +1,187 @@
#include "power_i.h"
#include "desktop/desktop_settings.h"
#include <furi.h>
#include <furi_hal.h>
#include "../../../settings/xtreme_settings/xtreme_settings.h"
#define POWER_OFF_TIMEOUT 90
void power_draw_battery_callback(Canvas* canvas, void* context) {
furi_assert(context);
Power* power = context;
if(power->displayBatteryPercentage == DISPLAY_BATTERY_NO) {
// no draw
} else {
BatteryStyle battery_style = XTREME_SETTINGS()->battery_style;
if(battery_style == BatteryStyleOff) return;
canvas_draw_icon(canvas, 0, 0, &I_Battery_25x8);
canvas_set_color(canvas, ColorWhite);
canvas_draw_box(canvas, -1, 0, 1, 8);
canvas_draw_box(canvas, 0, -1, 24, 1);
canvas_draw_box(canvas, 0, 8, 24, 1);
canvas_draw_box(canvas, 25, 1, 2, 6);
canvas_set_color(canvas, ColorBlack);
canvas_draw_box(canvas, 25, 2, 1, 4);
canvas_draw_icon(canvas, 0, 0, &I_Battery_25x8);
canvas_set_color(canvas, ColorWhite);
canvas_draw_box(canvas, -1, 0, 1, 8);
canvas_draw_box(canvas, 0, -1, 24, 1);
canvas_draw_box(canvas, 0, 8, 24, 1);
canvas_draw_box(canvas, 25, 1, 2, 6);
canvas_set_color(canvas, ColorBlack);
canvas_draw_box(canvas, 25, 2, 1, 4);
if(power->info.gauge_is_ok) {
char batteryPercentile[4];
snprintf(batteryPercentile, sizeof(batteryPercentile), "%d", power->info.charge);
if((power->displayBatteryPercentage == DISPLAY_BATTERY_PERCENT) &&
if(power->info.gauge_is_ok) {
char batteryPercentile[4];
snprintf(batteryPercentile, sizeof(batteryPercentile), "%d", power->info.charge);
if((battery_style == BatteryStylePercent) &&
(power->state !=
PowerStateCharging)) { //if display battery percentage, black background white text
canvas_set_font(canvas, FontBatteryPercent);
canvas_set_color(canvas, ColorBlack);
canvas_draw_box(canvas, 1, 1, 22, 6);
canvas_set_color(canvas, ColorWhite);
canvas_draw_str_aligned(canvas, 11, 4, AlignCenter, AlignCenter, batteryPercentile);
} else if(
(battery_style == BatteryStyleInvertedPercent) &&
(power->state !=
PowerStateCharging)) { //if display battery percentage, black background white text
canvas_set_font(canvas, FontBatteryPercent);
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) &&
(power->state != PowerStateCharging)) { //Retro style segmented display, 3 parts
if(power->info.charge > 25) {
canvas_draw_box(canvas, 2, 2, 6, 4);
}
if(power->info.charge > 50) {
canvas_draw_box(canvas, 9, 2, 6, 4);
}
if(power->info.charge > 75) {
canvas_draw_box(canvas, 16, 2, 6, 4);
}
} else if(
(battery_style == BatteryStyleRetro5) &&
(power->state != PowerStateCharging)) { //Retro style segmented display, 5 parts
if(power->info.charge > 10) {
canvas_draw_box(canvas, 2, 2, 3, 4);
}
if(power->info.charge > 30) {
canvas_draw_box(canvas, 6, 2, 3, 4);
}
if(power->info.charge > 50) {
canvas_draw_box(canvas, 10, 2, 3, 4);
}
if(power->info.charge > 70) {
canvas_draw_box(canvas, 14, 2, 3, 4);
}
if(power->info.charge > 90) {
canvas_draw_box(canvas, 18, 2, 3, 4);
}
} else if(
(battery_style == BatteryStyleBarPercent) &&
(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;
}
canvas_set_color(canvas, ColorBlack);
canvas_draw_box(canvas, 1, 1, (bar_charge * 22) / 100, 6);
// drawing digits
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 >= 62, 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);
}
// TODO: Verify if it displays correctly with custom battery skins !!!
if(power->info.voltage_battery_charging < 4.2) {
// Battery charging voltage is modified, indicate with cross pattern
canvas_invert_color(canvas);
uint8_t battery_bar_width = (power->info.charge + 4) / 5;
bool cross_odd = false;
// Start 1 further in from the battery bar's x position
for(uint8_t x = 3; x <= battery_bar_width; x++) {
// Cross pattern is from the center of the battery bar
// y = 2 + 1 (inset) + 1 (for every other)
canvas_draw_dot(canvas, x, 3 + (uint8_t)cross_odd);
cross_odd = !cross_odd;
}
canvas_invert_color(canvas);
}
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) {
canvas_set_color(canvas, ColorBlack);
canvas_draw_box(canvas, 1, 1, 22, 6);
canvas_draw_icon(canvas, 2, -1, &I_Charging_lightning_9x10);
canvas_set_color(canvas, ColorWhite);
canvas_draw_str_aligned(canvas, 11, 4, AlignCenter, AlignCenter, batteryPercentile);
} else if(
(power->displayBatteryPercentage == DISPLAY_BATTERY_INVERTED_PERCENT) &&
(power->state !=
PowerStateCharging)) { //if display inverted percentage, white background black text
canvas_draw_icon(canvas, 2, -1, &I_Charging_lightning_mask_9x10);
canvas_set_font(canvas, FontBatteryPercent);
canvas_draw_str_aligned(
canvas, 16, 4, AlignCenter, AlignCenter, batteryPercentile);
} else if(battery_style == BatteryStyleInvertedPercent) {
canvas_set_color(canvas, ColorWhite);
canvas_draw_box(canvas, 1, 1, 22, 6);
canvas_draw_icon(canvas, 2, -1, &I_Charging_lightning_9x10);
canvas_set_color(canvas, ColorBlack);
canvas_draw_str_aligned(canvas, 11, 4, AlignCenter, AlignCenter, batteryPercentile);
} else if(
(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);
}
if(power->info.charge > 50) {
canvas_draw_box(canvas, 9, 2, 6, 4);
}
if(power->info.charge > 75) {
canvas_draw_box(canvas, 16, 2, 6, 4);
}
} else if(
(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);
}
if(power->info.charge > 30) {
canvas_draw_box(canvas, 6, 2, 3, 4);
}
if(power->info.charge > 50) {
canvas_draw_box(canvas, 10, 2, 3, 4);
}
if(power->info.charge > 70) {
canvas_draw_box(canvas, 14, 2, 3, 4);
}
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_draw_icon(canvas, 2, -1, &I_Charging_lightning_mask_9x10);
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;
}
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);
canvas_set_color(canvas, ColorBlack);
canvas_draw_box(canvas, 1, 1, (bar_charge * 22) / 100, 6);
// drawing digits
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 >= 62, 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);
canvas_draw_icon(canvas, 8, -1, &I_Charging_lightning_9x10);
}
// TODO: Verify if it displays correctly with custom battery skins !!!
if(power->info.voltage_battery_charging < 4.2) {
// Battery charging voltage is modified, indicate with cross pattern
canvas_invert_color(canvas);
uint8_t battery_bar_width = (power->info.charge + 4) / 5;
bool cross_odd = false;
// Start 1 further in from the battery bar's x position
for(uint8_t x = 3; x <= battery_bar_width; x++) {
// Cross pattern is from the center of the battery bar
// y = 2 + 1 (inset) + 1 (for every other)
canvas_draw_dot(canvas, x, 3 + (uint8_t)cross_odd);
cross_odd = !cross_odd;
}
canvas_invert_color(canvas);
}
if(power->state == PowerStateCharging) {
canvas_set_bitmap_mode(canvas, 1);
// TODO: replace -1 magic for uint8_t with re-framing
if(power->displayBatteryPercentage == DISPLAY_BATTERY_PERCENT ||
power->displayBatteryPercentage == DISPLAY_BATTERY_BAR_PERCENT) {
canvas_set_color(canvas, ColorBlack);
canvas_draw_box(canvas, 1, 1, 22, 6);
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);
canvas_set_font(canvas, FontBatteryPercent);
canvas_draw_str_aligned(
canvas, 16, 4, AlignCenter, AlignCenter, batteryPercentile);
} 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);
canvas_set_color(canvas, ColorBlack);
canvas_draw_icon(canvas, 2, -1, &I_Charging_lightning_mask_9x10);
canvas_set_font(canvas, FontBatteryPercent);
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);
canvas_set_color(canvas, ColorBlack);
canvas_draw_icon(canvas, 8, -1, &I_Charging_lightning_9x10);
}
canvas_set_bitmap_mode(canvas, 0);
}
} else {
canvas_draw_box(canvas, 8, 3, 8, 2);
canvas_set_bitmap_mode(canvas, 0);
}
} else {
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);
}
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;
}
@@ -470,11 +464,6 @@ int32_t power_srv(void* p) {
power_update_info(power);
furi_record_create(RECORD_POWER, power);
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
power->displayBatteryPercentage = settings->displayBatteryPercentage;
free(settings);
while(1) {
// Update data from gauge and charger
bool need_refresh = power_update_info(power);
@@ -489,13 +478,7 @@ int32_t power_srv(void* p) {
power_check_battery_level_change(power);
// Update battery view port
if(need_refresh) {
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
power->displayBatteryPercentage = settings->displayBatteryPercentage;
free(settings);
view_port_update(power->battery_view_port);
}
if(need_refresh) view_port_update(power->battery_view_port);
// Check OTG status and disable it in case of fault
if(furi_hal_power_is_otg_enabled()) {
@@ -25,6 +25,16 @@ typedef enum {
PowerEventTypeBatteryLevelChanged,
} PowerEventType;
typedef enum {
BatteryStyleOff,
BatteryStyleBar,
BatteryStylePercent,
BatteryStyleInvertedPercent,
BatteryStyleRetro3,
BatteryStyleRetro5,
BatteryStyleBarPercent,
} BatteryStyle;
typedef union {
uint8_t battery_level;
} PowerEventData;
@@ -44,7 +44,6 @@ struct Power {
bool battery_low;
bool show_low_bat_level_message;
uint8_t displayBatteryPercentage;
uint8_t battery_level;
uint8_t power_off_timeout;
+1
View File
@@ -5,6 +5,7 @@ App(
provides=[
"passport",
"system_settings",
"xtreme_settings",
"about",
],
)
@@ -1,6 +1,6 @@
#include "../bt_settings_app.h"
#include "furi_hal_bt.h"
#include "../../desktop_settings/desktop_settings_app.h"
#include "../../xtreme_settings/xtreme_assets.h"
void bt_settings_app_scene_forget_dev_success_popup_callback(void* context) {
BtSettingsApp* app = context;
@@ -10,21 +10,14 @@ void bt_settings_app_scene_forget_dev_success_popup_callback(void* context) {
void bt_settings_scene_forget_dev_success_on_enter(void* context) {
BtSettingsApp* app = context;
Popup* popup = app->popup;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
if(settings->sfw_mode) {
popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59_sfw);
} else {
popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59);
}
popup_set_icon(popup, 32, 5, XTREME_ASSETS()->dolphin_nice);
popup_set_header(popup, "Done", 14, 15, AlignLeft, AlignTop);
popup_set_timeout(popup, 1500);
popup_set_context(popup, app);
popup_set_callback(popup, bt_settings_app_scene_forget_dev_success_popup_callback);
popup_enable_timeout(popup);
view_dispatcher_switch_to_view(app->view_dispatcher, BtSettingsAppViewPopup);
free(settings);
}
bool bt_settings_scene_forget_dev_success_on_event(void* context, SceneManagerEvent event) {
@@ -6,6 +6,7 @@
#include "../desktop_settings_app.h"
#include <desktop/desktop_settings.h>
#include "desktop_settings_scene.h"
#include "../../xtreme_settings/xtreme_assets.h"
#define SCENE_EVENT_EXIT (0U)
@@ -21,21 +22,14 @@ void desktop_settings_scene_pin_disable_on_enter(void* context) {
app->settings.pin_code.length = 0;
memset(app->settings.pin_code.data, '0', sizeof(app->settings.pin_code.data));
DESKTOP_SETTINGS_SAVE(&app->settings);
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
popup_set_context(app->popup, app);
popup_set_callback(app->popup, pin_disable_back_callback);
if(settings->sfw_mode) {
popup_set_icon(app->popup, 0, 2, &I_DolphinMafia_115x62_sfw);
} else {
popup_set_icon(app->popup, 0, 2, &I_DolphinMafia_115x62);
}
popup_set_icon(app->popup, 0, 2, XTREME_ASSETS()->dolphin_mafia);
popup_set_header(app->popup, "PIN\nDeleted!", 95, 9, AlignCenter, AlignCenter);
popup_set_timeout(app->popup, 1500);
popup_enable_timeout(app->popup);
view_dispatcher_switch_to_view(app->view_dispatcher, DesktopSettingsAppViewIdPopup);
free(settings);
}
bool desktop_settings_scene_pin_disable_on_event(void* context, SceneManagerEvent event) {
@@ -26,40 +26,6 @@ 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 7
const char* const battery_view_count_text[BATTERY_VIEW_COUNT] =
{"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,
DISPLAY_BATTERY_RETRO_3,
DISPLAY_BATTERY_RETRO_5,
DISPLAY_BATTERY_BAR_PERCENT};
uint8_t origBattDisp_value = 0;
#define CYCLE_ANIMATION_COUNT 13
const char* const cycle_animation_text[CYCLE_ANIMATION_COUNT] = {
"OFF",
"Manifest",
"30 S",
"1 M",
"5 M",
"10 M",
"15 M",
"30 M",
"1 H",
"2 H",
"6 H",
"12 H",
"24 H",
};
// Values are offset by 1 so that 0 is not a valid value and desktop.c can detect this to set a default value (3601 / 1 H)
const int32_t cycle_animation_value[CYCLE_ANIMATION_COUNT] =
{1, -1, 31, 61, 301, 601, 901, 1801, 3601, 7201, 21601, 43201, 86401};
static void desktop_settings_scene_start_var_list_enter_callback(void* context, uint32_t index) {
DesktopSettingsApp* app = context;
view_dispatcher_send_custom_event(app->view_dispatcher, index);
@@ -73,26 +39,9 @@ static void desktop_settings_scene_start_auto_lock_delay_changed(VariableItem* i
app->settings.auto_lock_delay_ms = auto_lock_delay_value[index];
}
static void desktop_settings_scene_start_battery_view_changed(VariableItem* item) {
DesktopSettingsApp* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, battery_view_count_text[index]);
app->settings.displayBatteryPercentage = index;
}
static void desktop_settings_scene_start_cycle_animation_changed(VariableItem* item) {
DesktopSettingsApp* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, cycle_animation_text[index]);
app->settings.cycle_animation_s = cycle_animation_value[index];
}
void desktop_settings_scene_start_on_enter(void* context) {
DesktopSettingsApp* app = context;
VariableItemList* variable_item_list = app->variable_item_list;
origBattDisp_value = app->settings.displayBatteryPercentage;
VariableItem* item;
uint8_t value_index;
@@ -117,32 +66,6 @@ void desktop_settings_scene_start_on_enter(void* context) {
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, auto_lock_delay_text[value_index]);
item = variable_item_list_add(
variable_item_list,
"Battery View",
BATTERY_VIEW_COUNT,
desktop_settings_scene_start_battery_view_changed,
app);
value_index = value_index_uint32(
app->settings.displayBatteryPercentage,
displayBatteryPercentage_value,
BATTERY_VIEW_COUNT);
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, battery_view_count_text[value_index]);
item = variable_item_list_add(
variable_item_list,
"Cycle Animation",
CYCLE_ANIMATION_COUNT,
desktop_settings_scene_start_cycle_animation_changed,
app);
value_index = value_index_int32(
app->settings.cycle_animation_s, cycle_animation_value, CYCLE_ANIMATION_COUNT);
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, cycle_animation_text[value_index]);
variable_item_list_set_enter_callback(
variable_item_list, desktop_settings_scene_start_var_list_enter_callback, app);
view_dispatcher_switch_to_view(app->view_dispatcher, DesktopSettingsAppViewVarItemList);
@@ -188,8 +111,4 @@ void desktop_settings_scene_start_on_exit(void* context) {
DesktopSettingsApp* app = context;
variable_item_list_reset(app->variable_item_list);
DESKTOP_SETTINGS_SAVE(&app->settings);
if(app->settings.displayBatteryPercentage != origBattDisp_value) {
furi_hal_power_reset();
}
}
@@ -6,36 +6,9 @@
#include <gui/gui.h>
#include <furi_hal_version.h>
#include "dolphin/dolphin.h"
#include "../desktop_settings/desktop_settings_app.h"
#include "../xtreme_settings/xtreme_assets.h"
#include "math.h"
#define MOODS_TOTAL 3
#define BUTTHURT_MAX 3
static const Icon* const portrait_happy_sfw[BUTTHURT_MAX] = {
&I_passport_happy1_46x49_sfw,
&I_passport_happy2_46x49_sfw,
&I_passport_happy3_46x49_sfw};
static const Icon* const portrait_ok_sfw[BUTTHURT_MAX] = {
&I_passport_okay1_46x49_sfw,
&I_passport_okay2_46x49_sfw,
&I_passport_okay3_46x49_sfw};
static const Icon* const portrait_bad_sfw[BUTTHURT_MAX] = {
&I_passport_bad1_46x49_sfw,
&I_passport_bad2_46x49_sfw,
&I_passport_bad3_46x49_sfw};
static const Icon* const portrait_happy[BUTTHURT_MAX] = {&I_flipper};
static const Icon* const portrait_ok[BUTTHURT_MAX] = {&I_flipper};
static const Icon* const portrait_bad[BUTTHURT_MAX] = {&I_flipper};
static const Icon* const* portraits_sfw[MOODS_TOTAL] = {
portrait_happy_sfw,
portrait_ok_sfw,
portrait_bad_sfw};
static const Icon* const* portraits[MOODS_TOTAL] = {portrait_happy, portrait_ok, portrait_bad};
// static const Icon* const* portraits[MOODS_TOTAL] = {portrait_happy};
typedef struct {
FuriSemaphore* semaphore;
DolphinStats* stats;
@@ -60,35 +33,34 @@ static void render_callback(Canvas* canvas, void* _ctx) {
PassportContext* ctx = _ctx;
DolphinStats* stats = ctx->stats;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
XtremeAssets* xtreme_assets = XTREME_ASSETS();
char level_str[20];
char xp_str[12];
char mood_str[32];
uint8_t mood = 0;
const char* mood_str = NULL;
const Icon* portrait = NULL;
if(settings->sfw_mode) {
if(XTREME_SETTINGS()->sfw_mode) {
if(stats->butthurt <= 4) {
mood = 0;
snprintf(mood_str, 20, "Mood: Happy");
portrait = xtreme_assets->passport_happy;
mood_str = "Mood: Happy";
} else if(stats->butthurt <= 9) {
mood = 1;
snprintf(mood_str, 20, "Mood: Okay");
portrait = xtreme_assets->passport_okay;
mood_str = "Mood: Okay";
} else {
mood = 2;
snprintf(mood_str, 20, "Mood: Angry");
portrait = xtreme_assets->passport_angry;
mood_str = "Mood: Angry";
}
} else {
if(stats->butthurt <= 4) {
mood = 0;
snprintf(mood_str, 20, "Status: Wet");
portrait = xtreme_assets->passport_happy;
mood_str = "Status: Wet";
} else if(stats->butthurt <= 9) {
mood = 1;
snprintf(mood_str, 20, "Status: Horny");
portrait = xtreme_assets->passport_okay;
mood_str = "Status: Horny";
} else {
mood = 2;
snprintf(mood_str, 20, "Status: Desperate");
portrait = xtreme_assets->passport_angry;
mood_str = "Status: Desperate";
}
}
uint32_t xp_progress = 0;
@@ -109,20 +81,11 @@ static void render_callback(Canvas* canvas, void* _ctx) {
}
// multipass
if(settings->sfw_mode) {
canvas_draw_icon(canvas, 0, 0, &I_passport_DB_sfw);
} else {
canvas_draw_icon(canvas, 0, 0, &I_passport_DB);
}
canvas_draw_icon(canvas, 0, 0, xtreme_assets->passport_background);
// portrait
furi_assert((stats->level > 0) && (stats->level <= DOLPHIN_LEVEL_COUNT + 1));
uint16_t tmpLvl = 0;
if(settings->sfw_mode) {
canvas_draw_icon(canvas, 11, 2, portraits_sfw[mood][tmpLvl]);
} else {
canvas_draw_icon(canvas, 11, 2, portraits[mood][tmpLvl]);
}
canvas_draw_icon(canvas, 11, 2, portrait);
const char* my_name = furi_hal_version_get_name_ptr();
snprintf(level_str, 12, "Level: %hu", stats->level);
@@ -148,8 +111,6 @@ static void render_callback(Canvas* canvas, void* _ctx) {
canvas_draw_icon(canvas, 52, 51, &I_Ok_btn_9x9);
canvas_draw_str(
canvas, ctx->progress_total ? 37 : 36, 59, ctx->progress_total ? "Lvl" : "Tot");
free(settings);
}
int32_t passport_app(void* p) {
@@ -1,5 +1,5 @@
#include "../power_settings_app.h"
#include "../../desktop_settings/desktop_settings_app.h"
#include "../../xtreme_settings/xtreme_assets.h"
void power_settings_scene_power_off_dialog_callback(DialogExResult result, void* context) {
furi_assert(context);
@@ -11,26 +11,21 @@ void power_settings_scene_power_off_on_enter(void* context) {
PowerSettingsApp* app = context;
DialogEx* dialog = app->dialog;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
dialog_ex_set_header(dialog, "Turn Off Device?", 64, 2, AlignCenter, AlignTop);
if(settings->sfw_mode) {
if(XTREME_SETTINGS()->sfw_mode) {
dialog_ex_set_text(
dialog, " I will be\nwaiting for\n you here", 78, 16, AlignLeft, AlignTop);
dialog_ex_set_icon(dialog, 21, 13, &I_Cry_dolph_55x52_sfw);
} else {
dialog_ex_set_text(
dialog, " I will be\nwaiting for\n you master", 78, 16, AlignLeft, AlignTop);
dialog_ex_set_icon(dialog, 21, 13, &I_Cry_dolph_55x52);
}
dialog_ex_set_icon(dialog, 21, 13, XTREME_ASSETS()->dolphin_cry);
dialog_ex_set_left_button_text(dialog, "Back");
dialog_ex_set_right_button_text(dialog, "OFF");
dialog_ex_set_result_callback(dialog, power_settings_scene_power_off_dialog_callback);
dialog_ex_set_context(dialog, app);
view_dispatcher_switch_to_view(app->view_dispatcher, PowerSettingsAppViewDialog);
free(settings);
}
bool power_settings_scene_power_off_on_event(void* context, SceneManagerEvent event) {
@@ -1,5 +1,5 @@
#include "../storage_settings.h"
#include "../../desktop_settings/desktop_settings_app.h"
#include "../../xtreme_settings/xtreme_assets.h"
static void
storage_settings_scene_unmounted_dialog_callback(DialogExResult result, void* context) {
@@ -12,15 +12,9 @@ void storage_settings_scene_unmounted_on_enter(void* context) {
StorageSettings* app = context;
FS_Error error = storage_sd_unmount(app->fs_api);
DialogEx* dialog_ex = app->dialog_ex;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
DESKTOP_SETTINGS_LOAD(settings);
dialog_ex_set_center_button_text(dialog_ex, "OK");
if(settings->sfw_mode) {
dialog_ex_set_icon(dialog_ex, 72, 17, &I_DolphinCommon_56x48_sfw);
} else {
dialog_ex_set_icon(dialog_ex, 72, 17, &I_DolphinCommon_56x48);
}
dialog_ex_set_icon(dialog_ex, 72, 17, XTREME_ASSETS()->dolphin_common);
if(error == FSE_OK) {
dialog_ex_set_header(dialog_ex, "SD Card Unmounted", 64, 3, AlignCenter, AlignTop);
@@ -36,7 +30,6 @@ void storage_settings_scene_unmounted_on_enter(void* context) {
dialog_ex_set_result_callback(dialog_ex, storage_settings_scene_unmounted_dialog_callback);
view_dispatcher_switch_to_view(app->view_dispatcher, StorageSettingsViewDialogEx);
free(settings);
}
bool storage_settings_scene_unmounted_on_event(void* context, SceneManagerEvent event) {
@@ -0,0 +1,11 @@
App(
appid="xtreme_settings",
name="Xtreme FW",
apptype=FlipperAppType.SETTINGS,
entry_point="xtreme_settings_app",
stack_size=2 * 1024,
requires=[
"gui",
],
order=90,
)
@@ -0,0 +1,30 @@
#include "xtreme_settings_scene.h"
// Generate scene on_enter handlers array
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter,
void (*const xtreme_settings_on_enter_handlers[])(void*) = {
#include "xtreme_settings_scene_config.h"
};
#undef ADD_SCENE
// Generate scene on_event handlers array
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_event,
bool (*const xtreme_settings_on_event_handlers[])(void* context, SceneManagerEvent event) = {
#include "xtreme_settings_scene_config.h"
};
#undef ADD_SCENE
// Generate scene on_exit handlers array
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_exit,
void (*const xtreme_settings_on_exit_handlers[])(void* context) = {
#include "xtreme_settings_scene_config.h"
};
#undef ADD_SCENE
// Initialize scene handlers configuration structure
const SceneManagerHandlers xtreme_settings_scene_handlers = {
.on_enter_handlers = xtreme_settings_on_enter_handlers,
.on_event_handlers = xtreme_settings_on_event_handlers,
.on_exit_handlers = xtreme_settings_on_exit_handlers,
.scene_num = XtremeSettingsAppSceneNum,
};
@@ -0,0 +1,29 @@
#pragma once
#include <gui/scene_manager.h>
// Generate scene id and total number
#define ADD_SCENE(prefix, name, id) XtremeSettingsAppScene##id,
typedef enum {
#include "xtreme_settings_scene_config.h"
XtremeSettingsAppSceneNum,
} XtremeSettingsAppScene;
#undef ADD_SCENE
extern const SceneManagerHandlers xtreme_settings_scene_handlers;
// Generate scene on_enter handlers declaration
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*);
#include "xtreme_settings_scene_config.h"
#undef ADD_SCENE
// Generate scene on_event handlers declaration
#define ADD_SCENE(prefix, name, id) \
bool prefix##_scene_##name##_on_event(void* context, SceneManagerEvent event);
#include "xtreme_settings_scene_config.h"
#undef ADD_SCENE
// Generate scene on_exit handlers declaration
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_exit(void* context);
#include "xtreme_settings_scene_config.h"
#undef ADD_SCENE
@@ -0,0 +1 @@
ADD_SCENE(xtreme_settings, start, Start)
@@ -0,0 +1,264 @@
#include "../xtreme_settings_app.h"
#include <lib/toolbox/value_index.h>
#include <power/power_service/power.h>
#include <lib/flipper_format/flipper_format.h>
static void xtreme_settings_scene_start_base_graphics_changed(VariableItem* item) {
XtremeSettingsApp* app = variable_item_get_context(item);
bool value = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, value ? "SFW" : "NSFW");
XTREME_SETTINGS()->sfw_mode = value;
app->settings_changed = true;
app->assets_changed = true;
}
static void xtreme_settings_scene_start_asset_pack_changed(VariableItem* item) {
XtremeSettingsApp* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, index == 0 ? "OFF" : *asset_packs_get(app->asset_packs, index - 1));
strlcpy(XTREME_SETTINGS()->asset_pack, index == 0 ? "" : *asset_packs_get(app->asset_packs, index - 1), MAX_PACK_NAME_LEN);
app->settings_changed = true;
app->assets_changed = true;
}
#define CYCLE_ANIMS_COUNT 13
const char* const cycle_anims_names[CYCLE_ANIMS_COUNT] = {
"OFF",
"Manifest",
"30 S",
"1 M",
"5 M",
"10 M",
"15 M",
"30 M",
"1 H",
"2 H",
"6 H",
"12 H",
"24 H",
};
const int32_t cycle_anims_values[CYCLE_ANIMS_COUNT] =
{-1, 0, 30, 60, 300, 600, 900, 1800, 3600, 7200, 21600, 43200, 86400};
static void xtreme_settings_scene_start_cycle_anims_changed(VariableItem* item) {
XtremeSettingsApp* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, cycle_anims_names[index]);
XTREME_SETTINGS()->cycle_anims = cycle_anims_values[index];
app->settings_changed = true;
}
static void xtreme_settings_scene_start_unlock_anims_changed(VariableItem* item) {
XtremeSettingsApp* app = variable_item_get_context(item);
bool value = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, value ? "ON" : "OFF");
XTREME_SETTINGS()->unlock_anims = value;
app->settings_changed = true;
}
#define BATTERY_STYLE_COUNT 7
const char* const battery_style_names[BATTERY_STYLE_COUNT] =
{"OFF", "Bar", "%", "Inv. %", "Retro 3", "Retro 5", "Bar %"};
const uint32_t battery_style_values[BATTERY_STYLE_COUNT] = {
BatteryStyleOff,
BatteryStyleBar,
BatteryStylePercent,
BatteryStyleInvertedPercent,
BatteryStyleRetro3,
BatteryStyleRetro5,
BatteryStyleBarPercent
};
static void xtreme_settings_scene_start_battery_style_changed(VariableItem* item) {
XtremeSettingsApp* 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];
app->settings_changed = true;
}
static void xtreme_settings_scene_start_xp_level_changed(VariableItem* item) {
XtremeSettingsApp* app = variable_item_get_context(item);
app->dolphin_level = variable_item_get_current_value_index(item) + 1;
char level_str[4];
snprintf(level_str, 4, "%i", app->dolphin_level);
variable_item_set_current_value_text(item, level_str);
}
static void xtreme_settings_scene_start_subghz_extend_changed(VariableItem* item) {
bool value = variable_item_get_current_value_index(item);
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* subghz_range = flipper_format_file_alloc(storage);
if(flipper_format_file_open_existing(subghz_range, "/ext/subghz/assets/extend_range.txt") &&
flipper_format_insert_or_update_bool(subghz_range, "use_ext_range_at_own_risk", &value, 1)) {
variable_item_set_current_value_text(item, value ? "ON" : "OFF");
} else {
variable_item_set_current_value_index(item, !value);
}
flipper_format_free(subghz_range);
furi_record_close(RECORD_STORAGE);
}
static void xtreme_settings_scene_start_subghz_bypass_changed(VariableItem* item) {
bool value = variable_item_get_current_value_index(item);
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* subghz_range = flipper_format_file_alloc(storage);
if(flipper_format_file_open_existing(subghz_range, "/ext/subghz/assets/extend_range.txt") &&
flipper_format_insert_or_update_bool(subghz_range, "ignore_default_tx_region", &value, 1)) {
variable_item_set_current_value_text(item, value ? "ON" : "OFF");
} else {
variable_item_set_current_value_index(item, !value);
}
flipper_format_free(subghz_range);
furi_record_close(RECORD_STORAGE);
}
void xtreme_settings_scene_start_on_enter(void* context) {
XtremeSettingsApp* app = context;
XtremeSettings* xtreme_settings = XTREME_SETTINGS();
VariableItemList* var_item_list = app->var_item_list;
VariableItem* item;
uint8_t value_index;
Dolphin* dolphin = furi_record_open(RECORD_DOLPHIN);
DolphinStats stats = dolphin_stats(dolphin);
furi_record_close(RECORD_DOLPHIN);
app->dolphin_level = stats.level;
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* subghz_range = flipper_format_file_alloc(storage);
bool subghz_extend = false;
bool subghz_bypass = false;
if(flipper_format_file_open_existing(subghz_range, "/ext/subghz/assets/extend_range.txt")) {
flipper_format_read_bool(subghz_range, "use_ext_range_at_own_risk", &subghz_extend, 1);
flipper_format_read_bool(subghz_range, "ignore_default_tx_region", &subghz_bypass, 1);
}
flipper_format_free(subghz_range);
uint current_pack = 0;
asset_packs_init(app->asset_packs);
File* folder = storage_file_alloc(storage);
FileInfo info;
char* name = malloc(MAX_PACK_NAME_LEN);
do {
if (!storage_dir_open(folder, PACKS_DIR)) break;
while(true) {
if (!storage_dir_read(folder, &info, name, MAX_PACK_NAME_LEN)) break;
if(info.flags & FSF_DIRECTORY) {
char* copy = malloc(MAX_PACK_NAME_LEN);
strlcpy(copy, name, MAX_PACK_NAME_LEN);
asset_packs_push_back(app->asset_packs, copy);
if (strcmp(name, xtreme_settings->asset_pack) == 0) current_pack = asset_packs_size(app->asset_packs);
}
}
} while(false);
free(name);
storage_file_free(folder);
furi_record_close(RECORD_STORAGE);
item = variable_item_list_add(
var_item_list,
"Base Graphics",
2,
xtreme_settings_scene_start_base_graphics_changed,
app);
variable_item_set_current_value_index(item, xtreme_settings->sfw_mode);
variable_item_set_current_value_text(item, xtreme_settings->sfw_mode ? "SFW" : "NSFW");
item = variable_item_list_add(
var_item_list,
"Asset Pack",
asset_packs_size(app->asset_packs) + 1,
xtreme_settings_scene_start_asset_pack_changed,
app);
variable_item_set_current_value_index(item, current_pack);
variable_item_set_current_value_text(item, current_pack == 0 ? "OFF" : *asset_packs_get(app->asset_packs, current_pack - 1));
item = variable_item_list_add(
var_item_list,
"Cycle Anims",
CYCLE_ANIMS_COUNT,
xtreme_settings_scene_start_cycle_anims_changed,
app);
value_index = value_index_int32(
xtreme_settings->cycle_anims, cycle_anims_values, CYCLE_ANIMS_COUNT);
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, cycle_anims_names[value_index]);
item = variable_item_list_add(
var_item_list,
"Unlock Anims",
2,
xtreme_settings_scene_start_unlock_anims_changed,
app);
variable_item_set_current_value_index(item, xtreme_settings->unlock_anims);
variable_item_set_current_value_text(item, xtreme_settings->unlock_anims ? "ON" : "OFF");
item = variable_item_list_add(
var_item_list,
"Battery Style",
BATTERY_STYLE_COUNT,
xtreme_settings_scene_start_battery_style_changed,
app);
value_index = value_index_uint32(
xtreme_settings->battery_style, battery_style_values, BATTERY_STYLE_COUNT);
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, battery_style_names[value_index]);
char level_str[4];
snprintf(level_str, 4, "%i", app->dolphin_level);
item = variable_item_list_add(
var_item_list,
"XP Level",
DOLPHIN_LEVEL_COUNT + 1,
xtreme_settings_scene_start_xp_level_changed,
app);
variable_item_set_current_value_index(item, app->dolphin_level - 1);
variable_item_set_current_value_text(item, level_str);
item = variable_item_list_add(
var_item_list,
"SubGHz Extend",
2,
xtreme_settings_scene_start_subghz_extend_changed,
app);
variable_item_set_current_value_index(item, subghz_extend);
variable_item_set_current_value_text(item, subghz_extend ? "ON" : "OFF");
item = variable_item_list_add(
var_item_list,
"SubGHz Bypass",
2,
xtreme_settings_scene_start_subghz_bypass_changed,
app);
variable_item_set_current_value_index(item, subghz_bypass);
variable_item_set_current_value_text(item, subghz_bypass ? "ON" : "OFF");
view_dispatcher_switch_to_view(app->view_dispatcher, XtremeSettingsAppViewVarItemList);
}
bool xtreme_settings_scene_start_on_event(void* context, SceneManagerEvent event) {
UNUSED(context);
UNUSED(event);
bool consumed = false;
return consumed;
}
void xtreme_settings_scene_start_on_exit(void* context) {
XtremeSettingsApp* app = context;
Dolphin* dolphin = furi_record_open(RECORD_DOLPHIN);
DolphinStats stats = dolphin_stats(dolphin);
if (app->dolphin_level != stats.level) {
int xp = app->dolphin_level > 1 ? dolphin_get_levels()[app->dolphin_level - 2] : 0;
dolphin->state->data.icounter = xp + 1;
dolphin->state->dirty = true;
dolphin_state_save(dolphin->state);
}
furi_record_close(RECORD_DOLPHIN);
asset_packs_it_t it;
for (asset_packs_it(it, app->asset_packs); !asset_packs_end_p(it); asset_packs_next(it)) {
free(*asset_packs_cref(it));
}
asset_packs_clear(app->asset_packs);
variable_item_list_reset(app->var_item_list);
}
@@ -0,0 +1,126 @@
#include "xtreme_assets.h"
#include "assets_icons.h"
#include <core/dangerous_defines.h>
XtremeAssets* xtreme_assets = NULL;
XtremeAssets* XTREME_ASSETS() {
if (xtreme_assets == NULL) {
XTREME_ASSETS_LOAD();
}
return xtreme_assets;
}
void XTREME_ASSETS_LOAD() {
if (xtreme_assets != NULL) return;
xtreme_assets = malloc(sizeof(XtremeAssets));
XtremeSettings* xtreme_settings = XTREME_SETTINGS();
if (xtreme_settings->sfw_mode) {
xtreme_assets->authenticate = &I_Auth_62x31_sfw;
xtreme_assets->bt_pairing = &I_BLE_Pairing_128x64_sfw;
xtreme_assets->connect_me = &I_Connect_me_62x31_sfw;
xtreme_assets->connected = &I_Connected_62x31_sfw;
xtreme_assets->dolphin_common = &I_DolphinCommon_56x48_sfw;
xtreme_assets->dolphin_cry = &I_Cry_dolph_55x52_sfw;
xtreme_assets->dolphin_mafia = &I_DolphinMafia_115x62_sfw;
xtreme_assets->dolphin_nice = &I_DolphinNice_96x59_sfw;
xtreme_assets->dolphin_wait = &I_DolphinWait_61x59_sfw;
xtreme_assets->error = &I_Error_62x31_sfw;
xtreme_assets->ibutton_success = &I_iButtonDolphinVerySuccess_108x52_sfw;
xtreme_assets->ir_success = &I_DolphinReadingSuccess_59x63_sfw;
xtreme_assets->nfc_emulation = &I_NFC_dolphin_emulation_47x61_sfw;
xtreme_assets->rfid_receive = &I_RFIDDolphinReceive_97x61_sfw;
xtreme_assets->rfid_send = &I_RFIDDolphinSend_97x61_sfw;
xtreme_assets->rfid_success = &I_RFIDDolphinSuccess_108x57_sfw;
xtreme_assets->subghz_scanning = &I_Scanning_123x52_sfw;
xtreme_assets->passport_angry = &I_passport_bad1_46x49_sfw;
xtreme_assets->passport_background = &I_passport_DB_sfw;
xtreme_assets->passport_happy = &I_passport_happy1_46x49_sfw;
xtreme_assets->passport_okay = &I_passport_okay1_46x49_sfw;
} else {
xtreme_assets->authenticate = &I_Auth_62x31;
xtreme_assets->bt_pairing = &I_BLE_Pairing_128x64;
xtreme_assets->connect_me = &I_Connect_me_62x31;
xtreme_assets->connected = &I_Connected_62x31;
xtreme_assets->dolphin_common = &I_DolphinCommon_56x48;
xtreme_assets->dolphin_cry = &I_Cry_dolph_55x52;
xtreme_assets->dolphin_mafia = &I_DolphinMafia_115x62;
xtreme_assets->dolphin_nice = &I_DolphinNice_96x59;
xtreme_assets->dolphin_wait = &I_DolphinWait_61x59;
xtreme_assets->error = &I_Error_62x31;
xtreme_assets->ibutton_success = &I_iButtonDolphinVerySuccess_108x52;
xtreme_assets->ir_success = &I_DolphinReadingSuccess_59x63;
xtreme_assets->nfc_emulation = &I_NFC_dolphin_emulation_47x61;
xtreme_assets->rfid_receive = &I_RFIDDolphinReceive_97x61;
xtreme_assets->rfid_send = &I_RFIDDolphinSend_97x61;
xtreme_assets->rfid_success = &I_RFIDDolphinSuccess_108x57;
xtreme_assets->subghz_scanning = &I_Scanning_123x52;
xtreme_assets->passport_angry = &I_flipper;
xtreme_assets->passport_background = &I_passport_DB;
xtreme_assets->passport_happy = &I_flipper;
xtreme_assets->passport_okay = &I_flipper;
}
if (xtreme_settings->asset_pack[0] == '\0') return;
FileInfo info;
FuriString* path = furi_string_alloc();
const char* pack = xtreme_settings->asset_pack;
furi_string_printf(path, PACKS_DIR "/%s", pack);
Storage* storage = furi_record_open(RECORD_STORAGE);
if (storage_common_stat(storage, furi_string_get_cstr(path), &info) == FSE_OK && info.flags & FSF_DIRECTORY) {
File* file = storage_file_alloc(storage);
swap_bmx_icon(&xtreme_assets->authenticate, pack, "Icons/authenticate.bmx", path, file);
swap_bmx_icon(&xtreme_assets->bt_pairing, pack, "Icons/bt_pairing.bmx", path, file);
swap_bmx_icon(&xtreme_assets->connect_me, pack, "Icons/connect_me.bmx", path, file);
swap_bmx_icon(&xtreme_assets->connected, pack, "Icons/connected.bmx", path, file);
swap_bmx_icon(&xtreme_assets->dolphin_common, pack, "Icons/dolphin_common.bmx", path, file);
swap_bmx_icon(&xtreme_assets->dolphin_cry, pack, "Icons/dolphin_cry.bmx", path, file);
swap_bmx_icon(&xtreme_assets->dolphin_mafia, pack, "Icons/dolphin_mafia.bmx", path, file);
swap_bmx_icon(&xtreme_assets->dolphin_nice, pack, "Icons/dolphin_nice.bmx", path, file);
swap_bmx_icon(&xtreme_assets->dolphin_wait, pack, "Icons/dolphin_wait.bmx", path, file);
swap_bmx_icon(&xtreme_assets->error, pack, "Icons/error.bmx", path, file);
swap_bmx_icon(&xtreme_assets->ibutton_success, pack, "Icons/ibutton_success.bmx", path, file);
swap_bmx_icon(&xtreme_assets->ir_success, pack, "Icons/ir_success.bmx", path, file);
swap_bmx_icon(&xtreme_assets->nfc_emulation, pack, "Icons/nfc_emulation.bmx", path, file);
swap_bmx_icon(&xtreme_assets->rfid_receive, pack, "Icons/rfid_receive.bmx", path, file);
swap_bmx_icon(&xtreme_assets->rfid_send, pack, "Icons/rfid_send.bmx", path, file);
swap_bmx_icon(&xtreme_assets->rfid_success, pack, "Icons/rfid_success.bmx", path, file);
swap_bmx_icon(&xtreme_assets->subghz_scanning, pack, "Icons/subghz_scanning.bmx", path, file);
swap_bmx_icon(&xtreme_assets->passport_angry, pack, "Passport/angry.bmx", path, file);
swap_bmx_icon(&xtreme_assets->passport_background, pack, "Passport/background.bmx", path, file);
swap_bmx_icon(&xtreme_assets->passport_happy, pack, "Passport/happy.bmx", path, file);
swap_bmx_icon(&xtreme_assets->passport_okay, pack, "Passport/okay.bmx", path, file);
storage_file_free(file);
}
furi_record_close(RECORD_STORAGE);
furi_string_free(path);
}
void swap_bmx_icon(const Icon** replace, const char* pack, const char* name, FuriString* path, File* file) {
furi_string_printf(path, PACKS_DIR "/%s/%s", pack, name);
if (storage_file_open(file, furi_string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) {
uint64_t size = storage_file_size(file) - 8;
int32_t width, height;
storage_file_read(file, &width, 4);
storage_file_read(file, &height, 4);
Icon* icon = malloc(sizeof(Icon));
FURI_CONST_ASSIGN(icon->frame_count, 1);
FURI_CONST_ASSIGN(icon->frame_rate, 0);
FURI_CONST_ASSIGN(icon->width, width);
FURI_CONST_ASSIGN(icon->height, height);
icon->frames = malloc(sizeof(const uint8_t*));
FURI_CONST_ASSIGN_PTR(icon->frames[0], malloc(size));
storage_file_read(file, (void*)icon->frames[0], size);
*replace = icon;
storage_file_close(file);
}
}
@@ -0,0 +1,40 @@
#pragma once
#include <gui/icon_i.h>
#include "xtreme_settings.h"
#include <toolbox/path.h>
#define PACKS_DIR EXT_PATH("dolphin_custom")
typedef struct {
const Icon* authenticate;
const Icon* bt_pairing;
const Icon* connect_me;
const Icon* connected;
const Icon* dolphin_common;
const Icon* dolphin_cry;
const Icon* dolphin_mafia;
const Icon* dolphin_nice;
const Icon* dolphin_wait;
const Icon* error;
const Icon* ibutton_success;
const Icon* ir_success;
const Icon* nfc_emulation;
const Icon* rfid_receive;
const Icon* rfid_send;
const Icon* rfid_success;
const Icon* subghz_scanning;
const Icon* passport_angry;
const Icon* passport_background;
const Icon* passport_happy;
const Icon* passport_okay;
} XtremeAssets;
XtremeAssets* XTREME_ASSETS();
void XTREME_ASSETS_LOAD();
void swap_bmx_icon(const Icon** replace, const char* base, const char* name, FuriString* path, File* file);
void free_bmx_icon(Icon* icon);
@@ -0,0 +1,32 @@
#include "xtreme_settings.h"
XtremeSettings* xtreme_settings = NULL;
XtremeSettings* XTREME_SETTINGS() {
if (xtreme_settings == NULL) {
XTREME_SETTINGS_LOAD();
}
return xtreme_settings;
}
bool XTREME_SETTINGS_LOAD() {
if (xtreme_settings == NULL) {
xtreme_settings = malloc(sizeof(XtremeSettings));
bool loaded = saved_struct_load(
XTREME_SETTINGS_PATH, xtreme_settings, sizeof(XtremeSettings), XTREME_SETTINGS_MAGIC, XTREME_SETTINGS_VERSION);
if(!loaded) {
memset(xtreme_settings, 0, sizeof(XtremeSettings));
loaded = XTREME_SETTINGS_SAVE();
}
return loaded;
}
return true;
}
bool XTREME_SETTINGS_SAVE() {
if (xtreme_settings == NULL) {
XTREME_SETTINGS_LOAD();
}
return saved_struct_save(
XTREME_SETTINGS_PATH, xtreme_settings, sizeof(XtremeSettings), XTREME_SETTINGS_MAGIC, XTREME_SETTINGS_VERSION);
}
@@ -0,0 +1,30 @@
#pragma once
#include "xtreme_settings_filename.h"
#include <furi_hal.h>
#include <stdint.h>
#include <stdbool.h>
#include <toolbox/saved_struct.h>
#include <storage/storage.h>
#include <power/power_service/power.h>
#define MAX_PACK_NAME_LEN 32
#define XTREME_SETTINGS_VERSION (1)
#define XTREME_SETTINGS_PATH INT_PATH(XTREME_SETTINGS_FILE_NAME)
#define XTREME_SETTINGS_MAGIC (0x69)
typedef struct {
int32_t cycle_anims;
bool unlock_anims;
bool sfw_mode;
char asset_pack[MAX_PACK_NAME_LEN];
BatteryStyle battery_style;
} XtremeSettings;
XtremeSettings* XTREME_SETTINGS();
bool XTREME_SETTINGS_LOAD();
bool XTREME_SETTINGS_SAVE();
@@ -0,0 +1,92 @@
#include "xtreme_settings_app.h"
static bool xtreme_settings_custom_event_callback(void* context, uint32_t event) {
furi_assert(context);
XtremeSettingsApp* app = context;
return scene_manager_handle_custom_event(app->scene_manager, event);
}
void xtreme_settings_reboot(void* context) {
UNUSED(context);
power_reboot(PowerBootModeNormal);
}
static bool xtreme_settings_back_event_callback(void* context) {
furi_assert(context);
XtremeSettingsApp* app = context;
if (app->settings_changed) {
XTREME_SETTINGS_SAVE();
if (app->assets_changed) {
popup_set_header(app->popup, "Rebooting...", 64, 24, AlignCenter, AlignCenter);
popup_set_text(app->popup, "Swapping assets...", 64, 42, AlignCenter, AlignCenter);
popup_set_callback(app->popup, xtreme_settings_reboot);
popup_set_context(app->popup, app);
popup_set_timeout(app->popup, 1000);
popup_enable_timeout(app->popup);
view_dispatcher_switch_to_view(app->view_dispatcher, XtremeSettingsAppViewPopup);
return true;
}
}
return scene_manager_handle_back_event(app->scene_manager);
}
XtremeSettingsApp* xtreme_settings_app_alloc() {
XtremeSettingsApp* app = malloc(sizeof(XtremeSettingsApp));
app->gui = furi_record_open(RECORD_GUI);
// View Dispatcher and Scene Manager
app->view_dispatcher = view_dispatcher_alloc();
app->scene_manager = scene_manager_alloc(&xtreme_settings_scene_handlers, app);
view_dispatcher_enable_queue(app->view_dispatcher);
view_dispatcher_set_event_callback_context(app->view_dispatcher, app);
view_dispatcher_set_custom_event_callback(
app->view_dispatcher, xtreme_settings_custom_event_callback);
view_dispatcher_set_navigation_event_callback(
app->view_dispatcher, xtreme_settings_back_event_callback);
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
// Gui Modules
app->var_item_list = variable_item_list_alloc();
view_dispatcher_add_view(
app->view_dispatcher,
XtremeSettingsAppViewVarItemList,
variable_item_list_get_view(app->var_item_list));
app->popup = popup_alloc();
view_dispatcher_add_view(
app->view_dispatcher,
XtremeSettingsAppViewPopup,
popup_get_view(app->popup));
// Set first scene
scene_manager_next_scene(app->scene_manager, XtremeSettingsAppSceneStart);
return app;
}
void xtreme_settings_app_free(XtremeSettingsApp* app) {
furi_assert(app);
// Gui modules
view_dispatcher_remove_view(app->view_dispatcher, XtremeSettingsAppViewVarItemList);
variable_item_list_free(app->var_item_list);
view_dispatcher_remove_view(app->view_dispatcher, XtremeSettingsAppViewPopup);
popup_free(app->popup);
// View Dispatcher and Scene Manager
view_dispatcher_free(app->view_dispatcher);
scene_manager_free(app->scene_manager);
// Records
furi_record_close(RECORD_GUI);
free(app);
}
extern int32_t xtreme_settings_app(void* p) {
UNUSED(p);
XtremeSettingsApp* app = xtreme_settings_app_alloc();
view_dispatcher_run(app->view_dispatcher);
xtreme_settings_app_free(app);
return 0;
}
@@ -0,0 +1,36 @@
#pragma once
#include <furi.h>
#include <gui/gui.h>
#include <gui/view.h>
#include <gui/view_dispatcher.h>
#include <gui/scene_manager.h>
#include <assets_icons.h>
#include <gui/modules/variable_item_list.h>
#include <gui/modules/popup.h>
#include "xtreme_settings.h"
#include "xtreme_assets.h"
#include "scenes/xtreme_settings_scene.h"
#include "dolphin/helpers/dolphin_state.h"
#include "dolphin/dolphin.h"
#include "dolphin/dolphin_i.h"
#include <m-array.h>
ARRAY_DEF(asset_packs, char*)
typedef struct {
Gui* gui;
SceneManager* scene_manager;
ViewDispatcher* view_dispatcher;
VariableItemList* var_item_list;
Popup* popup;
int dolphin_level;
bool settings_changed;
bool assets_changed;
asset_packs_t asset_packs;
} XtremeSettingsApp;
typedef enum {
XtremeSettingsAppViewVarItemList,
XtremeSettingsAppViewPopup,
} XtremeSettingsAppView;
@@ -0,0 +1,3 @@
#pragma once
#define XTREME_SETTINGS_FILE_NAME ".xtreme.settings"
Binary file not shown.

After

Width:  |  Height:  |  Size: 834 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

@@ -0,0 +1,14 @@
Filetype: Flipper Animation
Version: 1
Width: 128
Height: 64
Passive frames: 3
Active frames: 0
Frames order: 0 1 2
Active cycles: 0
Frame rate: 2
Duration: 3600
Active cooldown: 0
Bubble slots: 0
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

@@ -0,0 +1,14 @@
Filetype: Flipper Animation
Version: 1
Width: 128
Height: 64
Passive frames: 17
Active frames: 0
Frames order: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Active cycles: 0
Frame rate: 4
Duration: 3600
Active cooldown: 0
Bubble slots: 0
Binary file not shown.

After

Width:  |  Height:  |  Size: 847 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Some files were not shown because too many files have changed in this diff Show More