From f815fe49376628ae55062a431759d817f9c451c1 Mon Sep 17 00:00:00 2001 From: KlausMu Date: Sun, 28 Jan 2024 20:17:30 +0100 Subject: [PATCH] some more renaming --- .../src/device_appleTV/device_appleTV.cpp | 2 +- .../src/device_appleTV/device_appleTV.h | 2 +- .../device_keyboard_ble.cpp | 2 +- .../device_keyboard_ble/device_keyboard_ble.h | 2 +- .../device_keyboard_mqtt.cpp | 2 +- .../device_keyboard_mqtt.h | 2 +- .../src/device_samsungTV/device_samsungTV.cpp | 2 +- .../src/device_samsungTV/device_samsungTV.h | 2 +- .../src/device_smarthome/device_smarthome.cpp | 2 +- .../src/device_smarthome/device_smarthome.h | 2 +- .../src/device_yamahaAmp/device_yamahaAmp.cpp | 2 +- .../src/device_yamahaAmp/device_yamahaAmp.h | 2 +- Platformio/src/hardware/infrared_sender.cpp | 2 +- Platformio/src/hardware/infrared_sender.h | 2 +- Platformio/src/main.cpp | 85 +++++++++---------- 15 files changed, 52 insertions(+), 61 deletions(-) diff --git a/Platformio/src/device_appleTV/device_appleTV.cpp b/Platformio/src/device_appleTV/device_appleTV.cpp index af009ae..e1ee7ee 100644 --- a/Platformio/src/device_appleTV/device_appleTV.cpp +++ b/Platformio/src/device_appleTV/device_appleTV.cpp @@ -1,6 +1,6 @@ #include "commandHandler.h" #include "device_appleTV/device_appleTV.h" -void init_appleTV_commands() { +void register_device_appleTV() { commands[APPLETV_GUI_EVENT_USER_DATA] = makeCommandData(IR_SONY, {}); // payload must be set when calling commandHandler } diff --git a/Platformio/src/device_appleTV/device_appleTV.h b/Platformio/src/device_appleTV/device_appleTV.h index 6b25178..3cf6935 100644 --- a/Platformio/src/device_appleTV/device_appleTV.h +++ b/Platformio/src/device_appleTV/device_appleTV.h @@ -3,6 +3,6 @@ #define APPLETV_GUI_EVENT_USER_DATA "AppleTV_gui_event_user_data" -void init_appleTV_commands(); +void register_device_appleTV(); #endif /*__DEVICE_APPLETV_H__*/ diff --git a/Platformio/src/device_keyboard_ble/device_keyboard_ble.cpp b/Platformio/src/device_keyboard_ble/device_keyboard_ble.cpp index d1da02e..2cedda5 100644 --- a/Platformio/src/device_keyboard_ble/device_keyboard_ble.cpp +++ b/Platformio/src/device_keyboard_ble/device_keyboard_ble.cpp @@ -8,7 +8,7 @@ BleKeyboard bleKeyboard("OMOTE Keyboard", "CoretechR"); -void init_keyboard_ble_commands() { +void register_device_keyboard_ble() { commands[KEYBOARD_BLE_UP] = makeCommandData(BLE_KEYBOARD, {KEYBOARD_BLE_UP}); commands[KEYBOARD_BLE_DOWN] = makeCommandData(BLE_KEYBOARD, {KEYBOARD_BLE_DOWN}); commands[KEYBOARD_BLE_RIGHT] = makeCommandData(BLE_KEYBOARD, {KEYBOARD_BLE_RIGHT}); diff --git a/Platformio/src/device_keyboard_ble/device_keyboard_ble.h b/Platformio/src/device_keyboard_ble/device_keyboard_ble.h index 4e0fe45..b39506c 100644 --- a/Platformio/src/device_keyboard_ble/device_keyboard_ble.h +++ b/Platformio/src/device_keyboard_ble/device_keyboard_ble.h @@ -38,7 +38,7 @@ static_assert(false, "You have to use \"#define ENABLE_BLUETOOTH\" in \"commandH extern BleKeyboard bleKeyboard; -void init_keyboard_ble_commands(); +void register_device_keyboard_ble(); void keyboard_ble_executeCommand(std::string command, std::string additionalPayload = ""); void update_keyboard_ble_status(); diff --git a/Platformio/src/device_keyboard_mqtt/device_keyboard_mqtt.cpp b/Platformio/src/device_keyboard_mqtt/device_keyboard_mqtt.cpp index 8895317..ffafb9c 100644 --- a/Platformio/src/device_keyboard_mqtt/device_keyboard_mqtt.cpp +++ b/Platformio/src/device_keyboard_mqtt/device_keyboard_mqtt.cpp @@ -3,7 +3,7 @@ #ifdef ENABLE_KEYBOARD_MQTT -void init_keyboard_mqtt_commands() { +void register_device_keyboard_mqtt() { commands[KEYBOARD_MQTT_UP] = makeCommandData(MQTT, {"esp32_keyboard_firetv/cmnd/UP", "PRESS"}); commands[KEYBOARD_MQTT_DOWN] = makeCommandData(MQTT, {"esp32_keyboard_firetv/cmnd/DOWN", "PRESS"}); commands[KEYBOARD_MQTT_RIGHT] = makeCommandData(MQTT, {"esp32_keyboard_firetv/cmnd/RIGHT", "PRESS"}); diff --git a/Platformio/src/device_keyboard_mqtt/device_keyboard_mqtt.h b/Platformio/src/device_keyboard_mqtt/device_keyboard_mqtt.h index 8926bb5..f41f360 100644 --- a/Platformio/src/device_keyboard_mqtt/device_keyboard_mqtt.h +++ b/Platformio/src/device_keyboard_mqtt/device_keyboard_mqtt.h @@ -36,7 +36,7 @@ static_assert(false, "You have to use \"#define ENABLE_WIFI_AND_MQTT\" in \"comm #define KEYBOARD_MQTT_VOLUME_INCREMENT "Keyboard_mqtt_volume_increment" #define KEYBOARD_MQTT_VOLUME_DECREMENT "Keyboard_mqtt_volume_decrement" -void init_keyboard_mqtt_commands(); +void register_device_keyboard_mqtt(); #endif diff --git a/Platformio/src/device_samsungTV/device_samsungTV.cpp b/Platformio/src/device_samsungTV/device_samsungTV.cpp index a3deb85..f6936e6 100644 --- a/Platformio/src/device_samsungTV/device_samsungTV.cpp +++ b/Platformio/src/device_samsungTV/device_samsungTV.cpp @@ -1,7 +1,7 @@ #include "commandHandler.h" #include "device_samsungTV/device_samsungTV.h" -void init_samsung_commands() { +void register_device_samsung() { // both GC and SAMSUNG work well // https://github.com/natcl/studioimaginaire/blob/master/arduino_remote/ircodes.py diff --git a/Platformio/src/device_samsungTV/device_samsungTV.h b/Platformio/src/device_samsungTV/device_samsungTV.h index 6c60f1f..460f1cd 100644 --- a/Platformio/src/device_samsungTV/device_samsungTV.h +++ b/Platformio/src/device_samsungTV/device_samsungTV.h @@ -59,6 +59,6 @@ #define SAMSUNG_INPUT_COMPONENT "Samsung_input_component" #define SAMSUNG_INPUT_TV "Samsung_input_tv" -void init_samsung_commands(); +void register_device_samsung(); #endif /*__DEVICE_SAMSUNG_H__*/ diff --git a/Platformio/src/device_smarthome/device_smarthome.cpp b/Platformio/src/device_smarthome/device_smarthome.cpp index 536febb..bbbc3f4 100644 --- a/Platformio/src/device_smarthome/device_smarthome.cpp +++ b/Platformio/src/device_smarthome/device_smarthome.cpp @@ -1,7 +1,7 @@ #include "commandHandler.h" #include "device_smarthome/device_smarthome.h" -void init_smarthome_mqtt_commands() { +void register_device_smarthome() { commands[SMARTHOME_MQTT_BULB1_SET] = makeCommandData(MQTT, {"bulb1_set" }); // payload must be set when calling commandHandler commands[SMARTHOME_MQTT_BULB2_SET] = makeCommandData(MQTT, {"bulb2_set" }); // payload must be set when calling commandHandler commands[SMARTHOME_MQTT_BULB1_BRIGHTNESS_SET] = makeCommandData(MQTT, {"bulb1_setbrightness" }); // payload must be set when calling commandHandler diff --git a/Platformio/src/device_smarthome/device_smarthome.h b/Platformio/src/device_smarthome/device_smarthome.h index a1f272e..22ee525 100644 --- a/Platformio/src/device_smarthome/device_smarthome.h +++ b/Platformio/src/device_smarthome/device_smarthome.h @@ -6,6 +6,6 @@ #define SMARTHOME_MQTT_BULB1_BRIGHTNESS_SET "Smarthome_mqtt_bulb1_brightness_set" #define SMARTHOME_MQTT_BULB2_BRIGHTNESS_SET "Smarthome_mqtt_bulb2_brightness_set" -void init_smarthome_mqtt_commands(); +void register_device_smarthome(); #endif /*__DEVICE_SMARTHOME_H__*/ diff --git a/Platformio/src/device_yamahaAmp/device_yamahaAmp.cpp b/Platformio/src/device_yamahaAmp/device_yamahaAmp.cpp index cbf6df4..cd8c37f 100644 --- a/Platformio/src/device_yamahaAmp/device_yamahaAmp.cpp +++ b/Platformio/src/device_yamahaAmp/device_yamahaAmp.cpp @@ -1,7 +1,7 @@ #include "commandHandler.h" #include "device_yamahaAmp/device_yamahaAmp.h" -void init_yamaha_commands() { +void register_device_yamaha() { commands[YAMAHA_INPUT_DVD] = makeCommandData(IR_NEC, {"0x5EA1837C"}); commands[YAMAHA_INPUT_DTV] = makeCommandData(IR_NEC, {"0x5EA12AD5"}); commands[YAMAHA_INPUT_VCR] = makeCommandData(IR_NEC, {"0x5EA1F00F"}); diff --git a/Platformio/src/device_yamahaAmp/device_yamahaAmp.h b/Platformio/src/device_yamahaAmp/device_yamahaAmp.h index 7f6820e..f8202c0 100644 --- a/Platformio/src/device_yamahaAmp/device_yamahaAmp.h +++ b/Platformio/src/device_yamahaAmp/device_yamahaAmp.h @@ -43,6 +43,6 @@ #define YAMAHA_POWER_OFF "Yamaha_power_off" #define YAMAHA_POWER_ON "Yamaha_power_on" -void init_yamaha_commands(); +void register_device_yamaha(); #endif /*__DEVICE_YAMAHA_H__*/ diff --git a/Platformio/src/hardware/infrared_sender.cpp b/Platformio/src/hardware/infrared_sender.cpp index 52a9c0c..6efe03a 100644 --- a/Platformio/src/hardware/infrared_sender.cpp +++ b/Platformio/src/hardware/infrared_sender.cpp @@ -6,7 +6,7 @@ IRsend IrSender(IR_LED, true); -void init_infrared(void) { +void init_infraredSender(void) { // IR Pin Definition pinMode(IR_LED, OUTPUT); digitalWrite(IR_LED, HIGH); // HIGH off - LOW on diff --git a/Platformio/src/hardware/infrared_sender.h b/Platformio/src/hardware/infrared_sender.h index 258852f..a75ed08 100644 --- a/Platformio/src/hardware/infrared_sender.h +++ b/Platformio/src/hardware/infrared_sender.h @@ -9,6 +9,6 @@ // IR declarations extern IRsend IrSender; -void init_infrared(void); +void init_infraredSender(void); #endif /*__INFRARED_H__*/ diff --git a/Platformio/src/main.cpp b/Platformio/src/main.cpp index 0bf8c0e..8d2975e 100644 --- a/Platformio/src/main.cpp +++ b/Platformio/src/main.cpp @@ -3,26 +3,30 @@ // OMOTE firmware for ESP32 // 2023 Maximilian Kern +// hardware +#include "hardware/battery.h" +#include "hardware/sleep.h" +#include "hardware/user_led.h" #include "hardware/tft.h" +#include "hardware/mqtt.h" #include "hardware/infrared_sender.h" #include "hardware/infrared_receiver.h" -#include "hardware/mqtt.h" -#include "hardware/sleep.h" -#include "hardware/battery.h" -#include "hardware/user_led.h" +// devices #include "device_samsungTV/device_samsungTV.h" #include "device_yamahaAmp/device_yamahaAmp.h" -#include "device_appleTV/device_appleTV.h" #include "device_smarthome/device_smarthome.h" +#include "device_appleTV/device_appleTV.h" #include "device_keyboard_mqtt/device_keyboard_mqtt.h" #include "device_keyboard_ble/device_keyboard_ble.h" -#include "gui_general_and_keys/keys.h" +// gui and keys #include "gui_general_and_keys/guiBase.h" #include "gui_general_and_keys/gui_irReceiver.h" #include "gui_general_and_keys/gui_settings.h" #include "gui_general_and_keys/gui_numpad.h" #include "device_appleTV/gui_appleTV.h" #include "device_smarthome/gui_smarthome.h" +#include "gui_general_and_keys/keys.h" +// misc #include "preferences_storage.h" #include "commandHandler.h" @@ -34,21 +38,40 @@ void setup() { // Restore settings from internal flash memory init_preferences(); - - // Button Pin Definition + // Button Pin definition init_keys(); - - // Power Pin Definition + // Power Pin definition init_battery(); - + // get wakeup reason init_sleep(); - + // Pin definition init_userled(); - // init TFT init_tft(); + // init WiFi + #ifdef ENABLE_WIFI_AND_MQTT + init_mqtt(); + #endif + // setup the Inertial Measurement Unit (IMU) for motion detection + // needs to be after init_tft()) because of I2C + setup_IMU(); + // setup IR sender + init_infraredSender(); - // Here you can register the GUIs you want to display. Will be displayed in the order they are registered. + // register commands for the devices + register_device_samsung(); + register_device_yamaha(); + register_device_smarthome(); + register_device_appleTV(); + #ifdef ENABLE_KEYBOARD_MQTT + register_device_keyboard_mqtt(); + #endif + #ifdef ENABLE_KEYBOARD_BLE + register_device_keyboard_ble(); + #endif + init_deviceIndependantCommands(); + + // register the GUIs. They will be displayed in the order they are registered. register_gui_irReceiver(); register_gui_settings(); register_gui_numpad(); @@ -56,31 +79,6 @@ void setup() { register_gui_smarthome(); // init GUI init_gui(); - - // init WiFi - #ifdef ENABLE_WIFI_AND_MQTT - init_mqtt(); - #endif - - // needs to be here (after init_tft) because of I2C - setup_IMU(); - - // Setup IR - init_infrared(); - - // setup command list - init_samsung_commands(); - init_yamaha_commands(); - init_smarthome_mqtt_commands(); - init_appleTV_commands(); - #ifdef ENABLE_KEYBOARD_MQTT - init_keyboard_mqtt_commands(); - #endif - #ifdef ENABLE_KEYBOARD_BLE - init_keyboard_ble_commands(); - #endif - init_deviceIndependantCommands(); - gui_loop(); // Run the LVGL UI once before the loop takes over Serial.print("Setup finished in "); @@ -132,11 +130,4 @@ void loop() { infraredReceiver_loop(); } - // IR Test - //tft.drawString("IR Command: ", 10, 90, 1); - //decode_results results; - //if (IrReceiver.decode(&results)) { - // //tft.drawString(String(results.command) + " ", 80, 90, 1); - // IrReceiver.resume(); // Enable receiving of the next value - //} -} \ No newline at end of file +}