IR: Remember OTG state (#3549)

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
WillyJL 2024-04-01 14:42:47 +01:00 committed by GitHub
parent 002e5cd9de
commit 9f71be6fef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -13,11 +13,12 @@
#define INFRARED_TASK_STACK_SIZE (2048UL) #define INFRARED_TASK_STACK_SIZE (2048UL)
#define INFRARED_SETTINGS_PATH INT_PATH(".infrared.settings") #define INFRARED_SETTINGS_PATH INT_PATH(".infrared.settings")
#define INFRARED_SETTINGS_VERSION (0) #define INFRARED_SETTINGS_VERSION (1)
#define INFRARED_SETTINGS_MAGIC (0x1F) #define INFRARED_SETTINGS_MAGIC (0x1F)
typedef struct { typedef struct {
uint8_t tx_pin; FuriHalInfraredTxPin tx_pin;
bool otg_enabled;
} InfraredSettings; } InfraredSettings;
static const NotificationSequence* static const NotificationSequence*
@ -488,11 +489,15 @@ static void infrared_load_settings(InfraredApp* infrared) {
} }
infrared_set_tx_pin(infrared, settings.tx_pin); infrared_set_tx_pin(infrared, settings.tx_pin);
if(settings.tx_pin < FuriHalInfraredTxPinMax) {
infrared_enable_otg(infrared, settings.otg_enabled);
}
} }
void infrared_save_settings(InfraredApp* infrared) { void infrared_save_settings(InfraredApp* infrared) {
InfraredSettings settings = { InfraredSettings settings = {
.tx_pin = infrared->app_state.tx_pin, .tx_pin = infrared->app_state.tx_pin,
.otg_enabled = infrared->app_state.is_otg_enabled,
}; };
if(!saved_struct_save( if(!saved_struct_save(