Просмотр исходного кода

Universal Projector Remote (#2343)

Co-authored-by: Georgii Surkov <georgii.surkov@outlook.com>
Co-authored-by: あく <alleteam@gmail.com>
itsweekly 2 лет назад
Родитель
Сommit
39841bd5a9

+ 1 - 1
applications/main/infrared/infrared_cli.c

@@ -86,7 +86,7 @@ static void infrared_cli_print_usage(void) {
     printf("\tir universal <remote_name> <signal_name>\r\n");
     printf("\tir universal list <remote_name>\r\n");
     // TODO: Do not hardcode universal remote names
-    printf("\tAvailable universal remotes: tv audio ac\r\n");
+    printf("\tAvailable universal remotes: tv audio ac projector\r\n");
 }
 
 static void infrared_cli_start_ir_rx(Cli* cli, FuriString* args) {

+ 1 - 0
applications/main/infrared/scenes/infrared_scene_config.h

@@ -17,6 +17,7 @@ ADD_SCENE(infrared, universal, Universal)
 ADD_SCENE(infrared, universal_tv, UniversalTV)
 ADD_SCENE(infrared, universal_ac, UniversalAC)
 ADD_SCENE(infrared, universal_audio, UniversalAudio)
+ADD_SCENE(infrared, universal_projector, UniversalProjector)
 ADD_SCENE(infrared, debug, Debug)
 ADD_SCENE(infrared, error_databases, ErrorDatabases)
 ADD_SCENE(infrared, rpc, Rpc)

+ 11 - 1
applications/main/infrared/scenes/infrared_scene_universal.c

@@ -4,6 +4,7 @@ typedef enum {
     SubmenuIndexUniversalTV,
     SubmenuIndexUniversalAC,
     SubmenuIndexUniversalAudio,
+    SubmenuIndexUniversalProjector,
 } SubmenuIndex;
 
 static void infrared_scene_universal_submenu_callback(void* context, uint32_t index) {
@@ -27,6 +28,12 @@ void infrared_scene_universal_on_enter(void* context) {
         SubmenuIndexUniversalAudio,
         infrared_scene_universal_submenu_callback,
         context);
+    submenu_add_item(
+        submenu,
+        "Projectors",
+        SubmenuIndexUniversalProjector,
+        infrared_scene_universal_submenu_callback,
+        context);
     submenu_add_item(
         submenu,
         "Air Conditioners",
@@ -54,6 +61,9 @@ bool infrared_scene_universal_on_event(void* context, SceneManagerEvent event) {
         } else if(event.event == SubmenuIndexUniversalAudio) {
             scene_manager_next_scene(scene_manager, InfraredSceneUniversalAudio);
             consumed = true;
+        } else if(event.event == SubmenuIndexUniversalProjector) {
+            scene_manager_next_scene(scene_manager, InfraredSceneUniversalProjector);
+            consumed = true;
         }
         scene_manager_set_scene_state(scene_manager, InfraredSceneUniversal, event.event);
     }
@@ -64,4 +74,4 @@ bool infrared_scene_universal_on_event(void* context, SceneManagerEvent event) {
 void infrared_scene_universal_on_exit(void* context) {
     Infrared* infrared = context;
     submenu_reset(infrared->submenu);
-}
+}

+ 86 - 0
applications/main/infrared/scenes/infrared_scene_universal_projector.c

@@ -0,0 +1,86 @@
+#include "../infrared_i.h"
+
+#include "common/infrared_scene_universal_common.h"
+
+void infrared_scene_universal_projector_on_enter(void* context) {
+    infrared_scene_universal_common_on_enter(context);
+
+    Infrared* infrared = context;
+    ButtonPanel* button_panel = infrared->button_panel;
+    InfraredBruteForce* brute_force = infrared->brute_force;
+
+    infrared_brute_force_set_db_filename(brute_force, EXT_PATH("infrared/assets/projector.ir"));
+
+    button_panel_reserve(button_panel, 2, 2);
+    uint32_t i = 0;
+    button_panel_add_item(
+        button_panel,
+        i,
+        0,
+        0,
+        3,
+        19,
+        &I_Power_25x27,
+        &I_Power_hvr_25x27,
+        infrared_scene_universal_common_item_callback,
+        context);
+    infrared_brute_force_add_record(brute_force, i++, "Power");
+    button_panel_add_item(
+        button_panel,
+        i,
+        1,
+        0,
+        36,
+        19,
+        &I_Mute_25x27,
+        &I_Mute_hvr_25x27,
+        infrared_scene_universal_common_item_callback,
+        context);
+    infrared_brute_force_add_record(brute_force, i++, "Mute");
+    button_panel_add_item(
+        button_panel,
+        i,
+        0,
+        1,
+        3,
+        66,
+        &I_Vol_up_25x27,
+        &I_Vol_up_hvr_25x27,
+        infrared_scene_universal_common_item_callback,
+        context);
+    infrared_brute_force_add_record(brute_force, i++, "Vol_up");
+    button_panel_add_item(
+        button_panel,
+        i,
+        1,
+        1,
+        36,
+        66,
+        &I_Vol_down_25x27,
+        &I_Vol_down_hvr_25x27,
+        infrared_scene_universal_common_item_callback,
+        context);
+    infrared_brute_force_add_record(brute_force, i++, "Vol_dn");
+
+    button_panel_add_label(button_panel, 2, 11, FontPrimary, "Proj. remote");
+    button_panel_add_label(button_panel, 17, 62, FontSecondary, "Volume");
+
+    view_set_orientation(view_stack_get_view(infrared->view_stack), ViewOrientationVertical);
+    view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewStack);
+
+    infrared_show_loading_popup(infrared, true);
+    bool success = infrared_brute_force_calculate_messages(brute_force);
+    infrared_show_loading_popup(infrared, false);
+
+    if(!success) {
+        scene_manager_next_scene(infrared->scene_manager, InfraredSceneErrorDatabases);
+    }
+}
+
+bool infrared_scene_universal_projector_on_event(void* context, SceneManagerEvent event) {
+    return infrared_scene_universal_common_on_event(context, event);
+}
+
+void infrared_scene_universal_projector_on_exit(void* context) {
+    infrared_scene_universal_common_on_exit(context);
+}

Разница между файлами не показана из-за своего большого размера
+ 204 - 0
assets/resources/infrared/assets/projector.ir


+ 7 - 0
documentation/UniversalRemotes.md

@@ -25,6 +25,13 @@ Make sure that every signal does what it's supposed to.
 
 If everything checks out, append these signals **to the end** of the [audio player universal remote file](/assets/resources/infrared/assets/audio.ir).
 
+## Projectors
+
+Adding your projector to the universal remote is really simple. Up to 4 signals can be recorded: `Power`, `Mute`, `Vol_up`, `Vol_dn`. Any of them can be omitted if not supported by your projector.
+To save time, please make sure every recording has been named accordingly.
+In case of omitting, on most projectors with the 4 following buttons, you should not have a problem.
+
+
 ## Air conditioners
 
 Air conditioners differ from most other infrared-controlled devices because their state is tracked by the remote.

Некоторые файлы не были показаны из-за большого количества измененных файлов