Skip to content

Commit 1948dfe

Browse files
committed
Update and bug fix
1 parent c9d98ae commit 1948dfe

File tree

3 files changed

+55
-22
lines changed

3 files changed

+55
-22
lines changed

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
It is a plugin like [UniversalRF Remix](https://github.com/ESurge/flipperzero-firmware-unirfremix) but for infrared files. I do this plugin for convenience, because the main IR app need to navigate for different button abit troublesome (buttons like up,down,left,right,back). I found it useful for TV and TV box.
44

5-
It supports short press and long press input for different ir remote buttons. Tested on the [unleashed firmware version unlshd-023](https://github.com/DarkFlippers/unleashed-firmware/releases/tag/unlshd-023)
5+
It supports short press and long press input for different ir remote buttons. Tested on the [unleashed firmware version unlshd-047](https://github.com/DarkFlippers/unleashed-firmware/releases/tag/unlshd-047)
66

77

88
## How to install
99

10-
1. Update unleashed firmware to the version unlshd-023, then download the `ir_remote.fap` from [releases](https://github.com/Hong5489/ir_remote/tags)
10+
1. Update unleashed firmware to the version unlshd-047, then download the `ir_remote.fap` from [releases](https://github.com/Hong5489/ir_remote/tags)
1111

1212
2. Put the `ir_remote.fap` file in your flipper's SD card, under `apps` folder
1313

@@ -17,7 +17,7 @@ It supports short press and long press input for different ir remote buttons. Te
1717

1818
The format With `HOLD` one is long press, without is short press
1919

20-
Example of the configuration file:
20+
Example of the configuration file (Update: the string format can be in any order):
2121
```
2222
REMOTE: /ext/infrared/Philips_32PFL4208T.ir
2323
UP: Up
@@ -60,4 +60,13 @@ Choose config file to map
6060

6161
Show all button name in the config file (If empty will show N/A). Upper part short press, Lower part long press
6262

63-
![image2](ir2.png)
63+
![image2](ir2.png)
64+
65+
## Update
66+
Thanks to [friebel](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/pull/535), [d4ve10](https://github.com/Hong5489/ir_remote/pull/4) and [polarikus](https://github.com/Hong5489/ir_remote/pull/2)
67+
- Added auto create `ir_remote` directory
68+
- Fixed string format
69+
- Added for hold button will send IR multiple times
70+
71+
## TODO
72+
- Mulitiple remote in one config file

application.fam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ App(
88
"gui",
99
"dialogs",
1010
],
11-
fap_category="Tools",
11+
fap_category="Tools_Extra",
1212
fap_icon="ir_10px.png",
1313
fap_icon_assets="images",
1414
)

infrared_remote_app.c

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,18 @@
1515
#include "infrared_remote.h"
1616
#include "infrared_remote_button.h"
1717
#define TAG "ir_remote"
18+
#define MENU_BTN_TXT_X 36
1819

1920
#include <flipper_format/flipper_format.h>
2021

22+
struct InfraredSignal {
23+
bool is_raw;
24+
union {
25+
InfraredMessage message;
26+
InfraredRawSignal raw;
27+
} payload;
28+
};
29+
2130
typedef struct {
2231
int status;
2332
ViewPort* view_port;
@@ -61,12 +70,12 @@ static void app_draw_callback(Canvas* canvas, void* ctx) {
6170
//Labels
6271
canvas_set_font(canvas, FontSecondary);
6372

64-
canvas_draw_str_aligned(canvas, 32, 8,AlignCenter,AlignCenter, furi_string_get_cstr(app->up_button));
65-
canvas_draw_str_aligned(canvas, 32, 18,AlignCenter,AlignCenter, furi_string_get_cstr(app->down_button));
66-
canvas_draw_str_aligned(canvas, 32, 28,AlignCenter,AlignCenter, furi_string_get_cstr(app->left_button));
67-
canvas_draw_str_aligned(canvas, 32, 38,AlignCenter,AlignCenter, furi_string_get_cstr(app->right_button));
68-
canvas_draw_str_aligned(canvas, 32, 48,AlignCenter,AlignCenter, furi_string_get_cstr(app->ok_button));
69-
canvas_draw_str_aligned(canvas, 32, 58, AlignCenter, AlignCenter, furi_string_get_cstr(app->back_button));
73+
canvas_draw_str_aligned(canvas, MENU_BTN_TXT_X, 8,AlignCenter,AlignCenter, furi_string_get_cstr(app->up_button));
74+
canvas_draw_str_aligned(canvas, MENU_BTN_TXT_X, 18,AlignCenter,AlignCenter, furi_string_get_cstr(app->down_button));
75+
canvas_draw_str_aligned(canvas, MENU_BTN_TXT_X, 28,AlignCenter,AlignCenter, furi_string_get_cstr(app->left_button));
76+
canvas_draw_str_aligned(canvas, MENU_BTN_TXT_X, 38,AlignCenter,AlignCenter, furi_string_get_cstr(app->right_button));
77+
canvas_draw_str_aligned(canvas, MENU_BTN_TXT_X, 48,AlignCenter,AlignCenter, furi_string_get_cstr(app->ok_button));
78+
canvas_draw_str_aligned(canvas, MENU_BTN_TXT_X, 58, AlignCenter, AlignCenter, furi_string_get_cstr(app->back_button));
7079

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

@@ -77,12 +86,12 @@ static void app_draw_callback(Canvas* canvas, void* ctx) {
7786
canvas_draw_icon(canvas, 0, 107, &I_Ok_btn_9x9);
7887
canvas_draw_icon(canvas, 0, 118, &I_back_10px);
7988

80-
canvas_draw_str_aligned(canvas, 32, 73,AlignCenter,AlignCenter, furi_string_get_cstr(app->up_hold_button));
81-
canvas_draw_str_aligned(canvas, 32, 83,AlignCenter,AlignCenter, furi_string_get_cstr(app->down_hold_button));
82-
canvas_draw_str_aligned(canvas, 32, 93,AlignCenter,AlignCenter, furi_string_get_cstr(app->left_hold_button));
83-
canvas_draw_str_aligned(canvas, 32, 103,AlignCenter,AlignCenter, furi_string_get_cstr(app->right_hold_button));
84-
canvas_draw_str_aligned(canvas, 32, 113,AlignCenter,AlignCenter, furi_string_get_cstr(app->ok_hold_button));
85-
canvas_draw_str_aligned(canvas, 32, 123, AlignCenter, AlignCenter, "Exit App");
89+
canvas_draw_str_aligned(canvas, MENU_BTN_TXT_X, 73,AlignCenter,AlignCenter, furi_string_get_cstr(app->up_hold_button));
90+
canvas_draw_str_aligned(canvas, MENU_BTN_TXT_X, 83,AlignCenter,AlignCenter, furi_string_get_cstr(app->down_hold_button));
91+
canvas_draw_str_aligned(canvas, MENU_BTN_TXT_X, 93,AlignCenter,AlignCenter, furi_string_get_cstr(app->left_hold_button));
92+
canvas_draw_str_aligned(canvas, MENU_BTN_TXT_X, 103,AlignCenter,AlignCenter, furi_string_get_cstr(app->right_hold_button));
93+
canvas_draw_str_aligned(canvas, MENU_BTN_TXT_X, 113,AlignCenter,AlignCenter, furi_string_get_cstr(app->ok_hold_button));
94+
canvas_draw_str_aligned(canvas, MENU_BTN_TXT_X, 123, AlignCenter, AlignCenter, "Exit App");
8695
}
8796

8897

@@ -133,6 +142,9 @@ int32_t infrared_remote_app(void* p) {
133142
dialog_file_browser_set_basic_options(&browser_options, ".txt", &I_sub1_10px);
134143
FuriString* map_file = furi_string_alloc();
135144
furi_string_set(map_file,"/ext/ir_remote");
145+
if(!storage_file_exists(storage, ANY_PATH("ir_remote"))){
146+
storage_common_mkdir(storage, ANY_PATH("ir_remote"));//Make Folder If dir not exist
147+
}
136148

137149
bool res = dialog_file_browser_show(dialogs, map_file, map_file, &browser_options);
138150

@@ -220,6 +232,8 @@ int32_t infrared_remote_app(void* p) {
220232
//set missing filenames to N/A
221233
//assign button signals
222234
size_t index = 0;
235+
// Add rewind to fix the string ordering issue
236+
flipper_format_rewind(ff);
223237
if(!flipper_format_read_string(ff, "UP", app->up_button)) {
224238
FURI_LOG_W(TAG, "Could not read UP string");
225239
furi_string_set(app->up_button,"N/A");
@@ -232,6 +246,7 @@ int32_t infrared_remote_app(void* p) {
232246
}
233247
}
234248

249+
flipper_format_rewind(ff);
235250
if(!flipper_format_read_string(ff, "DOWN", app->down_button)) {
236251
FURI_LOG_W(TAG, "Could not read DOWN string");
237252
furi_string_set(app->down_button,"N/A");
@@ -244,6 +259,7 @@ int32_t infrared_remote_app(void* p) {
244259
}
245260
}
246261

262+
flipper_format_rewind(ff);
247263
if(!flipper_format_read_string(ff, "LEFT", app->left_button)) {
248264
FURI_LOG_W(TAG, "Could not read LEFT string");
249265
furi_string_set(app->left_button,"N/A");
@@ -256,6 +272,7 @@ int32_t infrared_remote_app(void* p) {
256272
}
257273
}
258274

275+
flipper_format_rewind(ff);
259276
if(!flipper_format_read_string(ff, "RIGHT", app->right_button)) {
260277
FURI_LOG_W(TAG, "Could not read RIGHT string");
261278
furi_string_set(app->right_button,"N/A");
@@ -268,6 +285,7 @@ int32_t infrared_remote_app(void* p) {
268285
}
269286
}
270287

288+
flipper_format_rewind(ff);
271289
if(!flipper_format_read_string(ff, "OK", app->ok_button)) {
272290
FURI_LOG_W(TAG, "Could not read OK string");
273291
furi_string_set(app->ok_button,"N/A");
@@ -280,6 +298,7 @@ int32_t infrared_remote_app(void* p) {
280298
}
281299
}
282300

301+
flipper_format_rewind(ff);
283302
if(!flipper_format_read_string(ff, "BACK", app->back_button)) {
284303
FURI_LOG_W(TAG, "Could not read BACK string");
285304
furi_string_set(app->back_button,"N/A");
@@ -292,6 +311,7 @@ int32_t infrared_remote_app(void* p) {
292311
}
293312
}
294313

314+
flipper_format_rewind(ff);
295315
if(!flipper_format_read_string(ff, "UPHOLD", app->up_hold_button)) {
296316
FURI_LOG_W(TAG, "Could not read UPHOLD string");
297317
furi_string_set(app->up_hold_button,"N/A");
@@ -304,6 +324,7 @@ int32_t infrared_remote_app(void* p) {
304324
}
305325
}
306326

327+
flipper_format_rewind(ff);
307328
if(!flipper_format_read_string(ff, "DOWNHOLD", app->down_hold_button)) {
308329
FURI_LOG_W(TAG, "Could not read DOWNHOLD string");
309330
furi_string_set(app->down_hold_button,"N/A");
@@ -316,6 +337,7 @@ int32_t infrared_remote_app(void* p) {
316337
}
317338
}
318339

340+
flipper_format_rewind(ff);
319341
if(!flipper_format_read_string(ff, "LEFTHOLD", app->left_hold_button)) {
320342
FURI_LOG_W(TAG, "Could not read LEFTHOLD string");
321343
furi_string_set(app->left_hold_button,"N/A");
@@ -328,6 +350,7 @@ int32_t infrared_remote_app(void* p) {
328350
}
329351
}
330352

353+
flipper_format_rewind(ff);
331354
if(!flipper_format_read_string(ff, "RIGHTHOLD", app->right_hold_button)) {
332355
FURI_LOG_W(TAG, "Could not read RIGHTHOLD string");
333356
furi_string_set(app->right_hold_button,"N/A");
@@ -339,7 +362,8 @@ int32_t infrared_remote_app(void* p) {
339362
right_hold_enabled = true;
340363
}
341364
}
342-
365+
366+
flipper_format_rewind(ff);
343367
if(!flipper_format_read_string(ff, "OKHOLD", app->ok_hold_button)) {
344368
FURI_LOG_W(TAG, "Could not read OKHOLD string");
345369
furi_string_set(app->ok_hold_button,"N/A");
@@ -472,11 +496,11 @@ int32_t infrared_remote_app(void* p) {
472496
if (is_transmitting) {
473497
infrared_worker_tx_stop(app->infrared_worker);
474498
}
475-
476-
if(infrared_signal_is_raw(active_signal)) {
499+
// Check the signal is raw
500+
if(active_signal->is_raw){
477501
InfraredRawSignal* raw_signal = infrared_signal_get_raw_signal(active_signal);
478-
infrared_worker_set_raw_signal(app->infrared_worker, raw_signal->timings, raw_signal->timings_size);
479-
} else {
502+
infrared_worker_set_raw_signal(app->infrared_worker,raw_signal->timings,raw_signal->timings_size);
503+
}else{
480504
InfraredMessage* message = infrared_signal_get_message(active_signal);
481505
infrared_worker_set_decoded_signal(app->infrared_worker, message);
482506
}

0 commit comments

Comments
 (0)