From 20f59bb8eb332020749d295753ede8f183a7dbc2 Mon Sep 17 00:00:00 2001 From: KlausMu Date: Mon, 29 Jan 2024 12:22:41 +0100 Subject: [PATCH] detailled definition of key layout for the diferrent scenes --- Platformio/src/commandHandler.h | 2 +- .../src/gui_general_and_keys/gui_numpad.cpp | 19 ++++++-- Platformio/src/scenes/sceneRegistry.cpp | 44 +++++++++---------- Platformio/src/scenes/sceneRegistry.h | 6 +-- Platformio/src/scenes/scene_TV.cpp | 44 +++++++++---------- Platformio/src/scenes/scene_TV.h | 1 + Platformio/src/scenes/scene_allOff.cpp | 44 +++++++++---------- Platformio/src/scenes/scene_allOff.h | 1 + Platformio/src/scenes/scene_chromecast.cpp | 44 +++++++++---------- Platformio/src/scenes/scene_chromecast.h | 1 + Platformio/src/scenes/scene_fireTV.cpp | 32 +++++++------- Platformio/src/scenes/scene_fireTV.h | 1 + 12 files changed, 127 insertions(+), 112 deletions(-) diff --git a/Platformio/src/commandHandler.h b/Platformio/src/commandHandler.h index d7001bb..3d2c5cb 100644 --- a/Platformio/src/commandHandler.h +++ b/Platformio/src/commandHandler.h @@ -97,7 +97,7 @@ enum commandHandlers { SPECIAL, - SCENE + SCENE, IR_GC, IR_NEC, IR_SAMSUNG, diff --git a/Platformio/src/gui_general_and_keys/gui_numpad.cpp b/Platformio/src/gui_general_and_keys/gui_numpad.cpp index d7589f3..6fbedc3 100644 --- a/Platformio/src/gui_general_and_keys/gui_numpad.cpp +++ b/Platformio/src/gui_general_and_keys/gui_numpad.cpp @@ -1,8 +1,12 @@ #include #include "hardware/tft.h" +#include "device_samsungTV/device_samsungTV.h" #include "gui_general_and_keys/guiBase.h" #include "gui_general_and_keys/guiRegistry.h" #include "commandHandler.h" +#include "scenes/sceneHandler.h" +#include "scenes/scene_TV.h" +#include "scenes/scene_fireTV.h" // Virtual Keypad Event handler static void virtualKeypad_event_cb(lv_event_t* e) { @@ -11,10 +15,17 @@ static void virtualKeypad_event_cb(lv_event_t* e) { if (target == cont) return; // stop if container was clicked // send corrensponding number - byte virtualKeyMapFireTVNumbers[10] = {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x0}; - int number = virtualKeyMapFireTVNumbers[(int)target->user_data]; - std::string numberStr = std::to_string(number); - executeCommand(KEYBOARD_SENDSTRING, numberStr); + if (currentScene == scene_name_TV) { + std::string virtualKeyMapTVNumbers[10] = {SAMSUNG_NUM_1, SAMSUNG_NUM_2, SAMSUNG_NUM_3, SAMSUNG_NUM_4, SAMSUNG_NUM_5, SAMSUNG_NUM_6, SAMSUNG_NUM_7, SAMSUNG_NUM_8, SAMSUNG_NUM_9, SAMSUNG_NUM_0}; + std::string command = virtualKeyMapTVNumbers[(int)target->user_data]; + executeCommand(command); + + } else if (currentScene == scene_name_fireTV) { + byte virtualKeyMapFireTVNumbers[10] = {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x0}; + int number = virtualKeyMapFireTVNumbers[(int)target->user_data]; + std::string numberStr = std::to_string(number); + executeCommand(KEYBOARD_SENDSTRING, numberStr); + } } void init_gui_tab_numpad(lv_obj_t* tabview) { diff --git a/Platformio/src/scenes/sceneRegistry.cpp b/Platformio/src/scenes/sceneRegistry.cpp index 1ad4f15..92a2d83 100644 --- a/Platformio/src/scenes/sceneRegistry.cpp +++ b/Platformio/src/scenes/sceneRegistry.cpp @@ -1,8 +1,8 @@ -#include #include -#include "scenes/sceneregistry.h" +#include #include "device_samsungTV/device_samsungTV.h" #include "device_yamahaAmp/device_yamahaAmp.h" +#include "scenes/sceneRegistry.h" #include "scenes/scene_allOff.h" #include "scenes/scene_TV.h" #include "scenes/scene_fireTV.h" @@ -10,34 +10,34 @@ #include "commandHandler.h" std::map key_repeatModes_default { - {'o', SHORT }, - {'=', SHORT }, {'<', SHORTorLONG }, {'p', SHORT }, {'>', SHORTorLONG }, - {'c', SHORT }, {'i', SHORT }, - {'u', SHORT }, - {'l', SHORT }, {'k', SHORT }, {'r', SHORT }, - {'d', SHORT }, - {'b', SHORT }, {'s', SHORT }, - {'+', SHORT_REPEATED}, {'m', SHORT }, {'^', SHORT }, - {'-', SHORT_REPEATED}, {'e', SHORT }, {'v', SHORT }, - {'1', SHORT }, {'2', SHORT }, {'3', SHORT }, {'4', SHORT }, + {'o', SHORT }, + {'=', SHORT }, {'<', SHORTorLONG }, {'p', SHORT }, {'>', SHORTorLONG }, + {'c', SHORT }, {'i', SHORT }, + {'u', SHORT }, + {'l', SHORT }, {'k', SHORT }, {'r', SHORT }, + {'d', SHORT }, + {'b', SHORT }, {'s', SHORT }, + {'+', SHORT_REPEATED}, {'m', SHORT }, {'^', SHORT }, + {'-', SHORT_REPEATED}, {'e', SHORT }, {'v', SHORT }, + {'1', SHORT }, {'2', SHORT }, {'3', SHORT }, {'4', SHORT }, }; std::map key_commands_short_default { {'o', SCENE_ALLOFF}, -/*{'=', KEYBOARD_PLAYPAUSE},*/ {'<', KEYBOARD_REWIND}, {'p', KEYBOARD_PLAYPAUSE}, {'>', KEYBOARD_FASTFORWARD}, - {'c', KEYBOARD_HOME}, {'i', KEYBOARD_MENU}, - {'u', KEYBOARD_UP}, - {'l', KEYBOARD_LEFT}, {'k', KEYBOARD_SELECT}, {'r', KEYBOARD_RIGHT}, - {'d', KEYBOARD_DOWN}, - /* {'b', }, */ {'s', KEYBOARD_BACK}, - {'+', YAMAHA_VOL_PLUS}, {'m', YAMAHA_MUTE_TOGGLE}, {'^', SAMSUNG_CHANNEL_UP}, - {'-', YAMAHA_VOL_MINUS}, /* {'e', }, */ {'v', SAMSUNG_CHANNEL_DOWN}, +/*{'=', COMMAND_UNKNOWN},*/ /*{'<', COMMAND_UNKNOWN},*/ /*{'p', COMMAND_UNKNOWN},*/ /*{'>', COMMAND_UNKNOWN},*/ +/*{'c', COMMAND_UNKNOWN}, */ /*{'i', COMMAND_UNKNOWN},*/ + /*{'u', COMMAND_UNKNOWN},*/ + /*{'l', COMMAND_UNKNOWN},*/ /*{'k', COMMAND_UNKNOWN},*/ /*{'r', COMMAND_UNKNOWN},*/ + /*{'d', COMMAND_UNKNOWN},*/ +/* {'b', COMMAND_UNKNOWN},*/ /*{'s', COMMAND_UNKNOWN},*/ + {'+', YAMAHA_VOL_PLUS}, {'m', YAMAHA_MUTE_TOGGLE}, /*{'^', COMMAND_UNKNOWN},*/ + {'-', YAMAHA_VOL_MINUS}, /*{'e', COMMAND_UNKNOWN},*/ /*{'v', COMMAND_UNKNOWN},*/ {'1', SCENE_TV}, {'2', SCENE_FIRETV}, {'3', SCENE_CHROMECAST}, {'4', YAMAHA_STANDARD}, }; std::map key_commands_long_default { - {'<', KEYBOARD_REWIND_LONG}, - {'>', KEYBOARD_FASTFORWARD_LONG}, + + }; // https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work diff --git a/Platformio/src/scenes/sceneRegistry.h b/Platformio/src/scenes/sceneRegistry.h index 9d34035..1a8a8b6 100644 --- a/Platformio/src/scenes/sceneRegistry.h +++ b/Platformio/src/scenes/sceneRegistry.h @@ -1,5 +1,5 @@ -#ifndef __SCENE_REGISTRY_H__ -#define __SCENE_REGISTRY_H__ +#ifndef __SCENEREGISTRY_H__ +#define __SCENEREGISTRY_H__ #include #include "gui_general_and_keys/keys.h" @@ -27,4 +27,4 @@ repeatModes get_key_repeatMode(std::string sceneName, char keyChar); std::string get_command_short(std::string sceneName, char keyChar); std::string get_command_long(std::string sceneName, char keyChar); -#endif /*__SCENE_REGISTRY_H__*/ +#endif /*__SCENEREGISTRY_H__*/ diff --git a/Platformio/src/scenes/scene_TV.cpp b/Platformio/src/scenes/scene_TV.cpp index 1fd2ce4..98db302 100644 --- a/Platformio/src/scenes/scene_TV.cpp +++ b/Platformio/src/scenes/scene_TV.cpp @@ -10,34 +10,34 @@ #include "commandHandler.h" std::map key_repeatModes_TV { - {'o', SHORT }, - {'=', SHORT }, {'<', SHORTorLONG }, {'p', SHORT }, {'>', SHORTorLONG }, - {'c', SHORT }, {'i', SHORT }, - {'u', SHORT }, - {'l', SHORT }, {'k', SHORT }, {'r', SHORT }, - {'d', SHORT }, - {'b', SHORT }, {'s', SHORT }, - {'+', SHORT_REPEATED}, {'m', SHORT }, {'^', SHORT }, - {'-', SHORT_REPEATED}, {'e', SHORT }, {'v', SHORT }, - {'1', SHORT }, {'2', SHORT }, {'3', SHORT }, {'4', SHORT }, + + {'=', SHORT_REPEATED}, {'<', SHORT }, {'p', SHORT }, {'>', SHORT_REPEATED }, + {'c', SHORT }, {'i', SHORT }, + {'u', SHORT_REPEATED}, + {'l', SHORT_REPEATED}, {'k', SHORT}, {'r', SHORT_REPEATED}, + {'d', SHORT_REPEATED}, + {'s', SHORT }, + {'^', SHORT }, + {'v', SHORT }, + }; std::map key_commands_short_TV { - {'o', SCENE_ALLOFF}, -/*{'=', KEYBOARD_PLAYPAUSE},*/ {'<', KEYBOARD_REWIND}, {'p', KEYBOARD_PLAYPAUSE}, {'>', KEYBOARD_FASTFORWARD}, - {'c', KEYBOARD_HOME}, {'i', KEYBOARD_MENU}, - {'u', KEYBOARD_UP}, - {'l', KEYBOARD_LEFT}, {'k', KEYBOARD_SELECT}, {'r', KEYBOARD_RIGHT}, - {'d', KEYBOARD_DOWN}, - /* {'b', }, */ {'s', KEYBOARD_BACK}, - {'+', YAMAHA_VOL_PLUS}, {'m', YAMAHA_MUTE_TOGGLE}, {'^', SAMSUNG_CHANNEL_UP}, - {'-', YAMAHA_VOL_MINUS}, /* {'e', }, */ {'v', SAMSUNG_CHANNEL_DOWN}, - {'1', SCENE_TV}, {'2', SCENE_FIRETV}, {'3', SCENE_CHROMECAST}, {'4', YAMAHA_STANDARD}, + + {'=', SAMSUNG_REWIND}, {'<', SAMSUNG_PAUSE}, {'p', SAMSUNG_PLAY}, {'>', SAMSUNG_FASTFORWARD}, + {'c', SAMSUNG_GUIDE}, {'i', SAMSUNG_MENU}, + {'u', SAMSUNG_UP}, + {'l', SAMSUNG_LEFT}, {'k', SAMSUNG_SELECT}, {'r', SAMSUNG_RIGHT}, + {'d', SAMSUNG_DOWN}, + {'s', SAMSUNG_EXIT}, + {'^', SAMSUNG_CHANNEL_UP}, + {'v', SAMSUNG_CHANNEL_DOWN}, + }; std::map key_commands_long_TV { - {'<', KEYBOARD_REWIND_LONG}, - {'>', KEYBOARD_FASTFORWARD_LONG}, + + }; void scene_start_sequence_TV(void) { diff --git a/Platformio/src/scenes/scene_TV.h b/Platformio/src/scenes/scene_TV.h index d5f1fe5..415f290 100644 --- a/Platformio/src/scenes/scene_TV.h +++ b/Platformio/src/scenes/scene_TV.h @@ -3,6 +3,7 @@ #define SCENE_TV "Scene_tv" +extern std::string scene_name_TV; void register_scene_TV(void); #endif /*__SCENE_TV_H__*/ diff --git a/Platformio/src/scenes/scene_allOff.cpp b/Platformio/src/scenes/scene_allOff.cpp index 2908f6e..ca21024 100644 --- a/Platformio/src/scenes/scene_allOff.cpp +++ b/Platformio/src/scenes/scene_allOff.cpp @@ -10,34 +10,34 @@ #include "commandHandler.h" std::map key_repeatModes_allOff { - {'o', SHORT }, - {'=', SHORT }, {'<', SHORTorLONG }, {'p', SHORT }, {'>', SHORTorLONG }, - {'c', SHORT }, {'i', SHORT }, - {'u', SHORT }, - {'l', SHORT }, {'k', SHORT }, {'r', SHORT }, - {'d', SHORT }, - {'b', SHORT }, {'s', SHORT }, - {'+', SHORT_REPEATED}, {'m', SHORT }, {'^', SHORT }, - {'-', SHORT_REPEATED}, {'e', SHORT }, {'v', SHORT }, - {'1', SHORT }, {'2', SHORT }, {'3', SHORT }, {'4', SHORT }, + + + + + + + + + + }; std::map key_commands_short_allOff { - {'o', SCENE_ALLOFF}, -/*{'=', KEYBOARD_PLAYPAUSE},*/ {'<', KEYBOARD_REWIND}, {'p', KEYBOARD_PLAYPAUSE}, {'>', KEYBOARD_FASTFORWARD}, - {'c', KEYBOARD_HOME}, {'i', KEYBOARD_MENU}, - {'u', KEYBOARD_UP}, - {'l', KEYBOARD_LEFT}, {'k', KEYBOARD_SELECT}, {'r', KEYBOARD_RIGHT}, - {'d', KEYBOARD_DOWN}, - /* {'b', }, */ {'s', KEYBOARD_BACK}, - {'+', YAMAHA_VOL_PLUS}, {'m', YAMAHA_MUTE_TOGGLE}, {'^', SAMSUNG_CHANNEL_UP}, - {'-', YAMAHA_VOL_MINUS}, /* {'e', }, */ {'v', SAMSUNG_CHANNEL_DOWN}, - {'1', SCENE_TV}, {'2', SCENE_FIRETV}, {'3', SCENE_CHROMECAST}, {'4', YAMAHA_STANDARD}, + + + + + + + + + + }; std::map key_commands_long_allOff { - {'<', KEYBOARD_REWIND_LONG}, - {'>', KEYBOARD_FASTFORWARD_LONG}, + + }; void scene_start_sequence_allOff(void) { diff --git a/Platformio/src/scenes/scene_allOff.h b/Platformio/src/scenes/scene_allOff.h index c4a9307..91b639c 100644 --- a/Platformio/src/scenes/scene_allOff.h +++ b/Platformio/src/scenes/scene_allOff.h @@ -3,6 +3,7 @@ #define SCENE_ALLOFF "Scene_allOff" +extern std::string scene_name_allOff; void register_scene_allOff(void); #endif /*__SCENE_ALLOFF_H__*/ diff --git a/Platformio/src/scenes/scene_chromecast.cpp b/Platformio/src/scenes/scene_chromecast.cpp index 2dfc68d..51c9d11 100644 --- a/Platformio/src/scenes/scene_chromecast.cpp +++ b/Platformio/src/scenes/scene_chromecast.cpp @@ -10,34 +10,34 @@ #include "commandHandler.h" std::map key_repeatModes_chromecast { - {'o', SHORT }, - {'=', SHORT }, {'<', SHORTorLONG }, {'p', SHORT }, {'>', SHORTorLONG }, - {'c', SHORT }, {'i', SHORT }, - {'u', SHORT }, - {'l', SHORT }, {'k', SHORT }, {'r', SHORT }, - {'d', SHORT }, - {'b', SHORT }, {'s', SHORT }, - {'+', SHORT_REPEATED}, {'m', SHORT }, {'^', SHORT }, - {'-', SHORT_REPEATED}, {'e', SHORT }, {'v', SHORT }, - {'1', SHORT }, {'2', SHORT }, {'3', SHORT }, {'4', SHORT }, + + + + + + + + + + }; std::map key_commands_short_chromecast { - {'o', SCENE_ALLOFF}, -/*{'=', KEYBOARD_PLAYPAUSE},*/ {'<', KEYBOARD_REWIND}, {'p', KEYBOARD_PLAYPAUSE}, {'>', KEYBOARD_FASTFORWARD}, - {'c', KEYBOARD_HOME}, {'i', KEYBOARD_MENU}, - {'u', KEYBOARD_UP}, - {'l', KEYBOARD_LEFT}, {'k', KEYBOARD_SELECT}, {'r', KEYBOARD_RIGHT}, - {'d', KEYBOARD_DOWN}, - /* {'b', }, */ {'s', KEYBOARD_BACK}, - {'+', YAMAHA_VOL_PLUS}, {'m', YAMAHA_MUTE_TOGGLE}, {'^', SAMSUNG_CHANNEL_UP}, - {'-', YAMAHA_VOL_MINUS}, /* {'e', }, */ {'v', SAMSUNG_CHANNEL_DOWN}, - {'1', SCENE_TV}, {'2', SCENE_FIRETV}, {'3', SCENE_CHROMECAST}, {'4', YAMAHA_STANDARD}, + + + + + + + + + + }; std::map key_commands_long_chromecast { - {'<', KEYBOARD_REWIND_LONG}, - {'>', KEYBOARD_FASTFORWARD_LONG}, + + }; void scene_start_sequence_chromecast(void) { diff --git a/Platformio/src/scenes/scene_chromecast.h b/Platformio/src/scenes/scene_chromecast.h index f73ee4e..87a8865 100644 --- a/Platformio/src/scenes/scene_chromecast.h +++ b/Platformio/src/scenes/scene_chromecast.h @@ -3,6 +3,7 @@ #define SCENE_CHROMECAST "Scene_chromecast" +extern std::string scene_name_chromecast; void register_scene_chromecast(void); #endif /*__SCENE_CHROMECAST_H__*/ diff --git a/Platformio/src/scenes/scene_fireTV.cpp b/Platformio/src/scenes/scene_fireTV.cpp index f84c31b..07350c7 100644 --- a/Platformio/src/scenes/scene_fireTV.cpp +++ b/Platformio/src/scenes/scene_fireTV.cpp @@ -10,29 +10,29 @@ #include "commandHandler.h" std::map key_repeatModes_fireTV { - {'o', SHORT }, - {'=', SHORT }, {'<', SHORTorLONG }, {'p', SHORT }, {'>', SHORTorLONG }, - {'c', SHORT }, {'i', SHORT }, - {'u', SHORT }, - {'l', SHORT }, {'k', SHORT }, {'r', SHORT }, - {'d', SHORT }, - {'b', SHORT }, {'s', SHORT }, - {'+', SHORT_REPEATED}, {'m', SHORT }, {'^', SHORT }, - {'-', SHORT_REPEATED}, {'e', SHORT }, {'v', SHORT }, - {'1', SHORT }, {'2', SHORT }, {'3', SHORT }, {'4', SHORT }, + + {'<', SHORTorLONG }, {'p', SHORT }, {'>', SHORTorLONG }, + {'c', SHORT }, {'i', SHORT }, + {'u', SHORT }, + {'l', SHORT }, {'k', SHORT }, {'r', SHORT }, + {'d', SHORT }, + {'s', SHORT }, + + + }; std::map key_commands_short_fireTV { - {'o', SCENE_ALLOFF}, -/*{'=', KEYBOARD_PLAYPAUSE},*/ {'<', KEYBOARD_REWIND}, {'p', KEYBOARD_PLAYPAUSE}, {'>', KEYBOARD_FASTFORWARD}, + + {'<', KEYBOARD_REWIND}, {'p', KEYBOARD_PLAYPAUSE}, {'>', KEYBOARD_FASTFORWARD}, {'c', KEYBOARD_HOME}, {'i', KEYBOARD_MENU}, {'u', KEYBOARD_UP}, {'l', KEYBOARD_LEFT}, {'k', KEYBOARD_SELECT}, {'r', KEYBOARD_RIGHT}, {'d', KEYBOARD_DOWN}, - /* {'b', }, */ {'s', KEYBOARD_BACK}, - {'+', YAMAHA_VOL_PLUS}, {'m', YAMAHA_MUTE_TOGGLE}, {'^', SAMSUNG_CHANNEL_UP}, - {'-', YAMAHA_VOL_MINUS}, /* {'e', }, */ {'v', SAMSUNG_CHANNEL_DOWN}, - {'1', SCENE_TV}, {'2', SCENE_FIRETV}, {'3', SCENE_CHROMECAST}, {'4', YAMAHA_STANDARD}, + {'s', KEYBOARD_BACK}, + + + }; std::map key_commands_long_fireTV { diff --git a/Platformio/src/scenes/scene_fireTV.h b/Platformio/src/scenes/scene_fireTV.h index f5e2585..ec3c4d3 100644 --- a/Platformio/src/scenes/scene_fireTV.h +++ b/Platformio/src/scenes/scene_fireTV.h @@ -3,6 +3,7 @@ #define SCENE_FIRETV "Scene_firetv" +extern std::string scene_name_fireTV; void register_scene_fireTV(void); #endif /*__SCENE_FIRETV_H__*/