Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IR Remote plugin improvements #535

Merged
merged 2 commits into from
Feb 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 25 additions & 12 deletions applications/plugins/ir_remote/infrared_remote_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "infrared_remote.h"
#include "infrared_remote_button.h"
#define TAG "IR_Remote"
#define MENU_BTN_TXT_X 36

#include <flipper_format/flipper_format.h>

Expand Down Expand Up @@ -59,17 +60,17 @@ static void app_draw_callback(Canvas* canvas, void* ctx) {
canvas_set_font(canvas, FontSecondary);

canvas_draw_str_aligned(
canvas, 32, 8, AlignCenter, AlignCenter, furi_string_get_cstr(app->up_button));
canvas, MENU_BTN_TXT_X, 8, AlignCenter, AlignCenter, furi_string_get_cstr(app->up_button));
canvas_draw_str_aligned(
canvas, 32, 18, AlignCenter, AlignCenter, furi_string_get_cstr(app->down_button));
canvas, MENU_BTN_TXT_X, 18, AlignCenter, AlignCenter, furi_string_get_cstr(app->down_button));
canvas_draw_str_aligned(
canvas, 32, 28, AlignCenter, AlignCenter, furi_string_get_cstr(app->left_button));
canvas, MENU_BTN_TXT_X, 28, AlignCenter, AlignCenter, furi_string_get_cstr(app->left_button));
canvas_draw_str_aligned(
canvas, 32, 38, AlignCenter, AlignCenter, furi_string_get_cstr(app->right_button));
canvas, MENU_BTN_TXT_X, 38, AlignCenter, AlignCenter, furi_string_get_cstr(app->right_button));
canvas_draw_str_aligned(
canvas, 32, 48, AlignCenter, AlignCenter, furi_string_get_cstr(app->ok_button));
canvas, MENU_BTN_TXT_X, 48, AlignCenter, AlignCenter, furi_string_get_cstr(app->ok_button));
canvas_draw_str_aligned(
canvas, 32, 58, AlignCenter, AlignCenter, furi_string_get_cstr(app->back_button));
canvas, MENU_BTN_TXT_X, 58, AlignCenter, AlignCenter, furi_string_get_cstr(app->back_button));

canvas_draw_line(canvas, 0, 65, 64, 65);

Expand All @@ -81,21 +82,21 @@ static void app_draw_callback(Canvas* canvas, void* ctx) {
canvas_draw_icon(canvas, 0, 118, &I_back_10px);

canvas_draw_str_aligned(
canvas, 32, 73, AlignCenter, AlignCenter, furi_string_get_cstr(app->up_hold_button));
canvas, MENU_BTN_TXT_X, 73, AlignCenter, AlignCenter, furi_string_get_cstr(app->up_hold_button));
canvas_draw_str_aligned(
canvas, 32, 83, AlignCenter, AlignCenter, furi_string_get_cstr(app->down_hold_button));
canvas, MENU_BTN_TXT_X, 83, AlignCenter, AlignCenter, furi_string_get_cstr(app->down_hold_button));
canvas_draw_str_aligned(
canvas, 32, 93, AlignCenter, AlignCenter, furi_string_get_cstr(app->left_hold_button));
canvas, MENU_BTN_TXT_X, 93, AlignCenter, AlignCenter, furi_string_get_cstr(app->left_hold_button));
canvas_draw_str_aligned(
canvas,
32,
MENU_BTN_TXT_X,
103,
AlignCenter,
AlignCenter,
furi_string_get_cstr(app->right_hold_button));
canvas_draw_str_aligned(
canvas, 32, 113, AlignCenter, AlignCenter, furi_string_get_cstr(app->ok_hold_button));
canvas_draw_str_aligned(canvas, 32, 123, AlignCenter, AlignCenter, "Exit App");
canvas, MENU_BTN_TXT_X, 113, AlignCenter, AlignCenter, furi_string_get_cstr(app->ok_hold_button));
canvas_draw_str_aligned(canvas, MENU_BTN_TXT_X, 123, AlignCenter, AlignCenter, "Exit App");
}
}

Expand Down Expand Up @@ -229,6 +230,8 @@ int32_t infrared_remote_app(void* p) {
//set missing filenames to N/A
//assign button signals
size_t index = 0;

flipper_format_rewind(ff);
if(!flipper_format_read_string(ff, "UP", app->up_button)) {
FURI_LOG_W(TAG, "Could not read UP string");
furi_string_set(app->up_button, "N/A");
Expand All @@ -243,6 +246,7 @@ int32_t infrared_remote_app(void* p) {
}
}

flipper_format_rewind(ff);
if(!flipper_format_read_string(ff, "DOWN", app->down_button)) {
FURI_LOG_W(TAG, "Could not read DOWN string");
furi_string_set(app->down_button, "N/A");
Expand All @@ -257,6 +261,7 @@ int32_t infrared_remote_app(void* p) {
}
}

flipper_format_rewind(ff);
if(!flipper_format_read_string(ff, "LEFT", app->left_button)) {
FURI_LOG_W(TAG, "Could not read LEFT string");
furi_string_set(app->left_button, "N/A");
Expand All @@ -271,6 +276,7 @@ int32_t infrared_remote_app(void* p) {
}
}

flipper_format_rewind(ff);
if(!flipper_format_read_string(ff, "RIGHT", app->right_button)) {
FURI_LOG_W(TAG, "Could not read RIGHT string");
furi_string_set(app->right_button, "N/A");
Expand All @@ -285,6 +291,7 @@ int32_t infrared_remote_app(void* p) {
}
}

flipper_format_rewind(ff);
if(!flipper_format_read_string(ff, "OK", app->ok_button)) {
FURI_LOG_W(TAG, "Could not read OK string");
furi_string_set(app->ok_button, "N/A");
Expand All @@ -299,6 +306,7 @@ int32_t infrared_remote_app(void* p) {
}
}

flipper_format_rewind(ff);
if(!flipper_format_read_string(ff, "BACK", app->back_button)) {
FURI_LOG_W(TAG, "Could not read BACK string");
furi_string_set(app->back_button, "N/A");
Expand All @@ -313,6 +321,7 @@ int32_t infrared_remote_app(void* p) {
}
}

flipper_format_rewind(ff);
if(!flipper_format_read_string(ff, "UPHOLD", app->up_hold_button)) {
FURI_LOG_W(TAG, "Could not read UPHOLD string");
furi_string_set(app->up_hold_button, "N/A");
Expand All @@ -327,6 +336,7 @@ int32_t infrared_remote_app(void* p) {
}
}

flipper_format_rewind(ff);
if(!flipper_format_read_string(ff, "DOWNHOLD", app->down_hold_button)) {
FURI_LOG_W(TAG, "Could not read DOWNHOLD string");
furi_string_set(app->down_hold_button, "N/A");
Expand All @@ -341,6 +351,7 @@ int32_t infrared_remote_app(void* p) {
}
}

flipper_format_rewind(ff);
if(!flipper_format_read_string(ff, "LEFTHOLD", app->left_hold_button)) {
FURI_LOG_W(TAG, "Could not read LEFTHOLD string");
furi_string_set(app->left_hold_button, "N/A");
Expand All @@ -355,6 +366,7 @@ int32_t infrared_remote_app(void* p) {
}
}

flipper_format_rewind(ff);
if(!flipper_format_read_string(ff, "RIGHTHOLD", app->right_hold_button)) {
FURI_LOG_W(TAG, "Could not read RIGHTHOLD string");
furi_string_set(app->right_hold_button, "N/A");
Expand All @@ -369,6 +381,7 @@ int32_t infrared_remote_app(void* p) {
}
}

flipper_format_rewind(ff);
if(!flipper_format_read_string(ff, "OKHOLD", app->ok_hold_button)) {
FURI_LOG_W(TAG, "Could not read OKHOLD string");
furi_string_set(app->ok_hold_button, "N/A");
Expand Down