mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-23 05:24:46 -07:00
IR: Easy Learn (#350)
* initial working commit * update names + format * add skip functionality * misc tweaks * change back gpio label * remove gpio setting changes * misc fixes * bug fixes and polish * add subtitle button and reorganize order * update ir settings to version 2 * ir settings v1 migration support * fixes * format * misc fixes * Simplify and standardize settings handling * Auto-calculate easy_mode_button_count * Case insensitive match existing remote buttons * Display button name more prominently * Sort submenu indexes and handling * Fine to keep text highlighted * Some formatting for less conflicts * Not sure how these got lost kek * Update changelog --------- Co-authored-by: Willy-JL <49810075+Willy-JL@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include "infrared_app_i.h"
|
||||
|
||||
#include "infrared_settings.h"
|
||||
|
||||
#include <furi_hal_power.h>
|
||||
|
||||
#include <string.h>
|
||||
@@ -153,6 +155,9 @@ static InfraredApp* infrared_alloc(void) {
|
||||
InfraredAppState* app_state = &infrared->app_state;
|
||||
app_state->is_learning_new_remote = false;
|
||||
app_state->is_debug_enabled = furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug);
|
||||
app_state->is_transmitting = false;
|
||||
app_state->is_otg_enabled = false;
|
||||
app_state->is_easy_mode = false;
|
||||
app_state->edit_target = InfraredEditTargetNone;
|
||||
app_state->edit_mode = InfraredEditModeNone;
|
||||
app_state->current_button_index = InfraredButtonIndexNone;
|
||||
@@ -503,12 +508,7 @@ void infrared_enable_otg(InfraredApp* infrared, bool enable) {
|
||||
static void infrared_load_settings(InfraredApp* infrared) {
|
||||
InfraredSettings settings = {0};
|
||||
|
||||
if(!saved_struct_load(
|
||||
INFRARED_SETTINGS_PATH,
|
||||
&settings,
|
||||
sizeof(InfraredSettings),
|
||||
INFRARED_SETTINGS_MAGIC,
|
||||
INFRARED_SETTINGS_VERSION)) {
|
||||
if(!infrared_settings_load(&settings)) {
|
||||
FURI_LOG_D(TAG, "Failed to load settings, using defaults");
|
||||
// infrared_save_settings(infrared);
|
||||
}
|
||||
@@ -517,20 +517,17 @@ static void infrared_load_settings(InfraredApp* infrared) {
|
||||
if(settings.tx_pin < FuriHalInfraredTxPinMax) {
|
||||
infrared_enable_otg(infrared, settings.otg_enabled);
|
||||
}
|
||||
infrared->app_state.is_easy_mode = settings.easy_mode;
|
||||
}
|
||||
|
||||
void infrared_save_settings(InfraredApp* infrared) {
|
||||
InfraredSettings settings = {
|
||||
.tx_pin = infrared->app_state.tx_pin,
|
||||
.otg_enabled = infrared->app_state.is_otg_enabled,
|
||||
.easy_mode = infrared->app_state.is_easy_mode,
|
||||
};
|
||||
|
||||
if(!saved_struct_save(
|
||||
INFRARED_SETTINGS_PATH,
|
||||
&settings,
|
||||
sizeof(InfraredSettings),
|
||||
INFRARED_SETTINGS_MAGIC,
|
||||
INFRARED_SETTINGS_VERSION)) {
|
||||
if(!infrared_settings_save(&settings)) {
|
||||
FURI_LOG_E(TAG, "Failed to save settings");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user