Skip to content

Commit

Permalink
Add docs to infrared_app_i.h
Browse files Browse the repository at this point in the history
  • Loading branch information
gsurkov committed Oct 25, 2023
1 parent 4e40901 commit 80100dc
Show file tree
Hide file tree
Showing 4 changed files with 228 additions and 94 deletions.
55 changes: 27 additions & 28 deletions applications/main/infrared/infrared_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@

#define INFRARED_TX_MIN_INTERVAL_MS 50U

static const NotificationSequence* infrared_notification_sequences[] = {
&sequence_success,
&sequence_set_only_green_255,
&sequence_reset_green,
&sequence_solid_yellow,
&sequence_reset_rgb,
&sequence_blink_start_cyan,
&sequence_blink_start_magenta,
&sequence_blink_stop,
static const NotificationSequence*
infrared_notification_sequences[InfraredNotificationMessageCount] = {
&sequence_success,
&sequence_set_only_green_255,
&sequence_reset_green,
&sequence_solid_yellow,
&sequence_reset_rgb,
&sequence_blink_start_cyan,
&sequence_blink_start_magenta,
&sequence_blink_stop,
};

static void infrared_make_app_folder(InfraredApp* infrared) {
Expand Down Expand Up @@ -251,9 +252,9 @@ static void infrared_free(InfraredApp* infrared) {
}

bool infrared_add_remote_with_button(
InfraredApp* infrared,
const InfraredApp* infrared,
const char* button_name,
InfraredSignal* signal) {
const InfraredSignal* signal) {
InfraredRemote* remote = infrared->remote;

FuriString* new_name = furi_string_alloc_set(INFRARED_DEFAULT_REMOTE_NAME);
Expand All @@ -277,7 +278,7 @@ bool infrared_add_remote_with_button(
return success;
}

bool infrared_rename_current_remote(InfraredApp* infrared, const char* new_name) {
bool infrared_rename_current_remote(const InfraredApp* infrared, const char* new_name) {
InfraredRemote* remote = infrared->remote;
const char* old_path = infrared_remote_get_path(remote);

Expand Down Expand Up @@ -305,7 +306,7 @@ bool infrared_rename_current_remote(InfraredApp* infrared, const char* new_name)
return success;
}

void infrared_tx_start_signal(InfraredApp* infrared, const InfraredSignal* signal) {
void infrared_tx_start(InfraredApp* infrared) {
if(infrared->app_state.is_transmitting) {
return;
}
Expand All @@ -316,12 +317,12 @@ void infrared_tx_start_signal(InfraredApp* infrared, const InfraredSignal* signa
return;
}

if(infrared_signal_is_raw(signal)) {
const InfraredRawSignal* raw = infrared_signal_get_raw_signal(signal);
if(infrared_signal_is_raw(infrared->current_signal)) {
const InfraredRawSignal* raw = infrared_signal_get_raw_signal(infrared->current_signal);
infrared_worker_set_raw_signal(
infrared->worker, raw->timings, raw->timings_size, raw->frequency, raw->duty_cycle);
} else {
const InfraredMessage* message = infrared_signal_get_message(signal);
const InfraredMessage* message = infrared_signal_get_message(infrared->current_signal);
infrared_worker_set_decoded_signal(infrared->worker, message);
}

Expand All @@ -339,7 +340,7 @@ void infrared_tx_start_button_index(InfraredApp* infrared, size_t button_index)
furi_assert(button_index < infrared_remote_get_signal_count(infrared->remote));

if(infrared_remote_load_signal(infrared->remote, infrared->current_signal, button_index)) {
infrared_tx_start_current(infrared);
infrared_tx_start(infrared);
} else {
infrared_show_error_message(
infrared,
Expand All @@ -348,10 +349,6 @@ void infrared_tx_start_button_index(InfraredApp* infrared, size_t button_index)
}
}

void infrared_tx_start_current(InfraredApp* infrared) {
infrared_tx_start_signal(infrared, infrared->current_signal);
}

void infrared_tx_stop(InfraredApp* infrared) {
if(!infrared->app_state.is_transmitting) {
return;
Expand All @@ -366,11 +363,11 @@ void infrared_tx_stop(InfraredApp* infrared) {
infrared->app_state.last_transmit_time = furi_get_tick();
}

void infrared_text_store_set(InfraredApp* infrared, uint32_t bank, const char* text, ...) {
void infrared_text_store_set(InfraredApp* infrared, uint32_t bank, const char* fmt, ...) {
va_list args;
va_start(args, text);
va_start(args, fmt);

vsnprintf(infrared->text_store[bank], INFRARED_TEXT_STORE_SIZE, text, args);
vsnprintf(infrared->text_store[bank], INFRARED_TEXT_STORE_SIZE, fmt, args);

va_end(args);
}
Expand All @@ -379,12 +376,14 @@ void infrared_text_store_clear(InfraredApp* infrared, uint32_t bank) {
memset(infrared->text_store[bank], 0, INFRARED_TEXT_STORE_SIZE + 1);
}

void infrared_play_notification_message(InfraredApp* infrared, uint32_t message) {
furi_assert(message < sizeof(infrared_notification_sequences) / sizeof(NotificationSequence*));
void infrared_play_notification_message(
const InfraredApp* infrared,
InfraredNotificationMessage message) {
furi_assert(message < InfraredNotificationMessageCount);
notification_message(infrared->notifications, infrared_notification_sequences[message]);
}

void infrared_show_loading_popup(InfraredApp* infrared, bool show) {
void infrared_show_loading_popup(const InfraredApp* infrared, bool show) {
TaskHandle_t timer_task = xTaskGetHandle(configTIMER_SERVICE_TASK_NAME);
ViewStack* view_stack = infrared->view_stack;
Loading* loading = infrared->loading;
Expand All @@ -400,7 +399,7 @@ void infrared_show_loading_popup(InfraredApp* infrared, bool show) {
}
}

void infrared_show_error_message(InfraredApp* infrared, const char* fmt, ...) {
void infrared_show_error_message(const InfraredApp* infrared, const char* fmt, ...) {
va_list args;
va_start(args, fmt);

Expand Down
Loading

0 comments on commit 80100dc

Please sign in to comment.