diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fec85590..ed4cf658a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ ### Breaking Changes: -- Desktop: Settings restructured due to LFS removal +- Desktop: Settings restructured due to removal of LFS / LittleFS Internal Storage - You might need to reconfigure Desktop Settings (PIN code, auto lock, show clock) - Desktop Keybinds should transfer correctly automatically @@ -7,7 +7,7 @@ - Settings: Show free flash amount in internal storage info (by @Willy-JL) - Services: - OFW: On SD insert load BT, Desktop, Dolphin, Expansion, Notification, Region files (by @gsurkov) - - On SD insert also load Momentum settings, Asset Packs, FindMy Flipper, NameSpoof, SubGHz options, and migrate files (by @Willy-JL) + - On SD insert also load Momentum Settings, Asset Packs, FindMy Flipper, NameSpoof, SubGHz options, and migrate files (by @Willy-JL) - Furi: Re-enabled `FURI_TRACE` since LFS removal frees DFU, will get better crash messages with source code path (by @Willy-JL) - OFW: Sub-GHz: Add Dickert MAHS garage door protocol (by @OevreFlataeker) - OFW: RFID: Add GProxII support (by @BarTenderNZ) @@ -27,10 +27,11 @@ - Sub-GHz Bruteforcer: Fix one/two byte text (by @Willy-JL) - Various app fixes for `-Wundef` option (by @Willy-JL) - BadKB: Lower BLE conn interval like base HID profile (by @Willy-JL) -- Desktop: Refactor Keybinds, no more 63 character limit, keybinds only loaded when pressed to save RAM (by @Willy-JL) +- Desktop: Refactor Keybinds, no more 63 character limit, only load when activated to save RAM (by @Willy-JL) +- MNTM Settings: SubGHz frequency add screen uses new NumberInput view (by @Willy-JL) - Settings: Statusbar Clock and Left Handed options show in normal Settings app like OFW (by @Willy-JL) - Services: - - Big cleanup of services and settings handling, refactor some old code (by @Willy-JL) + - Big cleanup of all services and settings handling, refactor lots old code (by @Willy-JL) - Update all settings paths to use equivalents like OFW or UL for better compatibility (by @Willy-JL) - OFW: NFC: Refactor detected protocols list (by @Astrrra) - Furi: diff --git a/applications/main/momentum_app/momentum_app.c b/applications/main/momentum_app/momentum_app.c index b54ecc863..c82f6ac46 100644 --- a/applications/main/momentum_app/momentum_app.c +++ b/applications/main/momentum_app/momentum_app.c @@ -223,6 +223,12 @@ MomentumApp* momentum_app_alloc() { view_dispatcher_add_view( app->view_dispatcher, MomentumAppViewByteInput, byte_input_get_view(app->byte_input)); + app->number_input = number_input_alloc(); + view_dispatcher_add_view( + app->view_dispatcher, + MomentumAppViewNumberInput, + number_input_get_view(app->number_input)); + app->popup = popup_alloc(); view_dispatcher_add_view( app->view_dispatcher, MomentumAppViewPopup, popup_get_view(app->popup)); @@ -421,6 +427,8 @@ void momentum_app_free(MomentumApp* app) { text_input_free(app->text_input); view_dispatcher_remove_view(app->view_dispatcher, MomentumAppViewByteInput); byte_input_free(app->byte_input); + view_dispatcher_remove_view(app->view_dispatcher, MomentumAppViewNumberInput); + number_input_free(app->number_input); view_dispatcher_remove_view(app->view_dispatcher, MomentumAppViewPopup); popup_free(app->popup); view_dispatcher_remove_view(app->view_dispatcher, MomentumAppViewDialogEx); diff --git a/applications/main/momentum_app/momentum_app.h b/applications/main/momentum_app/momentum_app.h index 53a96b4ad..00f9f5e1b 100644 --- a/applications/main/momentum_app/momentum_app.h +++ b/applications/main/momentum_app/momentum_app.h @@ -1,39 +1,44 @@ #pragma once +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include #include -#include -#include -#include -#include -#include -#include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include -#include #include -#include #include -#include -#include -#include -#include -#include -#include -#include #include +#include "scenes/momentum_app_scene.h" + ARRAY_DEF(CharList, char*) typedef struct { @@ -44,10 +49,12 @@ typedef struct { NotificationApp* notification; SceneManager* scene_manager; ViewDispatcher* view_dispatcher; + VariableItemList* var_item_list; Submenu* submenu; TextInput* text_input; ByteInput* byte_input; + NumberInput* number_input; Popup* popup; DialogEx* dialog_ex; @@ -62,7 +69,6 @@ typedef struct { uint8_t subghz_static_index; FrequencyList_t subghz_hopper_freqs; uint8_t subghz_hopper_index; - char subghz_freq_buffer[7]; bool subghz_extend; bool subghz_bypass; RgbColor lcd_color; @@ -92,6 +98,7 @@ typedef enum { MomentumAppViewSubmenu, MomentumAppViewTextInput, MomentumAppViewByteInput, + MomentumAppViewNumberInput, MomentumAppViewPopup, MomentumAppViewDialogEx, } MomentumAppView; diff --git a/applications/main/momentum_app/scenes/momentum_app_scene_protocols_freqs_add.c b/applications/main/momentum_app/scenes/momentum_app_scene_protocols_freqs_add.c index 3481cb4fc..b44419256 100644 --- a/applications/main/momentum_app/scenes/momentum_app_scene_protocols_freqs_add.c +++ b/applications/main/momentum_app/scenes/momentum_app_scene_protocols_freqs_add.c @@ -5,12 +5,12 @@ enum TextInputResult { TextInputResultError, }; -static void momentum_app_scene_protocols_freqs_add_text_input_callback(void* context) { +static void + momentum_app_scene_protocols_freqs_add_number_input_callback(void* context, int32_t number) { MomentumApp* app = context; - char* end; - uint32_t value = strtol(app->subghz_freq_buffer, &end, 0) * 1000; - if(*end || !furi_hal_subghz_is_frequency_valid(value)) { + uint32_t value = number * 1000; + if(!furi_hal_subghz_is_frequency_valid(value)) { view_dispatcher_send_custom_event(app->view_dispatcher, TextInputResultError); return; } @@ -27,26 +27,24 @@ static void momentum_app_scene_protocols_freqs_add_text_input_callback(void* con void momentum_app_scene_protocols_freqs_add_on_enter(void* context) { MomentumApp* app = context; - TextInput* text_input = app->text_input; + NumberInput* number_input = app->number_input; - text_input_set_header_text(text_input, "Ex: 123456 for 123.456 MHz"); + number_input_set_header_text(number_input, "Use kHz values, like 433920"); - strlcpy(app->subghz_freq_buffer, "", sizeof(app->subghz_freq_buffer)); - - text_input_set_result_callback( - text_input, - momentum_app_scene_protocols_freqs_add_text_input_callback, + number_input_set_result_callback( + number_input, + momentum_app_scene_protocols_freqs_add_number_input_callback, app, - app->subghz_freq_buffer, - sizeof(app->subghz_freq_buffer), - true); + 0, + 0, // TODO: support leaving default value empty, change min to 100000 + 999999); - view_dispatcher_switch_to_view(app->view_dispatcher, MomentumAppViewTextInput); + view_dispatcher_switch_to_view(app->view_dispatcher, MomentumAppViewNumberInput); } void callback_return(void* context) { MomentumApp* app = context; - scene_manager_previous_scene(app->scene_manager); + view_dispatcher_switch_to_view(app->view_dispatcher, MomentumAppViewNumberInput); } bool momentum_app_scene_protocols_freqs_add_on_event(void* context, SceneManagerEvent event) { @@ -60,9 +58,15 @@ bool momentum_app_scene_protocols_freqs_add_on_event(void* context, SceneManager scene_manager_previous_scene(app->scene_manager); break; case TextInputResultError: - popup_set_header(app->popup, "Invalid value!", 64, 26, AlignCenter, AlignCenter); + popup_set_header(app->popup, "Invalid frequency!", 64, 18, AlignCenter, AlignCenter); popup_set_text( - app->popup, "Frequency was not added...", 64, 40, AlignCenter, AlignCenter); + app->popup, + "Must be 281-361,\n" + "378-481, 749-962 MHz", + 64, + 40, + AlignCenter, + AlignCenter); popup_set_callback(app->popup, callback_return); popup_set_context(app->popup, app); popup_set_timeout(app->popup, 1000);