mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-23 05:24:46 -07:00
Merge remote-tracking branch 'ofw/dev' into mntm-dev
This commit is contained in:
@@ -288,7 +288,7 @@ static void infrared_free(InfraredApp* infrared) {
|
||||
free(infrared);
|
||||
}
|
||||
|
||||
bool infrared_add_remote_with_button(
|
||||
InfraredErrorCode infrared_add_remote_with_button(
|
||||
const InfraredApp* infrared,
|
||||
const char* button_name,
|
||||
const InfraredSignal* signal) {
|
||||
@@ -301,21 +301,23 @@ bool infrared_add_remote_with_button(
|
||||
furi_string_cat_printf(
|
||||
new_path, "/%s%s", furi_string_get_cstr(new_name), INFRARED_APP_EXTENSION);
|
||||
|
||||
bool success = false;
|
||||
InfraredErrorCode error = InfraredErrorCodeNone;
|
||||
|
||||
do {
|
||||
if(!infrared_remote_create(remote, furi_string_get_cstr(new_path))) break;
|
||||
if(!infrared_remote_append_signal(remote, signal, button_name)) break;
|
||||
success = true;
|
||||
error = infrared_remote_create(remote, furi_string_get_cstr(new_path));
|
||||
if(INFRARED_ERROR_PRESENT(error)) break;
|
||||
|
||||
error = infrared_remote_append_signal(remote, signal, button_name);
|
||||
} while(false);
|
||||
|
||||
furi_string_free(new_name);
|
||||
furi_string_free(new_path);
|
||||
|
||||
return success;
|
||||
return error;
|
||||
}
|
||||
|
||||
bool infrared_rename_current_remote(const InfraredApp* infrared, const char* new_name) {
|
||||
InfraredErrorCode
|
||||
infrared_rename_current_remote(const InfraredApp* infrared, const char* new_name) {
|
||||
InfraredRemote* remote = infrared->remote;
|
||||
const char* old_path = infrared_remote_get_path(remote);
|
||||
|
||||
@@ -335,12 +337,13 @@ bool infrared_rename_current_remote(const InfraredApp* infrared, const char* new
|
||||
path_append(new_path_fstr, furi_string_get_cstr(new_name_fstr));
|
||||
furi_string_cat(new_path_fstr, INFRARED_APP_EXTENSION);
|
||||
|
||||
const bool success = infrared_remote_rename(remote, furi_string_get_cstr(new_path_fstr));
|
||||
const InfraredErrorCode error =
|
||||
infrared_remote_rename(remote, furi_string_get_cstr(new_path_fstr));
|
||||
|
||||
furi_string_free(new_name_fstr);
|
||||
furi_string_free(new_path_fstr);
|
||||
|
||||
return success;
|
||||
return error;
|
||||
}
|
||||
|
||||
void infrared_tx_start(InfraredApp* infrared) {
|
||||
@@ -373,15 +376,16 @@ void infrared_tx_start(InfraredApp* infrared) {
|
||||
infrared->app_state.is_transmitting = true;
|
||||
}
|
||||
|
||||
bool infrared_tx_start_button_index(InfraredApp* infrared, size_t button_index) {
|
||||
InfraredErrorCode infrared_tx_start_button_index(InfraredApp* infrared, size_t button_index) {
|
||||
furi_assert(button_index < infrared_remote_get_signal_count(infrared->remote));
|
||||
|
||||
bool result =
|
||||
InfraredErrorCode error =
|
||||
infrared_remote_load_signal(infrared->remote, infrared->current_signal, button_index);
|
||||
if(result) {
|
||||
|
||||
if(!INFRARED_ERROR_PRESENT(error)) {
|
||||
infrared_tx_start(infrared);
|
||||
}
|
||||
return result;
|
||||
return error;
|
||||
}
|
||||
|
||||
void infrared_tx_stop(InfraredApp* infrared) {
|
||||
@@ -404,7 +408,7 @@ void infrared_blocking_task_start(InfraredApp* infrared, FuriThreadCallback call
|
||||
furi_thread_start(infrared->task_thread);
|
||||
}
|
||||
|
||||
bool infrared_blocking_task_finalize(InfraredApp* infrared) {
|
||||
InfraredErrorCode infrared_blocking_task_finalize(InfraredApp* infrared) {
|
||||
furi_thread_join(infrared->task_thread);
|
||||
return furi_thread_get_return_code(infrared->task_thread);
|
||||
}
|
||||
@@ -554,10 +558,18 @@ int32_t infrared_app(void* p) {
|
||||
is_rpc_mode = true;
|
||||
} else {
|
||||
const char* file_path = (const char*)p;
|
||||
is_remote_loaded = infrared_remote_load(infrared->remote, file_path);
|
||||
InfraredErrorCode error = infrared_remote_load(infrared->remote, file_path);
|
||||
|
||||
if(!is_remote_loaded) {
|
||||
infrared_show_error_message(infrared, "Failed to load\n\"%s\"", file_path);
|
||||
if(!INFRARED_ERROR_PRESENT(error)) {
|
||||
is_remote_loaded = true;
|
||||
} else {
|
||||
is_remote_loaded = false;
|
||||
bool wrong_file_type = INFRARED_ERROR_CHECK(error, InfraredErrorCodeWrongFileType);
|
||||
const char* format = wrong_file_type ?
|
||||
"Library file\n\"%s\" can't be openned as a remote" :
|
||||
"Failed to load\n\"%s\"";
|
||||
|
||||
infrared_show_error_message(infrared, format, file_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user