فهرست منبع

Finished control page

Sandro Kalatozishvili 2 سال پیش
والد
کامیت
f45f642693

+ 15 - 15
README.md

@@ -4,7 +4,7 @@ Advanced IR Remote App for Flipper Device
 ### Currently under development, additional details coming soon..
 ### Currently under development, additional details coming soon..
 
 
 ## Idea
 ## 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.
+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.
 
 
 `XRemote` also introduces a more user-friendly learning approach. Instead of having to manually name each button on the flipper when cloning a remote, the learn tool informs you upfront which buttons it will record. All you need to do is press the corresponding button on your existing remote, eliminating the need to name them individually.
 `XRemote` also introduces a more user-friendly learning approach. Instead of having to manually name each button on the flipper when cloning a remote, the learn tool informs you upfront which buttons it will record. All you need to do is press the corresponding button on your existing remote, eliminating the need to name them individually.
 
 
@@ -15,17 +15,17 @@ The application is compatible with standard `.ir` files. However, to ensure func
 - [x] Application menu
 - [x] Application menu
 - [ ] Learn new remote
 - [ ] Learn new remote
 - [ ] Use saved remote
 - [ ] Use saved remote
-    - [x] Saved remote general button page 
-    - [ ] Saved remote control buttons page
-    - [x] Saved remote navigation buttons page
-    - [x] Saved remote player buttons page
-    - [ ] Saved remote custom buttons page
-    - [ ] Saved remote full button list
-    - [ ] Delete saved remote file
-    - [ ] Edit saved remote file
+    - [x] General button page
+    - [x] Control buttons pag
+    - [x] Navigation buttons page
+    - [x] Player buttons page
+    - [ ] Custom buttons page
+    - [ ] Full button list
+    - [ ] Delete remote file
+    - [ ] Edit remote file
 - [ ] Application settings
 - [ ] Application settings
-    - [ ] Vertical/Horizontal menu setting
-    - [ ] Infrared command repeat count
+    - [ ] Vertical/Horizontal menu
+    - [ ] IR command repeat count
 
 
 ## Screens
 ## Screens
 
 
@@ -37,15 +37,15 @@ Main menu
 </p>
 </p>
 
 
 <p align="center">
 <p align="center">
-Saved remote menu and control
+Saved remote menu
 </p>
 </p>
 <p align="center">
 <p align="center">
-    <img src="https://github.com/kala13x/flipper-xremote/blob/main/screens/control.png" alt="XRemote main menu">
+    <img src="https://github.com/kala13x/flipper-xremote/blob/main/screens/saved_remote_menu.png" alt="XRemote main menu">
 </p>
 </p>
 
 
 <p align="center">
 <p align="center">
-Saved remote menu and playback
+Saved remote categorized controllers
 </p>
 </p>
 <p align="center">
 <p align="center">
-    <img src="https://github.com/kala13x/flipper-xremote/blob/main/screens/playback.png" alt="XRemote main menu">
+    <img src="https://github.com/kala13x/flipper-xremote/blob/main/screens/saved_remote_apps.png" alt="XRemote main menu">
 </p>
 </p>

BIN
screens/app_menu.png


BIN
screens/control.png


BIN
screens/control_2.png


BIN
screens/playback.png


BIN
screens/saved_remote_apps.png


BIN
screens/saved_remote_menu.png


+ 16 - 2
views/xremote_common_view.c

@@ -231,7 +231,21 @@ void xremote_canvas_draw_button_wide(Canvas* canvas, bool pressed, uint8_t x, ui
         canvas_set_color(canvas, ColorWhite);
         canvas_set_color(canvas, ColorWhite);
     }
     }
 
 
-    xremote_canvas_draw_icon(canvas, x + 16, y + 7, icon);
-    elements_multiline_text_aligned(canvas, x + 26, y + 10, AlignLeft, AlignBottom, text);
+    xremote_canvas_draw_icon(canvas, x + 15, y + 7, icon);
+    elements_multiline_text_aligned(canvas, x + 22, y + 10, AlignLeft, AlignBottom, text);
     canvas_set_color(canvas, ColorBlack);
     canvas_set_color(canvas, ColorBlack);
 }
 }
+
+void xremote_canvas_draw_frame(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, uint8_t xl, const char *text)
+{
+    elements_slightly_rounded_frame(canvas, x, y, xl, 15);
+
+    if (pressed)
+    {
+        elements_slightly_rounded_box(canvas, x + 2, y + 2, xl - 4, 11);
+        canvas_set_color(canvas, ColorWhite);
+    }
+
+    canvas_draw_str(canvas, x + 3, y + 11, text);
+    canvas_set_color(canvas, ColorBlack);
+}

+ 11 - 8
views/xremote_common_view.h

@@ -30,18 +30,20 @@
 #define XREMOTE_COMMAND_DOWN            "Down"
 #define XREMOTE_COMMAND_DOWN            "Down"
 #define XREMOTE_COMMAND_LEFT            "Left"
 #define XREMOTE_COMMAND_LEFT            "Left"
 #define XREMOTE_COMMAND_RIGHT           "Right"
 #define XREMOTE_COMMAND_RIGHT           "Right"
-#define XREMOTE_COMMAND_JUMP_FORWARD    "Jump_forward"
-#define XREMOTE_COMMAND_JUMP_BACKWARD   "Jump_backward"
-#define XREMOTE_COMMAND_FAST_FORWARD    "Fast_forward"
-#define XREMOTE_COMMAND_FAST_BACKWARD   "Fast_backward"
-#define XREMOTE_COMMAND_PAUSE_PLAY      "Pause_play"
+#define XREMOTE_COMMAND_JUMP_FORWARD    "Jump_fo"
+#define XREMOTE_COMMAND_JUMP_BACKWARD   "Jump_ba"
+#define XREMOTE_COMMAND_FAST_FORWARD    "Fast_fo"
+#define XREMOTE_COMMAND_FAST_BACKWARD   "Fast_ba"
+#define XREMOTE_COMMAND_PLAY_PAUSE      "Play_pa"
 #define XREMOTE_COMMAND_PAUSE           "Pause"
 #define XREMOTE_COMMAND_PAUSE           "Pause"
 #define XREMOTE_COMMAND_PLAY            "Play"
 #define XREMOTE_COMMAND_PLAY            "Play"
 #define XREMOTE_COMMAND_STOP            "Stop"
 #define XREMOTE_COMMAND_STOP            "Stop"
+#define XREMOTE_COMMAND_MUTE            "Mute"
+#define XREMOTE_COMMAND_MODE            "Mode"
 #define XREMOTE_COMMAND_VOL_UP          "Vol_up"
 #define XREMOTE_COMMAND_VOL_UP          "Vol_up"
-#define XREMOTE_COMMAND_VOL_DOWN        "Vol_down"
-#define XREMOTE_COMMAND_NEXT_CHAN       "Next_chan"
-#define XREMOTE_COMMAND_PREV_CHAN       "Prev_chan"
+#define XREMOTE_COMMAND_VOL_DOWN        "Vol_dn"
+#define XREMOTE_COMMAND_NEXT_CHAN       "Ch_next"
+#define XREMOTE_COMMAND_PREV_CHAN       "Ch_prev"
 
 
 typedef enum {
 typedef enum {
     /* Navigation */
     /* Navigation */
@@ -102,6 +104,7 @@ void xremote_canvas_draw_exit_footer(Canvas* canvas, char *text);
 void xremote_canvas_draw_icon(Canvas* canvas, uint8_t x, uint8_t y, XRemoteIcon icon);
 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(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, XRemoteIcon 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_wide(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, 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);
 
 
 XRemoteView* xremote_view_alloc(NotificationApp* notifications, ViewInputCallback input_cb, ViewDrawCallback draw_cb);
 XRemoteView* xremote_view_alloc(NotificationApp* notifications, ViewInputCallback input_cb, ViewDrawCallback draw_cb);
 void xremote_view_free(XRemoteView* rview);
 void xremote_view_free(XRemoteView* rview);

+ 66 - 4
views/xremote_control_view.c

@@ -10,15 +10,77 @@
 
 
 static void xremote_control_view_draw_callback(Canvas* canvas, void* context)
 static void xremote_control_view_draw_callback(Canvas* canvas, void* context)
 {
 {
-    (void)context;
+    furi_assert(context);
+    XRemoteViewModel* model = context;
+
     xremote_canvas_draw_header(canvas, "Control");
     xremote_canvas_draw_header(canvas, "Control");
-    canvas_set_font(canvas, FontSecondary);
-    canvas_draw_str(canvas, 0, 70, "Coming Soon");
+    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);
     xremote_canvas_draw_exit_footer(canvas, "Press to exit");
     xremote_canvas_draw_exit_footer(canvas, "Press to exit");
 }
 }
 
 
+static void xremote_control_view_process(XRemoteView* view, InputEvent* event)
+{
+    with_view_model(
+        xremote_view_get_view(view),
+        XRemoteViewModel* model,
+        {
+            if (event->type == InputTypePress)
+            {
+                if (event->key == InputKeyOk)
+                {
+                    model->ok_pressed = true;
+                    xremote_view_send_ir(view, XREMOTE_COMMAND_MUTE);
+                }
+                else if (event->key == InputKeyUp)
+                {
+                    model->up_pressed = true;
+                    xremote_view_send_ir(view, XREMOTE_COMMAND_VOL_UP);
+                }
+                else if (event->key == InputKeyDown)
+                {
+                    model->down_pressed = true;
+                    xremote_view_send_ir(view, XREMOTE_COMMAND_VOL_DOWN);
+                }
+                else if (event->key == InputKeyLeft)
+                {
+                    model->left_pressed = true;
+                    xremote_view_send_ir(view, XREMOTE_COMMAND_PREV_CHAN);
+                }
+                else if (event->key == InputKeyRight)
+                {
+                    model->right_pressed = true;
+                    xremote_view_send_ir(view, XREMOTE_COMMAND_NEXT_CHAN);
+                }
+            }
+            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;
+            }
+        },
+        true);
+}
+
+static bool xremote_control_view_input_callback(InputEvent* event, void* context)
+{
+    furi_assert(context);
+    XRemoteView* view = (XRemoteView*)context;
+    if (event->key == InputKeyBack) return false;
+
+    xremote_control_view_process(view, event);
+    return true;
+}
+
 XRemoteView* xremote_control_view_alloc(NotificationApp* notifications)
 XRemoteView* xremote_control_view_alloc(NotificationApp* notifications)
 {
 {
     return xremote_view_alloc(notifications,
     return xremote_view_alloc(notifications,
-        NULL, xremote_control_view_draw_callback);
+        xremote_control_view_input_callback,
+        xremote_control_view_draw_callback);
 }
 }

+ 4 - 4
views/xremote_general_view.c

@@ -17,8 +17,8 @@ static void xremote_general_view_draw_callback(Canvas* canvas, void* context)
     xremote_canvas_draw_button_wide(canvas, model->ok_pressed, 0, 27, "Power", XRemoteIconEnter);
     xremote_canvas_draw_button_wide(canvas, model->ok_pressed, 0, 27, "Power", XRemoteIconEnter);
     xremote_canvas_draw_button_wide(canvas, model->up_pressed, 0, 45, "Input", XRemoteIconArrowUp);
     xremote_canvas_draw_button_wide(canvas, model->up_pressed, 0, 45, "Input", XRemoteIconArrowUp);
     xremote_canvas_draw_button_wide(canvas, model->down_pressed, 0, 63, "Setup", XRemoteIconArrowDown);
     xremote_canvas_draw_button_wide(canvas, model->down_pressed, 0, 63, "Setup", XRemoteIconArrowDown);
-    xremote_canvas_draw_button_wide(canvas, model->left_pressed, 0, 81, "List", XRemoteIconArrowLeft);
-    xremote_canvas_draw_button_wide(canvas, model->right_pressed, 0, 99, "Menu", XRemoteIconArrowRight);
+    xremote_canvas_draw_button_wide(canvas, model->left_pressed, 0, 81, "Menu", XRemoteIconArrowLeft);
+    xremote_canvas_draw_button_wide(canvas, model->right_pressed, 0, 99, "List", XRemoteIconArrowRight);
     xremote_canvas_draw_exit_footer(canvas, "Press to exit");
     xremote_canvas_draw_exit_footer(canvas, "Press to exit");
 }
 }
 
 
@@ -48,12 +48,12 @@ static void xremote_general_view_process(XRemoteView* view, InputEvent* event)
                 else if (event->key == InputKeyLeft)
                 else if (event->key == InputKeyLeft)
                 {
                 {
                     model->left_pressed = true;
                     model->left_pressed = true;
-                    xremote_view_send_ir(view, XREMOTE_COMMAND_LIST);
+                    xremote_view_send_ir(view, XREMOTE_COMMAND_MENU);
                 }
                 }
                 else if (event->key == InputKeyRight)
                 else if (event->key == InputKeyRight)
                 {
                 {
                     model->right_pressed = true;
                     model->right_pressed = true;
-                    xremote_view_send_ir(view, XREMOTE_COMMAND_MENU);
+                    xremote_view_send_ir(view, XREMOTE_COMMAND_LIST);
                 }
                 }
             }
             }
             else if (event->type == InputTypeRelease)
             else if (event->type == InputTypeRelease)

+ 1 - 1
views/xremote_player_view.c

@@ -54,7 +54,7 @@ static void xremote_player_view_process(XRemoteView* view, InputEvent* event)
                 else if (event->key == InputKeyOk)
                 else if (event->key == InputKeyOk)
                 {
                 {
                     model->ok_pressed = true;
                     model->ok_pressed = true;
-                    xremote_view_send_ir(view, XREMOTE_COMMAND_PAUSE_PLAY);
+                    xremote_view_send_ir(view, XREMOTE_COMMAND_PLAY_PAUSE);
                 }
                 }
                 else if (event->key == InputKeyBack)
                 else if (event->key == InputKeyBack)
                 {
                 {

+ 1 - 1
xremote.h

@@ -10,6 +10,6 @@
 
 
 #define XREMOTE_VERSION_MAJOR  0
 #define XREMOTE_VERSION_MAJOR  0
 #define XREMOTE_VERSION_MINOR  9
 #define XREMOTE_VERSION_MINOR  9
-#define XREMOTE_BUILD_NUMBER   15
+#define XREMOTE_BUILD_NUMBER   16
 
 
 void xremote_get_version(char *version, size_t length);
 void xremote_get_version(char *version, size_t length);

+ 3 - 4
xremote_app.c

@@ -103,12 +103,11 @@ void xremote_app_submenu_alloc(XRemoteApp* app, uint32_t index, ViewNavigationCa
     app->submenu = submenu_alloc();
     app->submenu = submenu_alloc();
     app->submenu_id = index;
     app->submenu_id = index;
 
 
-    View* view = submenu_get_view(app->submenu);
-    view_set_orientation(view, ViewOrientationVertical);
-    view_set_previous_callback(view, prev_cb);
+    submenu_set_orientation(app->submenu, ViewOrientationVertical);
+    view_set_previous_callback(submenu_get_view(app->submenu), prev_cb);
 
 
     ViewDispatcher* view_disp = app->app_ctx->view_dispatcher;
     ViewDispatcher* view_disp = app->app_ctx->view_dispatcher;
-    view_dispatcher_add_view(view_disp, app->submenu_id, view);
+    view_dispatcher_add_view(view_disp, app->submenu_id, submenu_get_view(app->submenu));
 }
 }
 
 
 void xremote_app_submenu_free(XRemoteApp *app)
 void xremote_app_submenu_free(XRemoteApp *app)