Skip to content

Commit 5838267

Browse files
author
Sandro Kalatozishvili
committed
Updated icons, layout and button pressing stuff
1 parent b4de593 commit 5838267

13 files changed

+87
-28
lines changed

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# flipper-xremote
22
Advanced IR Remote App for Flipper Device
33

4-
### Currently under development, additional details coming soon..
5-
64
## Idea
75
With the current infrared application, users must navigate through the menu to locate each button individually. This requires scrolling to the desired button and selecting it, which can be uncomfortable. The idea behind `XRemote` is that all physical buttons are pre-mapped to specific category buttons, and pressing a physical button directly sends an infrared signal. This allows the flipper device to be used as a remote rather than as a tool that has a remote.
86

@@ -57,7 +55,7 @@ Button name | Description
5755
- [x] GUI to change settings
5856
- [x] Load settings from the file
5957
- [x] Store settings to the file
60-
- [x] Vertical/horizontal view
58+
- [x] Vertical/horizontal views
6159
- [x] IR command repeat count
6260
- [x] Exit button behavior
6361

@@ -80,3 +78,12 @@ Saved remote control apps
8078
<p align="center">
8179
<img src="https://github.com/kala13x/flipper-xremote/blob/main/screens/saved_remote_apps.png" alt="XRemote main menu">
8280
</p>
81+
82+
<table align="center">
83+
<tr>
84+
<td align="center">Settings</td>
85+
</tr>
86+
<tr>
87+
<td><img src="https://github.com/kala13x/flipper-xremote/blob/main/screens/settings_menu.png" alt="XRemote settings menu"></td>
88+
</tr>
89+
</table>

assets/Chandown_Icon_11x11.png

5 KB
Loading

assets/Chanup_Icon_11x11.png

5.22 KB
Loading

assets/Mute_Icon_11x11.png

4.33 KB
Loading

assets/Voldown_Icon_11x11.png

5 KB
Loading

assets/Volup_Icon_11x11.png

4.77 KB
Loading

screens/saved_remote_apps.png

3.6 KB
Loading

screens/settings_menu.png

5.73 KB
Loading

views/xremote_common_view.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,20 @@ void xremote_canvas_draw_button(Canvas* canvas, bool pressed, uint8_t x, uint8_t
260260
canvas_set_color(canvas, ColorBlack);
261261
}
262262

263+
void xremote_canvas_draw_button_png(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, const Icon* icon)
264+
{
265+
canvas_draw_icon(canvas, x, y, &I_Button_18x18);
266+
267+
if (pressed)
268+
{
269+
elements_slightly_rounded_box(canvas, x + 3, y + 2, 13, 13);
270+
canvas_set_color(canvas, ColorWhite);
271+
}
272+
273+
canvas_draw_icon(canvas, x + 4, y + 3, icon);
274+
canvas_set_color(canvas, ColorBlack);
275+
}
276+
263277
void xremote_canvas_draw_button_wide(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, char* text, XRemoteIcon icon)
264278
{
265279
(void)icon;

views/xremote_common_view.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ void xremote_canvas_draw_exit_footer(Canvas* canvas, ViewOrientation orient, con
106106

107107
void xremote_canvas_draw_icon(Canvas* canvas, uint8_t x, uint8_t y, XRemoteIcon icon);
108108
void xremote_canvas_draw_button(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, XRemoteIcon icon);
109+
void xremote_canvas_draw_button_png(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, const Icon* icon);
109110
void xremote_canvas_draw_button_wide(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, char* text, XRemoteIcon icon);
110111
void xremote_canvas_draw_button_size(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, uint8_t xy, char* text, XRemoteIcon icon);
111112
void xremote_canvas_draw_frame(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, uint8_t xl, const char *text);

views/xremote_control_view.c

Lines changed: 54 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,32 @@
1111

1212
static void xremote_control_view_draw_vertical(Canvas* canvas, XRemoteViewModel* model)
1313
{
14-
xremote_canvas_draw_frame(canvas, model->up_pressed, 17, 30, 31, "VOL +");
15-
xremote_canvas_draw_frame(canvas, model->left_pressed, 4, 50, 23, "< CH");
16-
xremote_canvas_draw_frame(canvas, model->right_pressed, 37, 50, 23, "CH >");
17-
xremote_canvas_draw_frame(canvas, model->down_pressed, 17, 70, 31, "VOL -");
18-
xremote_canvas_draw_button_wide(canvas, model->ok_pressed, 0, 95, "Mute", XRemoteIconEnter);
14+
XRemoteAppContext *app_ctx = model->context;
15+
16+
xremote_canvas_draw_button_png(canvas, model->up_pressed, 23, 30, &I_Chanup_Icon_11x11);
17+
xremote_canvas_draw_button_png(canvas, model->down_pressed, 23, 72, &I_Chandown_Icon_11x11);
18+
xremote_canvas_draw_button_png(canvas, model->left_pressed, 2, 51, &I_Voldown_Icon_11x11);
19+
xremote_canvas_draw_button_png(canvas, model->right_pressed, 44, 51, &I_Volup_Icon_11x11);
20+
xremote_canvas_draw_button_png(canvas, model->back_pressed, 2, 95, &I_Mute_Icon_11x11);
21+
xremote_canvas_draw_button(canvas, model->ok_pressed, 23, 51, XRemoteIconPlayPause);
22+
23+
if (app_ctx->app_settings->exit_behavior == XRemoteAppExitPress)
24+
canvas_draw_icon(canvas, 22, 107, &I_Hold_Text_17x4);
1925
}
2026

2127
static void xremote_control_view_draw_horizontal(Canvas* canvas, XRemoteViewModel* model)
2228
{
23-
xremote_canvas_draw_frame(canvas, model->up_pressed, 17, 5, 31, "VOL +");
24-
xremote_canvas_draw_frame(canvas, model->left_pressed, 4, 25, 23, "< CH");
25-
xremote_canvas_draw_frame(canvas, model->right_pressed, 37, 25, 23, "CH >");
26-
xremote_canvas_draw_frame(canvas, model->down_pressed, 17, 45, 31, "VOL -");
27-
xremote_canvas_draw_button_size(canvas, model->ok_pressed, 70, 30, 44, "Mute", XRemoteIconEnter);
29+
XRemoteAppContext *app_ctx = model->context;
30+
31+
xremote_canvas_draw_button_png(canvas, model->up_pressed, 23, 2, &I_Chanup_Icon_11x11);
32+
xremote_canvas_draw_button_png(canvas, model->down_pressed, 23, 44, &I_Chandown_Icon_11x11);
33+
xremote_canvas_draw_button_png(canvas, model->left_pressed, 2, 23, &I_Voldown_Icon_11x11);
34+
xremote_canvas_draw_button_png(canvas, model->right_pressed, 44, 23, &I_Volup_Icon_11x11);
35+
xremote_canvas_draw_button_png(canvas, model->back_pressed, 70, 33, &I_Mute_Icon_11x11);
36+
xremote_canvas_draw_button(canvas, model->ok_pressed, 23, 23, XRemoteIconPlayPause);
37+
38+
if (app_ctx->app_settings->exit_behavior == XRemoteAppExitPress)
39+
canvas_draw_icon(canvas, 90, 45, &I_Hold_Text_17x4);
2840
}
2941

3042
static void xremote_control_view_draw_callback(Canvas* canvas, void* context)
@@ -49,44 +61,61 @@ static void xremote_control_view_process(XRemoteView* view, InputEvent* event)
4961
xremote_view_get_view(view),
5062
XRemoteViewModel* model,
5163
{
52-
model->context = xremote_view_get_app_context(view);
64+
XRemoteAppContext* app_ctx = xremote_view_get_app_context(view);
65+
XRemoteAppExit exit = app_ctx->app_settings->exit_behavior;
5366
InfraredRemoteButton* button = NULL;
67+
model->context = app_ctx;
5468

5569
if (event->type == InputTypePress)
5670
{
5771
if (event->key == InputKeyOk)
5872
{
59-
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_MUTE);
73+
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_PLAY_PAUSE);
6074
if (xremote_view_press_button(view, button)) model->ok_pressed = true;
6175
}
6276
else if (event->key == InputKeyUp)
6377
{
64-
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_VOL_UP);
78+
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_NEXT_CHAN);
6579
if (xremote_view_press_button(view, button)) model->up_pressed = true;
6680
}
6781
else if (event->key == InputKeyDown)
6882
{
69-
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_VOL_DOWN);
83+
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_PREV_CHAN);
7084
if (xremote_view_press_button(view, button)) model->down_pressed = true;
7185
}
7286
else if (event->key == InputKeyLeft)
7387
{
74-
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_PREV_CHAN);
88+
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_VOL_DOWN);
7589
if (xremote_view_press_button(view, button)) model->left_pressed = true;
7690
}
7791
else if (event->key == InputKeyRight)
7892
{
79-
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_NEXT_CHAN);
93+
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_VOL_UP);
8094
if (xremote_view_press_button(view, button)) model->right_pressed = true;
8195
}
8296
}
97+
else if (event->type == InputTypeShort &&
98+
event->key == InputKeyBack &&
99+
exit == XRemoteAppExitHold)
100+
{
101+
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_MUTE);
102+
if (xremote_view_press_button(view, button)) model->back_pressed = true;
103+
}
104+
else if (event->type == InputTypeLong &&
105+
event->key == InputKeyBack &&
106+
exit == XRemoteAppExitPress)
107+
{
108+
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_MUTE);
109+
if (xremote_view_press_button(view, button)) model->back_pressed = true;
110+
}
83111
else if (event->type == InputTypeRelease)
84112
{
85113
if (event->key == InputKeyOk) model->ok_pressed = false;
86114
else if (event->key == InputKeyUp) model->up_pressed = false;
87115
else if (event->key == InputKeyDown) model->down_pressed = false;
88116
else if (event->key == InputKeyLeft) model->left_pressed = false;
89117
else if (event->key == InputKeyRight) model->right_pressed = false;
118+
else if (event->key == InputKeyBack) model->back_pressed = false;
90119
}
91120
},
92121
true);
@@ -96,7 +125,15 @@ static bool xremote_control_view_input_callback(InputEvent* event, void* context
96125
{
97126
furi_assert(context);
98127
XRemoteView* view = (XRemoteView*)context;
99-
if (event->key == InputKeyBack) return false;
128+
XRemoteAppContext* app_ctx = xremote_view_get_app_context(view);
129+
XRemoteAppExit exit = app_ctx->app_settings->exit_behavior;
130+
131+
if (event->key == InputKeyBack &&
132+
event->type == InputTypeShort &&
133+
exit == XRemoteAppExitPress) return false;
134+
else if (event->key == InputKeyBack &&
135+
event->type == InputTypeLong &&
136+
exit == XRemoteAppExitHold) return false;
100137

101138
xremote_control_view_process(view, event);
102139
return true;

views/xremote_player_view.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ static void xremote_player_view_draw_vertical(Canvas* canvas, XRemoteViewModel*
1717
xremote_canvas_draw_button(canvas, model->down_pressed, 23, 72, XRemoteIconJumpBackward);
1818
xremote_canvas_draw_button(canvas, model->left_pressed, 2, 51, XRemoteIconFastBackward);
1919
xremote_canvas_draw_button(canvas, model->right_pressed, 44, 51, XRemoteIconFastForward);
20-
xremote_canvas_draw_button(canvas, model->ok_pressed, 23, 51, XRemoteIconPlayPause);
21-
xremote_canvas_draw_button(canvas, model->back_pressed, 2, 95, XRemoteIconStop);
20+
xremote_canvas_draw_button(canvas, model->back_pressed, 2, 95, XRemoteIconPause);
21+
xremote_canvas_draw_button(canvas, model->ok_pressed, 23, 51, XRemoteIconPlay);
2222

2323
if (app_ctx->app_settings->exit_behavior == XRemoteAppExitPress)
2424
canvas_draw_icon(canvas, 22, 107, &I_Hold_Text_17x4);
@@ -32,8 +32,8 @@ static void xremote_player_view_draw_horizontal(Canvas* canvas, XRemoteViewModel
3232
xremote_canvas_draw_button(canvas, model->down_pressed, 23, 44, XRemoteIconJumpBackward);
3333
xremote_canvas_draw_button(canvas, model->left_pressed, 2, 23, XRemoteIconFastBackward);
3434
xremote_canvas_draw_button(canvas, model->right_pressed, 44, 23, XRemoteIconFastForward);
35-
xremote_canvas_draw_button(canvas, model->ok_pressed, 23, 23, XRemoteIconPlayPause);
36-
xremote_canvas_draw_button(canvas, model->back_pressed, 70, 33, XRemoteIconStop);
35+
xremote_canvas_draw_button(canvas, model->back_pressed, 70, 33, XRemoteIconPause);
36+
xremote_canvas_draw_button(canvas, model->ok_pressed, 23, 23, XRemoteIconPlay);
3737

3838
if (app_ctx->app_settings->exit_behavior == XRemoteAppExitPress)
3939
canvas_draw_icon(canvas, 90, 45, &I_Hold_Text_17x4);
@@ -91,22 +91,22 @@ static void xremote_player_view_process(XRemoteView* view, InputEvent* event)
9191
}
9292
else if (event->key == InputKeyOk)
9393
{
94-
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_PLAY_PAUSE);
94+
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_PLAY);
9595
if (xremote_view_press_button(view, button)) model->ok_pressed = true;
9696
}
9797
}
9898
else if (event->type == InputTypeShort &&
9999
event->key == InputKeyBack &&
100100
exit == XRemoteAppExitHold)
101101
{
102-
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_STOP);
102+
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_PAUSE);
103103
if (xremote_view_press_button(view, button)) model->back_pressed = true;
104104
}
105105
else if (event->type == InputTypeLong &&
106106
event->key == InputKeyBack &&
107107
exit == XRemoteAppExitPress)
108108
{
109-
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_STOP);
109+
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_PAUSE);
110110
if (xremote_view_press_button(view, button)) model->back_pressed = true;
111111
}
112112
else if (event->type == InputTypeRelease)

xremote.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010

1111
#define XREMOTE_VERSION_MAJOR 0
1212
#define XREMOTE_VERSION_MINOR 9
13-
#define XREMOTE_BUILD_NUMBER 23
13+
#define XREMOTE_BUILD_NUMBER 24
1414

1515
void xremote_get_version(char *version, size_t length);

0 commit comments

Comments
 (0)