Skip to content

Commit

Permalink
Updated icons, layout and button pressing stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandro Kalatozishvili committed Oct 2, 2023
1 parent b4de593 commit 5838267
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 28 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# flipper-xremote
Advanced IR Remote App for Flipper Device

### Currently under development, additional details coming soon..

## Idea
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.

Expand Down Expand Up @@ -57,7 +55,7 @@ Button name | Description
- [x] GUI to change settings
- [x] Load settings from the file
- [x] Store settings to the file
- [x] Vertical/horizontal view
- [x] Vertical/horizontal views
- [x] IR command repeat count
- [x] Exit button behavior

Expand All @@ -80,3 +78,12 @@ Saved remote control apps
<p align="center">
<img src="https://github.com/kala13x/flipper-xremote/blob/main/screens/saved_remote_apps.png" alt="XRemote main menu">
</p>

<table align="center">
<tr>
<td align="center">Settings</td>
</tr>
<tr>
<td><img src="https://github.com/kala13x/flipper-xremote/blob/main/screens/settings_menu.png" alt="XRemote settings menu"></td>
</tr>
</table>
Binary file added assets/Chandown_Icon_11x11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Chanup_Icon_11x11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Mute_Icon_11x11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Voldown_Icon_11x11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Volup_Icon_11x11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screens/saved_remote_apps.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screens/settings_menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions views/xremote_common_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,20 @@ void xremote_canvas_draw_button(Canvas* canvas, bool pressed, uint8_t x, uint8_t
canvas_set_color(canvas, ColorBlack);
}

void xremote_canvas_draw_button_png(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, const Icon* icon)
{
canvas_draw_icon(canvas, x, y, &I_Button_18x18);

if (pressed)
{
elements_slightly_rounded_box(canvas, x + 3, y + 2, 13, 13);
canvas_set_color(canvas, ColorWhite);
}

canvas_draw_icon(canvas, x + 4, y + 3, icon);
canvas_set_color(canvas, ColorBlack);
}

void xremote_canvas_draw_button_wide(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, char* text, XRemoteIcon icon)
{
(void)icon;
Expand Down
1 change: 1 addition & 0 deletions views/xremote_common_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ void xremote_canvas_draw_exit_footer(Canvas* canvas, ViewOrientation orient, con

void xremote_canvas_draw_icon(Canvas* canvas, uint8_t x, uint8_t y, XRemoteIcon icon);
void xremote_canvas_draw_button(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, XRemoteIcon icon);
void xremote_canvas_draw_button_png(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, const Icon* icon);
void xremote_canvas_draw_button_wide(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, char* text, XRemoteIcon icon);
void xremote_canvas_draw_button_size(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, uint8_t xy, char* text, XRemoteIcon icon);
void xremote_canvas_draw_frame(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, uint8_t xl, const char *text);
Expand Down
71 changes: 54 additions & 17 deletions views/xremote_control_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,32 @@

static void xremote_control_view_draw_vertical(Canvas* canvas, XRemoteViewModel* model)
{
xremote_canvas_draw_frame(canvas, model->up_pressed, 17, 30, 31, "VOL +");
xremote_canvas_draw_frame(canvas, model->left_pressed, 4, 50, 23, "< CH");
xremote_canvas_draw_frame(canvas, model->right_pressed, 37, 50, 23, "CH >");
xremote_canvas_draw_frame(canvas, model->down_pressed, 17, 70, 31, "VOL -");
xremote_canvas_draw_button_wide(canvas, model->ok_pressed, 0, 95, "Mute", XRemoteIconEnter);
XRemoteAppContext *app_ctx = model->context;

xremote_canvas_draw_button_png(canvas, model->up_pressed, 23, 30, &I_Chanup_Icon_11x11);
xremote_canvas_draw_button_png(canvas, model->down_pressed, 23, 72, &I_Chandown_Icon_11x11);
xremote_canvas_draw_button_png(canvas, model->left_pressed, 2, 51, &I_Voldown_Icon_11x11);
xremote_canvas_draw_button_png(canvas, model->right_pressed, 44, 51, &I_Volup_Icon_11x11);
xremote_canvas_draw_button_png(canvas, model->back_pressed, 2, 95, &I_Mute_Icon_11x11);
xremote_canvas_draw_button(canvas, model->ok_pressed, 23, 51, XRemoteIconPlayPause);

if (app_ctx->app_settings->exit_behavior == XRemoteAppExitPress)
canvas_draw_icon(canvas, 22, 107, &I_Hold_Text_17x4);
}

static void xremote_control_view_draw_horizontal(Canvas* canvas, XRemoteViewModel* model)
{
xremote_canvas_draw_frame(canvas, model->up_pressed, 17, 5, 31, "VOL +");
xremote_canvas_draw_frame(canvas, model->left_pressed, 4, 25, 23, "< CH");
xremote_canvas_draw_frame(canvas, model->right_pressed, 37, 25, 23, "CH >");
xremote_canvas_draw_frame(canvas, model->down_pressed, 17, 45, 31, "VOL -");
xremote_canvas_draw_button_size(canvas, model->ok_pressed, 70, 30, 44, "Mute", XRemoteIconEnter);
XRemoteAppContext *app_ctx = model->context;

xremote_canvas_draw_button_png(canvas, model->up_pressed, 23, 2, &I_Chanup_Icon_11x11);
xremote_canvas_draw_button_png(canvas, model->down_pressed, 23, 44, &I_Chandown_Icon_11x11);
xremote_canvas_draw_button_png(canvas, model->left_pressed, 2, 23, &I_Voldown_Icon_11x11);
xremote_canvas_draw_button_png(canvas, model->right_pressed, 44, 23, &I_Volup_Icon_11x11);
xremote_canvas_draw_button_png(canvas, model->back_pressed, 70, 33, &I_Mute_Icon_11x11);
xremote_canvas_draw_button(canvas, model->ok_pressed, 23, 23, XRemoteIconPlayPause);

if (app_ctx->app_settings->exit_behavior == XRemoteAppExitPress)
canvas_draw_icon(canvas, 90, 45, &I_Hold_Text_17x4);
}

static void xremote_control_view_draw_callback(Canvas* canvas, void* context)
Expand All @@ -49,44 +61,61 @@ static void xremote_control_view_process(XRemoteView* view, InputEvent* event)
xremote_view_get_view(view),
XRemoteViewModel* model,
{
model->context = xremote_view_get_app_context(view);
XRemoteAppContext* app_ctx = xremote_view_get_app_context(view);
XRemoteAppExit exit = app_ctx->app_settings->exit_behavior;
InfraredRemoteButton* button = NULL;
model->context = app_ctx;

if (event->type == InputTypePress)
{
if (event->key == InputKeyOk)
{
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_MUTE);
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_PLAY_PAUSE);
if (xremote_view_press_button(view, button)) model->ok_pressed = true;
}
else if (event->key == InputKeyUp)
{
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_VOL_UP);
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_NEXT_CHAN);
if (xremote_view_press_button(view, button)) model->up_pressed = true;
}
else if (event->key == InputKeyDown)
{
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_VOL_DOWN);
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_PREV_CHAN);
if (xremote_view_press_button(view, button)) model->down_pressed = true;
}
else if (event->key == InputKeyLeft)
{
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_PREV_CHAN);
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_VOL_DOWN);
if (xremote_view_press_button(view, button)) model->left_pressed = true;
}
else if (event->key == InputKeyRight)
{
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_NEXT_CHAN);
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_VOL_UP);
if (xremote_view_press_button(view, button)) model->right_pressed = true;
}
}
else if (event->type == InputTypeShort &&
event->key == InputKeyBack &&
exit == XRemoteAppExitHold)
{
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_MUTE);
if (xremote_view_press_button(view, button)) model->back_pressed = true;
}
else if (event->type == InputTypeLong &&
event->key == InputKeyBack &&
exit == XRemoteAppExitPress)
{
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_MUTE);
if (xremote_view_press_button(view, button)) model->back_pressed = true;
}
else if (event->type == InputTypeRelease)
{
if (event->key == InputKeyOk) model->ok_pressed = false;
else if (event->key == InputKeyUp) model->up_pressed = false;
else if (event->key == InputKeyDown) model->down_pressed = false;
else if (event->key == InputKeyLeft) model->left_pressed = false;
else if (event->key == InputKeyRight) model->right_pressed = false;
else if (event->key == InputKeyBack) model->back_pressed = false;
}
},
true);
Expand All @@ -96,7 +125,15 @@ static bool xremote_control_view_input_callback(InputEvent* event, void* context
{
furi_assert(context);
XRemoteView* view = (XRemoteView*)context;
if (event->key == InputKeyBack) return false;
XRemoteAppContext* app_ctx = xremote_view_get_app_context(view);
XRemoteAppExit exit = app_ctx->app_settings->exit_behavior;

if (event->key == InputKeyBack &&
event->type == InputTypeShort &&
exit == XRemoteAppExitPress) return false;
else if (event->key == InputKeyBack &&
event->type == InputTypeLong &&
exit == XRemoteAppExitHold) return false;

xremote_control_view_process(view, event);
return true;
Expand Down
14 changes: 7 additions & 7 deletions views/xremote_player_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ static void xremote_player_view_draw_vertical(Canvas* canvas, XRemoteViewModel*
xremote_canvas_draw_button(canvas, model->down_pressed, 23, 72, XRemoteIconJumpBackward);
xremote_canvas_draw_button(canvas, model->left_pressed, 2, 51, XRemoteIconFastBackward);
xremote_canvas_draw_button(canvas, model->right_pressed, 44, 51, XRemoteIconFastForward);
xremote_canvas_draw_button(canvas, model->ok_pressed, 23, 51, XRemoteIconPlayPause);
xremote_canvas_draw_button(canvas, model->back_pressed, 2, 95, XRemoteIconStop);
xremote_canvas_draw_button(canvas, model->back_pressed, 2, 95, XRemoteIconPause);
xremote_canvas_draw_button(canvas, model->ok_pressed, 23, 51, XRemoteIconPlay);

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

if (app_ctx->app_settings->exit_behavior == XRemoteAppExitPress)
canvas_draw_icon(canvas, 90, 45, &I_Hold_Text_17x4);
Expand Down Expand Up @@ -91,22 +91,22 @@ static void xremote_player_view_process(XRemoteView* view, InputEvent* event)
}
else if (event->key == InputKeyOk)
{
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_PLAY_PAUSE);
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_PLAY);
if (xremote_view_press_button(view, button)) model->ok_pressed = true;
}
}
else if (event->type == InputTypeShort &&
event->key == InputKeyBack &&
exit == XRemoteAppExitHold)
{
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_STOP);
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_PAUSE);
if (xremote_view_press_button(view, button)) model->back_pressed = true;
}
else if (event->type == InputTypeLong &&
event->key == InputKeyBack &&
exit == XRemoteAppExitPress)
{
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_STOP);
button = xremote_view_get_button_by_name(view, XREMOTE_COMMAND_PAUSE);
if (xremote_view_press_button(view, button)) model->back_pressed = true;
}
else if (event->type == InputTypeRelease)
Expand Down
2 changes: 1 addition & 1 deletion xremote.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@

#define XREMOTE_VERSION_MAJOR 0
#define XREMOTE_VERSION_MINOR 9
#define XREMOTE_BUILD_NUMBER 23
#define XREMOTE_BUILD_NUMBER 24

void xremote_get_version(char *version, size_t length);

0 comments on commit 5838267

Please sign in to comment.