diff --git a/Platformio/.gitignore b/Platformio/.gitignore index 9a696bd7..89cc49cb 100644 --- a/Platformio/.gitignore +++ b/Platformio/.gitignore @@ -1,7 +1,5 @@ .pio .vscode/.browse.c_cpp.db* .vscode/c_cpp_properties.json -.vscode/extensions.json .vscode/launch.json .vscode/ipch -src/secrets_override.h diff --git a/Platformio/.vscode/extensions.json b/Platformio/.vscode/extensions.json deleted file mode 100644 index 080e70d0..00000000 --- a/Platformio/.vscode/extensions.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - // See http://go.microsoft.com/fwlink/?LinkId=827846 - // for the documentation about the extensions.json format - "recommendations": [ - "platformio.platformio-ide" - ], - "unwantedRecommendations": [ - "ms-vscode.cpptools-extension-pack" - ] -} diff --git a/Platformio/.vscode/settings.json b/Platformio/.vscode/settings.json deleted file mode 100644 index 466b91b5..00000000 --- a/Platformio/.vscode/settings.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "cmake.configureOnOpen": false, - "files.associations": { - "random": "cpp", - "array": "cpp", - "lvgl.h": "c", - "atomic": "cpp", - "bit": "cpp", - "*.tcc": "cpp", - "cctype": "cpp", - "clocale": "cpp", - "cmath": "cpp", - "compare": "cpp", - "concepts": "cpp", - "cstdarg": "cpp", - "cstddef": "cpp", - "cstdint": "cpp", - "cstdio": "cpp", - "cstdlib": "cpp", - "cwchar": "cpp", - "cwctype": "cpp", - "deque": "cpp", - "list": "cpp", - "map": "cpp", - "string": "cpp", - "unordered_map": "cpp", - "vector": "cpp", - "exception": "cpp", - "algorithm": "cpp", - "functional": "cpp", - "iterator": "cpp", - "memory": "cpp", - "memory_resource": "cpp", - "numeric": "cpp", - "optional": "cpp", - "string_view": "cpp", - "system_error": "cpp", - "tuple": "cpp", - "type_traits": "cpp", - "utility": "cpp", - "initializer_list": "cpp", - "iosfwd": "cpp", - "istream": "cpp", - "limits": "cpp", - "new": "cpp", - "numbers": "cpp", - "ostream": "cpp", - "sstream": "cpp", - "stdexcept": "cpp", - "streambuf": "cpp", - "cinttypes": "cpp", - "typeinfo": "cpp" - }, - "cmake.sourceDirectory": "${workspaceFolder}/.pio/libdeps/esp32/Adafruit BusIO" -} \ No newline at end of file diff --git a/Platformio/hardware/ESP32/battery_hal_esp32.cpp b/Platformio/hardware/ESP32/battery_hal_esp32.cpp deleted file mode 100644 index 3af38941..00000000 --- a/Platformio/hardware/ESP32/battery_hal_esp32.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include -#if (OMOTE_HARDWARE_REV >= 4) - #include - // Initialize MAX17048 battery fuel gauge - SFE_MAX1704X fuelGauge(MAX1704X_MAX17048); -#endif - -uint8_t CRG_STAT_GPIO = 21; // battery charger feedback, GPIO21, VSPIHD, EMAC_TX_EN -uint8_t ADC_BAT_GPIO = 36; // Battery voltage sense input (1/2 divider), GPIO36, ADC1_CH0, RTC_GPIO0 - -void init_battery_HAL(void) { - #if (OMOTE_HARDWARE_REV >= 4) - // Initialize battery charger indicator input - pinMode(CRG_STAT_GPIO, INPUT_PULLUP); - - fuelGauge.begin(); - #else - // With hardware rev 3 the battery charge status cannot be recognized in a reliable way due to a design flaw in the PCB. - // See https://github.com/CoretechR/OMOTE/issues/55 - // So charge status is deactivated for now. - //pinMode(CRG_STAT_GPIO, INPUT_PULLUP); - pinMode(ADC_BAT_GPIO, INPUT); - #endif -} - -void get_battery_status_HAL(int *battery_voltage, int *battery_percentage, bool *battery_ischarging) { - #if (OMOTE_HARDWARE_REV >= 4) - // With hardware rev 4, battery state of charge is monitored by a MAX17048 fuel gauge - *battery_voltage = (int)(fuelGauge.getVoltage()*1000); - *battery_percentage = (int)fuelGauge.getSOC(); - *battery_ischarging = !digitalRead(CRG_STAT_GPIO); - - //Serial.print(" LiIon Voltage: "); - //Serial.print(fuelGauge.getVoltage()); // Print the battery voltage - //Serial.println("V"); - - //Serial.print(" Percentage: "); - //Serial.print(fuelGauge.getSOC(), 2); // Print the battery state of charge with 2 decimal places - //Serial.println("%"); - #else - int battery_analogRead = 0; - - battery_analogRead = analogRead(ADC_BAT_GPIO); - // original values - // battery_voltage = battery_analogRead*2*3300/4095 + 350; // 350mV ADC offset - // adjusted values due to new measurements - *battery_voltage = battery_analogRead*2*3350/4095 + 325; - *battery_percentage = constrain(map(*battery_voltage, 3700, 4200, 0, 100), 0, 100); - // Check if battery is charging, fully charged or disconnected - /* - "disconnected" cannot be recognized - https://electronics.stackexchange.com/questions/615215/level-shifting-of-a-3-state-pin - https://electrical.codidact.com/posts/286209 - https://how2electronics.com/lithium-ion-battery-charger-circuit-using-mcp73831/ - */ - //*battery_ischarging = !digitalRead(CRG_STAT_GPIO); - #endif -} diff --git a/Platformio/hardware/ESP32/battery_hal_esp32.h b/Platformio/hardware/ESP32/battery_hal_esp32.h deleted file mode 100644 index 2bfcc4ba..00000000 --- a/Platformio/hardware/ESP32/battery_hal_esp32.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -void init_battery_HAL(void); -void get_battery_status_HAL(int *battery_voltage, int *battery_percentage, bool *battery_ischarging); diff --git a/Platformio/hardware/ESP32/hardware_general_hal_esp32.cpp b/Platformio/hardware/ESP32/hardware_general_hal_esp32.cpp deleted file mode 100644 index 841c8f44..00000000 --- a/Platformio/hardware/ESP32/hardware_general_hal_esp32.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include -#include "tft_hal_esp32.h" - -void init_hardware_general_HAL(void) { - // Make sure ESP32 is running at full speed - setCpuFrequencyMhz(240); - - // this is power for the TFT IC - pinMode(LCD_EN_GPIO, OUTPUT); - digitalWrite(LCD_EN_GPIO, HIGH); - // this is power for backlight LEDs - pinMode(LCD_BL_GPIO, OUTPUT); - digitalWrite(LCD_BL_GPIO, HIGH); - -} diff --git a/Platformio/hardware/ESP32/hardware_general_hal_esp32.h b/Platformio/hardware/ESP32/hardware_general_hal_esp32.h deleted file mode 100644 index 8f7f6192..00000000 --- a/Platformio/hardware/ESP32/hardware_general_hal_esp32.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -void init_hardware_general_HAL(void); diff --git a/Platformio/hardware/ESP32/heapUsage_hal_esp32.cpp b/Platformio/hardware/ESP32/heapUsage_hal_esp32.cpp deleted file mode 100644 index 5b826c01..00000000 --- a/Platformio/hardware/ESP32/heapUsage_hal_esp32.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include - -void get_heapUsage_HAL(unsigned long *heapSize, unsigned long *freeHeap, unsigned long *maxAllocHeap, unsigned long *minFreeHeap) { - *heapSize = ESP.getHeapSize(); - *freeHeap = ESP.getFreeHeap(); - *maxAllocHeap = ESP.getMaxAllocHeap(); - *minFreeHeap = ESP.getMinFreeHeap(); -} diff --git a/Platformio/hardware/ESP32/heapUsage_hal_esp32.h b/Platformio/hardware/ESP32/heapUsage_hal_esp32.h deleted file mode 100644 index d290c699..00000000 --- a/Platformio/hardware/ESP32/heapUsage_hal_esp32.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -void get_heapUsage_HAL(unsigned long *heapSize, unsigned long *freeHeap, unsigned long *maxAllocHeap, unsigned long *minFreeHeap); diff --git a/Platformio/hardware/ESP32/include_hal_esp32.h b/Platformio/hardware/ESP32/include_hal_esp32.h deleted file mode 100644 index cdcc1608..00000000 --- a/Platformio/hardware/ESP32/include_hal_esp32.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include "ESP32/battery_hal_esp32.h" -#include "ESP32/hardware_general_hal_esp32.h" -#include "ESP32/heapUsage_hal_esp32.h" -#include "ESP32/infrared_receiver_hal_esp32.h" -#include "ESP32/infrared_sender_hal_esp32.h" -#include "ESP32/keyboard_ble_hal_esp32.h" -#include "ESP32/keypad_keys_hal_esp32.h" -#include "ESP32/lvgl_hal_esp32.h" -#include "ESP32/mqtt_hal_esp32.h" -#include "ESP32/preferencesStorage_hal_esp32.h" -#include "ESP32/sleep_hal_esp32.h" -#include "ESP32/tft_hal_esp32.h" -#include "ESP32/user_led_hal_esp32.h" diff --git a/Platformio/hardware/ESP32/infrared_receiver_hal_esp32.cpp b/Platformio/hardware/ESP32/infrared_receiver_hal_esp32.cpp deleted file mode 100644 index ce69ccfa..00000000 --- a/Platformio/hardware/ESP32/infrared_receiver_hal_esp32.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/* - Mainly based on IRrecvDumpV2 from IRremoteESP8266 - Slightly changed to run with OMOTE hardware. -*/ - -/* - * IRremoteESP8266: IRrecvDumpV2 - dump details of IR codes with IRrecv - * An IR detector/demodulator must be connected to the input kRecvPin. - * - * Copyright 2009 Ken Shirriff, http://arcfn.com - * Copyright 2017-2019 David Conran - * - * Example circuit diagram: - * https://github.com/crankyoldgit/IRremoteESP8266/wiki#ir-receiving - * - * Changes: - * Version 1.2 October, 2020 - * - Enable easy setting of the decoding tolerance value. - * Version 1.0 October, 2019 - * - Internationalisation (i18n) support. - * - Stop displaying the legacy raw timing info. - * Version 0.5 June, 2019 - * - Move A/C description to IRac.cpp. - * Version 0.4 July, 2018 - * - Minor improvements and more A/C unit support. - * Version 0.3 November, 2017 - * - Support for A/C decoding for some protocols. - * Version 0.2 April, 2017 - * - Decode from a copy of the data so we can start capturing faster thus - * reduce the likelihood of miscaptures. - * Based on Ken Shirriff's IrsendDemo Version 0.1 July, 2009, - */ - -//#include -#include -#include -#include -#include -#include -#include - -#include "infrared_receiver_hal_esp32.h" - -uint8_t IR_RX_GPIO = 15; // IR receiver input -uint8_t IR_VCC_GPIO = 25; // IR receiver power - -bool irReceiverEnabled = false; - -tAnnounceNewIRmessage_cb thisAnnounceNewIRmessage_cb = NULL; -void set_announceNewIRmessage_cb_HAL(tAnnounceNewIRmessage_cb pAnnounceNewIRmessage_cb) { - thisAnnounceNewIRmessage_cb = pAnnounceNewIRmessage_cb; -} - -// The Serial connection baud rate. -// i.e. Status message will be sent to the PC at this baud rate. -// Try to avoid slow speeds like 9600, as you will miss messages and -// cause other problems. 115200 (or faster) is recommended. -// NOTE: Make sure you set your Serial Monitor to the same speed. -const uint32_t kBaudRate = 115200; - -// As this program is a special purpose capture/decoder, let us use a larger -// than normal buffer so we can handle Air Conditioner remote codes. -const uint16_t kCaptureBufferSize = 1024; - -// kTimeout is the Nr. of milli-Seconds of no-more-data before we consider a -// message ended. -// This parameter is an interesting trade-off. The longer the timeout, the more -// complex a message it can capture. e.g. Some device protocols will send -// multiple message packets in quick succession, like Air Conditioner remotes. -// Air Coniditioner protocols often have a considerable gap (20-40+ms) between -// packets. -// The downside of a large timeout value is a lot of less complex protocols -// send multiple messages when the remote's button is held down. The gap between -// them is often also around 20+ms. This can result in the raw data be 2-3+ -// times larger than needed as it has captured 2-3+ messages in a single -// capture. Setting a low timeout value can resolve this. -// So, choosing the best kTimeout value for your use particular case is -// quite nuanced. Good luck and happy hunting. -// NOTE: Don't exceed kMaxTimeoutMs. Typically 130ms. -#if DECODE_AC -// Some A/C units have gaps in their protocols of ~40ms. e.g. Kelvinator -// A value this large may swallow repeats of some protocols -const uint8_t kTimeout = 50; -#else // DECODE_AC -// Suits most messages, while not swallowing many repeats. -const uint8_t kTimeout = 15; -#endif // DECODE_AC -// Alternatives: -// const uint8_t kTimeout = 90; -// Suits messages with big gaps like XMP-1 & some aircon units, but can -// accidentally swallow repeated messages in the rawData[] output. -// -// const uint8_t kTimeout = kMaxTimeoutMs; -// This will set it to our currently allowed maximum. -// Values this high are problematic because it is roughly the typical boundary -// where most messages repeat. -// e.g. It will stop decoding a message and start sending it to serial at -// precisely the time when the next message is likely to be transmitted, -// and may miss it. - -// Set the smallest sized "UNKNOWN" message packets we actually care about. -// This value helps reduce the false-positive detection rate of IR background -// noise as real messages. The chances of background IR noise getting detected -// as a message increases with the length of the kTimeout value. (See above) -// The downside of setting this message too large is you can miss some valid -// short messages for protocols that this library doesn't yet decode. -// -// Set higher if you get lots of random short UNKNOWN messages when nothing -// should be sending a message. -// Set lower if you are sure your setup is working, but it doesn't see messages -// from your device. (e.g. Other IR remotes work.) -// NOTE: Set this value very high to effectively turn off UNKNOWN detection. -const uint16_t kMinUnknownSize = 12; - -// How much percentage lee way do we give to incoming signals in order to match -// it? -// e.g. +/- 25% (default) to an expected value of 500 would mean matching a -// value between 375 & 625 inclusive. -// Note: Default is 25(%). Going to a value >= 50(%) will cause some protocols -// to no longer match correctly. In normal situations you probably do not -// need to adjust this value. Typically that's when the library detects -// your remote's message some of the time, but not all of the time. -const uint8_t kTolerancePercentage = kTolerance; // kTolerance is normally 25% - -// Legacy (No longer supported!) -// -// Change to `true` if you miss/need the old "Raw Timing[]" display. -#define LEGACY_TIMING_INFO false -// ==================== end of TUNEABLE PARAMETERS ==================== - -// Use turn on the save buffer feature for more complete capture coverage. -IRrecv irrecv(IR_RX_GPIO, kCaptureBufferSize, kTimeout, true); -decode_results results; // Somewhere to store the results - -// This section of code runs only once at start-up. -void start_infraredReceiver_HAL() { - pinMode(IR_RX_GPIO, INPUT); - pinMode(IR_VCC_GPIO, OUTPUT); - digitalWrite(IR_VCC_GPIO, HIGH); // Turn on IR receiver - - // Perform a low level sanity checks that the compiler performs bit field - // packing as we expect and Endianness is as we expect. - assert(irutils::lowLevelSanityCheck() == 0); - - Serial.printf("\n" D_STR_IRRECVDUMP_STARTUP "\n", IR_RX_GPIO); -#if DECODE_HASH - // Ignore messages with less than minimum on or off pulses. - irrecv.setUnknownThreshold(kMinUnknownSize); -#endif // DECODE_HASH - irrecv.setTolerance(kTolerancePercentage); // Override the default tolerance. - irrecv.enableIRIn(); // Start the receiver -} - -void shutdown_infraredReceiver_HAL() { - irrecv.disableIRIn(); - digitalWrite(IR_VCC_GPIO, LOW); // IR Receiver off -} - -// The repeating section of the code -void infraredReceiver_loop_HAL() { - // Check if the IR code has been received. - if (irrecv.decode(&results)) { - // Display a crude timestamp. - uint32_t now = millis(); - Serial.printf(D_STR_TIMESTAMP " : %06u.%03u\n", now / 1000, now % 1000); - // Check if we got an IR message that was to big for our capture buffer. - if (results.overflow) - Serial.printf(D_WARN_BUFFERFULL "\n", kCaptureBufferSize); - // Display the library version the message was captured with. - Serial.println(D_STR_LIBRARY " : v" _IRREMOTEESP8266_VERSION_STR "\n"); - // Display the tolerance percentage if it has been change from the default. - if (kTolerancePercentage != kTolerance) - Serial.printf(D_STR_TOLERANCE " : %d%%\n", kTolerancePercentage); - // Display the basic output of what we found. - Serial.print(resultToHumanReadableBasic(&results)); - // Display any extra A/C info if we have it. - String description = IRAcUtils::resultAcToString(&results); - if (description.length()) Serial.println(D_STR_MESGDESC ": " + description); - yield(); // Feed the WDT as the text output can take a while to print. -#if LEGACY_TIMING_INFO - // Output legacy RAW timing info of the result. - Serial.println(resultToTimingInfo(&results)); - yield(); // Feed the WDT (again) -#endif // LEGACY_TIMING_INFO - // Output the results as source code - Serial.println(resultToSourceCode(&results)); - Serial.println(); // Blank line between entries - - String message = ""; - message += typeToString((&results)->decode_type, (&results)->repeat); - message += " "; - message += resultToHexidecimal(&results); - if (thisAnnounceNewIRmessage_cb != NULL) { - thisAnnounceNewIRmessage_cb(std::string(message.c_str())); - } - - yield(); // Feed the WDT (again) - - // if message repeats infinitely, you can try one of these two workarounds. Don't know why this is needed. - // irrecv.resume(); - // another workaround could be: - // irrecv.disableIRIn(); - // irrecv.enableIRIn(); - - } -} - -bool get_irReceiverEnabled_HAL() { - return irReceiverEnabled; -} -void set_irReceiverEnabled_HAL(bool aIrReceiverEnabled) { - irReceiverEnabled = aIrReceiverEnabled; -} diff --git a/Platformio/hardware/ESP32/infrared_receiver_hal_esp32.h b/Platformio/hardware/ESP32/infrared_receiver_hal_esp32.h deleted file mode 100644 index 7bcbc980..00000000 --- a/Platformio/hardware/ESP32/infrared_receiver_hal_esp32.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -extern uint8_t IR_RX_GPIO; -extern uint8_t IR_VCC_GPIO; - -#include - -void start_infraredReceiver_HAL(void); -void shutdown_infraredReceiver_HAL(void); -void infraredReceiver_loop_HAL(void); - -bool get_irReceiverEnabled_HAL(); -void set_irReceiverEnabled_HAL(bool aIrReceiverEnabled); - -typedef void (*tAnnounceNewIRmessage_cb)(std::string message); -void set_announceNewIRmessage_cb_HAL(tAnnounceNewIRmessage_cb pAnnounceNewIRmessage_cb); diff --git a/Platformio/hardware/ESP32/infrared_sender_hal_esp32.cpp b/Platformio/hardware/ESP32/infrared_sender_hal_esp32.cpp deleted file mode 100644 index c4559cff..00000000 --- a/Platformio/hardware/ESP32/infrared_sender_hal_esp32.cpp +++ /dev/null @@ -1,145 +0,0 @@ -#include -#include -#include -#include -#include -#include - -uint8_t IR_LED_GPIO = 33; // IR LED output - -IRsend IrSender(IR_LED_GPIO, true); - -void init_infraredSender_HAL(void) { - // IR Pin Definition - pinMode(IR_LED_GPIO, OUTPUT); - digitalWrite(IR_LED_GPIO, HIGH); // HIGH off - LOW on - - IrSender.begin(); -} - -// IR protocols -enum IRprotocols { - IR_PROTOCOL_GC = 0, - IR_PROTOCOL_NEC = 1, - IR_PROTOCOL_SAMSUNG = 2, - IR_PROTOCOL_SONY = 3, - IR_PROTOCOL_RC5 = 4, - IR_PROTOCOL_DENON = 5, - IR_PROTOCOL_SAMSUNG36 = 6 -}; -void sendIRcode_HAL(int protocol, std::list commandPayloads, std::string additionalPayload) { - switch (protocol) { - case IR_PROTOCOL_GC: { - auto current = commandPayloads.begin(); - std::string arrayStr = *current; - // first create array of needed size - std::string::difference_type size = std::count(arrayStr.begin(), arrayStr.end(), ','); - size += 1; - uint16_t *buf = new uint16_t[size]; - // now get comma separated values and fill array - int pos = 0; - std::stringstream ss(arrayStr); - while(ss.good()) { - std::string dataStr; - std::getline(ss, dataStr, ','); - // https://cplusplus.com/reference/string/stoull/ - std::string::size_type sz = 0; // alias of size_t - const uint64_t data = std::stoull(dataStr, &sz, 0); - // Serial.printf(" next string value %s (%" PRIu64 ")\r\n", dataStr.c_str(), data); - buf[pos] = data; - pos += 1; - } - Serial.printf("execute: will send IR GC, array size %d\r\n", size); - IrSender.sendGC(buf, size); - delete [] buf; - break; - } - - case IR_PROTOCOL_NEC: { - auto current = commandPayloads.begin(); - std::string dataStr = *current; - // https://cplusplus.com/reference/string/stoull/ - std::string::size_type sz = 0; // alias of size_t - const uint64_t data = std::stoull(dataStr, &sz, 0); - Serial.printf("execute: will send IR NEC, data %s (%" PRIu64 ")\r\n", dataStr.c_str(), data); - IrSender.sendNEC(data); - break; - } - - case IR_PROTOCOL_SAMSUNG: { - auto current = commandPayloads.begin(); - std::string dataStr = *current; - // https://cplusplus.com/reference/string/stoull/ - std::string::size_type sz = 0; // alias of size_t - const uint64_t data = std::stoull(dataStr, &sz, 0); - Serial.printf("execute: will send IR SAMSUNG, data %s (%" PRIu64 ")\r\n", dataStr.c_str(), data); - IrSender.sendSAMSUNG(data); - break; - } - - case IR_PROTOCOL_SONY: { - std::string::size_type sz = 0; // alias of size_t - uint64_t data; - if (commandPayloads.empty() && (additionalPayload == "")) { - Serial.printf("execute: cannot send IR SONY, because both data and payload are empty\r\n"); - } else { - if (additionalPayload != "") { - data = std::stoull(additionalPayload, &sz, 0); - } else { - auto current = commandPayloads.begin(); - data = std::stoull(*current, &sz, 0); - } - Serial.printf("execute: will send IR SONY 15 bit, data (%" PRIu64 ")\r\n", data); - IrSender.sendSony(data, 15); - } - break; - } - - case IR_PROTOCOL_RC5: { - std::string::size_type sz = 0; // alias of size_t - uint64_t data; - if (commandPayloads.empty() && (additionalPayload == "")) { - Serial.printf("execute: cannot send IR RC5, because both data and payload are empty\r\n"); - } else { - if (additionalPayload != "") { - data = std::stoull(additionalPayload, &sz, 0); - } else { - auto current = commandPayloads.begin(); - data = std::stoull(*current, &sz, 0); - } - Serial.printf("execute: will send IR RC5, data (%" PRIu64 ")\r\n", data); - IrSender.sendRC5(IrSender.encodeRC5X(0x00, data)); - } - break; - } - - case IR_PROTOCOL_DENON: { - std::string::size_type sz = 0; // alias of size_t - uint64_t data; - if (commandPayloads.empty() && (additionalPayload == "")) { - Serial.printf("execute: cannot send IR DENON 48 bit, because both data and payload are empty\r\n"); - } else { - if (additionalPayload != "") { - data = std::stoull(additionalPayload, &sz, 0); - } else { - auto current = commandPayloads.begin(); - data = std::stoull(*current, &sz, 0); - } - Serial.printf("execute: will send IR DENON 48 bit, data (%" PRIu64 ")\r\n", data); - IrSender.sendDenon(data, 48); - } - break; - } - - case IR_PROTOCOL_SAMSUNG36: { - auto current = commandPayloads.begin(); - std::string dataStr = *current; - // https://cplusplus.com/reference/string/stoull/ - std::string::size_type sz = 0; // alias of size_t - const uint64_t data = std::stoull(dataStr, &sz, 0); - Serial.printf("execute: will send IR SAMSUNG36, data %s (%" PRIu64 ")\r\n", dataStr.c_str(), data); - IrSender.sendSamsung36(data); - break; - } - } -} \ No newline at end of file diff --git a/Platformio/hardware/ESP32/infrared_sender_hal_esp32.h b/Platformio/hardware/ESP32/infrared_sender_hal_esp32.h deleted file mode 100644 index ae000370..00000000 --- a/Platformio/hardware/ESP32/infrared_sender_hal_esp32.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#include -#include - -// infrared -void init_infraredSender_HAL(void); -void sendIRcode_HAL(int protocol, std::list commandPayloads, std::string additionalPayload); \ No newline at end of file diff --git a/Platformio/hardware/ESP32/keyboard_ble_hal_esp32.cpp b/Platformio/hardware/ESP32/keyboard_ble_hal_esp32.cpp deleted file mode 100644 index ecc814f0..00000000 --- a/Platformio/hardware/ESP32/keyboard_ble_hal_esp32.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#if (ENABLE_KEYBOARD_BLE == 1) - -#include "lib/ESP32-BLE-Keyboard/BleKeyboard.h" -#include "battery_hal_esp32.h" - -BleKeyboard bleKeyboard("OMOTE Keyboard", "CoretechR"); - -void init_keyboardBLE_HAL() { - int battery_voltage; - int battery_percentage; - boolean battery_ischarging; - get_battery_status_HAL(&battery_voltage, &battery_percentage, &battery_ischarging); - bleKeyboard.setBatteryLevel(battery_percentage); - bleKeyboard.begin(); -} - -bool keyboardBLE_isConnected_HAL() { - return bleKeyboard.isConnected(); -} - -void keyboardBLE_end_HAL() { - bleKeyboard.end(); -} - -void keyboardBLE_write_HAL(uint8_t c) { - bleKeyboard.write(c); -} - -void keyboardBLE_longpress_HAL(uint8_t c) { - bleKeyboard.press(c); - delay(1000); - bleKeyboard.release(c); -} - -void keyboardBLE_home_HAL() { - bleKeyboard.press(KEY_LEFT_ALT); - bleKeyboard.press(KEY_ESC); - bleKeyboard.releaseAll(); -} - -void keyboardBLE_sendString_HAL(const std::string &s) { - bleKeyboard.print(s.c_str()); -} - -void consumerControlBLE_write_HAL(const MediaKeyReport value) { - bleKeyboard.write(value); -} - -void consumerControlBLE_longpress_HAL(const MediaKeyReport value) { - bleKeyboard.press(value); - delay(1000); - bleKeyboard.release(value); -} - -#endif diff --git a/Platformio/hardware/ESP32/keyboard_ble_hal_esp32.h b/Platformio/hardware/ESP32/keyboard_ble_hal_esp32.h deleted file mode 100644 index 3c1fc860..00000000 --- a/Platformio/hardware/ESP32/keyboard_ble_hal_esp32.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#if (ENABLE_KEYBOARD_BLE == 1) - -#include "lib/ESP32-BLE-Keyboard/BleKeyboard.h" - -void init_keyboardBLE_HAL(); -bool keyboardBLE_isConnected_HAL(); -void keyboardBLE_end_HAL(); -void keyboardBLE_write_HAL(uint8_t c); -void keyboardBLE_longpress_HAL(uint8_t c); -void keyboardBLE_home_HAL(); -void keyboardBLE_sendString_HAL(const std::string &s); -void consumerControlBLE_write_HAL(const MediaKeyReport value); -void consumerControlBLE_longpress_HAL(const MediaKeyReport value); - -#endif \ No newline at end of file diff --git a/Platformio/hardware/ESP32/keypad_keys_hal_esp32.cpp b/Platformio/hardware/ESP32/keypad_keys_hal_esp32.cpp deleted file mode 100644 index 2ef31bac..00000000 --- a/Platformio/hardware/ESP32/keypad_keys_hal_esp32.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include -#include "lib/Keypad/src/Keypad.h" // modified for inverted logic - -uint8_t SW_1_GPIO = 32; // 1...5: Output -uint8_t SW_2_GPIO = 26; -uint8_t SW_3_GPIO = 27; -uint8_t SW_4_GPIO = 14; -uint8_t SW_5_GPIO = 12; -uint8_t SW_A_GPIO = 37; // A...E: Input -uint8_t SW_B_GPIO = 38; -uint8_t SW_C_GPIO = 39; -uint8_t SW_D_GPIO = 34; -uint8_t SW_E_GPIO = 35; -uint64_t BUTTON_PIN_BITMASK = 0b1110110000000000000000000010000000000000; //IO34+IO35+IO37+IO38+IO39(+IO13) - -const byte ROWS = 5; //five rows -const byte COLS = 5; //five columns - -// Keypad declarations -// define the symbols on the buttons of the keypads -char hexaKeys[ROWS][COLS] = { - {'s','^','-','m','e'}, // source, channel+, Volume-, mute, record - {'i','r','+','k','d'}, // info, right, Volume+, OK, down - {'4','v','1','3','2'}, // blue, channel-, red, yellow, green - {'>','o','b','u','l'}, // forward, off, back, up, left - {'?','p','c','<','='} // ?, play, config, rewind, stop -}; -/* - off o - -stop = rewind < play p forward > - - config c info i - up u - left l OK k right r - down d - back b source s - -Volume+ + mute m channel+ ^ -Volume- - record e channel- v - -red 1 green 2 yellow 3 blue 4 -*/ -byte rowPins[ROWS] = {SW_A_GPIO, SW_B_GPIO, SW_C_GPIO, SW_D_GPIO, SW_E_GPIO}; //connect to the row pinouts of the keypad -byte colPins[COLS] = {SW_1_GPIO, SW_2_GPIO, SW_3_GPIO, SW_4_GPIO, SW_5_GPIO}; //connect to the column pinouts of the keypad -Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); - -void init_keys_HAL(void) { - // Button Pin Definition - pinMode(SW_1_GPIO, OUTPUT); - pinMode(SW_2_GPIO, OUTPUT); - pinMode(SW_3_GPIO, OUTPUT); - pinMode(SW_4_GPIO, OUTPUT); - pinMode(SW_5_GPIO, OUTPUT); - pinMode(SW_A_GPIO, INPUT); - pinMode(SW_B_GPIO, INPUT); - pinMode(SW_C_GPIO, INPUT); - pinMode(SW_D_GPIO, INPUT); - pinMode(SW_E_GPIO, INPUT); -} - -enum keypad_keyStates {IDLE_HAL, PRESSED_HAL, HOLD_HAL, RELEASED_HAL}; -struct keypad_key { - char kchar; - int kcode; - keypad_keyStates kstate; - boolean stateChanged; -}; -keypad_key keys[10]; - -void keys_getKeys_HAL(void* ptr) { - customKeypad.getKeys(); - - for(int i=0; i < LIST_MAX; i++) { - (*(keypad_key*)ptr).kchar = customKeypad.key[i].kchar; - (*(keypad_key*)ptr).kcode = customKeypad.key[i].kcode; - (*(keypad_key*)ptr).kstate = (keypad_keyStates)(customKeypad.key[i].kstate); - (*(keypad_key*)ptr).stateChanged = customKeypad.key[i].stateChanged; - // https://www.geeksforgeeks.org/void-pointer-c-cpp/ - ptr = (void *) ((intptr_t)(ptr) + sizeof(keypad_key)); - } -} \ No newline at end of file diff --git a/Platformio/hardware/ESP32/keypad_keys_hal_esp32.h b/Platformio/hardware/ESP32/keypad_keys_hal_esp32.h deleted file mode 100644 index 90f4b7a8..00000000 --- a/Platformio/hardware/ESP32/keypad_keys_hal_esp32.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -extern uint8_t SW_1_GPIO; // 1...5: Output -extern uint8_t SW_2_GPIO; -extern uint8_t SW_3_GPIO; -extern uint8_t SW_4_GPIO; -extern uint8_t SW_5_GPIO; -extern uint8_t SW_A_GPIO; // A...E: Input -extern uint8_t SW_B_GPIO; -extern uint8_t SW_C_GPIO; -extern uint8_t SW_D_GPIO; -extern uint8_t SW_E_GPIO; -extern uint64_t BUTTON_PIN_BITMASK; - -void init_keys_HAL(void); -void keys_getKeys_HAL(void* ptr); diff --git a/Platformio/hardware/ESP32/lib/ESP32-BLE-Keyboard/.piopm b/Platformio/hardware/ESP32/lib/ESP32-BLE-Keyboard/.piopm deleted file mode 100644 index 83d5c7f2..00000000 --- a/Platformio/hardware/ESP32/lib/ESP32-BLE-Keyboard/.piopm +++ /dev/null @@ -1 +0,0 @@ -{"type": "library", "name": "ESP32 BLE Keyboard", "version": "0.3.2", "spec": {"owner": "t-vk", "id": 6749, "name": "ESP32 BLE Keyboard", "requirements": null, "uri": null}} \ No newline at end of file diff --git a/Platformio/hardware/ESP32/lib/ESP32-BLE-Keyboard/BleKeyboard.cpp b/Platformio/hardware/ESP32/lib/ESP32-BLE-Keyboard/BleKeyboard.cpp deleted file mode 100644 index b74572ce..00000000 --- a/Platformio/hardware/ESP32/lib/ESP32-BLE-Keyboard/BleKeyboard.cpp +++ /dev/null @@ -1,553 +0,0 @@ -#include "BleKeyboard.h" - -#if defined(USE_NIMBLE) -#include -#include -#include -#include -#else -#include -#include -#include -#include "BLE2902.h" -#include "BLEHIDDevice.h" -#endif // USE_NIMBLE -#include "HIDTypes.h" -#include -#include "sdkconfig.h" - - -#if defined(CONFIG_ARDUHAL_ESP_LOG) - #include "esp32-hal-log.h" - #define LOG_TAG "" -#else - #include "esp_log.h" - static const char* LOG_TAG = "BLEDevice"; -#endif - - -// Report IDs: -#define KEYBOARD_ID 0x01 -#define MEDIA_KEYS_ID 0x02 - -static const uint8_t _hidReportDescriptor[] = { - USAGE_PAGE(1), 0x01, // USAGE_PAGE (Generic Desktop Ctrls) - USAGE(1), 0x06, // USAGE (Keyboard) - COLLECTION(1), 0x01, // COLLECTION (Application) - // ------------------------------------------------- Keyboard - REPORT_ID(1), KEYBOARD_ID, // REPORT_ID (1) - USAGE_PAGE(1), 0x07, // USAGE_PAGE (Kbrd/Keypad) - USAGE_MINIMUM(1), 0xE0, // USAGE_MINIMUM (0xE0) - USAGE_MAXIMUM(1), 0xE7, // USAGE_MAXIMUM (0xE7) - LOGICAL_MINIMUM(1), 0x00, // LOGICAL_MINIMUM (0) - LOGICAL_MAXIMUM(1), 0x01, // Logical Maximum (1) - REPORT_SIZE(1), 0x01, // REPORT_SIZE (1) - REPORT_COUNT(1), 0x08, // REPORT_COUNT (8) - HIDINPUT(1), 0x02, // INPUT (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - REPORT_COUNT(1), 0x01, // REPORT_COUNT (1) ; 1 byte (Reserved) - REPORT_SIZE(1), 0x08, // REPORT_SIZE (8) - HIDINPUT(1), 0x01, // INPUT (Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position) - REPORT_COUNT(1), 0x05, // REPORT_COUNT (5) ; 5 bits (Num lock, Caps lock, Scroll lock, Compose, Kana) - REPORT_SIZE(1), 0x01, // REPORT_SIZE (1) - USAGE_PAGE(1), 0x08, // USAGE_PAGE (LEDs) - USAGE_MINIMUM(1), 0x01, // USAGE_MINIMUM (0x01) ; Num Lock - USAGE_MAXIMUM(1), 0x05, // USAGE_MAXIMUM (0x05) ; Kana - HIDOUTPUT(1), 0x02, // OUTPUT (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) - REPORT_COUNT(1), 0x01, // REPORT_COUNT (1) ; 3 bits (Padding) - REPORT_SIZE(1), 0x03, // REPORT_SIZE (3) - HIDOUTPUT(1), 0x01, // OUTPUT (Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) - REPORT_COUNT(1), 0x06, // REPORT_COUNT (6) ; 6 bytes (Keys) - REPORT_SIZE(1), 0x08, // REPORT_SIZE(8) - LOGICAL_MINIMUM(1), 0x00, // LOGICAL_MINIMUM(0) - LOGICAL_MAXIMUM(1), 0x65, // LOGICAL_MAXIMUM(0x65) ; 101 keys - USAGE_PAGE(1), 0x07, // USAGE_PAGE (Kbrd/Keypad) - USAGE_MINIMUM(1), 0x00, // USAGE_MINIMUM (0) - USAGE_MAXIMUM(1), 0x65, // USAGE_MAXIMUM (0x65) - HIDINPUT(1), 0x00, // INPUT (Data,Array,Abs,No Wrap,Linear,Preferred State,No Null Position) - END_COLLECTION(0), // END_COLLECTION - // ------------------------------------------------- Media Keys - USAGE_PAGE(1), 0x0C, // USAGE_PAGE (Consumer) - USAGE(1), 0x01, // USAGE (Consumer Control) - COLLECTION(1), 0x01, // COLLECTION (Application) - REPORT_ID(1), MEDIA_KEYS_ID, // REPORT_ID (3) - USAGE_PAGE(1), 0x0C, // USAGE_PAGE (Consumer) - LOGICAL_MINIMUM(1), 0x00, // LOGICAL_MINIMUM (0) - LOGICAL_MAXIMUM(1), 0x01, // LOGICAL_MAXIMUM (1) - REPORT_SIZE(1), 0x01, // REPORT_SIZE (1) - REPORT_COUNT(1), 0x10, // REPORT_COUNT (16) - USAGE(1), 0xB5, // USAGE (Scan Next Track) ; bit 0: 1 - USAGE(1), 0xB6, // USAGE (Scan Previous Track) ; bit 1: 2 - USAGE(1), 0xB7, // USAGE (Stop) ; bit 2: 4 - USAGE(1), 0xCD, // USAGE (Play/Pause) ; bit 3: 8 - USAGE(1), 0xE2, // USAGE (Mute) ; bit 4: 16 - USAGE(1), 0xE9, // USAGE (Volume Increment) ; bit 5: 32 - USAGE(1), 0xEA, // USAGE (Volume Decrement) ; bit 6: 64 - USAGE(2), 0x23, 0x02, // Usage (WWW Home) ; bit 7: 128 - USAGE(2), 0x94, 0x01, // Usage (My Computer) ; bit 0: 1 - // original from BLE-Keyboard - // USAGE(2), 0x92, 0x01, // Usage (Calculator) ; bit 1: 2 - // changed for usage in OMOTE - USAGE(1), 0xB3, // USAGE (Fast Forward); bit 1: 2 - USAGE(2), 0x2A, 0x02, // Usage (WWW fav) ; bit 2: 4 - USAGE(2), 0x21, 0x02, // Usage (WWW search) ; bit 3: 8 - USAGE(2), 0x26, 0x02, // Usage (WWW stop) ; bit 4: 16 - USAGE(2), 0x24, 0x02, // Usage (WWW back) ; bit 5: 32 - USAGE(2), 0x83, 0x01, // Usage (Media sel) ; bit 6: 64 - // original from BLE-Keyboard - // USAGE(2), 0x8A, 0x01, // Usage (Mail) ; bit 7: 128 - // changed for usage in OMOTE - USAGE(1), 0xB4, // USAGE (Rewind) ; bit 7: 128 - HIDINPUT(1), 0x02, // INPUT (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - END_COLLECTION(0) // END_COLLECTION -}; - -BleKeyboard::BleKeyboard(std::string deviceName, std::string deviceManufacturer, uint8_t batteryLevel) - : hid(0) - , deviceName(std::string(deviceName).substr(0, 15)) - , deviceManufacturer(std::string(deviceManufacturer).substr(0,15)) - , batteryLevel(batteryLevel) {} - -void BleKeyboard::begin(void) -{ - BLEDevice::init(deviceName); - BLEServer* pServer = BLEDevice::createServer(); - pServer->setCallbacks(this); - - hid = new BLEHIDDevice(pServer); - inputKeyboard = hid->inputReport(KEYBOARD_ID); // <-- input REPORTID from report map - outputKeyboard = hid->outputReport(KEYBOARD_ID); - inputMediaKeys = hid->inputReport(MEDIA_KEYS_ID); - - outputKeyboard->setCallbacks(this); - - hid->manufacturer()->setValue(deviceManufacturer); - - hid->pnp(0x02, vid, pid, version); - hid->hidInfo(0x00, 0x01); - - -#if defined(USE_NIMBLE) - - BLEDevice::setSecurityAuth(true, true, true); - -#else - - BLESecurity* pSecurity = new BLESecurity(); - pSecurity->setAuthenticationMode(ESP_LE_AUTH_REQ_SC_MITM_BOND); - -#endif // USE_NIMBLE - - hid->reportMap((uint8_t*)_hidReportDescriptor, sizeof(_hidReportDescriptor)); - hid->startServices(); - - onStarted(pServer); - - advertising = pServer->getAdvertising(); - advertising->setAppearance(HID_KEYBOARD); - advertising->addServiceUUID(hid->hidService()->getUUID()); - advertising->setScanResponse(false); - advertising->start(); - hid->setBatteryLevel(batteryLevel); - - ESP_LOGD(LOG_TAG, "Advertising started!"); -} - -void BleKeyboard::end(void) -{ -} - -bool BleKeyboard::isConnected(void) { - return this->connected; -} - -void BleKeyboard::setBatteryLevel(uint8_t level) { - this->batteryLevel = level; - if (hid != 0) - this->hid->setBatteryLevel(this->batteryLevel); -} - -//must be called before begin in order to set the name -void BleKeyboard::setName(std::string deviceName) { - this->deviceName = deviceName; -} - -/** - * @brief Sets the waiting time (in milliseconds) between multiple keystrokes in NimBLE mode. - * - * @param ms Time in milliseconds - */ -void BleKeyboard::setDelay(uint32_t ms) { - this->_delay_ms = ms; -} - -void BleKeyboard::set_vendor_id(uint16_t vid) { - this->vid = vid; -} - -void BleKeyboard::set_product_id(uint16_t pid) { - this->pid = pid; -} - -void BleKeyboard::set_version(uint16_t version) { - this->version = version; -} - -void BleKeyboard::sendReport(KeyReport* keys) -{ - if (this->isConnected()) - { - this->inputKeyboard->setValue((uint8_t*)keys, sizeof(KeyReport)); - this->inputKeyboard->notify(); -#if defined(USE_NIMBLE) - // vTaskDelay(delayTicks); - this->delay_ms(_delay_ms); -#endif // USE_NIMBLE - } -} - -void BleKeyboard::sendReport(MediaKeyReport* keys) -{ - if (this->isConnected()) - { - this->inputMediaKeys->setValue((uint8_t*)keys, sizeof(MediaKeyReport)); - this->inputMediaKeys->notify(); -#if defined(USE_NIMBLE) - //vTaskDelay(delayTicks); - this->delay_ms(_delay_ms); -#endif // USE_NIMBLE - } -} - -extern -const uint8_t _asciimap[128] PROGMEM; - -#define SHIFT 0x80 -const uint8_t _asciimap[128] = -{ - 0x00, // NUL - 0x00, // SOH - 0x00, // STX - 0x00, // ETX - 0x00, // EOT - 0x00, // ENQ - 0x00, // ACK - 0x00, // BEL - 0x2a, // BS Backspace - 0x2b, // TAB Tab - 0x28, // LF Enter - 0x00, // VT - 0x00, // FF - 0x00, // CR - 0x00, // SO - 0x00, // SI - 0x00, // DEL - 0x00, // DC1 - 0x00, // DC2 - 0x00, // DC3 - 0x00, // DC4 - 0x00, // NAK - 0x00, // SYN - 0x00, // ETB - 0x00, // CAN - 0x00, // EM - 0x00, // SUB - 0x00, // ESC - 0x00, // FS - 0x00, // GS - 0x00, // RS - 0x00, // US - - 0x2c, // ' ' - 0x1e|SHIFT, // ! - 0x34|SHIFT, // " - 0x20|SHIFT, // # - 0x21|SHIFT, // $ - 0x22|SHIFT, // % - 0x24|SHIFT, // & - 0x34, // ' - 0x26|SHIFT, // ( - 0x27|SHIFT, // ) - 0x25|SHIFT, // * - 0x2e|SHIFT, // + - 0x36, // , - 0x2d, // - - 0x37, // . - 0x38, // / - 0x27, // 0 - 0x1e, // 1 - 0x1f, // 2 - 0x20, // 3 - 0x21, // 4 - 0x22, // 5 - 0x23, // 6 - 0x24, // 7 - 0x25, // 8 - 0x26, // 9 - 0x33|SHIFT, // : - 0x33, // ; - 0x36|SHIFT, // < - 0x2e, // = - 0x37|SHIFT, // > - 0x38|SHIFT, // ? - 0x1f|SHIFT, // @ - 0x04|SHIFT, // A - 0x05|SHIFT, // B - 0x06|SHIFT, // C - 0x07|SHIFT, // D - 0x08|SHIFT, // E - 0x09|SHIFT, // F - 0x0a|SHIFT, // G - 0x0b|SHIFT, // H - 0x0c|SHIFT, // I - 0x0d|SHIFT, // J - 0x0e|SHIFT, // K - 0x0f|SHIFT, // L - 0x10|SHIFT, // M - 0x11|SHIFT, // N - 0x12|SHIFT, // O - 0x13|SHIFT, // P - 0x14|SHIFT, // Q - 0x15|SHIFT, // R - 0x16|SHIFT, // S - 0x17|SHIFT, // T - 0x18|SHIFT, // U - 0x19|SHIFT, // V - 0x1a|SHIFT, // W - 0x1b|SHIFT, // X - 0x1c|SHIFT, // Y - 0x1d|SHIFT, // Z - 0x2f, // [ - 0x31, // bslash - 0x30, // ] - 0x23|SHIFT, // ^ - 0x2d|SHIFT, // _ - 0x35, // ` - 0x04, // a - 0x05, // b - 0x06, // c - 0x07, // d - 0x08, // e - 0x09, // f - 0x0a, // g - 0x0b, // h - 0x0c, // i - 0x0d, // j - 0x0e, // k - 0x0f, // l - 0x10, // m - 0x11, // n - 0x12, // o - 0x13, // p - 0x14, // q - 0x15, // r - 0x16, // s - 0x17, // t - 0x18, // u - 0x19, // v - 0x1a, // w - 0x1b, // x - 0x1c, // y - 0x1d, // z - 0x2f|SHIFT, // { - 0x31|SHIFT, // | - 0x30|SHIFT, // } - 0x35|SHIFT, // ~ - 0 // DEL -}; - - -uint8_t USBPutChar(uint8_t c); - -// press() adds the specified key (printing, non-printing, or modifier) -// to the persistent key report and sends the report. Because of the way -// USB HID works, the host acts like the key remains pressed until we -// call release(), releaseAll(), or otherwise clear the report and resend. -size_t BleKeyboard::press(uint8_t k) -{ - uint8_t i; - if (k >= 136) { // it's a non-printing key (not a modifier) - k = k - 136; - } else if (k >= 128) { // it's a modifier key - _keyReport.modifiers |= (1<<(k-128)); - k = 0; - } else { // it's a printing key - k = pgm_read_byte(_asciimap + k); - if (!k) { - setWriteError(); - return 0; - } - if (k & 0x80) { // it's a capital letter or other character reached with shift - _keyReport.modifiers |= 0x02; // the left shift modifier - k &= 0x7F; - } - } - - // Add k to the key report only if it's not already present - // and if there is an empty slot. - if (_keyReport.keys[0] != k && _keyReport.keys[1] != k && - _keyReport.keys[2] != k && _keyReport.keys[3] != k && - _keyReport.keys[4] != k && _keyReport.keys[5] != k) { - - for (i=0; i<6; i++) { - if (_keyReport.keys[i] == 0x00) { - _keyReport.keys[i] = k; - break; - } - } - if (i == 6) { - setWriteError(); - return 0; - } - } - sendReport(&_keyReport); - return 1; -} - -size_t BleKeyboard::press(const MediaKeyReport k) -{ - uint16_t k_16 = k[1] | (k[0] << 8); - uint16_t mediaKeyReport_16 = _mediaKeyReport[1] | (_mediaKeyReport[0] << 8); - - mediaKeyReport_16 |= k_16; - _mediaKeyReport[0] = (uint8_t)((mediaKeyReport_16 & 0xFF00) >> 8); - _mediaKeyReport[1] = (uint8_t)(mediaKeyReport_16 & 0x00FF); - - sendReport(&_mediaKeyReport); - return 1; -} - -// release() takes the specified key out of the persistent key report and -// sends the report. This tells the OS the key is no longer pressed and that -// it shouldn't be repeated any more. -size_t BleKeyboard::release(uint8_t k) -{ - uint8_t i; - if (k >= 136) { // it's a non-printing key (not a modifier) - k = k - 136; - } else if (k >= 128) { // it's a modifier key - _keyReport.modifiers &= ~(1<<(k-128)); - k = 0; - } else { // it's a printing key - k = pgm_read_byte(_asciimap + k); - if (!k) { - return 0; - } - if (k & 0x80) { // it's a capital letter or other character reached with shift - _keyReport.modifiers &= ~(0x02); // the left shift modifier - k &= 0x7F; - } - } - - // Test the key report to see if k is present. Clear it if it exists. - // Check all positions in case the key is present more than once (which it shouldn't be) - for (i=0; i<6; i++) { - if (0 != k && _keyReport.keys[i] == k) { - _keyReport.keys[i] = 0x00; - } - } - - sendReport(&_keyReport); - return 1; -} - -size_t BleKeyboard::release(const MediaKeyReport k) -{ - uint16_t k_16 = k[1] | (k[0] << 8); - uint16_t mediaKeyReport_16 = _mediaKeyReport[1] | (_mediaKeyReport[0] << 8); - mediaKeyReport_16 &= ~k_16; - _mediaKeyReport[0] = (uint8_t)((mediaKeyReport_16 & 0xFF00) >> 8); - _mediaKeyReport[1] = (uint8_t)(mediaKeyReport_16 & 0x00FF); - - sendReport(&_mediaKeyReport); - return 1; -} - -void BleKeyboard::releaseAll(void) -{ - _keyReport.keys[0] = 0; - _keyReport.keys[1] = 0; - _keyReport.keys[2] = 0; - _keyReport.keys[3] = 0; - _keyReport.keys[4] = 0; - _keyReport.keys[5] = 0; - _keyReport.modifiers = 0; - _mediaKeyReport[0] = 0; - _mediaKeyReport[1] = 0; - sendReport(&_keyReport); - sendReport(&_mediaKeyReport); -} - -size_t BleKeyboard::write(uint8_t c) -{ - uint8_t p = press(c); // Keydown - release(c); // Keyup - return p; // just return the result of press() since release() almost always returns 1 -} - -size_t BleKeyboard::write(const MediaKeyReport c) -{ - uint16_t p = press(c); // Keydown - release(c); // Keyup - return p; // just return the result of press() since release() almost always returns 1 -} - -size_t BleKeyboard::write(const uint8_t *buffer, size_t size) { - size_t n = 0; - while (size--) { - if (*buffer != '\r') { - if (write(*buffer)) { - n++; - } else { - break; - } - } - buffer++; - } - return n; -} - -void BleKeyboard::onConnect(BLEServer* pServer) { - this->connected = true; - -#if !defined(USE_NIMBLE) - - BLE2902* desc = (BLE2902*)this->inputKeyboard->getDescriptorByUUID(BLEUUID((uint16_t)0x2902)); - desc->setNotifications(true); - desc = (BLE2902*)this->inputMediaKeys->getDescriptorByUUID(BLEUUID((uint16_t)0x2902)); - desc->setNotifications(true); - -#endif // !USE_NIMBLE - -} - -void BleKeyboard::onDisconnect(BLEServer* pServer) { - this->connected = false; - -#if !defined(USE_NIMBLE) - - BLE2902* desc = (BLE2902*)this->inputKeyboard->getDescriptorByUUID(BLEUUID((uint16_t)0x2902)); - desc->setNotifications(false); - desc = (BLE2902*)this->inputMediaKeys->getDescriptorByUUID(BLEUUID((uint16_t)0x2902)); - desc->setNotifications(false); - - advertising->start(); - -#endif // !USE_NIMBLE -} - -void BleKeyboard::onWrite(BLECharacteristic* me) { - uint8_t* value = (uint8_t*)(me->getValue().c_str()); - (void)value; - ESP_LOGI(LOG_TAG, "special keys: %d", *value); -} - -void BleKeyboard::delay_ms(uint64_t ms) { - uint64_t m = esp_timer_get_time(); - if(ms){ - uint64_t e = (m + (ms * 1000)); - if(m > e){ //overflow - while(esp_timer_get_time() > e) { } - } - while(esp_timer_get_time() < e) {} - } -} \ No newline at end of file diff --git a/Platformio/hardware/ESP32/lib/ESP32-BLE-Keyboard/BleKeyboard.h b/Platformio/hardware/ESP32/lib/ESP32-BLE-Keyboard/BleKeyboard.h deleted file mode 100644 index f30dd40d..00000000 --- a/Platformio/hardware/ESP32/lib/ESP32-BLE-Keyboard/BleKeyboard.h +++ /dev/null @@ -1,189 +0,0 @@ -// uncomment the following line to use NimBLE library -//#define USE_NIMBLE - -#ifndef ESP32_BLE_KEYBOARD_H -#define ESP32_BLE_KEYBOARD_H -#include "sdkconfig.h" -#if defined(CONFIG_BT_ENABLED) - -#if defined(USE_NIMBLE) - -#include "NimBLECharacteristic.h" -#include "NimBLEHIDDevice.h" - -#define BLEDevice NimBLEDevice -#define BLEServerCallbacks NimBLEServerCallbacks -#define BLECharacteristicCallbacks NimBLECharacteristicCallbacks -#define BLEHIDDevice NimBLEHIDDevice -#define BLECharacteristic NimBLECharacteristic -#define BLEAdvertising NimBLEAdvertising -#define BLEServer NimBLEServer - -#else - -#include "BLEHIDDevice.h" -#include "BLECharacteristic.h" - -#endif // USE_NIMBLE - -#include "Print.h" - -#define BLE_KEYBOARD_VERSION "0.0.4" -#define BLE_KEYBOARD_VERSION_MAJOR 0 -#define BLE_KEYBOARD_VERSION_MINOR 0 -#define BLE_KEYBOARD_VERSION_REVISION 4 - -const uint8_t KEY_LEFT_CTRL = 0x80; -const uint8_t KEY_LEFT_SHIFT = 0x81; -const uint8_t KEY_LEFT_ALT = 0x82; -const uint8_t KEY_LEFT_GUI = 0x83; -const uint8_t KEY_RIGHT_CTRL = 0x84; -const uint8_t KEY_RIGHT_SHIFT = 0x85; -const uint8_t KEY_RIGHT_ALT = 0x86; -const uint8_t KEY_RIGHT_GUI = 0x87; - -const uint8_t KEY_UP_ARROW = 0xDA; -const uint8_t KEY_DOWN_ARROW = 0xD9; -const uint8_t KEY_LEFT_ARROW = 0xD8; -const uint8_t KEY_RIGHT_ARROW = 0xD7; -const uint8_t KEY_BACKSPACE = 0xB2; -const uint8_t KEY_TAB = 0xB3; -const uint8_t KEY_RETURN = 0xB0; -const uint8_t KEY_ESC = 0xB1; -const uint8_t KEY_INSERT = 0xD1; -const uint8_t KEY_PRTSC = 0xCE; -const uint8_t KEY_DELETE = 0xD4; -const uint8_t KEY_PAGE_UP = 0xD3; -const uint8_t KEY_PAGE_DOWN = 0xD6; -const uint8_t KEY_HOME = 0xD2; -const uint8_t KEY_END = 0xD5; -const uint8_t KEY_CAPS_LOCK = 0xC1; -const uint8_t KEY_F1 = 0xC2; -const uint8_t KEY_F2 = 0xC3; -const uint8_t KEY_F3 = 0xC4; -const uint8_t KEY_F4 = 0xC5; -const uint8_t KEY_F5 = 0xC6; -const uint8_t KEY_F6 = 0xC7; -const uint8_t KEY_F7 = 0xC8; -const uint8_t KEY_F8 = 0xC9; -const uint8_t KEY_F9 = 0xCA; -const uint8_t KEY_F10 = 0xCB; -const uint8_t KEY_F11 = 0xCC; -const uint8_t KEY_F12 = 0xCD; -const uint8_t KEY_F13 = 0xF0; -const uint8_t KEY_F14 = 0xF1; -const uint8_t KEY_F15 = 0xF2; -const uint8_t KEY_F16 = 0xF3; -const uint8_t KEY_F17 = 0xF4; -const uint8_t KEY_F18 = 0xF5; -const uint8_t KEY_F19 = 0xF6; -const uint8_t KEY_F20 = 0xF7; -const uint8_t KEY_F21 = 0xF8; -const uint8_t KEY_F22 = 0xF9; -const uint8_t KEY_F23 = 0xFA; -const uint8_t KEY_F24 = 0xFB; - -const uint8_t KEY_NUM_0 = 0xEA; -const uint8_t KEY_NUM_1 = 0xE1; -const uint8_t KEY_NUM_2 = 0xE2; -const uint8_t KEY_NUM_3 = 0xE3; -const uint8_t KEY_NUM_4 = 0xE4; -const uint8_t KEY_NUM_5 = 0xE5; -const uint8_t KEY_NUM_6 = 0xE6; -const uint8_t KEY_NUM_7 = 0xE7; -const uint8_t KEY_NUM_8 = 0xE8; -const uint8_t KEY_NUM_9 = 0xE9; -const uint8_t KEY_NUM_SLASH = 0xDC; -const uint8_t KEY_NUM_ASTERISK = 0xDD; -const uint8_t KEY_NUM_MINUS = 0xDE; -const uint8_t KEY_NUM_PLUS = 0xDF; -const uint8_t KEY_NUM_ENTER = 0xE0; -const uint8_t KEY_NUM_PERIOD = 0xEB; - -typedef uint8_t MediaKeyReport[2]; - -const MediaKeyReport KEY_MEDIA_NEXT_TRACK = {1, 0}; -const MediaKeyReport KEY_MEDIA_PREVIOUS_TRACK = {2, 0}; -const MediaKeyReport KEY_MEDIA_STOP = {4, 0}; -const MediaKeyReport KEY_MEDIA_PLAY_PAUSE = {8, 0}; -const MediaKeyReport KEY_MEDIA_MUTE = {16, 0}; -const MediaKeyReport KEY_MEDIA_VOLUME_UP = {32, 0}; -const MediaKeyReport KEY_MEDIA_VOLUME_DOWN = {64, 0}; -const MediaKeyReport KEY_MEDIA_WWW_HOME = {128, 0}; -const MediaKeyReport KEY_MEDIA_LOCAL_MACHINE_BROWSER = {0, 1}; // Opens "My Computer" on Windows -// original from BLE-Keyboard -// const MediaKeyReport KEY_MEDIA_CALCULATOR = {0, 2}; -// changed for usage in OMOTE -const MediaKeyReport KEY_MEDIA_FASTFORWARD = {0, 2}; -const MediaKeyReport KEY_MEDIA_WWW_BOOKMARKS = {0, 4}; -const MediaKeyReport KEY_MEDIA_WWW_SEARCH = {0, 8}; -const MediaKeyReport KEY_MEDIA_WWW_STOP = {0, 16}; -const MediaKeyReport KEY_MEDIA_WWW_BACK = {0, 32}; -const MediaKeyReport KEY_MEDIA_CONSUMER_CONTROL_CONFIGURATION = {0, 64}; // Media Selection -// original from BLE-Keyboard -// const MediaKeyReport KEY_MEDIA_EMAIL_READER = {0, 128}; -// changed for usage in OMOTE -const MediaKeyReport KEY_MEDIA_REWIND = {0, 128}; - - -// Low level key report: up to 6 keys and shift, ctrl etc at once -typedef struct -{ - uint8_t modifiers; - uint8_t reserved; - uint8_t keys[6]; -} KeyReport; - -class BleKeyboard : public Print, public BLEServerCallbacks, public BLECharacteristicCallbacks -{ -private: - BLEHIDDevice* hid; - BLECharacteristic* inputKeyboard; - BLECharacteristic* outputKeyboard; - BLECharacteristic* inputMediaKeys; - BLEAdvertising* advertising; - KeyReport _keyReport; - MediaKeyReport _mediaKeyReport; - std::string deviceName; - std::string deviceManufacturer; - uint8_t batteryLevel; - bool connected = false; - uint32_t _delay_ms = 7; - void delay_ms(uint64_t ms); - - uint16_t vid = 0x05ac; - uint16_t pid = 0x820a; - uint16_t version = 0x0210; - -public: - BleKeyboard(std::string deviceName = "ESP32 Keyboard", std::string deviceManufacturer = "Espressif", uint8_t batteryLevel = 100); - void begin(void); - void end(void); - void sendReport(KeyReport* keys); - void sendReport(MediaKeyReport* keys); - size_t press(uint8_t k); - size_t press(const MediaKeyReport k); - size_t release(uint8_t k); - size_t release(const MediaKeyReport k); - size_t write(uint8_t c); - size_t write(const MediaKeyReport c); - size_t write(const uint8_t *buffer, size_t size); - void releaseAll(void); - bool isConnected(void); - void setBatteryLevel(uint8_t level); - void setName(std::string deviceName); - void setDelay(uint32_t ms); - - void set_vendor_id(uint16_t vid); - void set_product_id(uint16_t pid); - void set_version(uint16_t version); -protected: - virtual void onStarted(BLEServer *pServer) { }; - virtual void onConnect(BLEServer* pServer) override; - virtual void onDisconnect(BLEServer* pServer) override; - virtual void onWrite(BLECharacteristic* me) override; - -}; - -#endif // CONFIG_BT_ENABLED -#endif // ESP32_BLE_KEYBOARD_H diff --git a/Platformio/hardware/ESP32/lib/ESP32-BLE-Keyboard/README.md b/Platformio/hardware/ESP32/lib/ESP32-BLE-Keyboard/README.md deleted file mode 100644 index eac0d4ef..00000000 --- a/Platformio/hardware/ESP32/lib/ESP32-BLE-Keyboard/README.md +++ /dev/null @@ -1,162 +0,0 @@ -# ESP32 BLE Keyboard library - -This library allows you to make the ESP32 act as a Bluetooth Keyboard and control what it does. -You might also be interested in: -- [ESP32-BLE-Mouse](https://github.com/T-vK/ESP32-BLE-Mouse) -- [ESP32-BLE-Gamepad](https://github.com/lemmingDev/ESP32-BLE-Gamepad) - - -## Features - - - [x] Send key strokes - - [x] Send text - - [x] Press/release individual keys - - [x] Media keys are supported - - [ ] Read Numlock/Capslock/Scrolllock state - - [x] Set battery level (basically works, but doesn't show up in Android's status bar) - - [x] Compatible with Android - - [x] Compatible with Windows - - [x] Compatible with Linux - - [x] Compatible with MacOS X (not stable, some people have issues, doesn't work with old devices) - - [x] Compatible with iOS (not stable, some people have issues, doesn't work with old devices) - -## Installation -- (Make sure you can use the ESP32 with the Arduino IDE. [Instructions can be found here.](https://github.com/espressif/arduino-esp32#installation-instructions)) -- [Download the latest release of this library from the release page.](https://github.com/T-vK/ESP32-BLE-Keyboard/releases) -- In the Arduino IDE go to "Sketch" -> "Include Library" -> "Add .ZIP Library..." and select the file you just downloaded. -- You can now go to "File" -> "Examples" -> "ESP32 BLE Keyboard" and select any of the examples to get started. - -## Example - -``` C++ -/** - * This example turns the ESP32 into a Bluetooth LE keyboard that writes the words, presses Enter, presses a media key and then Ctrl+Alt+Delete - */ -#include - -BleKeyboard bleKeyboard; - -void setup() { - Serial.begin(115200); - Serial.println("Starting BLE work!"); - bleKeyboard.begin(); -} - -void loop() { - if(bleKeyboard.isConnected()) { - Serial.println("Sending 'Hello world'..."); - bleKeyboard.print("Hello world"); - - delay(1000); - - Serial.println("Sending Enter key..."); - bleKeyboard.write(KEY_RETURN); - - delay(1000); - - Serial.println("Sending Play/Pause media key..."); - bleKeyboard.write(KEY_MEDIA_PLAY_PAUSE); - - delay(1000); - - // - // Below is an example of pressing multiple keyboard modifiers - // which by default is commented out. - // - /* Serial.println("Sending Ctrl+Alt+Delete..."); - bleKeyboard.press(KEY_LEFT_CTRL); - bleKeyboard.press(KEY_LEFT_ALT); - bleKeyboard.press(KEY_DELETE); - delay(100); - bleKeyboard.releaseAll(); - */ - - } - Serial.println("Waiting 5 seconds..."); - delay(5000); -} -``` - -## API docs -The BleKeyboard interface is almost identical to the Keyboard Interface, so you can use documentation right here: -https://www.arduino.cc/reference/en/language/functions/usb/keyboard/ - -Just remember that you have to use `bleKeyboard` instead of just `Keyboard` and you need these two lines at the top of your script: -``` -#include -BleKeyboard bleKeyboard; -``` - -In addition to that you can send media keys (which is not possible with the USB keyboard library). Supported are the following: -- KEY_MEDIA_NEXT_TRACK -- KEY_MEDIA_PREVIOUS_TRACK -- KEY_MEDIA_STOP -- KEY_MEDIA_PLAY_PAUSE -- KEY_MEDIA_MUTE -- KEY_MEDIA_VOLUME_UP -- KEY_MEDIA_VOLUME_DOWN -- KEY_MEDIA_WWW_HOME -- KEY_MEDIA_LOCAL_MACHINE_BROWSER // Opens "My Computer" on Windows -- KEY_MEDIA_CALCULATOR -- KEY_MEDIA_WWW_BOOKMARKS -- KEY_MEDIA_WWW_SEARCH -- KEY_MEDIA_WWW_STOP -- KEY_MEDIA_WWW_BACK -- KEY_MEDIA_CONSUMER_CONTROL_CONFIGURATION // Media Selection -- KEY_MEDIA_EMAIL_READER - -There is also Bluetooth specific information that you can set (optional): -Instead of `BleKeyboard bleKeyboard;` you can do `BleKeyboard bleKeyboard("Bluetooth Device Name", "Bluetooth Device Manufacturer", 100);`. (Max lenght is 15 characters, anything beyond that will be truncated.) -The third parameter is the initial battery level of your device. To adjust the battery level later on you can simply call e.g. `bleKeyboard.setBatteryLevel(50)` (set battery level to 50%). -By default the battery level will be set to 100%, the device name will be `ESP32 Bluetooth Keyboard` and the manufacturer will be `Espressif`. -There is also a `setDelay` method to set a delay between each key event. E.g. `bleKeyboard.setDelay(10)` (10 milliseconds). The default is `8`. -This feature is meant to compensate for some applications and devices that can't handle fast input and will skip letters if too many keys are sent in a small time frame. - -## NimBLE-Mode -The NimBLE mode enables a significant saving of RAM and FLASH memory. - -### Comparison (SendKeyStrokes.ino at compile-time) - -**Standard** -``` -RAM: [= ] 9.3% (used 30548 bytes from 327680 bytes) -Flash: [======== ] 75.8% (used 994120 bytes from 1310720 bytes) -``` - -**NimBLE mode** -``` -RAM: [= ] 8.3% (used 27180 bytes from 327680 bytes) -Flash: [==== ] 44.2% (used 579158 bytes from 1310720 bytes) -``` - -### Comparison (SendKeyStrokes.ino at run-time) - -| | Standard | NimBLE mode | difference -|---|--:|--:|--:| -| `ESP.getHeapSize()` | 296.804 | 321.252 | **+ 24.448** | -| `ESP.getFreeHeap()` | 143.572 | 260.764 | **+ 117.192** | -| `ESP.getSketchSize()` | 994.224 | 579.264 | **- 414.960** | - -## How to activate NimBLE mode? - -### ArduinoIDE: -Uncomment the first line in BleKeyboard.h -```C++ -#define USE_NIMBLE -``` - -### PlatformIO: -Change your `platformio.ini` to the following settings -```ini -lib_deps = - NimBLE-Arduino - -build_flags = - -D USE_NIMBLE -``` - -## Credits - -Credits to [chegewara](https://github.com/chegewara) and [the authors of the USB keyboard library](https://github.com/arduino-libraries/Keyboard/) as this project is heavily based on their work! -Also, credits to [duke2421](https://github.com/T-vK/ESP32-BLE-Keyboard/issues/1) who helped a lot with testing, debugging and fixing the device descriptor! -And credits to [sivar2311](https://github.com/sivar2311) for adding NimBLE support, greatly reducing the memory footprint, fixing advertising issues and for adding the `setDelay` method. diff --git a/Platformio/hardware/ESP32/lib/ESP32-BLE-Keyboard/examples/SendKeyStrokes/SendKeyStrokes.ino b/Platformio/hardware/ESP32/lib/ESP32-BLE-Keyboard/examples/SendKeyStrokes/SendKeyStrokes.ino deleted file mode 100644 index 03d1e70a..00000000 --- a/Platformio/hardware/ESP32/lib/ESP32-BLE-Keyboard/examples/SendKeyStrokes/SendKeyStrokes.ino +++ /dev/null @@ -1,46 +0,0 @@ -/** - * This example turns the ESP32 into a Bluetooth LE keyboard that writes the words, presses Enter, presses a media key and then Ctrl+Alt+Delete - */ -#include - -BleKeyboard bleKeyboard; - -void setup() { - Serial.begin(115200); - Serial.println("Starting BLE work!"); - bleKeyboard.begin(); -} - -void loop() { - if(bleKeyboard.isConnected()) { - Serial.println("Sending 'Hello world'..."); - bleKeyboard.print("Hello world"); - - delay(1000); - - Serial.println("Sending Enter key..."); - bleKeyboard.write(KEY_RETURN); - - delay(1000); - - Serial.println("Sending Play/Pause media key..."); - bleKeyboard.write(KEY_MEDIA_PLAY_PAUSE); - - delay(1000); - - // - // Below is an example of pressing multiple keyboard modifiers - // which by default is commented out. - /* - Serial.println("Sending Ctrl+Alt+Delete..."); - bleKeyboard.press(KEY_LEFT_CTRL); - bleKeyboard.press(KEY_LEFT_ALT); - bleKeyboard.press(KEY_DELETE); - delay(100); - bleKeyboard.releaseAll(); - */ - } - - Serial.println("Waiting 5 seconds..."); - delay(5000); -} diff --git a/Platformio/hardware/ESP32/lib/ESP32-BLE-Keyboard/keywords.txt b/Platformio/hardware/ESP32/lib/ESP32-BLE-Keyboard/keywords.txt deleted file mode 100644 index 0aa35b70..00000000 --- a/Platformio/hardware/ESP32/lib/ESP32-BLE-Keyboard/keywords.txt +++ /dev/null @@ -1,24 +0,0 @@ -####################################### -# Syntax Coloring Map For ESP32 BLE Keyboard -####################################### -# Class -####################################### - -BleKeyboard KEYWORD1 - -####################################### -# Methods and Functions -####################################### - -begin KEYWORD2 -end KEYWORD2 -write KEYWORD2 -press KEYWORD2 -release KEYWORD2 -releaseAll KEYWORD2 -setBatteryLevel KEYWORD2 -isConnected KEYWORD2 - -####################################### -# Constants -####################################### diff --git a/Platformio/hardware/ESP32/lib/ESP32-BLE-Keyboard/library.properties b/Platformio/hardware/ESP32/lib/ESP32-BLE-Keyboard/library.properties deleted file mode 100644 index 263a10fc..00000000 --- a/Platformio/hardware/ESP32/lib/ESP32-BLE-Keyboard/library.properties +++ /dev/null @@ -1,9 +0,0 @@ -name=ESP32 BLE Keyboard -version=0.3.2 -author=T-vK -maintainer=T-vK -sentence=Bluetooth LE Keyboard library for the ESP32. -paragraph=Bluetooth LE Keyboard library for the ESP32. -category=Communication -url=https://github.com/T-vK/ESP32-BLE-Keyboard -architectures=esp32 diff --git a/Platformio/hardware/ESP32/lvgl_hal_esp32.cpp b/Platformio/hardware/ESP32/lvgl_hal_esp32.cpp deleted file mode 100644 index fed725f0..00000000 --- a/Platformio/hardware/ESP32/lvgl_hal_esp32.cpp +++ /dev/null @@ -1,90 +0,0 @@ -#include -#include "tft_hal_esp32.h" -#include "sleep_hal_esp32.h" - -// ----------------------- -// https://docs.lvgl.io/8.3/porting/display.html?highlight=lv_disp_draw_buf_init#buffering-modes -// With two buffers, the rendering and refreshing of the display become parallel operations -// Second buffer needs 15.360 bytes more memory in heap. -#define useTwoBuffersForlvgl - -// Display flushing -void my_disp_flush( lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p ){ - uint32_t w = ( area->x2 - area->x1 + 1 ); - uint32_t h = ( area->y2 - area->y1 + 1 ); - - tft.startWrite(); - tft.setAddrWindow(area->x1, area->y1, w, h); - #ifdef useTwoBuffersForlvgl - tft.pushPixelsDMA((uint16_t*)&color_p->full, w * h); - #else - tft.pushColors((uint16_t*)&color_p->full, w * h, true); - #endif - tft.endWrite(); - - lv_disp_flush_ready( disp ); -} - -// Read the touchpad -void my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data){ - int16_t touchX; - int16_t touchY; - get_touchpoint(&touchX, &touchY); - - bool touched = false; - if ((touchX > 0) || (touchY > 0)) { - touched = true; - setLastActivityTimestamp_HAL(); - } - - if( !touched ){ - data->state = LV_INDEV_STATE_REL; - } - else{ - data->state = LV_INDEV_STATE_PR; - - // Set the coordinates - data->point.x = SCR_WIDTH - touchX; - data->point.y = SCR_HEIGHT - touchY; - - //Serial.print( "touchpoint: x" ); - //Serial.print( touchX ); - //Serial.print( " y" ); - //Serial.println( touchY ); - //tft.drawFastHLine(0, SCR_HEIGHT - touchY, SCR_WIDTH, TFT_RED); - //tft.drawFastVLine(SCR_WIDTH - touchX, 0, SCR_HEIGHT, TFT_RED); - } -} - -static lv_disp_draw_buf_t draw_buf; - -void init_lvgl_HAL() { - // first init TFT - init_tft(); - - #ifdef useTwoBuffersForlvgl - lv_color_t * bufA = (lv_color_t *) malloc(sizeof(lv_color_t) * SCR_WIDTH * SCR_HEIGHT / 10); - lv_color_t * bufB = (lv_color_t *) malloc(sizeof(lv_color_t) * SCR_WIDTH * SCR_HEIGHT / 10); - lv_disp_draw_buf_init(&draw_buf, bufA, bufB, SCR_WIDTH * SCR_HEIGHT / 10); - #else - lv_color_t * bufA = (lv_color_t *) malloc(sizeof(lv_color_t) * SCR_WIDTH * SCR_HEIGHT / 10); - lv_disp_draw_buf_init(&draw_buf, bufA, NULL, SCR_WIDTH * SCR_HEIGHT / 10); - #endif - - // Initialize the display driver -------------------------------------------------------------------------- - static lv_disp_drv_t disp_drv; - lv_disp_drv_init( &disp_drv ); - disp_drv.hor_res = SCR_WIDTH; - disp_drv.ver_res = SCR_HEIGHT; - disp_drv.flush_cb = my_disp_flush; - disp_drv.draw_buf = &draw_buf; - lv_disp_drv_register( &disp_drv ); - - // Initialize the touchscreen driver - static lv_indev_drv_t indev_drv; - lv_indev_drv_init( &indev_drv ); - indev_drv.type = LV_INDEV_TYPE_POINTER; - indev_drv.read_cb = my_touchpad_read; - lv_indev_drv_register( &indev_drv ); - -} diff --git a/Platformio/hardware/ESP32/lvgl_hal_esp32.h b/Platformio/hardware/ESP32/lvgl_hal_esp32.h deleted file mode 100644 index 54ba69a1..00000000 --- a/Platformio/hardware/ESP32/lvgl_hal_esp32.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -void init_lvgl_HAL(); diff --git a/Platformio/hardware/ESP32/mqtt_hal_esp32.cpp b/Platformio/hardware/ESP32/mqtt_hal_esp32.cpp deleted file mode 100644 index 818b9a42..00000000 --- a/Platformio/hardware/ESP32/mqtt_hal_esp32.cpp +++ /dev/null @@ -1,159 +0,0 @@ -#include "WiFi.h" -#include -#include "mqtt_hal_esp32.h" -#include "secrets.h" - -#if (ENABLE_WIFI_AND_MQTT == 1) -WiFiClient espClient; -PubSubClient mqttClient(espClient); -bool isWifiConnected = false; - -tAnnounceWiFiconnected_cb thisAnnounceWiFiconnected_cb = NULL; -void set_announceWiFiconnected_cb_HAL(tAnnounceWiFiconnected_cb pAnnounceWiFiconnected_cb) { - thisAnnounceWiFiconnected_cb = pAnnounceWiFiconnected_cb; -} - -tAnnounceSubscribedTopics_cb thisAnnounceSubscribedTopics_cb = NULL; -void set_announceSubscribedTopics_cb_HAL(tAnnounceSubscribedTopics_cb pAnnounceSubscribedTopics_cb) { - thisAnnounceSubscribedTopics_cb = pAnnounceSubscribedTopics_cb; -} - -bool getIsWifiConnected_HAL() { - return isWifiConnected; -} - -// WiFi status event -void WiFiEvent(WiFiEvent_t event){ - //Serial.printf("[WiFi-event] event: %d\r\n", event); - if(event == ARDUINO_EVENT_WIFI_STA_GOT_IP){ - // connection to MQTT server will be done in checkMQTTconnection() - // mqttClient.setServer(MQTT_SERVER, 1883); // MQTT initialization - // mqttClient.connect("OMOTE"); // Connect using a client id - - } - - // Set status bar icon based on WiFi status - if (event == ARDUINO_EVENT_WIFI_STA_GOT_IP || event == ARDUINO_EVENT_WIFI_STA_GOT_IP6) { - isWifiConnected = true; - thisAnnounceWiFiconnected_cb(true); - Serial.printf("WiFi connected, IP address: %s\r\n", WiFi.localIP().toString().c_str()); - - } else if (event == ARDUINO_EVENT_WIFI_STA_DISCONNECTED) { - isWifiConnected = false; - thisAnnounceWiFiconnected_cb(false); - // automatically try to reconnect - Serial.printf("WiFi got disconnected. Will try to reconnect.\r\n"); - WiFi.begin(WIFI_SSID, WIFI_PASSWORD); - - } else { - // e.g. ARDUINO_EVENT_WIFI_STA_CONNECTED or many others - // connected is not enough, will wait for IP - isWifiConnected = false; - thisAnnounceWiFiconnected_cb(false); - - } -} - -void init_mqtt_HAL(void) { - // Setup WiFi - WiFi.setHostname("OMOTE"); //define hostname - WiFi.onEvent(WiFiEvent); - WiFi.begin(WIFI_SSID, WIFI_PASSWORD); - WiFi.setSleep(true); -} - -std::string subscribeTopicOMOTEtest = "OMOTE/test"; - -void callback(char* topic, byte* payload, unsigned int length) { - // handle message arrived - std::string topicReceived(topic); - std::string strPayload(reinterpret_cast(payload), length); - - if (topicReceived == subscribeTopicOMOTEtest) { - Serial.printf("MQTT: received topic %s with payload %s\r\n", subscribeTopicOMOTEtest.c_str(), strPayload.c_str()); - - } - - thisAnnounceSubscribedTopics_cb(topicReceived, strPayload); -} - -void mqtt_subscribeTopics() { - mqttClient.setCallback(&callback); - - mqttClient.subscribe(subscribeTopicOMOTEtest.c_str()); - Serial.printf(" Successfully subscribed to MQTT topic %s\r\n", subscribeTopicOMOTEtest.c_str()); - -} - -bool checkMQTTconnection() { - - if (WiFi.isConnected()) { - if (mqttClient.connected()) { - return true; - } else { - // try to connect to mqtt server - mqttClient.setBufferSize(512); // default is 256 - //mqttClient.setKeepAlive(15); // default is 15 Client will send MQTTPINGREQ to keep connection alive - //mqttClient.setSocketTimeout(15); // default is 15 This determines how long the client will wait for incoming data when it expects data to arrive - for example, whilst it is in the middle of reading an MQTT packet. - mqttClient.setServer(MQTT_SERVER, MQTT_SERVER_PORT); // MQTT initialization - - std::string mqttClientName = std::string(MQTT_CLIENTNAME) + "_esp32_" + std::string(WiFi.macAddress().c_str()); - if (mqttClient.connect(mqttClientName.c_str(), MQTT_USER, MQTT_PASS)) { - Serial.printf(" Successfully connected to MQTT broker\r\n"); - - mqtt_subscribeTopics(); - - } else { - Serial.printf(" MQTT connection failed (but WiFi is available). Will try later ...\r\n"); - - } - return mqttClient.connected(); - } - } else { - // Serial.printf(" No connection to MQTT server, because WiFi ist not connected.\r\n"); - return false; - } -} - -unsigned long reconnectInterval = 100; -// in order to do reconnect immediately ... -unsigned long lastReconnectAttempt = millis() - reconnectInterval - 1; -void mqtt_loop_HAL() { - if (!mqttClient.connected()) { - unsigned long currentMillis = millis(); - if ((currentMillis - lastReconnectAttempt) > reconnectInterval) { - lastReconnectAttempt = currentMillis; - // Attempt to reconnect - checkMQTTconnection(); - } - } - - if (mqttClient.connected()) { - mqttClient.loop(); - } -} - -bool publishMQTTMessage_HAL(const char *topic, const char *payload){ - - if (checkMQTTconnection()) { - // Serial.printf("Sending mqtt payload to topic \"%s\": %s\r\n", topic, payload); - - if (mqttClient.publish(topic, payload)) { - // Serial.printf("Publish ok\r\n"); - return true; - } - else { - Serial.printf("Publish failed\r\n"); - } - } else { - Serial.printf(" Cannot publish mqtt message, because checkMQTTconnection failed (WiFi or mqtt is not connected)\r\n"); - } - return false; -} - -void wifiStop_HAL() { - WiFi.disconnect(); - WiFi.mode(WIFI_OFF); -} - -#endif diff --git a/Platformio/hardware/ESP32/mqtt_hal_esp32.h b/Platformio/hardware/ESP32/mqtt_hal_esp32.h deleted file mode 100644 index 116ae601..00000000 --- a/Platformio/hardware/ESP32/mqtt_hal_esp32.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#if (ENABLE_WIFI_AND_MQTT == 1) - -void init_mqtt_HAL(void); -bool getIsWifiConnected_HAL(); -void mqtt_loop_HAL(); -bool publishMQTTMessage_HAL(const char *topic, const char *payload); -void wifiStop_HAL(); - -typedef void (*tAnnounceWiFiconnected_cb)(bool connected); -void set_announceWiFiconnected_cb_HAL(tAnnounceWiFiconnected_cb pAnnounceWiFiconnected_cb); -typedef void (*tAnnounceSubscribedTopics_cb)(std::string topic, std::string payload); -void set_announceSubscribedTopics_cb_HAL(tAnnounceSubscribedTopics_cb pAnnounceSubscribedTopics_cb); - -#endif diff --git a/Platformio/hardware/ESP32/preferencesStorage_hal_esp32.cpp b/Platformio/hardware/ESP32/preferencesStorage_hal_esp32.cpp deleted file mode 100644 index e60fe0d0..00000000 --- a/Platformio/hardware/ESP32/preferencesStorage_hal_esp32.cpp +++ /dev/null @@ -1,75 +0,0 @@ -#include -#include "sleep_hal_esp32.h" -#include "tft_hal_esp32.h" - -Preferences preferences; - -std::string activeScene; -std::string activeGUIname; -int activeGUIlist; -int lastActiveGUIlistIndex; - -void init_preferences_HAL(void) { - // Restore settings from internal flash memory - preferences.begin("settings", false); - if (preferences.getBool("alreadySetUp")) { - // from sleep.h - set_wakeupByIMUEnabled_HAL(preferences.getBool("wkpByIMU")); - set_sleepTimeout_HAL(preferences.getUInt("slpTimeout")); - // from tft.h - set_backlightBrightness_HAL(preferences.getUChar("blBrightness")); - // from here - activeScene = std::string(preferences.getString("currentScene").c_str()); - activeGUIname = std::string(preferences.getString("currentGUIname").c_str()); - activeGUIlist =(preferences.getInt("currentGUIlist")); - lastActiveGUIlistIndex = (preferences.getInt("lastActiveIndex")); - - // Serial.printf("Preferences restored: brightness %d, GUI %s, scene %s\r\n", get_backlightBrightness_HAL(), get_activeGUIname().c_str(), get_activeScene().c_str()); - } else { - // Serial.printf("No preferences to restore\r\n"); - } - preferences.end(); -} - -void save_preferences_HAL(void) { - preferences.begin("settings", false); - // from sleep.h - preferences.putBool("wkpByIMU", get_wakeupByIMUEnabled_HAL()); - // from tft.h - preferences.putUInt("slpTimeout", get_sleepTimeout_HAL()); - preferences.putUChar("blBrightness", get_backlightBrightness_HAL()); - // from here - preferences.putString("currentScene", activeScene.c_str()); - preferences.putString("currentGUIname", activeGUIname.c_str()); - preferences.putInt("currentGUIlist", activeGUIlist); - preferences.putInt("lastActiveIndex", lastActiveGUIlistIndex); - if (!preferences.getBool("alreadySetUp")) { - preferences.putBool("alreadySetUp", true); - } - preferences.end(); -} - -std::string get_activeScene_HAL() { - return activeScene; -} -void set_activeScene_HAL(std::string anActiveScene) { - activeScene = anActiveScene; -} -std::string get_activeGUIname_HAL(){ - return activeGUIname; -} -void set_activeGUIname_HAL(std::string anActiveGUIname) { - activeGUIname = anActiveGUIname; -} -int get_activeGUIlist_HAL() { - return activeGUIlist; -} -void set_activeGUIlist_HAL(int anActiveGUIlist) { - activeGUIlist = anActiveGUIlist; -} -int get_lastActiveGUIlistIndex_HAL() { - return lastActiveGUIlistIndex; -} -void set_lastActiveGUIlistIndex_HAL(int aGUIlistIndex) { - lastActiveGUIlistIndex = aGUIlistIndex; -} diff --git a/Platformio/hardware/ESP32/preferencesStorage_hal_esp32.h b/Platformio/hardware/ESP32/preferencesStorage_hal_esp32.h deleted file mode 100644 index e223648a..00000000 --- a/Platformio/hardware/ESP32/preferencesStorage_hal_esp32.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include - -void init_preferences_HAL(void); -void save_preferences_HAL(void); - -std::string get_activeScene_HAL(); -void set_activeScene_HAL(std::string anActiveScene); -std::string get_activeGUIname_HAL(); -void set_activeGUIname_HAL(std::string anActiveGUIname); -int get_activeGUIlist_HAL(); -void set_activeGUIlist_HAL(int anActiveGUIlist); -int get_lastActiveGUIlistIndex_HAL(); -void set_lastActiveGUIlistIndex_HAL(int aGUIlistIndex); diff --git a/Platformio/hardware/ESP32/sleep_hal_esp32.cpp b/Platformio/hardware/ESP32/sleep_hal_esp32.cpp deleted file mode 100644 index 0b69e9d9..00000000 --- a/Platformio/hardware/ESP32/sleep_hal_esp32.cpp +++ /dev/null @@ -1,254 +0,0 @@ -#include -#include "SparkFunLIS3DH.h" -#include "sleep_hal_esp32.h" -// before going to sleep, some tasks have to be done -// save settings -#include "preferencesStorage_hal_esp32.h" -// turn off power of IR receiver -#include "infrared_receiver_hal_esp32.h" -// turn off tft -#include "tft_hal_esp32.h" -// disconnect WiFi -#include "mqtt_hal_esp32.h" -// disconnect BLE keyboard -#include "keyboard_ble_hal_esp32.h" -// prepare keypad keys to wakeup -#include "keypad_keys_hal_esp32.h" - -uint8_t ACC_INT_GPIO = 13; - -int MOTION_THRESHOLD = 50; // motion above threshold keeps device awake -int DEFAULT_SLEEP_TIMEOUT = 20000; // default time until device enters sleep mode in milliseconds. Can be overridden. - -// is "lift to wake" enabled -bool wakeupByIMUEnabled = true; -// timeout before going to sleep -uint32_t sleepTimeout; -// Timestamp of the last activity. Go to sleep if (millis() - lastActivityTimestamp > sleepTimeout) -uint32_t lastActivityTimestamp; - -LIS3DH IMU(I2C_MODE, 0x19); -Wakeup_reasons wakeup_reason; - -void setLastActivityTimestamp_HAL() { - // There was motion, touchpad or key hit. - // Set the time where this happens. - lastActivityTimestamp = millis(); -} - -void activityDetection() { - // if there is any motion, setLastActivityTimestamp_HAL() is called - int motion = 0; - - // A variable declared static inside a function is visible only inside that function, exists only once (not created/destroyed for each call) and is permanent. It is in a sense a private global variable. - static int accXold; - static int accYold; - static int accZold; - int accX = IMU.readFloatAccelX()*1000; - int accY = IMU.readFloatAccelY()*1000; - int accZ = IMU.readFloatAccelZ()*1000; - - // determine motion value as da/dt - motion = (abs(accXold - accX) + abs(accYold - accY) + abs(accZold - accZ)); - // If the motion exceeds the threshold, the lastActivityTimestamp is updated - if(motion > MOTION_THRESHOLD) { - setLastActivityTimestamp_HAL(); - } - - // Store the current acceleration and time - accXold = accX; - accYold = accY; - accZold = accZ; -} - -void configIMUInterruptsBeforeGoingToSleep() -{ - uint8_t dataToWrite = 0; - - //LIS3DH_INT1_CFG - //dataToWrite |= 0x80;//AOI, 0 = OR 1 = AND - //dataToWrite |= 0x40;//6D, 0 = interrupt source, 1 = 6 direction source - //Set these to enable individual axes of generation source (or direction) - // -- high and low are used generically - dataToWrite |= 0x20;//Z high - //dataToWrite |= 0x10;//Z low - dataToWrite |= 0x08;//Y high - //dataToWrite |= 0x04;//Y low - dataToWrite |= 0x02;//X high - //dataToWrite |= 0x01;//X low - if (wakeupByIMUEnabled) { - IMU.writeRegister(LIS3DH_INT1_CFG, 0b00101010); - } else { - IMU.writeRegister(LIS3DH_INT1_CFG, 0b00000000); - } - - //LIS3DH_INT1_THS - dataToWrite = 0; - //Provide 7 bit value, 0x7F always equals max range by accelRange setting - dataToWrite |= 0x45; - IMU.writeRegister(LIS3DH_INT1_THS, dataToWrite); - - //LIS3DH_INT1_DURATION - dataToWrite = 0; - //minimum duration of the interrupt - //LSB equals 1/(sample rate) - dataToWrite |= 0x00; // 1 * 1/50 s = 20ms - IMU.writeRegister(LIS3DH_INT1_DURATION, dataToWrite); - - //LIS3DH_CTRL_REG5 - //Int1 latch interrupt and 4D on int1 (preserve fifo en) - IMU.readRegister(&dataToWrite, LIS3DH_CTRL_REG5); - dataToWrite &= 0xF3; //Clear bits of interest - dataToWrite |= 0x08; //Latch interrupt (Cleared by reading int1_src) - //dataToWrite |= 0x04; //Pipe 4D detection from 6D recognition to int1? - IMU.writeRegister(LIS3DH_CTRL_REG5, dataToWrite); - - //LIS3DH_CTRL_REG3 - //Choose source for pin 1 - dataToWrite = 0; - //dataToWrite |= 0x80; //Click detect on pin 1 - dataToWrite |= 0x40; //AOI1 event (Generator 1 interrupt on pin 1) - dataToWrite |= 0x20; //AOI2 event () - //dataToWrite |= 0x10; //Data ready - //dataToWrite |= 0x04; //FIFO watermark - //dataToWrite |= 0x02; //FIFO overrun - IMU.writeRegister(LIS3DH_CTRL_REG3, dataToWrite); - -} - -// Enter Sleep Mode -void enterSleep(){ - // Save settings to internal flash memory - save_preferences_HAL(); - - // Configure IMU - uint8_t intDataRead; - // clear interrupt - IMU.readRegister(&intDataRead, LIS3DH_INT1_SRC); - configIMUInterruptsBeforeGoingToSleep(); - // really clear interrupt - IMU.readRegister(&intDataRead, LIS3DH_INT1_SRC); - - #if (ENABLE_WIFI_AND_MQTT == 1) - // Power down modem - wifiStop_HAL(); - #endif - - #if (ENABLE_KEYBOARD_BLE == 1) - keyboardBLE_end_HAL(); - #endif - - // Prepare IO states - digitalWrite(TFT_DC, LOW); // LCD control signals off - digitalWrite(TFT_CS, LOW); - digitalWrite(TFT_MOSI, LOW); - digitalWrite(TFT_SCLK, LOW); - digitalWrite(LCD_EN_GPIO, HIGH); // LCD logic off - digitalWrite(LCD_BL_GPIO, HIGH); // LCD backlight off - // pinMode(CRG_STAT, INPUT); // Disable Pull-Up - pinMode(IR_RX_GPIO, INPUT); // force IR receiver pin to INPUT to prevent high current during sleep (additional 60 uA) - digitalWrite(IR_VCC_GPIO, LOW); // IR Receiver off - - // Configure button matrix for ext1 interrupt - pinMode(SW_1_GPIO, OUTPUT); - pinMode(SW_2_GPIO, OUTPUT); - pinMode(SW_3_GPIO, OUTPUT); - pinMode(SW_4_GPIO, OUTPUT); - pinMode(SW_5_GPIO, OUTPUT); - digitalWrite(SW_1_GPIO, HIGH); - digitalWrite(SW_2_GPIO, HIGH); - digitalWrite(SW_3_GPIO, HIGH); - digitalWrite(SW_4_GPIO, HIGH); - digitalWrite(SW_5_GPIO, HIGH); - gpio_hold_en((gpio_num_t)SW_1_GPIO); - gpio_hold_en((gpio_num_t)SW_2_GPIO); - gpio_hold_en((gpio_num_t)SW_3_GPIO); - gpio_hold_en((gpio_num_t)SW_4_GPIO); - gpio_hold_en((gpio_num_t)SW_5_GPIO); - // Force display pins to high impedance - // Without this the display might not wake up from sleep - pinMode(LCD_BL_GPIO, INPUT); - pinMode(LCD_EN_GPIO, INPUT); - gpio_hold_en((gpio_num_t)LCD_BL_GPIO); - gpio_hold_en((gpio_num_t)LCD_EN_GPIO); - gpio_deep_sleep_hold_en(); - - esp_sleep_enable_ext1_wakeup(BUTTON_PIN_BITMASK, ESP_EXT1_WAKEUP_ANY_HIGH); - - delay(100); - // Sleep - esp_deep_sleep_start(); -} - -void init_sleep_HAL() { - // will be called after boot or wakeup. Releases GPIO hold and sets wakeup_reason - if (sleepTimeout == 0){ - sleepTimeout = DEFAULT_SLEEP_TIMEOUT; - } - - // Find out wakeup cause - if (esp_sleep_get_wakeup_cause() == ESP_SLEEP_WAKEUP_EXT1) { - if (log(esp_sleep_get_ext1_wakeup_status())/log(2) == 13) { - wakeup_reason = WAKEUP_BY_IMU; - } else { - wakeup_reason = WAKEUP_BY_KEYPAD; - } - } else { - wakeup_reason = WAKEUP_BY_RESET; - } - - pinMode(ACC_INT_GPIO, INPUT); - - // Release GPIO hold in case we are coming out of standby - gpio_hold_dis((gpio_num_t)SW_1_GPIO); - gpio_hold_dis((gpio_num_t)SW_2_GPIO); - gpio_hold_dis((gpio_num_t)SW_3_GPIO); - gpio_hold_dis((gpio_num_t)SW_4_GPIO); - gpio_hold_dis((gpio_num_t)SW_5_GPIO); - gpio_hold_dis((gpio_num_t)LCD_EN_GPIO); - gpio_hold_dis((gpio_num_t)LCD_BL_GPIO); - gpio_deep_sleep_hold_dis(); -} - -void init_IMU_HAL(void) { - // setup IMU to recognize motion - IMU.settings.accelSampleRate = 50; //Hz. Can be: 0,1,10,25,50,100,200,400,1600,5000 Hz - IMU.settings.accelRange = 2; //Max G force readable. Can be: 2, 4, 8, 16 - IMU.settings.adcEnabled = 0; - IMU.settings.tempEnabled = 0; - IMU.settings.xAccelEnabled = 1; - IMU.settings.yAccelEnabled = 1; - IMU.settings.zAccelEnabled = 1; - IMU.begin(); - uint8_t intDataRead; - IMU.readRegister(&intDataRead, LIS3DH_INT1_SRC);//clear interrupt - -} - -void check_activity_HAL() { - activityDetection(); - if(millis() - lastActivityTimestamp > sleepTimeout){ - Serial.println("Entering Sleep Mode. Goodbye."); - enterSleep(); - } -} - -uint32_t get_sleepTimeout_HAL() { - return sleepTimeout; -} -void set_sleepTimeout_HAL(uint32_t aSleepTimeout) { - sleepTimeout = aSleepTimeout; - // For reason unknown, some users reported sleepTimeout was set to 0. In this case device would immediately go to sleep. Prevent this. - if (sleepTimeout == 0) { - sleepTimeout = DEFAULT_SLEEP_TIMEOUT; - } -} -bool get_wakeupByIMUEnabled_HAL() { - return wakeupByIMUEnabled; -} -void set_wakeupByIMUEnabled_HAL(bool aWakeupByIMUEnabled) { - wakeupByIMUEnabled = aWakeupByIMUEnabled; -} -uint32_t get_lastActivityTimestamp() { - return lastActivityTimestamp; -} diff --git a/Platformio/hardware/ESP32/sleep_hal_esp32.h b/Platformio/hardware/ESP32/sleep_hal_esp32.h deleted file mode 100644 index bb56b90e..00000000 --- a/Platformio/hardware/ESP32/sleep_hal_esp32.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include - -// wakeup reason -enum Wakeup_reasons{WAKEUP_BY_RESET, WAKEUP_BY_IMU, WAKEUP_BY_KEYPAD}; -extern Wakeup_reasons wakeup_reason; - -// only called by tft.cpp, needs to know this because tft gets dimmed 2000 ms before going to sleep -uint32_t get_lastActivityTimestamp(); - -// called from the HAL -void init_sleep_HAL(); -void init_IMU_HAL(); -void check_activity_HAL(); -void setLastActivityTimestamp_HAL(); - -uint32_t get_sleepTimeout_HAL(); -void set_sleepTimeout_HAL(uint32_t aSleepTimeout); -bool get_wakeupByIMUEnabled_HAL(); -void set_wakeupByIMUEnabled_HAL(bool aWakeupByIMUEnabled); diff --git a/Platformio/hardware/ESP32/tft_hal_esp32.cpp b/Platformio/hardware/ESP32/tft_hal_esp32.cpp deleted file mode 100644 index 6e44e76b..00000000 --- a/Platformio/hardware/ESP32/tft_hal_esp32.cpp +++ /dev/null @@ -1,109 +0,0 @@ -#include -#include "driver/ledc.h" -#include "tft_hal_esp32.h" -#include "sleep_hal_esp32.h" - -uint8_t SDA_GPIO = 19; -uint8_t SCL_GPIO = 22; - -uint8_t LCD_BL_GPIO = 4; -uint8_t LCD_EN_GPIO = 10; - -TFT_eSPI tft = TFT_eSPI(); -Adafruit_FT6206 touch = Adafruit_FT6206(); -TS_Point touchPoint; -byte backlightBrightness = 255; - -void init_tft(void) { - // Configure the backlight PWM - // Manual setup because ledcSetup() briefly turns on the backlight - ledc_channel_config_t ledc_channel_left; - ledc_channel_left.gpio_num = (gpio_num_t)LCD_BL_GPIO; - ledc_channel_left.speed_mode = LEDC_HIGH_SPEED_MODE; - ledc_channel_left.channel = LEDC_CHANNEL_5; - ledc_channel_left.intr_type = LEDC_INTR_DISABLE; - ledc_channel_left.timer_sel = LEDC_TIMER_1; - // LEDC channel duty, the range of duty setting is [0, (2**duty_resolution)] - ledc_channel_left.duty = 0; - // needs to be set to 0, otherwise log message "E (324) ledc: ledc_set_duty_with_hpoint(699): hpoint argument is invalid" - // https://github.com/mudassar-tamboli/ESP32-OV7670-WebSocket-Camera/issues/13 - // LEDC channel hpoint value, the max value is 0xfffff - ledc_channel_left.hpoint = 0; - ledc_channel_left.flags.output_invert = 1; // Can't do this with ledcSetup() - // hpoint and duty explained: - // https://miro.medium.com/v2/resize:fit:1400/1*ViqSTFdH9COZ51iKYrIyMA.png - ledc_channel_config(&ledc_channel_left); - - ledc_timer_config_t ledc_timer; - ledc_timer.speed_mode = LEDC_HIGH_SPEED_MODE; - ledc_timer.duty_resolution = LEDC_TIMER_8_BIT; - ledc_timer.timer_num = LEDC_TIMER_1; - ledc_timer.freq_hz = 640; - // https://github.com/mudassar-tamboli/ESP32-OV7670-WebSocket-Camera/issues/13 - // otherwise crash with "assert failed: ledc_clk_cfg_to_global_clk ledc.c:444 (false)" - ledc_timer.clk_cfg = LEDC_USE_APB_CLK; - esp_err_t err = ledc_timer_config(&ledc_timer); - if (err != ESP_OK) { - Serial.println("Error when calling ledc_timer_config!"); - } - - #if (OMOTE_HARDWARE_REV == 1) - // Slowly charge the VSW voltage to prevent a brownout - // Workaround for hardware rev 1! - Serial.println("Will slowly charge VSW voltage to prevent that screen is completely bright, with no content"); - for(int i = 0; i < 100; i++) { - digitalWrite(LCD_EN_GPIO, HIGH); // LCD Logic off - delayMicroseconds(1); - digitalWrite(LCD_EN_GPIO, LOW); // LCD Logic on - } - #else - Serial.println("Will immediately charge VSW voltage. If screen is completely bright, with no content, then this is the reason."); - digitalWrite(LCD_EN_GPIO, LOW); - #endif - - // https://github.com/CoretechR/OMOTE/issues/70#issuecomment-2016763291 - delay(5); // Wait for the LCD driver to power on - tft.init(); - tft.initDMA(); - tft.setRotation(0); - tft.fillScreen(TFT_BLACK); - tft.setSwapBytes(true); - - // SDA and SCL need to be set explicitly, because for IMU you cannot set it explicitly in the constructor. - // Configure i2c pins and set frequency to 400kHz - Wire.begin(SDA_GPIO, SCL_GPIO, 400000); - // Setup touchscreen - touch.begin(128); // Initialize touchscreen and set sensitivity threshold -} - -void get_touchpoint(int16_t *touchX, int16_t *touchY) { - touchPoint = touch.getPoint(); - *touchX = touchPoint.x; - *touchY = touchPoint.y; -} - -void update_backligthBrighness_HAL(void) { - // A variable declared static inside a function is visible only inside that function, exists only once (not created/destroyed for each call) and is permanent. It is in a sense a private global variable. - static int fadeInTimer = millis(); // fadeInTimer = time after setup - if (millis() < fadeInTimer + backlightBrightness) { - // after boot or wakeup, fade in backlight brightness - // fade in lasts for ms - ledcWrite(5, millis() - fadeInTimer); - } else { - if (millis() - get_lastActivityTimestamp() > get_sleepTimeout_HAL() - 2000) { - // less than 2000 ms until standby - // dim backlight - ledcWrite(5, get_backlightBrightness_HAL() * 0.3); - } else { - // normal mode, set full backlightBrightness - ledcWrite(5, backlightBrightness); - } - } -} - -uint8_t get_backlightBrightness_HAL() { - return backlightBrightness; -}; -void set_backlightBrightness_HAL(uint8_t aBacklightBrightness) { - backlightBrightness = aBacklightBrightness; -}; diff --git a/Platformio/hardware/ESP32/tft_hal_esp32.h b/Platformio/hardware/ESP32/tft_hal_esp32.h deleted file mode 100644 index 3bff1fb2..00000000 --- a/Platformio/hardware/ESP32/tft_hal_esp32.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include -#include - -extern uint8_t LCD_BL_GPIO; -extern uint8_t LCD_EN_GPIO; - -// used in lvgl_hal.cpp "void my_disp_flush(..." -extern TFT_eSPI tft; - -// only called from lvgl_hal.cpp, not from the HAL -void init_tft(void); -void get_touchpoint(int16_t *touchX, int16_t *touchY); - -// called from the HAL -void update_backligthBrighness_HAL(void); -uint8_t get_backlightBrightness_HAL(); -void set_backlightBrightness_HAL(uint8_t aBacklightBrightness); diff --git a/Platformio/hardware/ESP32/user_led_hal_esp32.cpp b/Platformio/hardware/ESP32/user_led_hal_esp32.cpp deleted file mode 100644 index 989aa949..00000000 --- a/Platformio/hardware/ESP32/user_led_hal_esp32.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include - -uint8_t USER_LED_GPIO = 2; - -void init_userled_HAL(void) { - pinMode(USER_LED_GPIO, OUTPUT); - digitalWrite(USER_LED_GPIO, LOW); -} - -void update_userled_HAL(void) { - digitalWrite(USER_LED_GPIO, millis() % 2000 > 1000); -} diff --git a/Platformio/hardware/ESP32/user_led_hal_esp32.h b/Platformio/hardware/ESP32/user_led_hal_esp32.h deleted file mode 100644 index 5a41e793..00000000 --- a/Platformio/hardware/ESP32/user_led_hal_esp32.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -void init_userled_HAL(void); -void update_userled_HAL(void); diff --git a/Platformio/hardware/hardwareLayer.h b/Platformio/hardware/hardwareLayer.h deleted file mode 100644 index 7a5ee977..00000000 --- a/Platformio/hardware/hardwareLayer.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#if defined(WIN32) || defined(__linux__) - #include "windows_linux/include_hal_windows_linux.h" -#elif defined(ARDUINO) - #include "ESP32/include_hal_esp32.h" -#endif diff --git a/Platformio/hardware/windows_linux/battery_hal_windows_linux.cpp b/Platformio/hardware/windows_linux/battery_hal_windows_linux.cpp deleted file mode 100644 index e98c15eb..00000000 --- a/Platformio/hardware/windows_linux/battery_hal_windows_linux.cpp +++ /dev/null @@ -1,7 +0,0 @@ -void init_battery_HAL(void) {}; - -void get_battery_status_HAL(int *battery_voltage, int *battery_percentage, bool *battery_ischarging) { - *battery_voltage = 3950; - *battery_percentage = 50; - *battery_ischarging = false; -} diff --git a/Platformio/hardware/windows_linux/battery_hal_windows_linux.h b/Platformio/hardware/windows_linux/battery_hal_windows_linux.h deleted file mode 100644 index 2bfcc4ba..00000000 --- a/Platformio/hardware/windows_linux/battery_hal_windows_linux.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -void init_battery_HAL(void); -void get_battery_status_HAL(int *battery_voltage, int *battery_percentage, bool *battery_ischarging); diff --git a/Platformio/hardware/windows_linux/hardware_general_hal_windows_linux.cpp b/Platformio/hardware/windows_linux/hardware_general_hal_windows_linux.cpp deleted file mode 100644 index 06dd3527..00000000 --- a/Platformio/hardware/windows_linux/hardware_general_hal_windows_linux.cpp +++ /dev/null @@ -1,3 +0,0 @@ -void init_hardware_general_HAL(void) { - -} diff --git a/Platformio/hardware/windows_linux/hardware_general_hal_windows_linux.h b/Platformio/hardware/windows_linux/hardware_general_hal_windows_linux.h deleted file mode 100644 index 8f7f6192..00000000 --- a/Platformio/hardware/windows_linux/hardware_general_hal_windows_linux.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -void init_hardware_general_HAL(void); diff --git a/Platformio/hardware/windows_linux/heapUsage_hal_windows_linux.cpp b/Platformio/hardware/windows_linux/heapUsage_hal_windows_linux.cpp deleted file mode 100644 index 47a9d7f9..00000000 --- a/Platformio/hardware/windows_linux/heapUsage_hal_windows_linux.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include - -#if defined(WIN32) -// https://www.daniweb.com/programming/software-development/threads/135188/calculate-the-amount-of-heap-memory -// returns used heap size in bytes or negative if heap is corrupted. -long HeapUsed() -{ - _HEAPINFO info = { 0, 0, 0 }; - long used = 0; - int rc; - - while ((rc=_heapwalk(&info)) == _HEAPOK) - { - if (info._useflag == _USEDENTRY) - used += info._size; - } - if (rc != _HEAPEND && rc != _HEAPEMPTY) - used = (used?-used:-1); - - return used; -} - -#elif defined(__linux__) -long HeapUsed() { - // don't know how to get used heap size in linux - return 800000; -} -#endif - -void get_heapUsage_HAL(unsigned long *heapSize, unsigned long *freeHeap, unsigned long *maxAllocHeap, unsigned long *minFreeHeap) { - *freeHeap = HeapUsed(); - // Don't know how big heap can get including swap. So we report twice the size of used heap. With that, free heap is the same as used heap. - *heapSize = 2 * *freeHeap; - *maxAllocHeap = 0; - *minFreeHeap = 0; -} diff --git a/Platformio/hardware/windows_linux/heapUsage_hal_windows_linux.h b/Platformio/hardware/windows_linux/heapUsage_hal_windows_linux.h deleted file mode 100644 index d290c699..00000000 --- a/Platformio/hardware/windows_linux/heapUsage_hal_windows_linux.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -void get_heapUsage_HAL(unsigned long *heapSize, unsigned long *freeHeap, unsigned long *maxAllocHeap, unsigned long *minFreeHeap); diff --git a/Platformio/hardware/windows_linux/include_hal_windows_linux.h b/Platformio/hardware/windows_linux/include_hal_windows_linux.h deleted file mode 100644 index 3df3c653..00000000 --- a/Platformio/hardware/windows_linux/include_hal_windows_linux.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include "windows_linux/battery_hal_windows_linux.h" -#include "windows_linux/hardware_general_hal_windows_linux.h" -#include "windows_linux/heapUsage_hal_windows_linux.h" -#include "windows_linux/infrared_receiver_hal_windows_linux.h" -#include "windows_linux/infrared_sender_hal_windows_linux.h" -#include "windows_linux/keyboard_ble_hal_windows_linux.h" -#include "windows_linux/keypad_keys_hal_windows_linux.h" -#include "windows_linux/lvgl_hal_windows_linux.h" -#include "windows_linux/mqtt_hal_windows_linux.h" -#include "windows_linux/preferencesStorage_hal_windows_linux.h" -#include "windows_linux/sleep_hal_windows_linux.h" -#include "windows_linux/tft_hal_windows_linux.h" -#include "windows_linux/user_led_hal_windows_linux.h" diff --git a/Platformio/hardware/windows_linux/infrared_receiver_hal_windows_linux.cpp b/Platformio/hardware/windows_linux/infrared_receiver_hal_windows_linux.cpp deleted file mode 100644 index 50cd1bca..00000000 --- a/Platformio/hardware/windows_linux/infrared_receiver_hal_windows_linux.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "infrared_receiver_hal_windows_linux.h" - -bool irReceiverEnabled = false; - -void start_infraredReceiver_HAL() { -} - -void shutdown_infraredReceiver_HAL() { -} - -// The repeating section of the code -void infraredReceiver_loop_HAL() { -} - -bool get_irReceiverEnabled_HAL() { - return irReceiverEnabled; -} -void set_irReceiverEnabled_HAL(bool aIrReceiverEnabled) { - irReceiverEnabled = aIrReceiverEnabled; -} - -void set_announceNewIRmessage_cb_HAL(tAnnounceNewIRmessage_cb pAnnounceNewIRmessage_cb) {} diff --git a/Platformio/hardware/windows_linux/infrared_receiver_hal_windows_linux.h b/Platformio/hardware/windows_linux/infrared_receiver_hal_windows_linux.h deleted file mode 100644 index 5ebde4d8..00000000 --- a/Platformio/hardware/windows_linux/infrared_receiver_hal_windows_linux.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include - -void start_infraredReceiver_HAL(void); -void shutdown_infraredReceiver_HAL(void); -void infraredReceiver_loop_HAL(void); - -bool get_irReceiverEnabled_HAL(); -void set_irReceiverEnabled_HAL(bool aIrReceiverEnabled); - -typedef void (*tAnnounceNewIRmessage_cb)(std::string message); -void set_announceNewIRmessage_cb_HAL(tAnnounceNewIRmessage_cb pAnnounceNewIRmessage_cb); diff --git a/Platformio/hardware/windows_linux/infrared_sender_hal_windows_linux.cpp b/Platformio/hardware/windows_linux/infrared_sender_hal_windows_linux.cpp deleted file mode 100644 index 4e4cb3d7..00000000 --- a/Platformio/hardware/windows_linux/infrared_sender_hal_windows_linux.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include - -void init_infraredSender_HAL(void) { -} - -// IR protocols -enum IRprotocols { - IR_PROTOCOL_GC = 0, - IR_PROTOCOL_NEC = 1, - IR_PROTOCOL_SAMSUNG = 2, - IR_PROTOCOL_SONY = 3, - IR_PROTOCOL_RC5 = 4, - IR_PROTOCOL_DENON = 5, - IR_PROTOCOL_SAMSUNG36 = 6 -}; -void sendIRcode_HAL(int protocol, std::list commandPayloads, std::string additionalPayload) { -} \ No newline at end of file diff --git a/Platformio/hardware/windows_linux/infrared_sender_hal_windows_linux.h b/Platformio/hardware/windows_linux/infrared_sender_hal_windows_linux.h deleted file mode 100644 index ae000370..00000000 --- a/Platformio/hardware/windows_linux/infrared_sender_hal_windows_linux.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#include -#include - -// infrared -void init_infraredSender_HAL(void); -void sendIRcode_HAL(int protocol, std::list commandPayloads, std::string additionalPayload); \ No newline at end of file diff --git a/Platformio/hardware/windows_linux/keyboard_ble_hal_windows_linux.cpp b/Platformio/hardware/windows_linux/keyboard_ble_hal_windows_linux.cpp deleted file mode 100644 index 88eeff8a..00000000 --- a/Platformio/hardware/windows_linux/keyboard_ble_hal_windows_linux.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#if (ENABLE_KEYBOARD_BLE == 1) - -#include -#include "keyboard_ble_hal_windows_linux.h" - -void init_keyboardBLE_HAL() {}; -bool keyboardBLE_isConnected_HAL() {return false;}; -void keyboardBLE_end_HAL() {}; -void keyboardBLE_write_HAL(uint8_t c) {}; -void keyboardBLE_longpress_HAL(uint8_t c) {}; -void keyboardBLE_home_HAL() {}; -void keyboardBLE_sendString_HAL(const std::string &s) {}; -void consumerControlBLE_write_HAL(const MediaKeyReport value) {}; -void consumerControlBLE_longpress_HAL(const MediaKeyReport value) {}; - -#endif \ No newline at end of file diff --git a/Platformio/hardware/windows_linux/keyboard_ble_hal_windows_linux.h b/Platformio/hardware/windows_linux/keyboard_ble_hal_windows_linux.h deleted file mode 100644 index 57ffefe8..00000000 --- a/Platformio/hardware/windows_linux/keyboard_ble_hal_windows_linux.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -#if (ENABLE_KEYBOARD_BLE == 1) - -#include -#include - -typedef uint8_t MediaKeyReport[2]; -const uint8_t KEY_UP_ARROW = 0; -const uint8_t KEY_DOWN_ARROW = 0; -const uint8_t KEY_RIGHT_ARROW = 0; -const uint8_t KEY_LEFT_ARROW = 0; -const uint8_t KEY_RETURN = 0; -const MediaKeyReport KEY_MEDIA_WWW_BACK = {0, 0}; -const MediaKeyReport KEY_MEDIA_WWW_HOME = {0, 0}; -const MediaKeyReport KEY_MEDIA_PREVIOUS_TRACK = {0, 0}; -const MediaKeyReport KEY_MEDIA_REWIND = {0, 0}; -const MediaKeyReport KEY_MEDIA_PLAY_PAUSE = {0, 0}; -const MediaKeyReport KEY_MEDIA_FASTFORWARD = {0, 0}; -const MediaKeyReport KEY_MEDIA_NEXT_TRACK = {0, 0}; -const MediaKeyReport KEY_MEDIA_MUTE = {0, 0}; -const MediaKeyReport KEY_MEDIA_VOLUME_UP = {0, 0}; -const MediaKeyReport KEY_MEDIA_VOLUME_DOWN = {0, 0}; - -void init_keyboardBLE_HAL(); -bool keyboardBLE_isConnected_HAL(); -void keyboardBLE_end_HAL(); -void keyboardBLE_write_HAL(uint8_t c); -void keyboardBLE_longpress_HAL(uint8_t c); -void keyboardBLE_home_HAL(); -void keyboardBLE_sendString_HAL(const std::string &s); -void consumerControlBLE_write_HAL(const MediaKeyReport value); -void consumerControlBLE_longpress_HAL(const MediaKeyReport value); - -#endif \ No newline at end of file diff --git a/Platformio/hardware/windows_linux/keypad_keys_hal_windows_linux.cpp b/Platformio/hardware/windows_linux/keypad_keys_hal_windows_linux.cpp deleted file mode 100644 index 49880875..00000000 --- a/Platformio/hardware/windows_linux/keypad_keys_hal_windows_linux.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include - -void init_keys_HAL(void) { -} - -enum keypad_keyStates {IDLE_HAL, PRESSED_HAL, HOLD_HAL, RELEASED_HAL}; -struct keypad_key { - char kchar; - int kcode; - keypad_keyStates kstate; - bool stateChanged; -}; -keypad_key keys[10]; - -void keys_getKeys_HAL(void* ptr) { - for(int i=0; i < 19; i++) { - (*(keypad_key*)ptr).kchar = ' '; - (*(keypad_key*)ptr).kcode = 0; - (*(keypad_key*)ptr).kstate = IDLE_HAL; - (*(keypad_key*)ptr).stateChanged = false; - // https://www.geeksforgeeks.org/void-pointer-c-cpp/ - ptr = (void *) ((intptr_t)(ptr) + sizeof(keypad_key)); - } -} \ No newline at end of file diff --git a/Platformio/hardware/windows_linux/keypad_keys_hal_windows_linux.h b/Platformio/hardware/windows_linux/keypad_keys_hal_windows_linux.h deleted file mode 100644 index fd3704e9..00000000 --- a/Platformio/hardware/windows_linux/keypad_keys_hal_windows_linux.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -void init_keys_HAL(void); -void keys_getKeys_HAL(void* ptr); diff --git a/Platformio/hardware/windows_linux/lib/MQTT-C/LICENSE b/Platformio/hardware/windows_linux/lib/MQTT-C/LICENSE deleted file mode 100644 index 0bbb8455..00000000 --- a/Platformio/hardware/windows_linux/lib/MQTT-C/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Liam Bindle - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/Platformio/hardware/windows_linux/lib/MQTT-C/README.md b/Platformio/hardware/windows_linux/lib/MQTT-C/README.md deleted file mode 100644 index 1367d25c..00000000 --- a/Platformio/hardware/windows_linux/lib/MQTT-C/README.md +++ /dev/null @@ -1,106 +0,0 @@ -

- - -

- -

-
- - - - - -

- -MQTT-C is an [MQTT v3.1.1](http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html) -client written in C. MQTT is a lightweight publisher-subscriber-based messaging protocol that is -commonly used in IoT and networking applications where high-latency and low data-rate links -are expected. The purpose of MQTT-C is to provide a **portable** MQTT client, **written in C**, -for embedded systems and PC's alike. MQTT-C does this by providing a transparent Platform -Abstraction Layer (PAL) which makes porting to new platforms easy. MQTT-C is completely -thread-safe but can also run perfectly fine on single-threaded systems making MQTT-C -well-suited for embedded systems and microcontrollers. Finally, MQTT-C is small; there are only -two source files totalling less than 2000 lines. - -#### A note from the author -It's been great to hear about all the places MQTT-C is being used! Please don't hesitate -to get in touch with me or submit issues on GitHub! - -## Getting Started -To use MQTT-C you first instantiate a `struct mqtt_client` and initialize it by calling -@ref mqtt_init. -```c - struct mqtt_client client; /* instantiate the client */ - mqtt_init(&client, ...); /* initialize the client */ -``` -Once your client is initialized you need to connect to an MQTT broker. -```c - mqtt_connect(&client, ...); /* send a connection request to the broker. */ -``` -At this point the client is ready to use! For example, we can subscribe to a topic like so: -```c - /* subscribe to "toaster/temperature" with a max QoS level of 0 */ - mqtt_subscribe(&client, "toaster/temperature", 0); -``` -And we can publish to a topic like so: -```c - /* publish coffee temperature with a QoS level of 1 */ - int temperature = 67; - mqtt_publish(&client, "coffee/temperature", &temperature, sizeof(int), MQTT_PUBLISH_QOS_1); -``` -Those are the basics! From here the [examples](https://github.com/LiamBindle/MQTT-C/tree/master/examples) and [API documentation](https://liambindle.ca/MQTT-C/group__api.html) are good places to get started. - -## Building -There are **only two source files** that need to be built, `mqtt.c` and `mqtt_pal.c`. -These files are ANSI C (C89) compatible, and should compile with any C compiler. - -Then, simply \#include . - -Alternatively, you can build MQTT-C with CMake or the provided Makefile. These are provided for convenience. - -## Documentation -Pre-built documentation can be found here: [https://liambindle.ca/MQTT-C](https://liambindle.ca/MQTT-C). Be sure to check out the [examples](https://github.com/LiamBindle/MQTT-C/tree/master/examples) too. - -The @ref api documentation contains all the documentation application programmers should need. -The @ref pal documentation contains everything you should need to port MQTT-C to a new platform, -and the other modules contain documentation for MQTT-C developers. - -## Testing and Building the Tests -The MQTT-C unit tests use the [cmocka unit testing framework](https://cmocka.org/). -Therefore, [cmocka](https://cmocka.org/) *must* be installed on your machine to build and run -the unit tests. For convenience, a simple `"makefile"` is included to build the unit tests and -examples on UNIX-like machines. The unit tests and examples can be built as follows: -```bash - $ make all -``` -The unit tests and examples will be built in the `"bin/"` directory. The unit tests can be run -like so: -```bash - $ ./bin/tests [address [port]] -``` -Note that the \c address and \c port arguments are both optional to specify the location of the -MQTT broker that is to be used for the tests. If no \c address is given then the -[Mosquitto MQTT Test Server](https://test.mosquitto.org/) will be used. If no \c port is given, -port 1883 will be used. - -## Portability -MQTT-C provides a transparent platform abstraction layer (PAL) in `mqtt_pal.h` and `mqtt_pal.c`. -These files declare and implement the types and calls that MQTT-C requires. Refer to -@ref pal for the complete documentation of the PAL. - -## Contributing -Please feel free to submit issues and pull-requests [here](https://github.com/LiamBindle/MQTT-C). -When submitting a pull-request please ensure you have *fully documented* your changes and -added the appropriate unit tests. - - -## License -This project is licensed under the [MIT License](https://opensource.org/licenses/MIT). See the -`"LICENSE"` file for more details. - -## Authors -MQTT-C was initially developed as a CMPT 434 (Winter Term, 2018) final project at the University of -Saskatchewan by: -- **Liam Bindle** -- **Demilade Adeoye** - diff --git a/Platformio/hardware/windows_linux/lib/MQTT-C/include/mqtt.h b/Platformio/hardware/windows_linux/lib/MQTT-C/include/mqtt.h deleted file mode 100644 index 8695ab88..00000000 --- a/Platformio/hardware/windows_linux/lib/MQTT-C/include/mqtt.h +++ /dev/null @@ -1,1623 +0,0 @@ -#if !defined(__MQTT_H__) -#define __MQTT_H__ - -/* -MIT License - -Copyright(c) 2018 Liam Bindle - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files(the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions : - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#if defined(__cplusplus) -extern "C" { -#endif - -// Users can override mqtt_pal.h with their own configuration by defining -// MQTTC_PAL_FILE as a header file to include (-DMQTTC_PAL_FILE=my_mqtt_pal.h). -// -// If MQTTC_PAL_FILE is used, none of the default utils will be emitted and must be -// provided by the config file. To start, I would suggest copying mqtt_pal.h -// and modifying as needed. -#if defined(MQTTC_PAL_FILE) -#define MQTTC_STR2(x) #x -#define MQTTC_STR(x) MQTTC_STR2(x) -#include MQTTC_STR(MQTTC_PAL_FILE) -#else -#include -#endif /* MQTT_PAL_FILE */ - -/** - * @file - * @brief Declares all the MQTT-C functions and datastructures. - * - * @note You should \#include . - * - * @example simple_publisher.c - * A simple program to that publishes the current time whenever ENTER is pressed. - * - * Usage: - * \code{.sh} - * ./bin/simple_publisher [address [port [topic]]] - * \endcode - * - * Where \c address is the address of the MQTT broker, \c port is the port number the - * MQTT broker is running on, and \c topic is the name of the topic to publish with. Note - * that all these arguments are optional and the defaults are \c address = \c "test.mosquitto.org", - * \c port = \c "1883", and \c topic = "datetime". - * - * @example simple_subscriber.c - * A simple program that subscribes to a single topic and prints all updates that are received. - * - * Usage: - * \code{.sh} - * ./bin/simple_subscriber [address [port [topic]]] - * \endcode - * - * Where \c address is the address of the MQTT broker, \c port is the port number the - * MQTT broker is running on, and \c topic is the name of the topic subscribe to. Note - * that all these arguments are optional and the defaults are \c address = \c "test.mosquitto.org", - * \c port = \c "1883", and \c topic = "datetime". - * - * @example reconnect_subscriber.c - * Same program as \ref simple_subscriber.c, but using the automatic reconnect functionality. - * - * @example bio_publisher.c - * Same program as \ref simple_publisher.c, but uses a unencrypted BIO socket. - * - * @example openssl_publisher.c - * Same program as \ref simple_publisher.c, but over an encrypted connection using OpenSSL. - * - * Usage: - * \code{.sh} - * ./bin/openssl_publisher ca_file [address [port [topic]]] - * \endcode - * - * - * @defgroup api API - * @brief Documentation of everything you need to know to use the MQTT-C client. - * - * This module contains everything you need to know to use MQTT-C in your application. - * For usage examples see: - * - @ref simple_publisher.c - * - @ref simple_subscriber.c - * - @ref reconnect_subscriber.c - * - @ref bio_publisher.c - * - @ref openssl_publisher.c - * - * @note MQTT-C can be used in both single-threaded and multi-threaded applications. All - * the functions in \ref api are thread-safe. - * - * @defgroup packers Control Packet Serialization - * @brief Developer documentation of the functions and datastructures used for serializing MQTT - * control packets. - * - * @defgroup unpackers Control Packet Deserialization - * @brief Developer documentation of the functions and datastructures used for deserializing MQTT - * control packets. - * - * @defgroup details Utilities - * @brief Developer documentation for the utilities used to implement the MQTT-C client. - * - * @note To deserialize a packet from a buffer use \ref mqtt_unpack_response (it's the only - * function you need). - */ - - - /** - * @brief An enumeration of the MQTT control packet types. - * @ingroup unpackers - * - * @see - * MQTT v3.1.1: MQTT Control Packet Types - * - */ - enum MQTTControlPacketType { - MQTT_CONTROL_CONNECT=1u, - MQTT_CONTROL_CONNACK=2u, - MQTT_CONTROL_PUBLISH=3u, - MQTT_CONTROL_PUBACK=4u, - MQTT_CONTROL_PUBREC=5u, - MQTT_CONTROL_PUBREL=6u, - MQTT_CONTROL_PUBCOMP=7u, - MQTT_CONTROL_SUBSCRIBE=8u, - MQTT_CONTROL_SUBACK=9u, - MQTT_CONTROL_UNSUBSCRIBE=10u, - MQTT_CONTROL_UNSUBACK=11u, - MQTT_CONTROL_PINGREQ=12u, - MQTT_CONTROL_PINGRESP=13u, - MQTT_CONTROL_DISCONNECT=14u -}; - -/** - * @brief The fixed header of an MQTT control packet. - * @ingroup unpackers - * - * @see - * MQTT v3.1.1: Fixed Header - * - */ -struct mqtt_fixed_header { - /** The type of packet. */ - enum MQTTControlPacketType control_type; - - /** The packets control flags.*/ - uint32_t control_flags: 4; - - /** The remaining size of the packet in bytes (i.e. the size of variable header and payload).*/ - uint32_t remaining_length; -}; - -/** - * @brief The protocol identifier for MQTT v3.1.1. - * @ingroup packers - * - * @see - * MQTT v3.1.1: CONNECT Variable Header. - * - */ -#define MQTT_PROTOCOL_LEVEL 0x04 - -/** - * @brief A macro used to declare the enum MQTTErrors and associated - * error messages (the members of the num) at the same time. - */ -#define __ALL_MQTT_ERRORS(MQTT_ERROR) \ - MQTT_ERROR(MQTT_ERROR_NULLPTR) \ - MQTT_ERROR(MQTT_ERROR_CONTROL_FORBIDDEN_TYPE) \ - MQTT_ERROR(MQTT_ERROR_CONTROL_INVALID_FLAGS) \ - MQTT_ERROR(MQTT_ERROR_CONTROL_WRONG_TYPE) \ - MQTT_ERROR(MQTT_ERROR_CONNECT_CLIENT_ID_REFUSED) \ - MQTT_ERROR(MQTT_ERROR_CONNECT_NULL_WILL_MESSAGE) \ - MQTT_ERROR(MQTT_ERROR_CONNECT_FORBIDDEN_WILL_QOS) \ - MQTT_ERROR(MQTT_ERROR_CONNACK_FORBIDDEN_FLAGS) \ - MQTT_ERROR(MQTT_ERROR_CONNACK_FORBIDDEN_CODE) \ - MQTT_ERROR(MQTT_ERROR_PUBLISH_FORBIDDEN_QOS) \ - MQTT_ERROR(MQTT_ERROR_SUBSCRIBE_TOO_MANY_TOPICS) \ - MQTT_ERROR(MQTT_ERROR_MALFORMED_RESPONSE) \ - MQTT_ERROR(MQTT_ERROR_UNSUBSCRIBE_TOO_MANY_TOPICS) \ - MQTT_ERROR(MQTT_ERROR_RESPONSE_INVALID_CONTROL_TYPE) \ - MQTT_ERROR(MQTT_ERROR_CONNECT_NOT_CALLED) \ - MQTT_ERROR(MQTT_ERROR_SEND_BUFFER_IS_FULL) \ - MQTT_ERROR(MQTT_ERROR_SOCKET_ERROR) \ - MQTT_ERROR(MQTT_ERROR_MALFORMED_REQUEST) \ - MQTT_ERROR(MQTT_ERROR_RECV_BUFFER_TOO_SMALL) \ - MQTT_ERROR(MQTT_ERROR_ACK_OF_UNKNOWN) \ - MQTT_ERROR(MQTT_ERROR_NOT_IMPLEMENTED) \ - MQTT_ERROR(MQTT_ERROR_CONNECTION_REFUSED) \ - MQTT_ERROR(MQTT_ERROR_SUBSCRIBE_FAILED) \ - MQTT_ERROR(MQTT_ERROR_CONNECTION_CLOSED) \ - MQTT_ERROR(MQTT_ERROR_INITIAL_RECONNECT) \ - MQTT_ERROR(MQTT_ERROR_INVALID_REMAINING_LENGTH) \ - MQTT_ERROR(MQTT_ERROR_CLEAN_SESSION_IS_REQUIRED) \ - MQTT_ERROR(MQTT_ERROR_RECONNECT_FAILED) \ - MQTT_ERROR(MQTT_ERROR_RECONNECTING) - -/* todo: add more connection refused errors */ - -/** - * @brief A macro used to generate the enum MQTTErrors from - * \ref __ALL_MQTT_ERRORS - * @see __ALL_MQTT_ERRORS -*/ -#define GENERATE_ENUM(ENUM) ENUM, - -/** - * @brief A macro used to generate the error messages associated with - * MQTTErrors from \ref __ALL_MQTT_ERRORS - * @see __ALL_MQTT_ERRORS -*/ -#define GENERATE_STRING(STRING) #STRING, - - -/** - * @brief An enumeration of error codes. Error messages can be retrieved by calling \ref mqtt_error_str. - * @ingroup api - * - * @see mqtt_error_str - */ -enum MQTTErrors { - MQTT_ERROR_UNKNOWN=INT_MIN, - __ALL_MQTT_ERRORS(GENERATE_ENUM) - MQTT_OK = 1 -}; - -/** - * @brief Returns an error message for error code, \p error. - * @ingroup api - * - * @param[in] error the error code. - * - * @returns The associated error message. - */ -const char* mqtt_error_str(enum MQTTErrors error); - -/** - * @brief Pack a MQTT 16 bit integer, given a native 16 bit integer . - * - * @param[out] buf the buffer that the MQTT integer will be written to. - * @param[in] integer the native integer to be written to \p buf. - * - * @warning This function provides no error checking. - * - * @returns 2 -*/ -ssize_t __mqtt_pack_uint16(uint8_t *buf, uint16_t integer); - -/** - * @brief Unpack a MQTT 16 bit integer to a native 16 bit integer. - * - * @param[in] buf the buffer that the MQTT integer will be read from. - * - * @warning This function provides no error checking and does not modify \p buf. - * - * @returns The native integer -*/ -uint16_t __mqtt_unpack_uint16(const uint8_t *buf); - -/** - * @brief Pack a MQTT string, given a c-string \p str. - * - * @param[out] buf the buffer that the MQTT string will be written to. - * @param[in] str the c-string to be written to \p buf. - * - * @warning This function provides no error checking. - * - * @returns strlen(str) + 2 -*/ -ssize_t __mqtt_pack_str(uint8_t *buf, const char* str); - -/** @brief A macro to get the MQTT string length from a c-string. */ -#define __mqtt_packed_cstrlen(x) (2 + (unsigned int)strlen(x)) - -/* RESPONSES */ - -/** - * @brief An enumeration of the return codes returned in a CONNACK packet. - * @ingroup unpackers - * - * @see - * MQTT v3.1.1: CONNACK return codes. - * - */ -enum MQTTConnackReturnCode { - MQTT_CONNACK_ACCEPTED = 0u, - MQTT_CONNACK_REFUSED_PROTOCOL_VERSION = 1u, - MQTT_CONNACK_REFUSED_IDENTIFIER_REJECTED = 2u, - MQTT_CONNACK_REFUSED_SERVER_UNAVAILABLE = 3u, - MQTT_CONNACK_REFUSED_BAD_USER_NAME_OR_PASSWORD = 4u, - MQTT_CONNACK_REFUSED_NOT_AUTHORIZED = 5u -}; - -/** - * @brief A connection response datastructure. - * @ingroup unpackers - * - * @see - * MQTT v3.1.1: CONNACK - Acknowledgement connection response. - * - */ -struct mqtt_response_connack { - /** - * @brief Allows client and broker to check if they have a consistent view about whether there is - * already a stored session state. - */ - uint8_t session_present_flag; - - /** - * @brief The return code of the connection request. - * - * @see MQTTConnackReturnCode - */ - enum MQTTConnackReturnCode return_code; -}; - - /** - * @brief A publish packet received from the broker. - * @ingroup unpackers - * - * A publish packet is received from the broker when a client publishes to a topic that the - * \em {local client} is subscribed to. - * - * @see - * MQTT v3.1.1: PUBLISH - Publish Message. - * - */ -struct mqtt_response_publish { - /** - * @brief The DUP flag. DUP flag is 0 if its the first attempt to send this publish packet. A DUP flag - * of 1 means that this might be a re-delivery of the packet. - */ - uint8_t dup_flag; - - /** - * @brief The quality of service level. - * - * @see - * MQTT v3.1.1: QoS Definitions - * - */ - uint8_t qos_level; - - /** @brief The retain flag of this publish message. */ - uint8_t retain_flag; - - /** @brief Size of the topic name (number of characters). */ - uint16_t topic_name_size; - - /** - * @brief The topic name. - * @note topic_name is not null terminated. Therefore topic_name_size must be used to get the - * string length. - */ - const void* topic_name; - - /** @brief The publish message's packet ID. */ - uint16_t packet_id; - - /** @brief The publish message's application message.*/ - const void* application_message; - - /** @brief The size of the application message in bytes. */ - size_t application_message_size; -}; - -/** - * @brief A publish acknowledgement for messages that were published with QoS level 1. - * @ingroup unpackers - * - * @see - * MQTT v3.1.1: PUBACK - Publish Acknowledgement. - * - * - */ -struct mqtt_response_puback { - /** @brief The published messages packet ID. */ - uint16_t packet_id; -}; - -/** - * @brief The response packet to a PUBLISH packet with QoS level 2. - * @ingroup unpackers - * - * @see - * MQTT v3.1.1: PUBREC - Publish Received. - * - * - */ -struct mqtt_response_pubrec { - /** @brief The published messages packet ID. */ - uint16_t packet_id; -}; - -/** - * @brief The response to a PUBREC packet. - * @ingroup unpackers - * - * @see - * MQTT v3.1.1: PUBREL - Publish Release. - * - * - */ -struct mqtt_response_pubrel { - /** @brief The published messages packet ID. */ - uint16_t packet_id; -}; - -/** - * @brief The response to a PUBREL packet. - * @ingroup unpackers - * - * @see - * MQTT v3.1.1: PUBCOMP - Publish Complete. - * - * - */ -struct mqtt_response_pubcomp { - /** T@brief he published messages packet ID. */ - uint16_t packet_id; -}; - -/** - * @brief An enumeration of subscription acknowledgement return codes. - * @ingroup unpackers - * - * @see - * MQTT v3.1.1: SUBACK Return Codes. - * - */ -enum MQTTSubackReturnCodes { - MQTT_SUBACK_SUCCESS_MAX_QOS_0 = 0u, - MQTT_SUBACK_SUCCESS_MAX_QOS_1 = 1u, - MQTT_SUBACK_SUCCESS_MAX_QOS_2 = 2u, - MQTT_SUBACK_FAILURE = 128u -}; - -/** - * @brief The response to a subscription request. - * @ingroup unpackers - * - * @see - * MQTT v3.1.1: SUBACK - Subscription Acknowledgement. - * - */ -struct mqtt_response_suback { - /** @brief The published messages packet ID. */ - uint16_t packet_id; - - /** - * Array of return codes corresponding to the requested subscribe topics. - * - * @see MQTTSubackReturnCodes - */ - const uint8_t *return_codes; - - /** The number of return codes. */ - size_t num_return_codes; -}; - -/** - * @brief The brokers response to a UNSUBSCRIBE request. - * @ingroup unpackers - * - * @see - * MQTT v3.1.1: UNSUBACK - Unsubscribe Acknowledgement. - * - */ -struct mqtt_response_unsuback { - /** @brief The published messages packet ID. */ - uint16_t packet_id; -}; - -/** - * @brief The response to a ping request. - * @ingroup unpackers - * - * @note This response contains no members. - * - * @see - * MQTT v3.1.1: PINGRESP - Ping Response. - * - */ -struct mqtt_response_pingresp { - int dummy; -}; - -/** - * @brief A struct used to deserialize/interpret an incoming packet from the broker. - * @ingroup unpackers - */ -struct mqtt_response { - /** @brief The mqtt_fixed_header of the deserialized packet. */ - struct mqtt_fixed_header fixed_header; - - /** - * @brief A union of the possible responses from the broker. - * - * @note The fixed_header contains the control type. This control type corresponds to the - * member of this union that should be accessed. For example if - * fixed_header#control_type == \c MQTT_CONTROL_PUBLISH then - * decoded#publish should be accessed. - */ - union { - struct mqtt_response_connack connack; - struct mqtt_response_publish publish; - struct mqtt_response_puback puback; - struct mqtt_response_pubrec pubrec; - struct mqtt_response_pubrel pubrel; - struct mqtt_response_pubcomp pubcomp; - struct mqtt_response_suback suback; - struct mqtt_response_unsuback unsuback; - struct mqtt_response_pingresp pingresp; - } decoded; -}; - -/** - * @brief Deserialize the contents of \p buf into an mqtt_fixed_header object. - * @ingroup unpackers - * - * @note This function performs complete error checking and a positive return value - * means the entire mqtt_response can be deserialized from \p buf. - * - * @param[out] response the response who's \ref mqtt_response.fixed_header will be initialized. - * @param[in] buf the buffer. - * @param[in] bufsz the total number of bytes in the buffer. - * - * @returns The number of bytes that were consumed, or 0 if the buffer does not contain enough - * bytes to parse the packet, or a negative value if there was a protocol violation. - */ -ssize_t mqtt_unpack_fixed_header(struct mqtt_response *response, const uint8_t *buf, size_t bufsz); - -/** - * @brief Deserialize a CONNACK response from \p buf. - * @ingroup unpackers - * - * @pre \ref mqtt_unpack_fixed_header must have returned a positive value and the control packet type - * must be \c MQTT_CONTROL_CONNACK. - * - * @param[out] mqtt_response the mqtt_response that will be initialized. - * @param[in] buf the buffer that contains the variable header and payload of the packet. The - * first byte of \p buf should be the first byte of the variable header. - * - * @relates mqtt_response_connack - * - * @returns The number of bytes that were consumed, or 0 if the buffer does not contain enough - * bytes to parse the packet, or a negative value if there was a protocol violation. - */ -ssize_t mqtt_unpack_connack_response (struct mqtt_response *mqtt_response, const uint8_t *buf); - -/** - * @brief Deserialize a publish response from \p buf. - * @ingroup unpackers - * - * @pre \ref mqtt_unpack_fixed_header must have returned a positive value and the mqtt_response must - * have a control type of \c MQTT_CONTROL_PUBLISH. - * - * @param[out] mqtt_response the response that is initialized from the contents of \p buf. - * @param[in] buf the buffer with the incoming data. - * - * @relates mqtt_response_publish - * - * @returns The number of bytes that were consumed, or 0 if the buffer does not contain enough - * bytes to parse the packet, or a negative value if there was a protocol violation. - */ -ssize_t mqtt_unpack_publish_response (struct mqtt_response *mqtt_response, const uint8_t *buf); - -/** - * @brief Deserialize a PUBACK/PUBREC/PUBREL/PUBCOMP packet from \p buf. - * @ingroup unpackers - * - * @pre \ref mqtt_unpack_fixed_header must have returned a positive value and the mqtt_response must - * have a control type of \c MQTT_CONTROL_PUBACK, \c MQTT_CONTROL_PUBREC, \c MQTT_CONTROL_PUBREL - * or \c MQTT_CONTROL_PUBCOMP. - * - * @param[out] mqtt_response the response that is initialized from the contents of \p buf. - * @param[in] buf the buffer with the incoming data. - * - * @relates mqtt_response_puback mqtt_response_pubrec mqtt_response_pubrel mqtt_response_pubcomp - * - * @returns The number of bytes that were consumed, or 0 if the buffer does not contain enough - * bytes to parse the packet, or a negative value if there was a protocol violation. - */ -ssize_t mqtt_unpack_pubxxx_response(struct mqtt_response *mqtt_response, const uint8_t *buf); - -/** - * @brief Deserialize a SUBACK packet from \p buf. - * @ingroup unpacker - * - * @pre \ref mqtt_unpack_fixed_header must have returned a positive value and the mqtt_response must - * have a control type of \c MQTT_CONTROL_SUBACK. - * - * @param[out] mqtt_response the response that is initialized from the contents of \p buf. - * @param[in] buf the buffer with the incoming data. - * - * @relates mqtt_response_suback - * - * @returns The number of bytes that were consumed, or 0 if the buffer does not contain enough - * bytes to parse the packet, or a negative value if there was a protocol violation. - */ -ssize_t mqtt_unpack_suback_response(struct mqtt_response *mqtt_response, const uint8_t *buf); - -/** - * @brief Deserialize an UNSUBACK packet from \p buf. - * @ingroup unpacker - * - * @pre \ref mqtt_unpack_fixed_header must have returned a positive value and the mqtt_response must - * have a control type of \c MQTT_CONTROL_UNSUBACK. - * - * @param[out] mqtt_response the response that is initialized from the contents of \p buf. - * @param[in] buf the buffer with the incoming data. - * - * @relates mqtt_response_unsuback - * - * @returns The number of bytes that were consumed, or 0 if the buffer does not contain enough - * bytes to parse the packet, or a negative value if there was a protocol violation. - */ -ssize_t mqtt_unpack_unsuback_response(struct mqtt_response *mqtt_response, const uint8_t *buf); - -/** - * @brief Deserialize a packet from the broker. - * @ingroup unpackers - * - * @param[out] response the mqtt_response that will be initialize from \p buf. - * @param[in] buf the incoming data buffer. - * @param[in] bufsz the number of bytes available in the buffer. - * - * @relates mqtt_response - * - * @returns The number of bytes consumed on success, zero \p buf does not contain enough bytes - * to deserialize the packet, a negative value if a protocol violation was encountered. - */ -ssize_t mqtt_unpack_response(struct mqtt_response* response, const uint8_t *buf, size_t bufsz); - -/* REQUESTS */ - - /** - * @brief Serialize an mqtt_fixed_header and write it to \p buf. - * @ingroup packers - * - * @note This function performs complete error checking and a positive return value - * guarantees the entire packet will fit into the given buffer. - * - * @param[out] buf the buffer to write to. - * @param[in] bufsz the maximum number of bytes that can be put in to \p buf. - * @param[in] fixed_header the fixed header that will be serialized. - * - * @returns The number of bytes written to \p buf, or 0 if \p buf is too small, or a - * negative value if there was a protocol violation. - */ -ssize_t mqtt_pack_fixed_header(uint8_t *buf, size_t bufsz, const struct mqtt_fixed_header *fixed_header); - -/** - * @brief An enumeration of CONNECT packet flags. - * @ingroup packers - * - * @see - * MQTT v3.1.1: CONNECT Variable Header. - * - */ -enum MQTTConnectFlags { - MQTT_CONNECT_RESERVED = 1u, - MQTT_CONNECT_CLEAN_SESSION = 2u, - MQTT_CONNECT_WILL_FLAG = 4u, - MQTT_CONNECT_WILL_QOS_0 = (0u & 0x03) << 3, - MQTT_CONNECT_WILL_QOS_1 = (1u & 0x03) << 3, - MQTT_CONNECT_WILL_QOS_2 = (2u & 0x03) << 3, - MQTT_CONNECT_WILL_RETAIN = 32u, - MQTT_CONNECT_PASSWORD = 64u, - MQTT_CONNECT_USER_NAME = 128u -}; - -/** - * @brief Serialize a connection request into a buffer. - * @ingroup packers - * - * @param[out] buf the buffer to pack the connection request packet into. - * @param[in] bufsz the number of bytes left in \p buf. - * @param[in] client_id the ID that identifies the local client. \p client_id can be NULL or an empty - * string for Anonymous clients. - * @param[in] will_topic the topic under which the local client's will message will be published. - * Set to \c NULL for no will message. If \p will_topic is not \c NULL a - * \p will_message must also be provided. - * @param[in] will_message the will message to be published upon a unsuccessful disconnection of - * the local client. Set to \c NULL if \p will_topic is \c NULL. - * \p will_message must \em not be \c NULL if \p will_topic is not - * \c NULL. - * @param[in] will_message_size The size of \p will_message in bytes. - * @param[in] user_name the username to be used to connect to the broker with. Set to \c NULL if - * no username is required. - * @param[in] password the password to be used to connect to the broker with. Set to \c NULL if - * no password is required. - * @param[in] connect_flags additional MQTTConnectFlags to be set. The only flags that need to be - * set manually are \c MQTT_CONNECT_CLEAN_SESSION, - * \c MQTT_CONNECT_WILL_QOS_X (for \c X ∈ {0, 1, 2}), and - * \c MQTT_CONNECT_WILL_RETAIN. Set to 0 if no additional flags are - * required. - * @param[in] keep_alive the keep alive time in seconds. It is the responsibility of the clinet - * to ensure packets are sent to the server \em {at least} this frequently. - * - * @note If there is a \p will_topic and no additional \p connect_flags are given, then by - * default \p will_message will be published at QoS level 0. - * - * @see - * MQTT v3.1.1: CONNECT - Client Requests a Connection to a Server. - * - * - * @returns The number of bytes put into \p buf, 0 if \p buf is too small to fit the CONNECT - * packet, a negative value if there was a protocol violation. - */ -ssize_t mqtt_pack_connection_request(uint8_t* buf, size_t bufsz, - const char* client_id, - const char* will_topic, - const void* will_message, - size_t will_message_size, - const char* user_name, - const char* password, - uint8_t connect_flags, - uint16_t keep_alive); - -/** - * @brief An enumeration of the PUBLISH flags. - * @ingroup packers - * - * @see - * MQTT v3.1.1: PUBLISH - Publish Message. - * - */ -enum MQTTPublishFlags { - MQTT_PUBLISH_DUP = 8u, - MQTT_PUBLISH_QOS_0 = ((0u << 1) & 0x06), - MQTT_PUBLISH_QOS_1 = ((1u << 1) & 0x06), - MQTT_PUBLISH_QOS_2 = ((2u << 1) & 0x06), - MQTT_PUBLISH_QOS_MASK = ((3u << 1) & 0x06), - MQTT_PUBLISH_RETAIN = 0x01 -}; - -/** - * @brief Serialize a PUBLISH request and put it in \p buf. - * @ingroup packers - * - * @param[out] buf the buffer to put the PUBLISH packet in. - * @param[in] bufsz the maximum number of bytes that can be put into \p buf. - * @param[in] topic_name the topic to publish \p application_message under. - * @param[in] packet_id this packets packet ID. - * @param[in] application_message the application message to be published. - * @param[in] application_message_size the size of \p application_message in bytes. - * @param[in] publish_flags The flags to publish \p application_message with. These include - * the \c MQTT_PUBLISH_DUP flag, \c MQTT_PUBLISH_QOS_X (\c X ∈ - * {0, 1, 2}), and \c MQTT_PUBLISH_RETAIN flag. - * - * @note The default QoS is level 0. - * - * @see - * MQTT v3.1.1: PUBLISH - Publish Message. - * - * - * @returns The number of bytes put into \p buf, 0 if \p buf is too small to fit the PUBLISH - * packet, a negative value if there was a protocol violation. - */ -ssize_t mqtt_pack_publish_request(uint8_t *buf, size_t bufsz, - const char* topic_name, - uint16_t packet_id, - const void* application_message, - size_t application_message_size, - uint8_t publish_flags); - -/** - * @brief Serialize a PUBACK, PUBREC, PUBREL, or PUBCOMP packet and put it in \p buf. - * @ingroup packers - * - * @param[out] buf the buffer to put the PUBXXX packet in. - * @param[in] bufsz the maximum number of bytes that can be put into \p buf. - * @param[in] control_type the type of packet. Must be one of: \c MQTT_CONTROL_PUBACK, - * \c MQTT_CONTROL_PUBREC, \c MQTT_CONTROL_PUBREL, - * or \c MQTT_CONTROL_PUBCOMP. - * @param[in] packet_id the packet ID of the packet being acknowledged. - * - * - * @see - * MQTT v3.1.1: PUBACK - Publish Acknowledgement. - * - * @see - * MQTT v3.1.1: PUBREC - Publish Received. - * - * @see - * MQTT v3.1.1: PUBREL - Publish Released. - * - * @see - * MQTT v3.1.1: PUBCOMP - Publish Complete. - * - * - * @returns The number of bytes put into \p buf, 0 if \p buf is too small to fit the PUBXXX - * packet, a negative value if there was a protocol violation. - */ -ssize_t mqtt_pack_pubxxx_request(uint8_t *buf, size_t bufsz, - enum MQTTControlPacketType control_type, - uint16_t packet_id); - -/** - * @brief The maximum number topics that can be subscribed to in a single call to - * mqtt_pack_subscribe_request. - * @ingroup packers - * - * @see mqtt_pack_subscribe_request - */ -#define MQTT_SUBSCRIBE_REQUEST_MAX_NUM_TOPICS 8 - -/** - * @brief Serialize a SUBSCRIBE packet and put it in \p buf. - * @ingroup packers - * - * @param[out] buf the buffer to put the SUBSCRIBE packet in. - * @param[in] bufsz the maximum number of bytes that can be put into \p buf. - * @param[in] packet_id the packet ID to be used. - * @param[in] ... \c NULL terminated list of (\c {const char *topic_name}, \c {int max_qos_level}) - * pairs. - * - * @note The variadic arguments, \p ..., \em must be followed by a \c NULL. For example: - * @code - * ssize_t n = mqtt_pack_subscribe_request(buf, bufsz, 1234, "topic_1", 0, "topic_2", 2, NULL); - * @endcode - * - * @see - * MQTT v3.1.1: SUBSCRIBE - Subscribe to Topics. - * - * - * @returns The number of bytes put into \p buf, 0 if \p buf is too small to fit the SUBSCRIBE - * packet, a negative value if there was a protocol violation. - */ -ssize_t mqtt_pack_subscribe_request(uint8_t *buf, size_t bufsz, - unsigned int packet_id, - ...); /* null terminated */ - -/** - * @brief The maximum number topics that can be subscribed to in a single call to - * mqtt_pack_unsubscribe_request. - * @ingroup packers - * - * @see mqtt_pack_unsubscribe_request - */ -#define MQTT_UNSUBSCRIBE_REQUEST_MAX_NUM_TOPICS 8 - -/** - * @brief Serialize a UNSUBSCRIBE packet and put it in \p buf. - * @ingroup packers - * - * @param[out] buf the buffer to put the UNSUBSCRIBE packet in. - * @param[in] bufsz the maximum number of bytes that can be put into \p buf. - * @param[in] packet_id the packet ID to be used. - * @param[in] ... \c NULL terminated list of \c {const char *topic_name}'s to unsubscribe from. - * - * @note The variadic arguments, \p ..., \em must be followed by a \c NULL. For example: - * @code - * ssize_t n = mqtt_pack_unsubscribe_request(buf, bufsz, 4321, "topic_1", "topic_2", NULL); - * @endcode - * - * @see - * MQTT v3.1.1: UNSUBSCRIBE - Unsubscribe from Topics. - * - * - * @returns The number of bytes put into \p buf, 0 if \p buf is too small to fit the UNSUBSCRIBE - * packet, a negative value if there was a protocol violation. - */ -ssize_t mqtt_pack_unsubscribe_request(uint8_t *buf, size_t bufsz, - unsigned int packet_id, - ...); /* null terminated */ - -/** - * @brief Serialize a PINGREQ and put it into \p buf. - * @ingroup packers - * - * @param[out] buf the buffer to put the PINGREQ packet in. - * @param[in] bufsz the maximum number of bytes that can be put into \p buf. - * - * @see - * MQTT v3.1.1: PINGREQ - Ping Request. - * - * - * @returns The number of bytes put into \p buf, 0 if \p buf is too small to fit the PINGREQ - * packet, a negative value if there was a protocol violation. - */ -ssize_t mqtt_pack_ping_request(uint8_t *buf, size_t bufsz); - -/** - * @brief Serialize a DISCONNECT and put it into \p buf. - * @ingroup packers - * - * @param[out] buf the buffer to put the DISCONNECT packet in. - * @param[in] bufsz the maximum number of bytes that can be put into \p buf. - * - * @see - * MQTT v3.1.1: DISCONNECT - Disconnect Notification. - * - * - * @returns The number of bytes put into \p buf, 0 if \p buf is too small to fit the DISCONNECT - * packet, a negative value if there was a protocol violation. - */ -ssize_t mqtt_pack_disconnect(uint8_t *buf, size_t bufsz); - - -/** - * @brief An enumeration of queued message states. - * @ingroup details - */ -enum MQTTQueuedMessageState { - MQTT_QUEUED_UNSENT, - MQTT_QUEUED_AWAITING_ACK, - MQTT_QUEUED_COMPLETE -}; - -/** - * @brief A message in a mqtt_message_queue. - * @ingroup details - */ -struct mqtt_queued_message { - /** @brief A pointer to the start of the message. */ - uint8_t *start; - - /** @brief The number of bytes in the message. */ - size_t size; - - - /** @brief The state of the message. */ - enum MQTTQueuedMessageState state; - - /** - * @brief The time at which the message was sent.. - * - * @note A timeout will only occur if the message is in - * the MQTT_QUEUED_AWAITING_ACK \c state. - */ - mqtt_pal_time_t time_sent; - - /** - * @brief The control type of the message. - */ - enum MQTTControlPacketType control_type; - - /** - * @brief The packet id of the message. - * - * @note This field is only used if the associate \c control_type has a - * \c packet_id field. - */ - uint16_t packet_id; -}; - -/** - * @brief A message queue. - * @ingroup details - * - * @note This struct is used internally to manage sending messages. - * @note The only members the user should use are \c curr and \c curr_sz. - */ -struct mqtt_message_queue { - /** - * @brief The start of the message queue's memory block. - * - * @warning This member should \em not be manually changed. - */ - void *mem_start; - - /** @brief The end of the message queue's memory block. */ - void *mem_end; - - /** - * @brief A pointer to the position in the buffer you can pack bytes at. - * - * @note Immediately after packing bytes at \c curr you \em must call - * mqtt_mq_register. - */ - uint8_t *curr; - - /** - * @brief The number of bytes that can be written to \c curr. - * - * @note curr_sz will decrease by more than the number of bytes you write to - * \c curr. This is because the mqtt_queued_message structs share the - * same memory (and thus, a mqtt_queued_message must be allocated in - * the message queue's memory whenever a new message is registered). - */ - size_t curr_sz; - - /** - * @brief The tail of the array of mqtt_queued_messages's. - * - * @note This member should not be used manually. - */ - struct mqtt_queued_message *queue_tail; -}; - -/** - * @brief Initialize a message queue. - * @ingroup details - * - * @param[out] mq The message queue to initialize. - * @param[in] buf The buffer for this message queue. - * @param[in] bufsz The number of bytes in the buffer. - * - * @relates mqtt_message_queue - */ -void mqtt_mq_init(struct mqtt_message_queue *mq, void *buf, size_t bufsz); - -/** - * @brief Clear as many messages from the front of the queue as possible. - * @ingroup details - * - * @note Calls to this function are the \em only way to remove messages from the queue. - * - * @param mq The message queue. - * - * @relates mqtt_message_queue - */ -void mqtt_mq_clean(struct mqtt_message_queue *mq); - -/** - * @brief Register a message that was just added to the buffer. - * @ingroup details - * - * @note This function should be called immediately following a call to a packer function - * that returned a positive value. The positive value (number of bytes packed) should - * be passed to this function. - * - * @param mq The message queue. - * @param[in] nbytes The number of bytes that were just packed. - * - * @note This function will step mqtt_message_queue::curr and update mqtt_message_queue::curr_sz. - * @relates mqtt_message_queue - * - * @returns The newly added struct mqtt_queued_message. - */ -struct mqtt_queued_message* mqtt_mq_register(struct mqtt_message_queue *mq, size_t nbytes); - -/** - * @brief Find a message in the message queue. - * @ingroup details - * - * @param mq The message queue. - * @param[in] control_type The control type of the message you want to find. - * @param[in] packet_id The packet ID of the message you want to find. Set to \c NULL if you - * don't want to specify a packet ID. - * - * @relates mqtt_message_queue - * @returns The found message. \c NULL if the message was not found. - */ -struct mqtt_queued_message* mqtt_mq_find(const struct mqtt_message_queue *mq, enum MQTTControlPacketType control_type, const uint16_t *packet_id); - -/** - * @brief Returns the mqtt_queued_message at \p index. - * @ingroup details - * - * @param mq_ptr A pointer to the message queue. - * @param index The index of the message. - * - * @returns The mqtt_queued_message at \p index. - */ -#define mqtt_mq_get(mq_ptr, index) (((struct mqtt_queued_message*) ((mq_ptr)->mem_end)) - 1 - index) - -/** - * @brief Returns the number of messages in the message queue, \p mq_ptr. - * @ingroup details - */ -#define mqtt_mq_length(mq_ptr) (((struct mqtt_queued_message*) ((mq_ptr)->mem_end)) - (mq_ptr)->queue_tail) - -/** - * @brief Used internally to recalculate the \c curr_sz. - * @ingroup details - */ -#define mqtt_mq_currsz(mq_ptr) (((mq_ptr)->curr >= (uint8_t*) ((mq_ptr)->queue_tail - 1)) ? 0 : ((uint8_t*) ((mq_ptr)->queue_tail - 1)) - (mq_ptr)->curr) - -/* CLIENT */ - -/** - * @brief An MQTT client. - * @ingroup details - * - * @note All members can be manipulated via the related functions. - */ -struct mqtt_client { - /** @brief The socket connecting to the MQTT broker. */ - mqtt_pal_socket_handle socketfd; - - /** @brief The LFSR state used to generate packet ID's. */ - uint16_t pid_lfsr; - - /** @brief The keep-alive time in seconds. */ - uint16_t keep_alive; - - /** - * @brief A counter counting pings that have been sent to keep the connection alive. - * @see keep_alive - */ - int number_of_keep_alives; - - /** - * @brief The current sent offset. - * - * This is used to allow partial send commands. - */ - size_t send_offset; - - /** - * @brief The timestamp of the last message sent to the buffer. - * - * This is used to detect the need for keep-alive pings. - * - * @see keep_alive - */ - mqtt_pal_time_t time_of_last_send; - - /** - * @brief The error state of the client. - * - * error should be MQTT_OK for the entirety of the connection. - * - * @note The error state will be MQTT_ERROR_CONNECT_NOT_CALLED until - * you call mqtt_connect. - */ - enum MQTTErrors error; - - /** - * @brief The timeout period in seconds. - * - * If the broker doesn't return an ACK within response_timeout seconds a timeout - * will occur and the message will be retransmitted. - * - * @note The default value is 30 [seconds] but you can change it at any time. - */ - int response_timeout; - - /** @brief A counter counting the number of timeouts that have occurred. */ - int number_of_timeouts; - - /** - * @brief Approximately much time it has typically taken to receive responses from the - * broker. - * - * @note This is tracked using a exponential-averaging. - */ - float typical_response_time; - - /** - * @brief The callback that is called whenever a publish is received from the broker. - * - * Any topics that you have subscribed to will be returned from the broker as - * mqtt_response_publish messages. All the publishes received from the broker will - * be passed to this function. - * - * @note A pointer to publish_response_callback_state is always passed to the callback. - * Use publish_response_callback_state to keep track of any state information you - * need. - */ - void (*publish_response_callback)(void** state, struct mqtt_response_publish *publish); - - /** - * @brief A pointer to any publish_response_callback state information you need. - * - * @note A pointer to this pointer will always be publish_response_callback upon - * receiving a publish message from the broker. - */ - void* publish_response_callback_state; - - /** - * @brief A user-specified callback, triggered on each \ref mqtt_sync, allowing - * the user to perform state inspections (and custom socket error detection) - * on the client. - * - * This callback is triggered on each call to \ref mqtt_sync. If it returns MQTT_OK - * then \ref mqtt_sync will continue normally (performing reads and writes). If it - * returns an error then \ref mqtt_sync will not call reads and writes. - * - * This callback can be used to perform custom error detection, namely platform - * specific socket error detection, and force the client into an error state. - * - * This member is always initialized to NULL but it can be manually set at any - * time. - */ - enum MQTTErrors (*inspector_callback)(struct mqtt_client*); - - /** - * @brief A callback that is called whenever the client is in an error state. - * - * This callback is responsible for: application level error handling, closing - * previous sockets, and reestabilishing the connection to the broker and - * session configurations (i.e. subscriptions). - */ - void (*reconnect_callback)(struct mqtt_client*, void**); - - /** - * @brief A pointer to some state. A pointer to this member is passed to - * \ref mqtt_client.reconnect_callback. - */ - void* reconnect_state; - - /** - * @brief The buffer where ingress data is temporarily stored. - */ - struct { - /** @brief The start of the receive buffer's memory. */ - uint8_t *mem_start; - - /** @brief The size of the receive buffer's memory. */ - size_t mem_size; - - /** @brief A pointer to the next writable location in the receive buffer. */ - uint8_t *curr; - - /** @brief The number of bytes that are still writable at curr. */ - size_t curr_sz; - } recv_buffer; - - /** - * @brief A variable passed to support thread-safety. - * - * A pointer to this variable is passed to \c MQTT_PAL_MUTEX_LOCK, and - * \c MQTT_PAL_MUTEX_UNLOCK. - */ - mqtt_pal_mutex_t mutex; - - /** @brief The sending message queue. */ - struct mqtt_message_queue mq; -}; - -/** - * @brief Generate a new next packet ID. - * @ingroup details - * - * Packet ID's are generated using a max-length LFSR. - * - * @param client The MQTT client. - * - * @returns The new packet ID that should be used. - */ -uint16_t __mqtt_next_pid(struct mqtt_client *client); - -/** - * @brief Handles egress client traffic. - * @ingroup details - * - * @param client The MQTT client. - * - * @returns MQTT_OK upon success, an \ref MQTTErrors otherwise. - */ -ssize_t __mqtt_send(struct mqtt_client *client); - -/** - * @brief Handles ingress client traffic. - * @ingroup details - * - * @param client The MQTT client. - * - * @returns MQTT_OK upon success, an \ref MQTTErrors otherwise. - */ -ssize_t __mqtt_recv(struct mqtt_client *client); - -/** - * @brief Function that does the actual sending and receiving of - * traffic from the network. - * @ingroup api - * - * All the other functions in the @ref api simply stage messages for - * being sent to the broker. This function does the actual sending of - * those messages. Additionally this function receives traffic (responses and - * acknowledgements) from the broker and responds to that traffic accordingly. - * Lastly this function also calls the \c publish_response_callback when - * any \c MQTT_CONTROL_PUBLISH messages are received. - * - * @pre mqtt_init must have been called. - * - * @param[in,out] client The MQTT client. - * - * @attention It is the responsibility of the application programmer to - * call this function periodically. All functions in the @ref api are - * thread-safe so it is perfectly reasonable to have a thread dedicated - * to calling this function every 200 ms or so. MQTT-C can be used in single - * threaded application though by simply calling this functino periodically - * inside your main thread. See @ref simple_publisher.c and @ref simple_subscriber.c - * for examples (specifically the \c client_refresher functions). - * - * @returns MQTT_OK upon success, an \ref MQTTErrors otherwise. - */ -enum MQTTErrors mqtt_sync(struct mqtt_client *client); - -/** - * @brief Initializes an MQTT client. - * @ingroup api - * - * This function \em must be called before any other API function calls. - * - * @pre None. - * - * @param[out] client The MQTT client. - * @param[in] sockfd The socket file descriptor (or equivalent socket handle, e.g. BIO pointer - * for OpenSSL sockets) connected to the MQTT broker. - * @param[in] sendbuf A buffer that will be used for sending messages to the broker. - * @param[in] sendbufsz The size of \p sendbuf in bytes. - * @param[in] recvbuf A buffer that will be used for receiving messages from the broker. - * @param[in] recvbufsz The size of \p recvbuf in bytes. - * @param[in] publish_response_callback The callback to call whenever application messages - * are received from the broker. - * - * @post mqtt_connect must be called. - * - * @note \p sockfd is a non-blocking TCP connection. - * @note If \p sendbuf fills up completely during runtime a \c MQTT_ERROR_SEND_BUFFER_IS_FULL - * error will be set. Similarly if \p recvbuf is ever to small to receive a message from - * the broker an MQTT_ERROR_RECV_BUFFER_TOO_SMALL error will be set. - * @note A pointer to \ref mqtt_client.publish_response_callback_state is always passed as the - * \c state argument to \p publish_response_callback. Note that the second argument is - * the mqtt_response_publish that was received from the broker. - * - * @attention Only initialize an MQTT client once (i.e. don't call \ref mqtt_init or - * \ref mqtt_init_reconnect more than once per client). - * @attention \p sendbuf internally mapped to client's message-to-send queue that actively uses - * pointer access. In the case of unaligned \p sendbuf, that may lead to - * Segmentation/Hard/Memory Faults on systems that do not support unaligned pointer - * access (e.g. ARMv6, ARMv7-M). To avoid that, you may use the following technique: - * \code{.c} - * // example for ARMv7-M that requires pointers to be word aligned (4 byte boundary) - * static unsigned char mqtt_tx_buffer[MAX_TX_BUFFER_SIZE] __attribute__((aligned(4))); - * static unsigned char mqtt_rx_buffer[MAX_RX_BUFFER_SIZE]; - * // ... - * int main(void) { - * // ... - * mqtt_init(p_client, p_client->socketfd, mqtt_tx_buffer, sizeof mqtt_tx_buffer, mqtt_rx_buffer, - * sizeof mqtt_rx_buffer, message_callback); - * // ... - * } - * \endcode - * - * @returns \c MQTT_OK upon success, an \ref MQTTErrors otherwise. - */ -enum MQTTErrors mqtt_init(struct mqtt_client *client, - mqtt_pal_socket_handle sockfd, - uint8_t *sendbuf, size_t sendbufsz, - uint8_t *recvbuf, size_t recvbufsz, - void (*publish_response_callback)(void** state, struct mqtt_response_publish *publish)); - -/** - * @brief Initializes an MQTT client and enables automatic reconnections. - * @ingroup api - * - * An alternative to \ref mqtt_init that allows the client to automatically reconnect to the - * broker after an error occurs (e.g. socket error or internal buffer overflows). - * - * This is accomplished by calling the \p reconnect_callback whenever the client enters an error - * state. The job of the \p reconnect_callback is to: (1) perform error handling/logging, - * (2) clean up the old connection (i.e. close client->socketfd), (3) \ref mqtt_reinit the - * client, and (4) reconfigure the MQTT session by calling \ref mqtt_connect followed by other - * API calls such as \ref mqtt_subscribe. - * - * The first argument to the \p reconnect_callback is the client (which will be in an error - * state) and the second argument is a pointer to a void pointer where you can store some state - * information. Internally, MQTT-C calls the reconnect callback like so: - * - * \code - * client->reconnect_callback(client, &client->reconnect_state) - * \endcode - * - * Note that the \p reconnect_callback is also called to setup the initial session. After - * calling \ref mqtt_init_reconnect the client will be in the error state - * \c MQTT_ERROR_INITIAL_RECONNECT. - * - * @pre None. - * - * @param[in,out] client The MQTT client that will be initialized. - * @param[in] reconnect_callback The callback that will be called to connect/reconnect the - * client to the broker and perform application level error handling. - * @param[in] reconnect_state A pointer to some state data for your \p reconnect_callback. - * If your \p reconnect_callback does not require any state information set this - * to NULL. A pointer to the memory address where the client stores a copy of this - * pointer is passed as the second argumnet to \p reconnect_callback. - * @param[in] publish_response_callback The callback to call whenever application messages - * are received from the broker. - * - * @post Call \p reconnect_callback yourself, or call \ref mqtt_sync - * (which will trigger the call to \p reconnect_callback). - * - * @attention Only initialize an MQTT client once (i.e. don't call \ref mqtt_init or - * \ref mqtt_init_reconnect more than once per client). - * - */ -void mqtt_init_reconnect(struct mqtt_client *client, - void (*reconnect_callback)(struct mqtt_client *client, void** state), - void *reconnect_state, - void (*publish_response_callback)(void** state, struct mqtt_response_publish *publish)); - -/** - * @brief Safely assign/reassign a socket and buffers to an new/existing client. - * @ingroup api - * - * This function also clears the \p client error state. Upon exiting this function - * \c client->error will be \c MQTT_ERROR_CONNECT_NOT_CALLED (which will be cleared) - * as soon as \ref mqtt_connect is called. - * - * @pre This function must be called BEFORE \ref mqtt_connect. - * - * @param[in,out] client The MQTT client. - * @param[in] socketfd The new socket connected to the broker. - * @param[in] sendbuf The buffer that will be used to buffer egress traffic to the broker. - * @param[in] sendbufsz The size of \p sendbuf in bytes. - * @param[in] recvbuf The buffer that will be used to buffer ingress traffic from the broker. - * @param[in] recvbufsz The size of \p recvbuf in bytes. - * - * @post Call \ref mqtt_connect. - * - * @attention This function should be used in conjunction with clients that have been - * initialzed with \ref mqtt_init_reconnect. - */ -void mqtt_reinit(struct mqtt_client* client, - mqtt_pal_socket_handle socketfd, - uint8_t *sendbuf, size_t sendbufsz, - uint8_t *recvbuf, size_t recvbufsz); - -/** - * @brief Establishes a session with the MQTT broker. - * @ingroup api - * - * @pre mqtt_init must have been called. - * - * @param[in,out] client The MQTT client. - * @param[in] client_id The unique name identifying the client. (or NULL) - * @param[in] will_topic The topic name of client's \p will_message. If no will message is - * desired set to \c NULL. - * @param[in] will_message The application message (data) to be published in the event the - * client ungracefully disconnects. Set to \c NULL if \p will_topic is \c NULL. - * @param[in] will_message_size The size of \p will_message in bytes. - * @param[in] user_name The username to use when establishing the session with the MQTT broker. - * Set to \c NULL if a username is not required. - * @param[in] password The password to use when establishing the session with the MQTT broker. - * Set to \c NULL if a password is not required. - * @param[in] connect_flags Additional \ref MQTTConnectFlags to use when establishing the connection. - * These flags are for forcing the session to start clean, - * \c MQTT_CONNECT_CLEAN_SESSION, the QOS level to publish the \p will_message with - * (provided \c will_message != \c NULL), MQTT_CONNECT_WILL_QOS_[0,1,2], and whether - * or not the broker should retain the \c will_message, MQTT_CONNECT_WILL_RETAIN. - * @param[in] keep_alive The keep-alive time in seconds. A reasonable value for this is 400 [seconds]. - * - * @returns \c MQTT_OK upon success, an \ref MQTTErrors otherwise. - */ -enum MQTTErrors mqtt_connect(struct mqtt_client *client, - const char* client_id, - const char* will_topic, - const void* will_message, - size_t will_message_size, - const char* user_name, - const char* password, - uint8_t connect_flags, - uint16_t keep_alive); - -/* - todo: will_message should be a void* -*/ - -/** - * @brief Publish an application message. - * @ingroup api - * - * Publishes an application message to the MQTT broker. - * - * @pre mqtt_connect must have been called. - * - * @param[in,out] client The MQTT client. - * @param[in] topic_name The name of the topic. - * @param[in] application_message The data to be published. - * @param[in] application_message_size The size of \p application_message in bytes. - * @param[in] publish_flags \ref MQTTPublishFlags to be used, namely the QOS level to - * publish at (MQTT_PUBLISH_QOS_[0,1,2]) or whether or not the broker should - * retain the publish (MQTT_PUBLISH_RETAIN). - * - * @returns \c MQTT_OK upon success, an \ref MQTTErrors otherwise. - */ -enum MQTTErrors mqtt_publish(struct mqtt_client *client, - const char* topic_name, - const void* application_message, - size_t application_message_size, - uint8_t publish_flags); - -/** - * @brief Acknowledge an ingree publish with QOS==1. - * @ingroup details - * - * @param[in,out] client The MQTT client. - * @param[in] packet_id The packet ID of the ingress publish being acknowledged. - * - * @returns \c MQTT_OK upon success, an \ref MQTTErrors otherwise. - */ -ssize_t __mqtt_puback(struct mqtt_client *client, uint16_t packet_id); - -/** - * @brief Acknowledge an ingree publish with QOS==2. - * @ingroup details - * - * @param[in,out] client The MQTT client. - * @param[in] packet_id The packet ID of the ingress publish being acknowledged. - * - * @returns \c MQTT_OK upon success, an \ref MQTTErrors otherwise. - */ -ssize_t __mqtt_pubrec(struct mqtt_client *client, uint16_t packet_id); - -/** - * @brief Acknowledge an ingree PUBREC packet. - * @ingroup details - * - * @param[in,out] client The MQTT client. - * @param[in] packet_id The packet ID of the ingress PUBREC being acknowledged. - * - * @returns \c MQTT_OK upon success, an \ref MQTTErrors otherwise. - */ -ssize_t __mqtt_pubrel(struct mqtt_client *client, uint16_t packet_id); - -/** - * @brief Acknowledge an ingree PUBREL packet. - * @ingroup details - * - * @param[in,out] client The MQTT client. - * @param[in] packet_id The packet ID of the ingress PUBREL being acknowledged. - * - * @returns \c MQTT_OK upon success, an \ref MQTTErrors otherwise. - */ -ssize_t __mqtt_pubcomp(struct mqtt_client *client, uint16_t packet_id); - - -/** - * @brief Subscribe to a topic. - * @ingroup api - * - * @pre mqtt_connect must have been called. - * - * @param[in,out] client The MQTT client. - * @param[in] topic_name The name of the topic to subscribe to. - * @param[in] max_qos_level The maximum QOS level with which the broker can send application - * messages for this topic. - * - * @returns \c MQTT_OK upon success, an \ref MQTTErrors otherwise. - */ -enum MQTTErrors mqtt_subscribe(struct mqtt_client *client, - const char* topic_name, - int max_qos_level); - -/** - * @brief Unsubscribe from a topic. - * @ingroup api - * - * @pre mqtt_connect must have been called. - * - * @param[in,out] client The MQTT client. - * @param[in] topic_name The name of the topic to unsubscribe from. - * - * @returns \c MQTT_OK upon success, an \ref MQTTErrors otherwise. - */ -enum MQTTErrors mqtt_unsubscribe(struct mqtt_client *client, - const char* topic_name); - -/** - * @brief Ping the broker. - * @ingroup api - * - * @pre mqtt_connect must have been called. - * - * @param[in,out] client The MQTT client. - * - * @returns \c MQTT_OK upon success, an \ref MQTTErrors otherwise. - */ -enum MQTTErrors mqtt_ping(struct mqtt_client *client); - -/** - * @brief Ping the broker without locking/unlocking the mutex. - * @see mqtt_ping - */ -enum MQTTErrors __mqtt_ping(struct mqtt_client *client); - -/** - * @brief Terminate the session with the MQTT broker. - * @ingroup api - * - * @pre mqtt_connect must have been called. - * - * @param[in,out] client The MQTT client. - * - * @note To re-establish the session, mqtt_connect must be called. - * - * @returns \c MQTT_OK upon success, an \ref MQTTErrors otherwise. - */ -enum MQTTErrors mqtt_disconnect(struct mqtt_client *client); - -/** - * @brief Terminate the session with the MQTT broker and prepare to - * reconnect. Client code should call \ref mqtt_sync immediately - * after this call to prevent message loss. - * @ingroup api - * - * @note The user must provide a reconnect callback function for this to - * work as expected. See \r mqtt_client_reconnect. - * - * @pre mqtt_connect must have been called -* - * @param[in,out] client The MQTT client. - * - * @returns \c MQTT_OK upon success, an \ref MQTTErrors otherwise. - */ -enum MQTTErrors mqtt_reconnect(struct mqtt_client *client); - -#if defined(__cplusplus) -} -#endif - -#endif diff --git a/Platformio/hardware/windows_linux/lib/MQTT-C/include/mqtt_pal.h b/Platformio/hardware/windows_linux/lib/MQTT-C/include/mqtt_pal.h deleted file mode 100644 index e73a3d82..00000000 --- a/Platformio/hardware/windows_linux/lib/MQTT-C/include/mqtt_pal.h +++ /dev/null @@ -1,203 +0,0 @@ -#if !defined(__MQTT_PAL_H__) -#define __MQTT_PAL_H__ - -/* -MIT License - -Copyright(c) 2018 Liam Bindle - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files(the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions : - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#if defined(__cplusplus) -extern "C" { -#endif - -/** - * @file - * @brief Includes/supports the types/calls required by the MQTT-C client. - * - * @note This is the \em only file included in mqtt.h, and mqtt.c. It is therefore - * responsible for including/supporting all the required types and calls. - * - * @defgroup pal Platform abstraction layer - * @brief Documentation of the types and calls required to port MQTT-C to a new platform. - * - * mqtt_pal.h is the \em only header file included in mqtt.c. Therefore, to port MQTT-C to a - * new platform the following types, functions, constants, and macros must be defined in - * mqtt_pal.h: - * - Types: - * - \c size_t, \c ssize_t - * - \c uint8_t, \c uint16_t, \c uint32_t - * - \c va_list - * - \c mqtt_pal_time_t : return type of \c MQTT_PAL_TIME() - * - \c mqtt_pal_mutex_t : type of the argument that is passed to \c MQTT_PAL_MUTEX_LOCK and - * \c MQTT_PAL_MUTEX_RELEASE - * - Functions: - * - \c memcpy, \c strlen - * - \c va_start, \c va_arg, \c va_end - * - Constants: - * - \c INT_MIN - * - * Additionally, three macro's are required: - * - \c MQTT_PAL_HTONS(s) : host-to-network endian conversion for uint16_t. - * - \c MQTT_PAL_NTOHS(s) : network-to-host endian conversion for uint16_t. - * - \c MQTT_PAL_TIME() : returns [type: \c mqtt_pal_time_t] current time in seconds. - * - \c MQTT_PAL_MUTEX_LOCK(mtx_pointer) : macro that locks the mutex pointed to by \c mtx_pointer. - * - \c MQTT_PAL_MUTEX_RELEASE(mtx_pointer) : macro that unlocks the mutex pointed to by - * \c mtx_pointer. - * - * Lastly, \ref mqtt_pal_sendall and \ref mqtt_pal_recvall, must be implemented in mqtt_pal.c - * for sending and receiving data using the platforms socket calls. - */ - - -/* UNIX-like platform support */ -#if defined(__unix__) || defined(__APPLE__) || defined(__NuttX__) - #include - #include - #include - #include - #include - #include - - #define MQTT_PAL_HTONS(s) htons(s) - #define MQTT_PAL_NTOHS(s) ntohs(s) - - #define MQTT_PAL_TIME() time(NULL) - - typedef time_t mqtt_pal_time_t; - typedef pthread_mutex_t mqtt_pal_mutex_t; - - #define MQTT_PAL_MUTEX_INIT(mtx_ptr) pthread_mutex_init(mtx_ptr, NULL) - #define MQTT_PAL_MUTEX_LOCK(mtx_ptr) pthread_mutex_lock(mtx_ptr) - #define MQTT_PAL_MUTEX_UNLOCK(mtx_ptr) pthread_mutex_unlock(mtx_ptr) - - #if !defined(MQTT_USE_CUSTOM_SOCKET_HANDLE) - #if defined(MQTT_USE_MBEDTLS) - struct mbedtls_ssl_context; - typedef struct mbedtls_ssl_context *mqtt_pal_socket_handle; - #elif defined(MQTT_USE_WOLFSSL) - #include - typedef WOLFSSL* mqtt_pal_socket_handle; - #elif defined(MQTT_USE_BIO) - #include - typedef BIO* mqtt_pal_socket_handle; - #elif defined(MQTT_USE_BEARSSL) - #include - - typedef struct _bearssl_context { - br_ssl_client_context sc; - br_x509_minimal_context xc; - br_sslio_context ioc; - size_t ta_count; - br_x509_trust_anchor *anchOut; - int fd; - int (*low_read)(void *read_context, unsigned char *buf, size_t len); - int (*low_write)(void *write_context, const unsigned char *buf, size_t len); - } bearssl_context; - - typedef bearssl_context* mqtt_pal_socket_handle; - #else - typedef int mqtt_pal_socket_handle; - #endif - #endif -#elif defined(_MSC_VER) || defined(WIN32) - #include - #include - #include - #include - #include - - // original from MQTT-C - // typedef SSIZE_T ssize_t; - // changed for usage in OMOTE - #if defined(WIN64) - typedef SSIZE_T ssize_t; - #endif - #define MQTT_PAL_HTONS(s) htons(s) - #define MQTT_PAL_NTOHS(s) ntohs(s) - - #define MQTT_PAL_TIME() time(NULL) - - typedef time_t mqtt_pal_time_t; - typedef CRITICAL_SECTION mqtt_pal_mutex_t; - - #define MQTT_PAL_MUTEX_INIT(mtx_ptr) InitializeCriticalSection(mtx_ptr) - #define MQTT_PAL_MUTEX_LOCK(mtx_ptr) EnterCriticalSection(mtx_ptr) - #define MQTT_PAL_MUTEX_UNLOCK(mtx_ptr) LeaveCriticalSection(mtx_ptr) - - - #if !defined(MQTT_USE_CUSTOM_SOCKET_HANDLE) - #if defined(MQTT_USE_BIO) - #include - typedef BIO* mqtt_pal_socket_handle; - #else - typedef SOCKET mqtt_pal_socket_handle; - #endif - #endif - -#endif - -/** - * @brief Sends all the bytes in a buffer. - * @ingroup pal - * - * @param[in] fd The file-descriptor (or handle) of the socket. - * @param[in] buf A pointer to the first byte in the buffer to send. - * @param[in] len The number of bytes to send (starting at \p buf). - * @param[in] flags Flags which are passed to the underlying socket. - * - * @returns The number of bytes sent if successful, an \ref MQTTErrors otherwise. - * - * Note about the error handling: - * - On an error, if some bytes have been processed already, - * this function should return the number of bytes successfully - * processed. (partial success) - * - Otherwise, if the error is an equivalent of EAGAIN, return 0. - * - Otherwise, return MQTT_ERROR_SOCKET_ERROR. - */ -ssize_t mqtt_pal_sendall(mqtt_pal_socket_handle fd, const void* buf, size_t len, int flags); - -/** - * @brief Non-blocking receive all the byte available. - * @ingroup pal - * - * @param[in] fd The file-descriptor (or handle) of the socket. - * @param[in] buf A pointer to the receive buffer. - * @param[in] bufsz The max number of bytes that can be put into \p buf. - * @param[in] flags Flags which are passed to the underlying socket. - * - * @returns The number of bytes received if successful, an \ref MQTTErrors otherwise. - * - * Note about the error handling: - * - On an error, if some bytes have been processed already, - * this function should return the number of bytes successfully - * processed. (partial success) - * - Otherwise, if the error is an equivalent of EAGAIN, return 0. - * - Otherwise, return MQTT_ERROR_SOCKET_ERROR. - */ -ssize_t mqtt_pal_recvall(mqtt_pal_socket_handle fd, void* buf, size_t bufsz, int flags); - -#if defined(__cplusplus) -} -#endif - - -#endif diff --git a/Platformio/hardware/windows_linux/lib/MQTT-C/include/posix_sockets.h b/Platformio/hardware/windows_linux/lib/MQTT-C/include/posix_sockets.h deleted file mode 100644 index 3ba9f289..00000000 --- a/Platformio/hardware/windows_linux/lib/MQTT-C/include/posix_sockets.h +++ /dev/null @@ -1,103 +0,0 @@ -#if !defined(__POSIX_SOCKET_TEMPLATE_H__) -#define __POSIX_SOCKET_TEMPLATE_H__ - -#include -#include -#if !defined(WIN32) -#include -#include -#include -#include -#else -#include -#endif -#if defined(__VMS) -#include -#endif -#include - -/* - A template for opening a non-blocking POSIX socket. -*/ -int open_nb_socket(const char* addr, const char* port); - -int open_nb_socket(const char* addr, const char* port, char *MACaddress) { - struct addrinfo hints = {0}; - - hints.ai_family = AF_UNSPEC; /* IPv4 or IPv6 */ - hints.ai_socktype = SOCK_STREAM; /* Must be TCP */ - int sockfd = -1; - int rv; - struct addrinfo *p, *servinfo; - - /* get address information */ - rv = getaddrinfo(addr, port, &hints, &servinfo); - if(rv != 0) { - fprintf(stderr, "Failed to open socket (getaddrinfo): %s\r\n", gai_strerror(rv)); - return -1; - } - - /* open the first possible socket */ - for(p = servinfo; p != NULL; p = p->ai_next) { - sockfd = socket(p->ai_family, p->ai_socktype, p->ai_protocol); - if (sockfd == -1) continue; - - /* connect to server */ - rv = connect(sockfd, p->ai_addr, p->ai_addrlen); - if(rv == -1) { - close(sockfd); - sockfd = -1; - continue; - } - - #if !defined(WIN32) - // get MAC address - struct ifreq s; - ioctl(sockfd, SIOCGIFHWADDR, &s); - char buffer[6*3]; - int i; - for (i = 0; i < 6; ++i) { - sprintf(&buffer[i*3], "%02x:", (unsigned char) s.ifr_addr.sa_data[i]); - //printf(" %02x", (unsigned char) s.ifr_addr.sa_data[i]); - } - //printf("\r\n"); - buffer[17] = '\0'; - - std::string strMACaddress = std::string(buffer, 18); - strMACaddress.copy(MACaddress, 18); - // printf(" MAC address from posix_sockets %s\r\n", strMACaddress.c_str()); - #endif - - break; - } - - /* free servinfo */ - freeaddrinfo(servinfo); - - /* make non-blocking */ -#if !defined(WIN32) - if (sockfd != -1) fcntl(sockfd, F_SETFL, fcntl(sockfd, F_GETFL) | O_NONBLOCK); -#else - if (sockfd != INVALID_SOCKET) { - // original from MQTT-C - // int iMode = 1; - // changed for usage in OMOTE - u_long iMode = 1; - ioctlsocket(sockfd, FIONBIO, &iMode); - } -#endif -#if defined(__VMS) - /* - OpenVMS only partially implements fcntl. It works on file descriptors - but silently fails on socket descriptors. So we need to fall back on - to the older ioctl system to set non-blocking IO - */ - int on = 1; - if (sockfd != -1) ioctl(sockfd, FIONBIO, &on); -#endif - - /* return the new socket fd */ - return sockfd; -} - -#endif diff --git a/Platformio/hardware/windows_linux/lib/MQTT-C/src/mqtt.c b/Platformio/hardware/windows_linux/lib/MQTT-C/src/mqtt.c deleted file mode 100644 index d914c1a3..00000000 --- a/Platformio/hardware/windows_linux/lib/MQTT-C/src/mqtt.c +++ /dev/null @@ -1,1791 +0,0 @@ -/* -MIT License - -Copyright(c) 2018 Liam Bindle - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files(the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions : - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#include - -/** - * @file - * @brief Implements the functionality of MQTT-C. - * @note The only files that are included are mqtt.h and mqtt_pal.h. - * - * @cond Doxygen_Suppress - */ - -enum MQTTErrors mqtt_sync(struct mqtt_client *client) { - /* Recover from any errors */ - enum MQTTErrors err; - int reconnecting = 0; - MQTT_PAL_MUTEX_LOCK(&client->mutex); - if (client->error != MQTT_ERROR_RECONNECTING && client->error != MQTT_OK && client->reconnect_callback != NULL) { - client->reconnect_callback(client, &client->reconnect_state); - if (client->error != MQTT_OK) { - client->error = MQTT_ERROR_RECONNECT_FAILED; - - /* normally unlocked during CONNECT */ - MQTT_PAL_MUTEX_UNLOCK(&client->mutex); - } - err = client->error; - - if (err != MQTT_OK) return err; - } else { - /* mqtt_reconnect will have queued the disconnect packet - that needs to be sent and then call reconnect */ - if (client->error == MQTT_ERROR_RECONNECTING) { - reconnecting = 1; - client->error = MQTT_OK; - } - MQTT_PAL_MUTEX_UNLOCK(&client->mutex); - } - - /* Call inspector callback if necessary */ - - if (client->inspector_callback != NULL) { - MQTT_PAL_MUTEX_LOCK(&client->mutex); - err = client->inspector_callback(client); - MQTT_PAL_MUTEX_UNLOCK(&client->mutex); - if (err != MQTT_OK) return err; - } - - /* Call receive */ - err = (enum MQTTErrors)__mqtt_recv(client); - if (err != MQTT_OK) return err; - - /* Call send */ - err = (enum MQTTErrors)__mqtt_send(client); - - /* mqtt_reconnect will essentially be a disconnect if there is no callback */ - if (reconnecting && client->reconnect_callback != NULL) { - MQTT_PAL_MUTEX_LOCK(&client->mutex); - client->reconnect_callback(client, &client->reconnect_state); - } - - return err; -} - -uint16_t __mqtt_next_pid(struct mqtt_client *client) { - int pid_exists = 0; - if (client->pid_lfsr == 0) { - client->pid_lfsr = 163u; - } - /* LFSR taps taken from: https://en.wikipedia.org/wiki/Linear-feedback_shift_register */ - - do { - struct mqtt_queued_message *curr; - unsigned lsb = client->pid_lfsr & 1; - (client->pid_lfsr) >>= 1; - if (lsb) { - client->pid_lfsr ^= 0xB400u; - } - - /* check that the PID is unique */ - pid_exists = 0; - for(curr = mqtt_mq_get(&(client->mq), 0); curr >= client->mq.queue_tail; --curr) { - if (curr->packet_id == client->pid_lfsr) { - pid_exists = 1; - break; - } - } - - } while(pid_exists); - return client->pid_lfsr; -} - -enum MQTTErrors mqtt_init(struct mqtt_client *client, - mqtt_pal_socket_handle sockfd, - uint8_t *sendbuf, size_t sendbufsz, - uint8_t *recvbuf, size_t recvbufsz, - void (*publish_response_callback)(void** state,struct mqtt_response_publish *publish)) -{ - if (client == NULL || sendbuf == NULL || recvbuf == NULL) { - return MQTT_ERROR_NULLPTR; - } - - /* initialize mutex */ - MQTT_PAL_MUTEX_INIT(&client->mutex); - MQTT_PAL_MUTEX_LOCK(&client->mutex); /* unlocked during CONNECT */ - - client->socketfd = sockfd; - - mqtt_mq_init(&client->mq, sendbuf, sendbufsz); - - client->recv_buffer.mem_start = recvbuf; - client->recv_buffer.mem_size = recvbufsz; - client->recv_buffer.curr = client->recv_buffer.mem_start; - client->recv_buffer.curr_sz = client->recv_buffer.mem_size; - - client->error = MQTT_ERROR_CONNECT_NOT_CALLED; - client->response_timeout = 30; - client->number_of_timeouts = 0; - client->number_of_keep_alives = 0; - client->typical_response_time = -1.0f; - client->publish_response_callback = publish_response_callback; - client->pid_lfsr = 0; - client->send_offset = 0; - - client->inspector_callback = NULL; - client->reconnect_callback = NULL; - client->reconnect_state = NULL; - - return MQTT_OK; -} - -void mqtt_init_reconnect(struct mqtt_client *client, - void (*reconnect)(struct mqtt_client *, void**), - void *reconnect_state, - void (*publish_response_callback)(void** state, struct mqtt_response_publish *publish)) -{ - /* initialize mutex */ - MQTT_PAL_MUTEX_INIT(&client->mutex); - - client->socketfd = (mqtt_pal_socket_handle) -1; - - mqtt_mq_init(&client->mq, NULL, 0uL); - - client->recv_buffer.mem_start = NULL; - client->recv_buffer.mem_size = 0; - client->recv_buffer.curr = NULL; - client->recv_buffer.curr_sz = 0; - - client->error = MQTT_ERROR_INITIAL_RECONNECT; - client->response_timeout = 30; - client->number_of_timeouts = 0; - client->number_of_keep_alives = 0; - client->typical_response_time = -1.0f; - client->publish_response_callback = publish_response_callback; - client->pid_lfsr = 0; - client->send_offset = 0; - - client->inspector_callback = NULL; - client->reconnect_callback = reconnect; - client->reconnect_state = reconnect_state; -} - -void mqtt_reinit(struct mqtt_client* client, - mqtt_pal_socket_handle socketfd, - uint8_t *sendbuf, size_t sendbufsz, - uint8_t *recvbuf, size_t recvbufsz) -{ - client->error = MQTT_ERROR_CONNECT_NOT_CALLED; - client->socketfd = socketfd; - - mqtt_mq_init(&client->mq, sendbuf, sendbufsz); - - client->recv_buffer.mem_start = recvbuf; - client->recv_buffer.mem_size = recvbufsz; - client->recv_buffer.curr = client->recv_buffer.mem_start; - client->recv_buffer.curr_sz = client->recv_buffer.mem_size; -} - -/** - * A macro function that: - * 1) Checks that the client isn't in an error state. - * 2) Attempts to pack to client's message queue. - * a) handles errors - * b) if mq buffer is too small, cleans it and tries again - * 3) Upon successful pack, registers the new message. - */ -#define MQTT_CLIENT_TRY_PACK(tmp, msg, client, pack_call, release) \ - if (client->error < 0) { \ - if (release) MQTT_PAL_MUTEX_UNLOCK(&client->mutex); \ - return client->error; \ - } \ - tmp = pack_call; \ - if (tmp < 0) { \ - client->error = (enum MQTTErrors)tmp; \ - if (release) MQTT_PAL_MUTEX_UNLOCK(&client->mutex); \ - return (enum MQTTErrors)tmp; \ - } else if (tmp == 0) { \ - mqtt_mq_clean(&client->mq); \ - tmp = pack_call; \ - if (tmp < 0) { \ - client->error = (enum MQTTErrors)tmp; \ - if (release) MQTT_PAL_MUTEX_UNLOCK(&client->mutex); \ - return (enum MQTTErrors)tmp; \ - } else if(tmp == 0) { \ - client->error = MQTT_ERROR_SEND_BUFFER_IS_FULL; \ - if (release) MQTT_PAL_MUTEX_UNLOCK(&client->mutex); \ - return (enum MQTTErrors)MQTT_ERROR_SEND_BUFFER_IS_FULL; \ - } \ - } \ - msg = mqtt_mq_register(&client->mq, (size_t)tmp); \ - - -enum MQTTErrors mqtt_connect(struct mqtt_client *client, - const char* client_id, - const char* will_topic, - const void* will_message, - size_t will_message_size, - const char* user_name, - const char* password, - uint8_t connect_flags, - uint16_t keep_alive) -{ - ssize_t rv; - struct mqtt_queued_message *msg; - - /* Note: Current thread already has mutex locked. */ - - /* update the client's state */ - client->keep_alive = keep_alive; - if (client->error == MQTT_ERROR_CONNECT_NOT_CALLED) { - client->error = MQTT_OK; - } - - /* try to pack the message */ - MQTT_CLIENT_TRY_PACK(rv, msg, client, - mqtt_pack_connection_request( - client->mq.curr, client->mq.curr_sz, - client_id, will_topic, will_message, - will_message_size,user_name, password, - connect_flags, keep_alive - ), - 1 - ); - /* save the control type of the message */ - msg->control_type = MQTT_CONTROL_CONNECT; - - MQTT_PAL_MUTEX_UNLOCK(&client->mutex); - return MQTT_OK; -} - -enum MQTTErrors mqtt_publish(struct mqtt_client *client, - const char* topic_name, - const void* application_message, - size_t application_message_size, - uint8_t publish_flags) -{ - struct mqtt_queued_message *msg; - ssize_t rv; - uint16_t packet_id; - MQTT_PAL_MUTEX_LOCK(&client->mutex); - packet_id = __mqtt_next_pid(client); - - - /* try to pack the message */ - MQTT_CLIENT_TRY_PACK( - rv, msg, client, - mqtt_pack_publish_request( - client->mq.curr, client->mq.curr_sz, - topic_name, - packet_id, - application_message, - application_message_size, - publish_flags - ), - 1 - ); - /* save the control type and packet id of the message */ - msg->control_type = MQTT_CONTROL_PUBLISH; - msg->packet_id = packet_id; - - MQTT_PAL_MUTEX_UNLOCK(&client->mutex); - return MQTT_OK; -} - -ssize_t __mqtt_puback(struct mqtt_client *client, uint16_t packet_id) { - ssize_t rv; - struct mqtt_queued_message *msg; - - /* try to pack the message */ - MQTT_CLIENT_TRY_PACK( - rv, msg, client, - mqtt_pack_pubxxx_request( - client->mq.curr, client->mq.curr_sz, - MQTT_CONTROL_PUBACK, - packet_id - ), - 0 - ); - /* save the control type and packet id of the message */ - msg->control_type = MQTT_CONTROL_PUBACK; - msg->packet_id = packet_id; - - return MQTT_OK; -} - -ssize_t __mqtt_pubrec(struct mqtt_client *client, uint16_t packet_id) { - ssize_t rv; - struct mqtt_queued_message *msg; - - /* try to pack the message */ - MQTT_CLIENT_TRY_PACK( - rv, msg, client, - mqtt_pack_pubxxx_request( - client->mq.curr, client->mq.curr_sz, - MQTT_CONTROL_PUBREC, - packet_id - ), - 0 - ); - /* save the control type and packet id of the message */ - msg->control_type = MQTT_CONTROL_PUBREC; - msg->packet_id = packet_id; - - return MQTT_OK; -} - -ssize_t __mqtt_pubrel(struct mqtt_client *client, uint16_t packet_id) { - ssize_t rv; - struct mqtt_queued_message *msg; - - /* try to pack the message */ - MQTT_CLIENT_TRY_PACK( - rv, msg, client, - mqtt_pack_pubxxx_request( - client->mq.curr, client->mq.curr_sz, - MQTT_CONTROL_PUBREL, - packet_id - ), - 0 - ); - /* save the control type and packet id of the message */ - msg->control_type = MQTT_CONTROL_PUBREL; - msg->packet_id = packet_id; - - return MQTT_OK; -} - -ssize_t __mqtt_pubcomp(struct mqtt_client *client, uint16_t packet_id) { - ssize_t rv; - struct mqtt_queued_message *msg; - - /* try to pack the message */ - MQTT_CLIENT_TRY_PACK( - rv, msg, client, - mqtt_pack_pubxxx_request( - client->mq.curr, client->mq.curr_sz, - MQTT_CONTROL_PUBCOMP, - packet_id - ), - 0 - ); - /* save the control type and packet id of the message */ - msg->control_type = MQTT_CONTROL_PUBCOMP; - msg->packet_id = packet_id; - - return MQTT_OK; -} - -enum MQTTErrors mqtt_subscribe(struct mqtt_client *client, - const char* topic_name, - int max_qos_level) -{ - ssize_t rv; - uint16_t packet_id; - struct mqtt_queued_message *msg; - MQTT_PAL_MUTEX_LOCK(&client->mutex); - packet_id = __mqtt_next_pid(client); - - /* try to pack the message */ - MQTT_CLIENT_TRY_PACK( - rv, msg, client, - mqtt_pack_subscribe_request( - client->mq.curr, client->mq.curr_sz, - packet_id, - topic_name, - max_qos_level, - (const char*)NULL - ), - 1 - ); - /* save the control type and packet id of the message */ - msg->control_type = MQTT_CONTROL_SUBSCRIBE; - msg->packet_id = packet_id; - - MQTT_PAL_MUTEX_UNLOCK(&client->mutex); - return MQTT_OK; -} - -enum MQTTErrors mqtt_unsubscribe(struct mqtt_client *client, - const char* topic_name) -{ - uint16_t packet_id = __mqtt_next_pid(client); - ssize_t rv; - struct mqtt_queued_message *msg; - MQTT_PAL_MUTEX_LOCK(&client->mutex); - - /* try to pack the message */ - MQTT_CLIENT_TRY_PACK( - rv, msg, client, - mqtt_pack_unsubscribe_request( - client->mq.curr, client->mq.curr_sz, - packet_id, - topic_name, - (const char*)NULL - ), - 1 - ); - /* save the control type and packet id of the message */ - msg->control_type = MQTT_CONTROL_UNSUBSCRIBE; - msg->packet_id = packet_id; - - MQTT_PAL_MUTEX_UNLOCK(&client->mutex); - return MQTT_OK; -} - -enum MQTTErrors mqtt_ping(struct mqtt_client *client) { - enum MQTTErrors rv; - MQTT_PAL_MUTEX_LOCK(&client->mutex); - rv = __mqtt_ping(client); - MQTT_PAL_MUTEX_UNLOCK(&client->mutex); - return rv; -} - -enum MQTTErrors __mqtt_ping(struct mqtt_client *client) -{ - ssize_t rv; - struct mqtt_queued_message *msg; - - /* try to pack the message */ - MQTT_CLIENT_TRY_PACK( - rv, msg, client, - mqtt_pack_ping_request( - client->mq.curr, client->mq.curr_sz - ), - 0 - ); - /* save the control type and packet id of the message */ - msg->control_type = MQTT_CONTROL_PINGREQ; - - - return MQTT_OK; -} - -enum MQTTErrors mqtt_reconnect(struct mqtt_client *client) -{ - enum MQTTErrors err = mqtt_disconnect(client); - - if (err == MQTT_OK) { - MQTT_PAL_MUTEX_LOCK(&client->mutex); - client->error = MQTT_ERROR_RECONNECTING; - MQTT_PAL_MUTEX_UNLOCK(&client->mutex); - } - return err; -} - -enum MQTTErrors mqtt_disconnect(struct mqtt_client *client) -{ - ssize_t rv; - struct mqtt_queued_message *msg; - MQTT_PAL_MUTEX_LOCK(&client->mutex); - - /* try to pack the message */ - MQTT_CLIENT_TRY_PACK( - rv, msg, client, - mqtt_pack_disconnect( - client->mq.curr, client->mq.curr_sz - ), - 1 - ); - /* save the control type and packet id of the message */ - msg->control_type = MQTT_CONTROL_DISCONNECT; - - MQTT_PAL_MUTEX_UNLOCK(&client->mutex); - return MQTT_OK; -} - -ssize_t __mqtt_send(struct mqtt_client *client) -{ - uint8_t inspected; - ssize_t len; - int inflight_qos2 = 0; - int i = 0; - - MQTT_PAL_MUTEX_LOCK(&client->mutex); - - if (client->error < 0 && client->error != MQTT_ERROR_SEND_BUFFER_IS_FULL) { - MQTT_PAL_MUTEX_UNLOCK(&client->mutex); - return client->error; - } - - /* loop through all messages in the queue */ - len = mqtt_mq_length(&client->mq); - for(; i < len; ++i) { - struct mqtt_queued_message *msg = mqtt_mq_get(&client->mq, i); - int resend = 0; - if (msg->state == MQTT_QUEUED_UNSENT) { - /* message has not been sent to lets send it */ - resend = 1; - } else if (msg->state == MQTT_QUEUED_AWAITING_ACK) { - /* check for timeout */ - if (MQTT_PAL_TIME() > msg->time_sent + client->response_timeout) { - resend = 1; - client->number_of_timeouts += 1; - client->send_offset = 0; - } - } - - /* only send QoS 2 message if there are no inflight QoS 2 PUBLISH messages */ - if (msg->control_type == MQTT_CONTROL_PUBLISH - && (msg->state == MQTT_QUEUED_UNSENT || msg->state == MQTT_QUEUED_AWAITING_ACK)) - { - inspected = 0x03 & ((msg->start[0]) >> 1); /* qos */ - if (inspected == 2) { - if (inflight_qos2) { - resend = 0; - } - inflight_qos2 = 1; - } - } - - /* goto next message if we don't need to send */ - if (!resend) { - continue; - } - - /* we're sending the message */ - { - ssize_t tmp = mqtt_pal_sendall(client->socketfd, msg->start + client->send_offset, msg->size - client->send_offset, 0); - if (tmp < 0) { - client->error = (enum MQTTErrors)tmp; - MQTT_PAL_MUTEX_UNLOCK(&client->mutex); - return tmp; - } else { - client->send_offset += (unsigned long)tmp; - if(client->send_offset < msg->size) { - /* partial sent. Await additional calls */ - break; - } else { - /* whole message has been sent */ - client->send_offset = 0; - } - - } - - } - - /* update timeout watcher */ - client->time_of_last_send = MQTT_PAL_TIME(); - msg->time_sent = client->time_of_last_send; - - /* - Determine the state to put the message in. - Control Types: - MQTT_CONTROL_CONNECT -> awaiting - MQTT_CONTROL_CONNACK -> n/a - MQTT_CONTROL_PUBLISH -> qos == 0 ? complete : awaiting - MQTT_CONTROL_PUBACK -> complete - MQTT_CONTROL_PUBREC -> awaiting - MQTT_CONTROL_PUBREL -> awaiting - MQTT_CONTROL_PUBCOMP -> complete - MQTT_CONTROL_SUBSCRIBE -> awaiting - MQTT_CONTROL_SUBACK -> n/a - MQTT_CONTROL_UNSUBSCRIBE -> awaiting - MQTT_CONTROL_UNSUBACK -> n/a - MQTT_CONTROL_PINGREQ -> awaiting - MQTT_CONTROL_PINGRESP -> n/a - MQTT_CONTROL_DISCONNECT -> complete - */ - switch (msg->control_type) { - case MQTT_CONTROL_PUBACK: - case MQTT_CONTROL_PUBCOMP: - case MQTT_CONTROL_DISCONNECT: - msg->state = MQTT_QUEUED_COMPLETE; - break; - case MQTT_CONTROL_PUBLISH: - inspected = ( MQTT_PUBLISH_QOS_MASK & (msg->start[0]) ) >> 1; /* qos */ - if (inspected == 0) { - msg->state = MQTT_QUEUED_COMPLETE; - } else if (inspected == 1) { - msg->state = MQTT_QUEUED_AWAITING_ACK; - /*set DUP flag for subsequent sends [Spec MQTT-3.3.1-1] */ - msg->start[0] |= MQTT_PUBLISH_DUP; - } else { - msg->state = MQTT_QUEUED_AWAITING_ACK; - } - break; - case MQTT_CONTROL_CONNECT: - case MQTT_CONTROL_PUBREC: - case MQTT_CONTROL_PUBREL: - case MQTT_CONTROL_SUBSCRIBE: - case MQTT_CONTROL_UNSUBSCRIBE: - case MQTT_CONTROL_PINGREQ: - msg->state = MQTT_QUEUED_AWAITING_ACK; - break; - default: - client->error = MQTT_ERROR_MALFORMED_REQUEST; - MQTT_PAL_MUTEX_UNLOCK(&client->mutex); - return MQTT_ERROR_MALFORMED_REQUEST; - } - } - - /* check for keep-alive */ - { - mqtt_pal_time_t keep_alive_timeout = client->time_of_last_send + (mqtt_pal_time_t)((float)(client->keep_alive)); - if (MQTT_PAL_TIME() > keep_alive_timeout) { - ssize_t rv = __mqtt_ping(client); - if (rv != MQTT_OK) { - client->error = (enum MQTTErrors)rv; - MQTT_PAL_MUTEX_UNLOCK(&client->mutex); - return rv; - } - } - } - - MQTT_PAL_MUTEX_UNLOCK(&client->mutex); - return MQTT_OK; -} - -ssize_t __mqtt_recv(struct mqtt_client *client) -{ - struct mqtt_response response; - ssize_t mqtt_recv_ret = MQTT_OK; - MQTT_PAL_MUTEX_LOCK(&client->mutex); - - /* read until there is nothing left to read, or there was an error */ - while(mqtt_recv_ret == MQTT_OK) { - /* read in as many bytes as possible */ - ssize_t rv, consumed; - struct mqtt_queued_message *msg = NULL; - - rv = mqtt_pal_recvall(client->socketfd, client->recv_buffer.curr, client->recv_buffer.curr_sz, 0); - if (rv < 0) { - /* an error occurred */ - client->error = (enum MQTTErrors)rv; - MQTT_PAL_MUTEX_UNLOCK(&client->mutex); - return rv; - } else { - client->recv_buffer.curr += rv; - client->recv_buffer.curr_sz -= (unsigned long)rv; - } - - /* attempt to parse */ - consumed = mqtt_unpack_response(&response, client->recv_buffer.mem_start, (size_t) (client->recv_buffer.curr - client->recv_buffer.mem_start)); - - if (consumed < 0) { - client->error = (enum MQTTErrors)consumed; - MQTT_PAL_MUTEX_UNLOCK(&client->mutex); - return consumed; - } else if (consumed == 0) { - /* if curr_sz is 0 then the buffer is too small to ever fit the message */ - if (client->recv_buffer.curr_sz == 0) { - client->error = MQTT_ERROR_RECV_BUFFER_TOO_SMALL; - MQTT_PAL_MUTEX_UNLOCK(&client->mutex); - return MQTT_ERROR_RECV_BUFFER_TOO_SMALL; - } - - /* just need to wait for the rest of the data */ - MQTT_PAL_MUTEX_UNLOCK(&client->mutex); - return MQTT_OK; - } - - /* response was unpacked successfully */ - - /* - The switch statement below manages how the client responds to messages from the broker. - - Control Types (that we expect to receive from the broker): - MQTT_CONTROL_CONNACK: - -> release associated CONNECT - -> handle response - MQTT_CONTROL_PUBLISH: - -> stage response, none if qos==0, PUBACK if qos==1, PUBREC if qos==2 - -> call publish callback - MQTT_CONTROL_PUBACK: - -> release associated PUBLISH - MQTT_CONTROL_PUBREC: - -> release PUBLISH - -> stage PUBREL - MQTT_CONTROL_PUBREL: - -> release associated PUBREC - -> stage PUBCOMP - MQTT_CONTROL_PUBCOMP: - -> release PUBREL - MQTT_CONTROL_SUBACK: - -> release SUBSCRIBE - -> handle response - MQTT_CONTROL_UNSUBACK: - -> release UNSUBSCRIBE - MQTT_CONTROL_PINGRESP: - -> release PINGREQ - */ - switch (response.fixed_header.control_type) { - case MQTT_CONTROL_CONNACK: - /* release associated CONNECT */ - msg = mqtt_mq_find(&client->mq, MQTT_CONTROL_CONNECT, NULL); - if (msg == NULL) { - client->error = MQTT_ERROR_ACK_OF_UNKNOWN; - mqtt_recv_ret = MQTT_ERROR_ACK_OF_UNKNOWN; - break; - } - msg->state = MQTT_QUEUED_COMPLETE; - /* initialize typical response time */ - client->typical_response_time = (float) (MQTT_PAL_TIME() - msg->time_sent); - /* check that connection was successful */ - if (response.decoded.connack.return_code != MQTT_CONNACK_ACCEPTED) { - if (response.decoded.connack.return_code == MQTT_CONNACK_REFUSED_IDENTIFIER_REJECTED) { - client->error = MQTT_ERROR_CONNECT_CLIENT_ID_REFUSED; - mqtt_recv_ret = MQTT_ERROR_CONNECT_CLIENT_ID_REFUSED; - } else { - client->error = MQTT_ERROR_CONNECTION_REFUSED; - mqtt_recv_ret = MQTT_ERROR_CONNECTION_REFUSED; - } - break; - } - break; - case MQTT_CONTROL_PUBLISH: - /* stage response, none if qos==0, PUBACK if qos==1, PUBREC if qos==2 */ - if (response.decoded.publish.qos_level == 1) { - rv = __mqtt_puback(client, response.decoded.publish.packet_id); - if (rv != MQTT_OK) { - client->error = (enum MQTTErrors)rv; - mqtt_recv_ret = rv; - break; - } - } else if (response.decoded.publish.qos_level == 2) { - /* check if this is a duplicate */ - if (mqtt_mq_find(&client->mq, MQTT_CONTROL_PUBREC, &response.decoded.publish.packet_id) != NULL) { - break; - } - - rv = __mqtt_pubrec(client, response.decoded.publish.packet_id); - if (rv != MQTT_OK) { - client->error = (enum MQTTErrors)rv; - mqtt_recv_ret = rv; - break; - } - } - /* call publish callback */ - client->publish_response_callback(&client->publish_response_callback_state, &response.decoded.publish); - break; - case MQTT_CONTROL_PUBACK: - /* release associated PUBLISH */ - msg = mqtt_mq_find(&client->mq, MQTT_CONTROL_PUBLISH, &response.decoded.puback.packet_id); - if (msg == NULL) { - client->error = MQTT_ERROR_ACK_OF_UNKNOWN; - mqtt_recv_ret = MQTT_ERROR_ACK_OF_UNKNOWN; - break; - } - msg->state = MQTT_QUEUED_COMPLETE; - /* update response time */ - client->typical_response_time = 0.875f * (client->typical_response_time) + 0.125f * (float) (MQTT_PAL_TIME() - msg->time_sent); - break; - case MQTT_CONTROL_PUBREC: - /* check if this is a duplicate */ - if (mqtt_mq_find(&client->mq, MQTT_CONTROL_PUBREL, &response.decoded.pubrec.packet_id) != NULL) { - break; - } - /* release associated PUBLISH */ - msg = mqtt_mq_find(&client->mq, MQTT_CONTROL_PUBLISH, &response.decoded.pubrec.packet_id); - if (msg == NULL) { - client->error = MQTT_ERROR_ACK_OF_UNKNOWN; - mqtt_recv_ret = MQTT_ERROR_ACK_OF_UNKNOWN; - break; - } - msg->state = MQTT_QUEUED_COMPLETE; - /* update response time */ - client->typical_response_time = 0.875f * (client->typical_response_time) + 0.125f * (float) (MQTT_PAL_TIME() - msg->time_sent); - /* stage PUBREL */ - rv = __mqtt_pubrel(client, response.decoded.pubrec.packet_id); - if (rv != MQTT_OK) { - client->error = (enum MQTTErrors)rv; - mqtt_recv_ret = rv; - break; - } - break; - case MQTT_CONTROL_PUBREL: - /* release associated PUBREC */ - msg = mqtt_mq_find(&client->mq, MQTT_CONTROL_PUBREC, &response.decoded.pubrel.packet_id); - if (msg == NULL) { - client->error = MQTT_ERROR_ACK_OF_UNKNOWN; - mqtt_recv_ret = MQTT_ERROR_ACK_OF_UNKNOWN; - break; - } - msg->state = MQTT_QUEUED_COMPLETE; - /* update response time */ - client->typical_response_time = 0.875f * (client->typical_response_time) + 0.125f * (float) (MQTT_PAL_TIME() - msg->time_sent); - /* stage PUBCOMP */ - rv = __mqtt_pubcomp(client, response.decoded.pubrec.packet_id); - if (rv != MQTT_OK) { - client->error = (enum MQTTErrors)rv; - mqtt_recv_ret = rv; - break; - } - break; - case MQTT_CONTROL_PUBCOMP: - /* release associated PUBREL */ - msg = mqtt_mq_find(&client->mq, MQTT_CONTROL_PUBREL, &response.decoded.pubcomp.packet_id); - if (msg == NULL) { - client->error = MQTT_ERROR_ACK_OF_UNKNOWN; - mqtt_recv_ret = MQTT_ERROR_ACK_OF_UNKNOWN; - break; - } - msg->state = MQTT_QUEUED_COMPLETE; - /* update response time */ - client->typical_response_time = 0.875f * (client->typical_response_time) + 0.125f * (float) (MQTT_PAL_TIME() - msg->time_sent); - break; - case MQTT_CONTROL_SUBACK: - /* release associated SUBSCRIBE */ - msg = mqtt_mq_find(&client->mq, MQTT_CONTROL_SUBSCRIBE, &response.decoded.suback.packet_id); - if (msg == NULL) { - client->error = MQTT_ERROR_ACK_OF_UNKNOWN; - mqtt_recv_ret = MQTT_ERROR_ACK_OF_UNKNOWN; - break; - } - msg->state = MQTT_QUEUED_COMPLETE; - /* update response time */ - client->typical_response_time = 0.875f * (client->typical_response_time) + 0.125f * (float) (MQTT_PAL_TIME() - msg->time_sent); - /* check that subscription was successful (not currently only one subscribe at a time) */ - if (response.decoded.suback.return_codes[0] == MQTT_SUBACK_FAILURE) { - client->error = MQTT_ERROR_SUBSCRIBE_FAILED; - mqtt_recv_ret = MQTT_ERROR_SUBSCRIBE_FAILED; - break; - } - break; - case MQTT_CONTROL_UNSUBACK: - /* release associated UNSUBSCRIBE */ - msg = mqtt_mq_find(&client->mq, MQTT_CONTROL_UNSUBSCRIBE, &response.decoded.unsuback.packet_id); - if (msg == NULL) { - client->error = MQTT_ERROR_ACK_OF_UNKNOWN; - mqtt_recv_ret = MQTT_ERROR_ACK_OF_UNKNOWN; - break; - } - msg->state = MQTT_QUEUED_COMPLETE; - /* update response time */ - client->typical_response_time = 0.875f * (client->typical_response_time) + 0.125f * (float) (MQTT_PAL_TIME() - msg->time_sent); - break; - case MQTT_CONTROL_PINGRESP: - /* release associated PINGREQ */ - msg = mqtt_mq_find(&client->mq, MQTT_CONTROL_PINGREQ, NULL); - if (msg == NULL) { - client->error = MQTT_ERROR_ACK_OF_UNKNOWN; - mqtt_recv_ret = MQTT_ERROR_ACK_OF_UNKNOWN; - break; - } - msg->state = MQTT_QUEUED_COMPLETE; - /* update response time */ - client->typical_response_time = 0.875f * (client->typical_response_time) + 0.125f * (float) (MQTT_PAL_TIME() - msg->time_sent); - break; - default: - client->error = MQTT_ERROR_MALFORMED_RESPONSE; - mqtt_recv_ret = MQTT_ERROR_MALFORMED_RESPONSE; - break; - } - { - /* we've handled the response, now clean the buffer */ - void* dest = (unsigned char*)client->recv_buffer.mem_start; - void* src = (unsigned char*)client->recv_buffer.mem_start + consumed; - size_t n = (size_t) (client->recv_buffer.curr - client->recv_buffer.mem_start - consumed); - memmove(dest, src, n); - client->recv_buffer.curr -= consumed; - client->recv_buffer.curr_sz += (unsigned long)consumed; - } - } - - /* In case there was some error handling the (well formed) message, we end up here */ - MQTT_PAL_MUTEX_UNLOCK(&client->mutex); - return mqtt_recv_ret; -} - -/* FIXED HEADER */ - -#define MQTT_BITFIELD_RULE_VIOLOATION(bitfield, rule_value, rule_mask) ((bitfield ^ rule_value) & rule_mask) - -struct mqtt_fixed_header_rules_s{ - uint8_t control_type_is_valid[16]; - uint8_t required_flags[16]; - uint8_t mask_required_flags[16]; -} ; - -static const struct mqtt_fixed_header_rules_s mqtt_fixed_header_rules ={ - { /* boolean value, true if type is valid */ - 0x00, /* MQTT_CONTROL_RESERVED */ - 0x01, /* MQTT_CONTROL_CONNECT */ - 0x01, /* MQTT_CONTROL_CONNACK */ - 0x01, /* MQTT_CONTROL_PUBLISH */ - 0x01, /* MQTT_CONTROL_PUBACK */ - 0x01, /* MQTT_CONTROL_PUBREC */ - 0x01, /* MQTT_CONTROL_PUBREL */ - 0x01, /* MQTT_CONTROL_PUBCOMP */ - 0x01, /* MQTT_CONTROL_SUBSCRIBE */ - 0x01, /* MQTT_CONTROL_SUBACK */ - 0x01, /* MQTT_CONTROL_UNSUBSCRIBE */ - 0x01, /* MQTT_CONTROL_UNSUBACK */ - 0x01, /* MQTT_CONTROL_PINGREQ */ - 0x01, /* MQTT_CONTROL_PINGRESP */ - 0x01, /* MQTT_CONTROL_DISCONNECT */ - 0x00 /* MQTT_CONTROL_RESERVED */ - }, - { /* flags that must be set for the associated control type */ - 0x00, /* MQTT_CONTROL_RESERVED */ - 0x00, /* MQTT_CONTROL_CONNECT */ - 0x00, /* MQTT_CONTROL_CONNACK */ - 0x00, /* MQTT_CONTROL_PUBLISH */ - 0x00, /* MQTT_CONTROL_PUBACK */ - 0x00, /* MQTT_CONTROL_PUBREC */ - 0x02, /* MQTT_CONTROL_PUBREL */ - 0x00, /* MQTT_CONTROL_PUBCOMP */ - 0x02, /* MQTT_CONTROL_SUBSCRIBE */ - 0x00, /* MQTT_CONTROL_SUBACK */ - 0x02, /* MQTT_CONTROL_UNSUBSCRIBE */ - 0x00, /* MQTT_CONTROL_UNSUBACK */ - 0x00, /* MQTT_CONTROL_PINGREQ */ - 0x00, /* MQTT_CONTROL_PINGRESP */ - 0x00, /* MQTT_CONTROL_DISCONNECT */ - 0x00 /* MQTT_CONTROL_RESERVED */ - }, - { /* mask of flags that must be specific values for the associated control type*/ - 0x00, /* MQTT_CONTROL_RESERVED */ - 0x0F, /* MQTT_CONTROL_CONNECT */ - 0x0F, /* MQTT_CONTROL_CONNACK */ - 0x00, /* MQTT_CONTROL_PUBLISH */ - 0x0F, /* MQTT_CONTROL_PUBACK */ - 0x0F, /* MQTT_CONTROL_PUBREC */ - 0x0F, /* MQTT_CONTROL_PUBREL */ - 0x0F, /* MQTT_CONTROL_PUBCOMP */ - 0x0F, /* MQTT_CONTROL_SUBSCRIBE */ - 0x0F, /* MQTT_CONTROL_SUBACK */ - 0x0F, /* MQTT_CONTROL_UNSUBSCRIBE */ - 0x0F, /* MQTT_CONTROL_UNSUBACK */ - 0x0F, /* MQTT_CONTROL_PINGREQ */ - 0x0F, /* MQTT_CONTROL_PINGRESP */ - 0x0F, /* MQTT_CONTROL_DISCONNECT */ - 0x00 /* MQTT_CONTROL_RESERVED */ - } -}; - -static ssize_t mqtt_fixed_header_rule_violation(const struct mqtt_fixed_header *fixed_header) { - uint8_t control_type; - uint8_t control_flags; - uint8_t required_flags; - uint8_t mask_required_flags; - - /* get value and rules */ - control_type = (uint8_t)fixed_header->control_type; - control_flags = fixed_header->control_flags; - required_flags = mqtt_fixed_header_rules.required_flags[control_type]; - mask_required_flags = mqtt_fixed_header_rules.mask_required_flags[control_type]; - - /* check for valid type */ - if (!mqtt_fixed_header_rules.control_type_is_valid[control_type]) { - return MQTT_ERROR_CONTROL_FORBIDDEN_TYPE; - } - - /* check that flags are appropriate */ - if(MQTT_BITFIELD_RULE_VIOLOATION(control_flags, required_flags, mask_required_flags)) { - return MQTT_ERROR_CONTROL_INVALID_FLAGS; - } - - return 0; -} - -ssize_t mqtt_unpack_fixed_header(struct mqtt_response *response, const uint8_t *buf, size_t bufsz) { - struct mqtt_fixed_header *fixed_header; - const uint8_t *start = buf; - int lshift; - ssize_t errcode; - - /* check for null pointers or empty buffer */ - if (response == NULL || buf == NULL) { - return MQTT_ERROR_NULLPTR; - } - fixed_header = &(response->fixed_header); - - /* check that bufsz is not zero */ - if (bufsz == 0) return 0; - - /* parse control type and flags */ - fixed_header->control_type = (enum MQTTControlPacketType) (*buf >> 4); - fixed_header->control_flags = (uint8_t) (*buf & 0x0F); - - /* parse remaining size */ - fixed_header->remaining_length = 0; - - lshift = 0; - do { - - /* MQTT spec (2.2.3) says the maximum length is 28 bits */ - if(lshift == 28) - return MQTT_ERROR_INVALID_REMAINING_LENGTH; - - /* consume byte and assert at least 1 byte left */ - --bufsz; - ++buf; - if (bufsz == 0) return 0; - - /* parse next byte*/ - fixed_header->remaining_length += (uint32_t) ((*buf & 0x7F) << lshift); - lshift += 7; - } while(*buf & 0x80); /* while continue bit is set */ - - /* consume last byte */ - --bufsz; - ++buf; - - /* check that the fixed header is valid */ - errcode = mqtt_fixed_header_rule_violation(fixed_header); - if (errcode) { - return errcode; - } - - /* check that the buffer size if GT remaining length */ - if (bufsz < fixed_header->remaining_length) { - return 0; - } - - /* return how many bytes were consumed */ - return buf - start; -} - -ssize_t mqtt_pack_fixed_header(uint8_t *buf, size_t bufsz, const struct mqtt_fixed_header *fixed_header) { - const uint8_t *start = buf; - ssize_t errcode; - uint32_t remaining_length; - - /* check for null pointers or empty buffer */ - if (fixed_header == NULL || buf == NULL) { - return MQTT_ERROR_NULLPTR; - } - - /* check that the fixed header is valid */ - errcode = mqtt_fixed_header_rule_violation(fixed_header); - if (errcode) { - return errcode; - } - - /* check that bufsz is not zero */ - if (bufsz == 0) return 0; - - /* pack control type and flags */ - *buf = (uint8_t)((((uint8_t) fixed_header->control_type) << 4) & 0xF0); - *buf = (uint8_t)(*buf | (((uint8_t) fixed_header->control_flags) & 0x0F)); - - remaining_length = fixed_header->remaining_length; - - /* MQTT spec (2.2.3) says maximum remaining length is 2^28-1 */ - if(remaining_length >= 256*1024*1024) - return MQTT_ERROR_INVALID_REMAINING_LENGTH; - - do { - /* consume byte and assert at least 1 byte left */ - --bufsz; - ++buf; - if (bufsz == 0) return 0; - - /* pack next byte */ - *buf = remaining_length & 0x7F; - if(remaining_length > 127) *buf |= 0x80; - remaining_length = remaining_length >> 7; - } while(*buf & 0x80); - - /* consume last byte */ - --bufsz; - ++buf; - - /* check that there's still enough space in buffer for packet */ - if (bufsz < fixed_header->remaining_length) { - return 0; - } - - /* return how many bytes were consumed */ - return buf - start; -} - -/* CONNECT */ -ssize_t mqtt_pack_connection_request(uint8_t* buf, size_t bufsz, - const char* client_id, - const char* will_topic, - const void* will_message, - size_t will_message_size, - const char* user_name, - const char* password, - uint8_t connect_flags, - uint16_t keep_alive) -{ - struct mqtt_fixed_header fixed_header; - size_t remaining_length; - const uint8_t *const start = buf; - ssize_t rv; - - /* pack the fixed headr */ - fixed_header.control_type = MQTT_CONTROL_CONNECT; - fixed_header.control_flags = 0x00; - - /* calculate remaining length and build connect_flags at the same time */ - connect_flags = (uint8_t) (connect_flags & ~MQTT_CONNECT_RESERVED); - remaining_length = 10; /* size of variable header */ - - if (client_id == NULL) { - client_id = ""; - } - /* For an empty client_id, a clean session is required */ - if (client_id[0] == '\0' && !(connect_flags & MQTT_CONNECT_CLEAN_SESSION)) { - return MQTT_ERROR_CLEAN_SESSION_IS_REQUIRED; - } - /* mqtt_string length is strlen + 2 */ - remaining_length += __mqtt_packed_cstrlen(client_id); - - if (will_topic != NULL) { - uint8_t temp; - /* there is a will */ - connect_flags |= MQTT_CONNECT_WILL_FLAG; - remaining_length += __mqtt_packed_cstrlen(will_topic); - - if (will_message == NULL) { - /* if there's a will there MUST be a will message */ - return MQTT_ERROR_CONNECT_NULL_WILL_MESSAGE; - } - remaining_length += 2 + will_message_size; /* size of will_message */ - - /* assert that the will QOS is valid (i.e. not 3) */ - temp = connect_flags & 0x18; /* mask to QOS */ - if (temp == 0x18) { - /* bitwise equality with QoS 3 (invalid)*/ - return MQTT_ERROR_CONNECT_FORBIDDEN_WILL_QOS; - } - } else { - /* there is no will so set all will flags to zero */ - connect_flags &= (uint8_t)~MQTT_CONNECT_WILL_FLAG; - connect_flags &= (uint8_t)~0x18; - connect_flags &= (uint8_t)~MQTT_CONNECT_WILL_RETAIN; - } - - if (user_name != NULL) { - /* a user name is present */ - connect_flags |= MQTT_CONNECT_USER_NAME; - remaining_length += __mqtt_packed_cstrlen(user_name); - } else { - connect_flags &= (uint8_t)~MQTT_CONNECT_USER_NAME; - } - - if (password != NULL) { - /* a password is present */ - connect_flags |= MQTT_CONNECT_PASSWORD; - remaining_length += __mqtt_packed_cstrlen(password); - } else { - connect_flags &= (uint8_t)~MQTT_CONNECT_PASSWORD; - } - - /* fixed header length is now calculated*/ - fixed_header.remaining_length = (uint32_t)remaining_length; - - /* pack fixed header and perform error checks */ - rv = mqtt_pack_fixed_header(buf, bufsz, &fixed_header); - if (rv <= 0) { - /* something went wrong */ - return rv; - } - buf += rv; - bufsz -= (size_t)rv; - - /* check that the buffer has enough space to fit the remaining length */ - if (bufsz < fixed_header.remaining_length) { - return 0; - } - - /* pack the variable header */ - *buf++ = 0x00; - *buf++ = 0x04; - *buf++ = (uint8_t) 'M'; - *buf++ = (uint8_t) 'Q'; - *buf++ = (uint8_t) 'T'; - *buf++ = (uint8_t) 'T'; - *buf++ = MQTT_PROTOCOL_LEVEL; - *buf++ = connect_flags; - buf += __mqtt_pack_uint16(buf, keep_alive); - - /* pack the payload */ - buf += __mqtt_pack_str(buf, client_id); - if (will_topic != NULL) { - buf += __mqtt_pack_str(buf, will_topic); - buf += __mqtt_pack_uint16(buf, (uint16_t)will_message_size); - memcpy(buf, will_message, will_message_size); - buf += will_message_size; - } - if (user_name != NULL) { - buf += __mqtt_pack_str(buf, user_name); - } - if (password != NULL) { - buf += __mqtt_pack_str(buf, password); - } - - /* return the number of bytes that were consumed */ - return buf - start; -} - -/* CONNACK */ -ssize_t mqtt_unpack_connack_response(struct mqtt_response *mqtt_response, const uint8_t *buf) { - const uint8_t *const start = buf; - struct mqtt_response_connack *response; - - /* check that remaining length is 2 */ - if (mqtt_response->fixed_header.remaining_length != 2) { - return MQTT_ERROR_MALFORMED_RESPONSE; - } - - response = &(mqtt_response->decoded.connack); - /* unpack */ - if (*buf & 0xFE) { - /* only bit 1 can be set */ - return MQTT_ERROR_CONNACK_FORBIDDEN_FLAGS; - } else { - response->session_present_flag = *buf++; - } - - if (*buf > 5u) { - /* only bit 1 can be set */ - return MQTT_ERROR_CONNACK_FORBIDDEN_CODE; - } else { - response->return_code = (enum MQTTConnackReturnCode) *buf++; - } - return buf - start; -} - -/* DISCONNECT */ -ssize_t mqtt_pack_disconnect(uint8_t *buf, size_t bufsz) { - struct mqtt_fixed_header fixed_header; - fixed_header.control_type = MQTT_CONTROL_DISCONNECT; - fixed_header.control_flags = 0; - fixed_header.remaining_length = 0; - return mqtt_pack_fixed_header(buf, bufsz, &fixed_header); -} - -/* PING */ -ssize_t mqtt_pack_ping_request(uint8_t *buf, size_t bufsz) { - struct mqtt_fixed_header fixed_header; - fixed_header.control_type = MQTT_CONTROL_PINGREQ; - fixed_header.control_flags = 0; - fixed_header.remaining_length = 0; - return mqtt_pack_fixed_header(buf, bufsz, &fixed_header); -} - -/* PUBLISH */ -ssize_t mqtt_pack_publish_request(uint8_t *buf, size_t bufsz, - const char* topic_name, - uint16_t packet_id, - const void* application_message, - size_t application_message_size, - uint8_t publish_flags) -{ - const uint8_t *const start = buf; - ssize_t rv; - struct mqtt_fixed_header fixed_header; - uint32_t remaining_length; - uint8_t inspected_qos; - - /* check for null pointers */ - if(buf == NULL || topic_name == NULL) { - return MQTT_ERROR_NULLPTR; - } - - /* inspect QoS level */ - inspected_qos = (publish_flags & MQTT_PUBLISH_QOS_MASK) >> 1; /* mask */ - - /* build the fixed header */ - fixed_header.control_type = MQTT_CONTROL_PUBLISH; - - /* calculate remaining length */ - remaining_length = (uint32_t)__mqtt_packed_cstrlen(topic_name); - if (inspected_qos > 0) { - remaining_length += 2; - } - remaining_length += (uint32_t)application_message_size; - fixed_header.remaining_length = remaining_length; - - /* force dup to 0 if qos is 0 [Spec MQTT-3.3.1-2] */ - if (inspected_qos == 0) { - publish_flags &= (uint8_t)~MQTT_PUBLISH_DUP; - } - - /* make sure that qos is not 3 [Spec MQTT-3.3.1-4] */ - if (inspected_qos == 3) { - return MQTT_ERROR_PUBLISH_FORBIDDEN_QOS; - } - fixed_header.control_flags = publish_flags & 0x7; - - /* pack fixed header */ - rv = mqtt_pack_fixed_header(buf, bufsz, &fixed_header); - if (rv <= 0) { - /* something went wrong */ - return rv; - } - buf += rv; - bufsz -= (size_t)rv; - - /* check that buffer is big enough */ - if (bufsz < remaining_length) { - return 0; - } - - /* pack variable header */ - buf += __mqtt_pack_str(buf, topic_name); - if (inspected_qos > 0) { - buf += __mqtt_pack_uint16(buf, packet_id); - } - - /* pack payload */ - memcpy(buf, application_message, application_message_size); - buf += application_message_size; - - return buf - start; -} - -ssize_t mqtt_unpack_publish_response(struct mqtt_response *mqtt_response, const uint8_t *buf) -{ - const uint8_t *const start = buf; - struct mqtt_fixed_header *fixed_header; - struct mqtt_response_publish *response; - - fixed_header = &(mqtt_response->fixed_header); - response = &(mqtt_response->decoded.publish); - - /* get flags */ - response->dup_flag = (fixed_header->control_flags & MQTT_PUBLISH_DUP) >> 3; - response->qos_level = (fixed_header->control_flags & MQTT_PUBLISH_QOS_MASK) >> 1; - response->retain_flag = fixed_header->control_flags & MQTT_PUBLISH_RETAIN; - - /* make sure that remaining length is valid */ - if (mqtt_response->fixed_header.remaining_length < 4) { - return MQTT_ERROR_MALFORMED_RESPONSE; - } - - /* parse variable header */ - response->topic_name_size = __mqtt_unpack_uint16(buf); - buf += 2; - response->topic_name = buf; - buf += response->topic_name_size; - - if (response->qos_level > 0) { - response->packet_id = __mqtt_unpack_uint16(buf); - buf += 2; - } - - /* get payload */ - response->application_message = buf; - if (response->qos_level == 0) { - response->application_message_size = fixed_header->remaining_length - response->topic_name_size - 2; - } else { - response->application_message_size = fixed_header->remaining_length - response->topic_name_size - 4; - } - buf += response->application_message_size; - - /* return number of bytes consumed */ - return buf - start; -} - -/* PUBXXX */ -ssize_t mqtt_pack_pubxxx_request(uint8_t *buf, size_t bufsz, - enum MQTTControlPacketType control_type, - uint16_t packet_id) -{ - const uint8_t *const start = buf; - struct mqtt_fixed_header fixed_header; - ssize_t rv; - if (buf == NULL) { - return MQTT_ERROR_NULLPTR; - } - - /* pack fixed header */ - fixed_header.control_type = control_type; - if (control_type == MQTT_CONTROL_PUBREL) { - fixed_header.control_flags = 0x02; - } else { - fixed_header.control_flags = 0; - } - fixed_header.remaining_length = 2; - rv = mqtt_pack_fixed_header(buf, bufsz, &fixed_header); - if (rv <= 0) { - return rv; - } - buf += rv; - bufsz -= (size_t)rv; - - if (bufsz < fixed_header.remaining_length) { - return 0; - } - - buf += __mqtt_pack_uint16(buf, packet_id); - - return buf - start; -} - -ssize_t mqtt_unpack_pubxxx_response(struct mqtt_response *mqtt_response, const uint8_t *buf) -{ - const uint8_t *const start = buf; - uint16_t packet_id; - - /* assert remaining length is correct */ - if (mqtt_response->fixed_header.remaining_length != 2) { - return MQTT_ERROR_MALFORMED_RESPONSE; - } - - /* parse packet_id */ - packet_id = __mqtt_unpack_uint16(buf); - buf += 2; - - if (mqtt_response->fixed_header.control_type == MQTT_CONTROL_PUBACK) { - mqtt_response->decoded.puback.packet_id = packet_id; - } else if (mqtt_response->fixed_header.control_type == MQTT_CONTROL_PUBREC) { - mqtt_response->decoded.pubrec.packet_id = packet_id; - } else if (mqtt_response->fixed_header.control_type == MQTT_CONTROL_PUBREL) { - mqtt_response->decoded.pubrel.packet_id = packet_id; - } else { - mqtt_response->decoded.pubcomp.packet_id = packet_id; - } - - return buf - start; -} - -/* SUBACK */ -ssize_t mqtt_unpack_suback_response (struct mqtt_response *mqtt_response, const uint8_t *buf) { - const uint8_t *const start = buf; - uint32_t remaining_length = mqtt_response->fixed_header.remaining_length; - - /* assert remaining length is at least 3 (for packet id and at least 1 topic) */ - if (remaining_length < 3) { - return MQTT_ERROR_MALFORMED_RESPONSE; - } - - /* unpack packet_id */ - mqtt_response->decoded.suback.packet_id = __mqtt_unpack_uint16(buf); - buf += 2; - remaining_length -= 2; - - /* unpack return codes */ - mqtt_response->decoded.suback.num_return_codes = (size_t) remaining_length; - mqtt_response->decoded.suback.return_codes = buf; - buf += remaining_length; - - return buf - start; -} - -/* SUBSCRIBE */ -ssize_t mqtt_pack_subscribe_request(uint8_t *buf, size_t bufsz, unsigned int packet_id, ...) { - va_list args; - const uint8_t *const start = buf; - ssize_t rv; - struct mqtt_fixed_header fixed_header; - unsigned int num_subs = 0; - unsigned int i; - const char *topic[MQTT_SUBSCRIBE_REQUEST_MAX_NUM_TOPICS]; - uint8_t max_qos[MQTT_SUBSCRIBE_REQUEST_MAX_NUM_TOPICS]; - - /* parse all subscriptions */ - va_start(args, packet_id); - for(;;) { - topic[num_subs] = va_arg(args, const char*); - if (topic[num_subs] == NULL) { - /* end of list */ - break; - } - - max_qos[num_subs] = (uint8_t) va_arg(args, unsigned int); - - ++num_subs; - if (num_subs >= MQTT_SUBSCRIBE_REQUEST_MAX_NUM_TOPICS) { - va_end(args); - return MQTT_ERROR_SUBSCRIBE_TOO_MANY_TOPICS; - } - } - va_end(args); - - /* build the fixed header */ - fixed_header.control_type = MQTT_CONTROL_SUBSCRIBE; - fixed_header.control_flags = 2u; - fixed_header.remaining_length = 2u; /* size of variable header */ - for(i = 0; i < num_subs; ++i) { - /* payload is topic name + max qos (1 byte) */ - fixed_header.remaining_length += __mqtt_packed_cstrlen(topic[i]) + 1; - } - - /* pack the fixed header */ - rv = mqtt_pack_fixed_header(buf, bufsz, &fixed_header); - if (rv <= 0) { - return rv; - } - buf += rv; - bufsz -= (unsigned long)rv; - - /* check that the buffer has enough space */ - if (bufsz < fixed_header.remaining_length) { - return 0; - } - - - /* pack variable header */ - buf += __mqtt_pack_uint16(buf, (uint16_t)packet_id); - - - /* pack payload */ - for(i = 0; i < num_subs; ++i) { - buf += __mqtt_pack_str(buf, topic[i]); - *buf++ = max_qos[i]; - } - - return buf - start; -} - -/* UNSUBACK */ -ssize_t mqtt_unpack_unsuback_response(struct mqtt_response *mqtt_response, const uint8_t *buf) -{ - const uint8_t *const start = buf; - - if (mqtt_response->fixed_header.remaining_length != 2) { - return MQTT_ERROR_MALFORMED_RESPONSE; - } - - /* parse packet_id */ - mqtt_response->decoded.unsuback.packet_id = __mqtt_unpack_uint16(buf); - buf += 2; - - return buf - start; -} - -/* UNSUBSCRIBE */ -ssize_t mqtt_pack_unsubscribe_request(uint8_t *buf, size_t bufsz, unsigned int packet_id, ...) { - va_list args; - const uint8_t *const start = buf; - ssize_t rv; - struct mqtt_fixed_header fixed_header; - unsigned int num_subs = 0; - unsigned int i; - const char *topic[MQTT_UNSUBSCRIBE_REQUEST_MAX_NUM_TOPICS]; - - /* parse all subscriptions */ - va_start(args, packet_id); - for(;;) { - topic[num_subs] = va_arg(args, const char*); - if (topic[num_subs] == NULL) { - /* end of list */ - break; - } - - ++num_subs; - if (num_subs >= MQTT_UNSUBSCRIBE_REQUEST_MAX_NUM_TOPICS) { - va_end(args); - return MQTT_ERROR_UNSUBSCRIBE_TOO_MANY_TOPICS; - } - } - va_end(args); - - /* build the fixed header */ - fixed_header.control_type = MQTT_CONTROL_UNSUBSCRIBE; - fixed_header.control_flags = 2u; - fixed_header.remaining_length = 2u; /* size of variable header */ - for(i = 0; i < num_subs; ++i) { - /* payload is topic name */ - fixed_header.remaining_length += __mqtt_packed_cstrlen(topic[i]); - } - - /* pack the fixed header */ - rv = mqtt_pack_fixed_header(buf, bufsz, &fixed_header); - if (rv <= 0) { - return rv; - } - buf += rv; - bufsz -= (unsigned long)rv; - - /* check that the buffer has enough space */ - if (bufsz < fixed_header.remaining_length) { - return 0; - } - - /* pack variable header */ - buf += __mqtt_pack_uint16(buf, (uint16_t)packet_id); - - - /* pack payload */ - for(i = 0; i < num_subs; ++i) { - buf += __mqtt_pack_str(buf, topic[i]); - } - - return buf - start; -} - -/* MESSAGE QUEUE */ -void mqtt_mq_init(struct mqtt_message_queue *mq, void *buf, size_t bufsz) -{ - mq->mem_start = buf; - mq->mem_end = (uint8_t *)buf + bufsz; - mq->curr = (uint8_t *)buf; - mq->queue_tail = (struct mqtt_queued_message *)mq->mem_end; - mq->curr_sz = buf == NULL ? 0 : mqtt_mq_currsz(mq); -} - -struct mqtt_queued_message* mqtt_mq_register(struct mqtt_message_queue *mq, size_t nbytes) -{ - /* make queued message header */ - --(mq->queue_tail); - mq->queue_tail->start = mq->curr; - mq->queue_tail->size = nbytes; - mq->queue_tail->state = MQTT_QUEUED_UNSENT; - - /* move curr and recalculate curr_sz */ - mq->curr += nbytes; - mq->curr_sz = (size_t) (mqtt_mq_currsz(mq)); - - return mq->queue_tail; -} - -void mqtt_mq_clean(struct mqtt_message_queue *mq) { - struct mqtt_queued_message *new_head; - - for(new_head = mqtt_mq_get(mq, 0); new_head >= mq->queue_tail; --new_head) { - if (new_head->state != MQTT_QUEUED_COMPLETE) break; - } - - /* check if everything can be removed */ - if (new_head < mq->queue_tail) { - mq->curr = (uint8_t *)mq->mem_start; - mq->queue_tail = (struct mqtt_queued_message *)mq->mem_end; - mq->curr_sz = (size_t) (mqtt_mq_currsz(mq)); - return; - } else if (new_head == mqtt_mq_get(mq, 0)) { - /* do nothing */ - return; - } - - /* move buffered data */ - { - size_t n = (size_t) (mq->curr - new_head->start); - size_t removing = (size_t) (new_head->start - (uint8_t*) mq->mem_start); - memmove(mq->mem_start, new_head->start, n); - mq->curr = (unsigned char*)mq->mem_start + n; - - - /* move queue */ - { - ssize_t new_tail_idx = new_head - mq->queue_tail; - memmove(mqtt_mq_get(mq, new_tail_idx), mq->queue_tail, sizeof(struct mqtt_queued_message) * (size_t) ((new_tail_idx + 1))); - mq->queue_tail = mqtt_mq_get(mq, new_tail_idx); - - { - /* bump back start's */ - ssize_t i = 0; - for(; i < new_tail_idx + 1; ++i) { - mqtt_mq_get(mq, i)->start -= removing; - } - } - } - } - - /* get curr_sz */ - mq->curr_sz = (size_t) (mqtt_mq_currsz(mq)); -} - -struct mqtt_queued_message* mqtt_mq_find(const struct mqtt_message_queue *mq, enum MQTTControlPacketType control_type, const uint16_t *packet_id) -{ - struct mqtt_queued_message *curr; - for(curr = mqtt_mq_get(mq, 0); curr >= mq->queue_tail; --curr) { - if (curr->control_type == control_type) { - if ((packet_id == NULL && curr->state != MQTT_QUEUED_COMPLETE) || - (packet_id != NULL && *packet_id == curr->packet_id)) { - return curr; - } - } - } - return NULL; -} - - -/* RESPONSE UNPACKING */ -ssize_t mqtt_unpack_response(struct mqtt_response* response, const uint8_t *buf, size_t bufsz) { - const uint8_t *const start = buf; - ssize_t rv = mqtt_unpack_fixed_header(response, buf, bufsz); - if (rv <= 0) return rv; - else buf += rv; - switch(response->fixed_header.control_type) { - case MQTT_CONTROL_CONNACK: - rv = mqtt_unpack_connack_response(response, buf); - break; - case MQTT_CONTROL_PUBLISH: - rv = mqtt_unpack_publish_response(response, buf); - break; - case MQTT_CONTROL_PUBACK: - rv = mqtt_unpack_pubxxx_response(response, buf); - break; - case MQTT_CONTROL_PUBREC: - rv = mqtt_unpack_pubxxx_response(response, buf); - break; - case MQTT_CONTROL_PUBREL: - rv = mqtt_unpack_pubxxx_response(response, buf); - break; - case MQTT_CONTROL_PUBCOMP: - rv = mqtt_unpack_pubxxx_response(response, buf); - break; - case MQTT_CONTROL_SUBACK: - rv = mqtt_unpack_suback_response(response, buf); - break; - case MQTT_CONTROL_UNSUBACK: - rv = mqtt_unpack_unsuback_response(response, buf); - break; - case MQTT_CONTROL_PINGRESP: - return rv; - default: - return MQTT_ERROR_RESPONSE_INVALID_CONTROL_TYPE; - } - - if (rv < 0) return rv; - buf += rv; - return buf - start; -} - -/* EXTRA DETAILS */ -ssize_t __mqtt_pack_uint16(uint8_t *buf, uint16_t integer) -{ - uint16_t integer_htons = MQTT_PAL_HTONS(integer); - memcpy(buf, &integer_htons, 2uL); - return 2; -} - -uint16_t __mqtt_unpack_uint16(const uint8_t *buf) -{ - uint16_t integer_htons; - memcpy(&integer_htons, buf, 2uL); - return MQTT_PAL_NTOHS(integer_htons); -} - -ssize_t __mqtt_pack_str(uint8_t *buf, const char* str) { - uint16_t length = (uint16_t)strlen(str); - int i = 0; - /* pack string length */ - buf += __mqtt_pack_uint16(buf, length); - - /* pack string */ - for(; i < length; ++i) { - *(buf++) = (uint8_t)str[i]; - } - - /* return number of bytes consumed */ - return length + 2; -} - -static const char * const MQTT_ERRORS_STR[] = { - "MQTT_UNKNOWN_ERROR", - __ALL_MQTT_ERRORS(GENERATE_STRING) -}; - -const char* mqtt_error_str(enum MQTTErrors error) { - int offset = error - MQTT_ERROR_UNKNOWN; - if (offset >= 0) { - return MQTT_ERRORS_STR[offset]; - } else if (error == 0) { - return "MQTT_ERROR: Buffer too small."; - } else if (error > 0) { - return "MQTT_OK"; - } else { - return MQTT_ERRORS_STR[0]; - } -} - -/** @endcond*/ diff --git a/Platformio/hardware/windows_linux/lib/MQTT-C/src/mqtt_pal.c b/Platformio/hardware/windows_linux/lib/MQTT-C/src/mqtt_pal.c deleted file mode 100644 index 27e8149d..00000000 --- a/Platformio/hardware/windows_linux/lib/MQTT-C/src/mqtt_pal.c +++ /dev/null @@ -1,440 +0,0 @@ -/* -MIT License - -Copyright(c) 2018 Liam Bindle - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files(the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions : - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#include - -/** - * @file - * @brief Implements @ref mqtt_pal_sendall and @ref mqtt_pal_recvall and - * any platform-specific helpers you'd like. - * @cond Doxygen_Suppress - */ - -#if defined(MQTT_USE_CUSTOM_SOCKET_HANDLE) - -/* - * In case of MQTT_USE_CUSTOM_SOCKET_HANDLE, a pal implemantation is - * provided by the user. - */ - -/* Note: Some toolchains complain on an object without symbols */ - -int _mqtt_pal_dummy; - -#else /* defined(MQTT_USE_CUSTOM_SOCKET_HANDLE) */ - -#if defined(MQTT_USE_MBEDTLS) -#include - -ssize_t mqtt_pal_sendall(mqtt_pal_socket_handle fd, const void* buf, size_t len, int flags) { - enum MQTTErrors error = 0; - size_t sent = 0; - while(sent < len) { - int rv = mbedtls_ssl_write(fd, (const unsigned char*)buf + sent, len - sent); - if (rv < 0) { - if (rv == MBEDTLS_ERR_SSL_WANT_READ || - rv == MBEDTLS_ERR_SSL_WANT_WRITE -#if defined(MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS) - || rv == MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS -#endif -#if defined(MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS) - || rv == MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS -#endif - ) { - /* should call mbedtls_ssl_write later again */ - break; - } - error = MQTT_ERROR_SOCKET_ERROR; - break; - } - /* - * Note: rv can be 0 here eg. when mbedtls just flushed - * the previous incomplete record. - * - * Note: we never send an empty TLS record. - */ - sent += (size_t) rv; - } - if (sent == 0) { - return error; - } - return (ssize_t)sent; -} - -ssize_t mqtt_pal_recvall(mqtt_pal_socket_handle fd, void* buf, size_t bufsz, int flags) { - const void *const start = buf; - enum MQTTErrors error = 0; - int rv; - do { - rv = mbedtls_ssl_read(fd, (unsigned char*)buf, bufsz); - if (rv == 0) { - /* - * Note: mbedtls_ssl_read returns 0 when the underlying - * transport was closed without CloseNotify. - * - * Raise an error to trigger a reconnect. - */ - error = MQTT_ERROR_SOCKET_ERROR; - break; - } - if (rv < 0) { - if (rv == MBEDTLS_ERR_SSL_WANT_READ || - rv == MBEDTLS_ERR_SSL_WANT_WRITE -#if defined(MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS) - || rv == MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS -#endif -#if defined(MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS) - || rv == MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS -#endif - ) { - /* should call mbedtls_ssl_read later again */ - break; - } - /* Note: MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY is handled here. */ - error = MQTT_ERROR_SOCKET_ERROR; - break; - } - buf = (char*)buf + rv; - bufsz -= (unsigned long)rv; - } while (bufsz > 0); - if (buf == start) { - return error; - } - return (const char *)buf - (const char*)start; -} - -#elif defined(MQTT_USE_WOLFSSL) -#include - -ssize_t mqtt_pal_sendall(mqtt_pal_socket_handle fd, const void* buf, size_t len, int flags) { - size_t sent = 0; - while (sent < len) { - int tmp = wolfSSL_write(fd, buf + sent, (int)(len - sent)); - if (tmp <= 0) { - tmp = wolfSSL_get_error(fd, tmp); - if (tmp == WOLFSSL_ERROR_WANT_READ || tmp == WOLFSSL_ERROR_WANT_WRITE) { - break; - } - return MQTT_ERROR_SOCKET_ERROR; - } - sent += (size_t)tmp; - } - return (ssize_t)sent; -} - -ssize_t mqtt_pal_recvall(mqtt_pal_socket_handle fd, void* buf, size_t bufsz, int flags) { - const void* const start = buf; - int tmp; - do { - tmp = wolfSSL_read(fd, buf, (int)bufsz); - if (tmp <= 0) { - tmp = wolfSSL_get_error(fd, tmp); - if (tmp == WOLFSSL_ERROR_WANT_READ || tmp == WOLFSSL_ERROR_WANT_WRITE) { - break; - } - return MQTT_ERROR_SOCKET_ERROR; - } - buf = (char*)buf + tmp; - bufsz -= tmp; - } while (tmp > 0 && bufsz > 0); - - return (ssize_t)(buf - start); -} - -#elif defined(MQTT_USE_BEARSSL) -#include -#include - -static int do_rec_data(mqtt_pal_socket_handle fd, unsigned int status) { - ssize_t rc; - uint8_t *buffer; - size_t length; - int err; - - err = br_ssl_engine_last_error(&fd->sc.eng); - - if (err != BR_ERR_OK) { - return MQTT_ERROR_SOCKET_ERROR; - } - - if ((status & BR_SSL_SENDREC) == BR_SSL_SENDREC) { - buffer = br_ssl_engine_sendrec_buf(&fd->sc.eng, &length); - - if (length > 0) { - if ((rc = fd->low_write(&fd->fd, buffer, length)) < 0) { - return MQTT_ERROR_SOCKET_ERROR; - } - - br_ssl_engine_sendrec_ack(&fd->sc.eng, rc); - } - } - else if ((status & BR_SSL_RECVREC) == BR_SSL_RECVREC) { - buffer = br_ssl_engine_recvrec_buf(&fd->sc.eng, &length); - - if (length > 0) { - if ((rc = fd->low_read(&fd->fd, buffer, length)) < 0) { - return MQTT_ERROR_SOCKET_ERROR; - } - - br_ssl_engine_recvrec_ack(&fd->sc.eng, rc); - } - } - else if ((status && BR_SSL_CLOSED) == BR_SSL_CLOSED) { - return MQTT_ERROR_SOCKET_ERROR; - } - - return MQTT_OK; -} - -ssize_t mqtt_pal_sendall(mqtt_pal_socket_handle fd, const void* buf, size_t len, int flags) { - int rc = MQTT_OK; - uint8_t *buffer; - size_t length; - size_t remaining_bytes = len; - const uint8_t *walker = buf; - unsigned int status; - - while (remaining_bytes > 0) { - - if (rc == MQTT_ERROR_SOCKET_ERROR) { - return rc; - } - - status = br_ssl_engine_current_state(&fd->sc.eng); - - if ((status & BR_SSL_CLOSED) != 0) { - return MQTT_ERROR_SOCKET_ERROR; - } - - if ((status & (BR_SSL_RECVREC | BR_SSL_SENDREC)) != 0) { - rc = do_rec_data(fd, status); - - if (rc != MQTT_OK) { - return rc; - } - status = br_ssl_engine_current_state(&fd->sc.eng); - } - - if ((status & BR_SSL_SENDAPP) == BR_SSL_SENDAPP) { - buffer = br_ssl_engine_sendapp_buf(&fd->sc.eng, &length); - - if (length > 0) { - size_t write = length >= remaining_bytes? remaining_bytes : length; - memcpy(buffer, walker, write); - remaining_bytes -= write; - walker += write; - br_ssl_engine_sendapp_ack(&fd->sc.eng, write); - br_ssl_engine_flush(&fd->sc.eng, 0); - } - } - } - - return len; -} - -ssize_t mqtt_pal_recvall(mqtt_pal_socket_handle fd, void* buf, size_t bufsz, int flags) { - int rc = MQTT_OK; - uint8_t *buffer; - size_t length; - size_t remaining_bytes = bufsz; - uint8_t *walker = buf; - unsigned int status; - - if (rc == MQTT_ERROR_SOCKET_ERROR) { - return rc; - } - - status = br_ssl_engine_current_state(&fd->sc.eng); - - if ((status & (BR_SSL_RECVREC | BR_SSL_SENDREC)) != 0) { - rc = do_rec_data(fd, status); - - if (rc != MQTT_OK) { - return rc; - } - status = br_ssl_engine_current_state(&fd->sc.eng); - } - - if ((status & BR_SSL_RECVAPP) == BR_SSL_RECVAPP) { - buffer = br_ssl_engine_recvapp_buf(&fd->sc.eng, &length); - - if (length > 0) { - size_t write = length >= remaining_bytes? remaining_bytes : length; - memcpy(walker, buffer, write); - remaining_bytes -= write; - walker += write; - br_ssl_engine_recvapp_ack(&fd->sc.eng, write); - } - } - - return bufsz - remaining_bytes; -} - -#elif defined(MQTT_USE_BIO) -#include -#include -#include - -ssize_t mqtt_pal_sendall(mqtt_pal_socket_handle fd, const void* buf, size_t len, int flags) { - size_t sent = 0; - while(sent < len) { - int tmp = BIO_write(fd, (const char*)buf + sent, (int)(len - sent)); - if (tmp > 0) { - sent += (size_t) tmp; - } else if (tmp <= 0 && !BIO_should_retry(fd)) { - return MQTT_ERROR_SOCKET_ERROR; - } - } - - return (ssize_t)sent; -} - -ssize_t mqtt_pal_recvall(mqtt_pal_socket_handle fd, void* buf, size_t bufsz, int flags) { - const char* const start = (const char*)buf; - char* bufptr = (char*)buf; - int rv; - do { - rv = BIO_read(fd, bufptr, (int)bufsz); - if (rv > 0) { - /* successfully read bytes from the socket */ - bufptr += rv; - bufsz -= (unsigned long)rv; - } else if (!BIO_should_retry(fd)) { - /* an error occurred that wasn't "nothing to read". */ - return MQTT_ERROR_SOCKET_ERROR; - } - } while (!BIO_should_read(fd) && bufsz > 0); - - return (ssize_t)(bufptr - start); -} - -#elif defined(__unix__) || defined(__APPLE__) || defined(__NuttX__) - -#include - -ssize_t mqtt_pal_sendall(mqtt_pal_socket_handle fd, const void* buf, size_t len, int flags) { - enum MQTTErrors error = 0; - size_t sent = 0; - while(sent < len) { - ssize_t rv = send(fd, (const char*)buf + sent, len - sent, flags); - if (rv < 0) { - if (errno == EAGAIN) { - /* should call send later again */ - break; - } - error = MQTT_ERROR_SOCKET_ERROR; - break; - } - if (rv == 0) { - /* is this possible? maybe OS bug. */ - error = MQTT_ERROR_SOCKET_ERROR; - break; - } - sent += (size_t) rv; - } - if (sent == 0) { - return error; - } - return (ssize_t)sent; -} - -ssize_t mqtt_pal_recvall(mqtt_pal_socket_handle fd, void* buf, size_t bufsz, int flags) { - const void *const start = buf; - enum MQTTErrors error = 0; - ssize_t rv; - do { - rv = recv(fd, buf, bufsz, flags); - if (rv == 0) { - /* - * recv returns 0 when the socket is (half) closed by the peer. - * - * Raise an error to trigger a reconnect. - */ - error = MQTT_ERROR_SOCKET_ERROR; - break; - } - if (rv < 0) { - if (errno == EAGAIN || errno == EWOULDBLOCK) { - /* should call recv later again */ - break; - } - /* an error occurred that wasn't "nothing to read". */ - error = MQTT_ERROR_SOCKET_ERROR; - break; - } - buf = (char*)buf + rv; - bufsz -= (unsigned long)rv; - } while (bufsz > 0); - if (buf == start) { - return error; - } - return (char*)buf - (const char*)start; -} - -#elif defined(_MSC_VER) || defined(WIN32) - -#include - -ssize_t mqtt_pal_sendall(mqtt_pal_socket_handle fd, const void* buf, size_t len, int flags) { - size_t sent = 0; - while(sent < len) { - ssize_t tmp = send(fd, (char*)buf + sent, len - sent, flags); - if (tmp < 1) { - return MQTT_ERROR_SOCKET_ERROR; - } - sent += (size_t) tmp; - } - return sent; -} - -ssize_t mqtt_pal_recvall(mqtt_pal_socket_handle fd, void* buf, size_t bufsz, int flags) { - const char *const start = buf; - ssize_t rv; - do { - rv = recv(fd, buf, bufsz, flags); - if (rv > 0) { - /* successfully read bytes from the socket */ - buf = (char*)buf + rv; - bufsz -= rv; - } else if (rv < 0) { - int err = WSAGetLastError(); - if (err != WSAEWOULDBLOCK) { - /* an error occurred that wasn't "nothing to read". */ - return MQTT_ERROR_SOCKET_ERROR; - } - } - } while (rv > 0 && bufsz > 0); - - return (ssize_t)((char*)buf - start); -} - -#else - -#error No PAL! - -#endif - -#endif /* defined(MQTT_USE_CUSTOM_SOCKET_HANDLE) */ - -/** @endcond */ diff --git a/Platformio/hardware/windows_linux/lvgl_hal_windows_linux.cpp b/Platformio/hardware/windows_linux/lvgl_hal_windows_linux.cpp deleted file mode 100644 index fae385ae..00000000 --- a/Platformio/hardware/windows_linux/lvgl_hal_windows_linux.cpp +++ /dev/null @@ -1,109 +0,0 @@ -#include -#include -#include -#include -#include "sdl/sdl.h" -#include "SDL2/SDL_events.h" - -long long current_timestamp_hal_windowsLinux() { - struct timeval te; - gettimeofday(&te, NULL); // get current time - long long milliseconds = te.tv_sec*1000LL + te.tv_usec/1000; // calculate milliseconds - // printf("milliseconds: %lld\r\n", milliseconds); - return milliseconds; -} -/** - * A task to measure the elapsed time for LittlevGL - * @param data unused - * @return never return - */ -static int tick_thread(void * data) -{ - (void)data; - - long long lastTimestamp = current_timestamp_hal_windowsLinux(); - long long newTimestamp = 0; - while(1) { - // we don't use this blackbox - // SDL_Delay(5); /*Sleep for 5 millisecond*/ - // lv_tick_inc(5); /*Tell lvgl that 5 milliseconds were elapsed*/ - - newTimestamp = current_timestamp_hal_windowsLinux(); - if ((newTimestamp - lastTimestamp) > 5) { - lv_tick_inc(newTimestamp - lastTimestamp); - lastTimestamp = newTimestamp; - } - } - - return 0; -} - -static lv_disp_draw_buf_t draw_buf; - -void init_lvgl_HAL() { - // Workaround for sdl2 `-m32` crash - // https://bugs.launchpad.net/ubuntu/+source/libsdl2/+bug/1775067/comments/7 - #ifndef WIN32 - setenv("DBUS_FATAL_WARNINGS", "0", 1); - #endif - - #ifdef useTwoBuffersForlvgl - lv_color_t * bufA = (lv_color_t *) malloc(sizeof(lv_color_t) * SDL_HOR_RES * SDL_VER_RES / 10); - lv_color_t * bufB = (lv_color_t *) malloc(sizeof(lv_color_t) * SDL_HOR_RES * SDL_VER_RES / 10); - lv_disp_draw_buf_init(&draw_buf, bufA, bufB, SDL_HOR_RES * SDL_VER_RES / 10); - #else - lv_color_t * bufA = (lv_color_t *) malloc(sizeof(lv_color_t) * SDL_HOR_RES * SDL_VER_RES / 10); - lv_disp_draw_buf_init(&draw_buf, bufA, NULL, SDL_HOR_RES * SDL_VER_RES / 10); - #endif - - // Initialize the display driver -------------------------------------------------------------------------- - static lv_disp_drv_t disp_drv; - lv_disp_drv_init( &disp_drv ); - disp_drv.hor_res = SDL_HOR_RES; - disp_drv.ver_res = SDL_VER_RES; - disp_drv.flush_cb = sdl_display_flush; /*Used when `LV_VDB_SIZE != 0` in lv_conf.h (buffered drawing)*/ - disp_drv.draw_buf = &draw_buf; - //disp_drv.disp_fill = monitor_fill; /*Used when `LV_VDB_SIZE == 0` in lv_conf.h (unbuffered drawing)*/ - //disp_drv.disp_map = monitor_map; /*Used when `LV_VDB_SIZE == 0` in lv_conf.h (unbuffered drawing)*/ - lv_disp_drv_register( &disp_drv ); - - /* Add the mouse as input device - * Use the 'mouse' driver which reads the PC's mouse*/ - static lv_indev_drv_t indev_drv_mouse; - lv_indev_drv_init( &indev_drv_mouse ); - indev_drv_mouse.type = LV_INDEV_TYPE_POINTER; - indev_drv_mouse.read_cb = sdl_mouse_read; /*This function will be called periodically (by the library) to get the mouse position and state*/ - lv_indev_drv_register( &indev_drv_mouse ); - - // /* Add the keyboard as input device - // * did not work */ - // static lv_indev_drv_t indev_drv_keyboard; - // lv_indev_drv_init( &indev_drv_keyboard ); - // indev_drv_keyboard.type = LV_INDEV_TYPE_KEYPAD; - // indev_drv_keyboard.read_cb = sdl_keyboard_read; /*This function will be called periodically (by the library) to get the keyboard events*/ - // lv_indev_t *keyboard_device = lv_indev_drv_register( &indev_drv_keyboard ); - // lv_group_t *group = lv_group_create(); - // lv_indev_set_group(keyboard_device, group); - // lv_group_add_obj(group, lv_scr_act()); - // lv_group_add_obj(group, tabview); - // lv_group_add_obj(group, lv_tabview_get_content(tabview)); - // lv_group_add_obj(group, tabs); - // - // need to be in a loop - // printf("last key: %d\n",lv_indev_get_key(keyboard_device)); - - sdl_init(); - - // Get the SDL window via an event - SDL_Event aWindowIdFinder; - SDL_PollEvent(&aWindowIdFinder); - SDL_Window *mSimWindow = SDL_GetWindowFromID(aWindowIdFinder.window.windowID); - - SDL_SetWindowTitle(mSimWindow, "OMOTE simulator"); - - /* Tick init. - * You have to call 'lv_tick_inc()' in periodically to inform lvgl about how much time were elapsed - * Create an SDL thread to do this*/ - SDL_CreateThread(tick_thread, "tick", NULL); - -} diff --git a/Platformio/hardware/windows_linux/lvgl_hal_windows_linux.h b/Platformio/hardware/windows_linux/lvgl_hal_windows_linux.h deleted file mode 100644 index 54ba69a1..00000000 --- a/Platformio/hardware/windows_linux/lvgl_hal_windows_linux.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -void init_lvgl_HAL(); diff --git a/Platformio/hardware/windows_linux/mqtt_hal_windows_linux.cpp b/Platformio/hardware/windows_linux/mqtt_hal_windows_linux.cpp deleted file mode 100644 index cfed6be1..00000000 --- a/Platformio/hardware/windows_linux/mqtt_hal_windows_linux.cpp +++ /dev/null @@ -1,198 +0,0 @@ -#include -#include "mqtt_hal_windows_linux.h" -#include "secrets.h" - -#if (ENABLE_WIFI_AND_MQTT == 1) -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// example is mainly taken from .pio/libdeps/windows_linux_64bit/MQTT-C/tests.c, TEST__api__publish_subscribe__single -#if !defined(WIN32) -#include -#include -#include -#include -#include -#include -#else -#include - -/* Some shortcuts to call winapi in a posix-like way */ -#define close(sock) closesocket(sock) -#define usleep(usec) Sleep((usec) / 1000) -#endif - -#include "lib/MQTT-C/include/mqtt.h" -#include "lib/MQTT-C/include/posix_sockets.h" - -int sockfd = -1; -uint8_t sendmem1[1024], sendmem2[1024]; -uint8_t recvmem1[1024], recvmem2[1024]; -struct mqtt_client mqttClient; -std::string uniqueClientSuffix = ""; -int state = 0; - -tAnnounceWiFiconnected_cb thisAnnounceWiFiconnected_cb = NULL; -void set_announceWiFiconnected_cb_HAL(tAnnounceWiFiconnected_cb pAnnounceWiFiconnected_cb) { - thisAnnounceWiFiconnected_cb = pAnnounceWiFiconnected_cb; -} - -tAnnounceSubscribedTopics_cb thisAnnounceSubscribedTopics_cb = NULL; -void set_announceSubscribedTopics_cb_HAL(tAnnounceSubscribedTopics_cb pAnnounceSubscribedTopics_cb) { - thisAnnounceSubscribedTopics_cb = pAnnounceSubscribedTopics_cb; -} - -bool getIsWifiConnected_HAL() { - return (sockfd != -1); -} - -void publish_callback(void** state, struct mqtt_response_publish *publish) { - **(int**)state += 1; - printf("message nr %d received\r\n", **(int**)state); - - std::string topic((const char*) (publish->topic_name), publish->topic_name_size); - std::string payload((const char*) (publish->application_message), publish->application_message_size); - - printf("Received a PUBLISH(topic=%s, DUP=%d, QOS=%d, RETAIN=%d, pid=%d) from the broker. Data='%s'\r\n", - topic.c_str(), publish->dup_flag, publish->qos_level, publish->retain_flag, publish->packet_id, - payload.c_str() - ); - - thisAnnounceSubscribedTopics_cb(topic, payload); -} - -void mqtt_subscribeTopics() { - mqtt_subscribe(&mqttClient, "OMOTE/test", 2); - -} - -void reconnect_mqtt(struct mqtt_client *mqttClient, void**) { - printf("MQTT: will reconnect ...\r\n"); - - mqtt_reinit(mqttClient, sockfd, sendmem1, sizeof(sendmem1), recvmem1, sizeof(recvmem1)); - - std::string mqttClientName = std::string(MQTT_CLIENTNAME) + uniqueClientSuffix; - // client_id, will_topic, will_message, will_message_size, user_name, password, connect_flags, keep_alive - mqtt_connect(mqttClient, mqttClientName.c_str(), NULL, NULL, 0, MQTT_USER, MQTT_PASS, 0, 30); - if (mqttClient->error != MQTT_OK) { - printf("MQTT: connect error: %s\r\n", mqtt_error_str(mqttClient->error)); - // sockfd = -1; - // return; - } -} - -#if !defined(WIN32) -std::string getMACaddress() { - struct ifreq s; - int fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP); - - strcpy(s.ifr_name, "eth0"); - if (0 == ioctl(fd, SIOCGIFHWADDR, &s)) { - char buffer[6*3]; - int i; - for (i = 0; i < 6; ++i) { - sprintf(&buffer[i*3], "%02x:", (unsigned char) s.ifr_addr.sa_data[i]); - // printf(" %02x", (unsigned char) s.ifr_addr.sa_data[i]); - } - //printf("\r\n"); - - std::string MACaddress = std::string(buffer, 17); - printf(" result in MACaddress(): %s\r\n", MACaddress.c_str()); - return MACaddress; - } - return ""; -} -#endif - -void init_mqtt_HAL(void) { - #if defined(WIN32) - WSADATA wsaData; - int iResult = WSAStartup(MAKEWORD(2, 2), &wsaData); - if (iResult != NO_ERROR) { - printf("Failed to init sockets: %i\r\n", iResult); - return; // return iResult; - } - #endif - - char MACaddress[6*3]; - sockfd = open_nb_socket(MQTT_SERVER, std::to_string(MQTT_SERVER_PORT).c_str(), MACaddress); - if (sockfd == -1) { - printf("MQTT: Failed to open socket\r\n"); - return; - } - - #if !defined(WIN32) - // MAC address is not the best. You cannot start more than one instance like that, otherwise the MQTT broker will only keep the last connection. - // printf("MQTT: received MAC address from posix_sockets.h is %s\r\n", MACaddress); - // uniqueClientSuffix = std::string(MACaddress, 18); - // simply use a random number - srand(time(NULL)); // Initialization, should only be called once. - int r = rand(); // Returns a pseudo-random integer between 0 and RAND_MAX. - uniqueClientSuffix = "_linux_" + std::to_string(r); - #else - srand(time(NULL)); // Initialization, should only be called once. - int r = rand(); // Returns a pseudo-random integer between 0 and RAND_MAX. - uniqueClientSuffix = "_windows_" + std::to_string(r); - #endif - - // printf("MQTT: MAC address from getMACaddress() in mqtt_hal_windows_linux.cpp is %s\r\n", getMACaddress().c_str()); - - // printf("MQTT: will init ...\r\n"); - // mqtt_init(&mqttClient, sockfd, sendmem1, sizeof(sendmem1), recvmem1, sizeof(recvmem1), publish_callback); - printf("MQTT: will init with reconnect ...\r\n"); - mqtt_init_reconnect(&mqttClient, reconnect_mqtt, NULL, publish_callback); - reconnect_mqtt(&mqttClient, NULL); - mqttClient.publish_response_callback_state = &state; - - mqtt_subscribeTopics(); - - thisAnnounceWiFiconnected_cb(true); - -} - -void mqtt_loop_HAL() { - if (sockfd != -1) { - mqtt_sync(&mqttClient); - } - -} - -bool publishMQTTMessage_HAL(const char *topic, const char *payload) { - - if (sockfd == -1) { - init_mqtt_HAL(); - } - - mqtt_publish(&mqttClient, topic, payload, strlen(payload), MQTT_PUBLISH_QOS_0); - if (mqttClient.error != MQTT_OK) { - printf("MQTT: publish error %s\r\n", mqtt_error_str(mqttClient.error)); - sockfd = -1; - return false; - } - - return true; -} - -void wifiStop_HAL() { - /* disconnect */ - if (sockfd != -1) { - mqtt_disconnect(&mqttClient); - mqtt_sync(&mqttClient); - } - - #if defined(WIN32) - WSACleanup(); - #endif - -} - -#endif diff --git a/Platformio/hardware/windows_linux/mqtt_hal_windows_linux.h b/Platformio/hardware/windows_linux/mqtt_hal_windows_linux.h deleted file mode 100644 index 116ae601..00000000 --- a/Platformio/hardware/windows_linux/mqtt_hal_windows_linux.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#if (ENABLE_WIFI_AND_MQTT == 1) - -void init_mqtt_HAL(void); -bool getIsWifiConnected_HAL(); -void mqtt_loop_HAL(); -bool publishMQTTMessage_HAL(const char *topic, const char *payload); -void wifiStop_HAL(); - -typedef void (*tAnnounceWiFiconnected_cb)(bool connected); -void set_announceWiFiconnected_cb_HAL(tAnnounceWiFiconnected_cb pAnnounceWiFiconnected_cb); -typedef void (*tAnnounceSubscribedTopics_cb)(std::string topic, std::string payload); -void set_announceSubscribedTopics_cb_HAL(tAnnounceSubscribedTopics_cb pAnnounceSubscribedTopics_cb); - -#endif diff --git a/Platformio/hardware/windows_linux/preferencesStorage_hal_windows_linux.cpp b/Platformio/hardware/windows_linux/preferencesStorage_hal_windows_linux.cpp deleted file mode 100644 index bff2b611..00000000 --- a/Platformio/hardware/windows_linux/preferencesStorage_hal_windows_linux.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include - -enum GUIlists { -// MAIN_GUI_LIST: we are in the main_gui_list (with the scene selector as first gui), either if a scene is active or not -// SCENE_GUI_LIST: a scene is active and we are not in the main_gui_list. In that case, we try to use the scene specific gui list, if the scene defined one. - MAIN_GUI_LIST, - SCENE_GUI_LIST -}; - -/* -Possible example: -main_gui_list : "Scene selection", "Smart Home", "Settings", "IR Receiver"}; - -"Off" : -"TV" : "Numpad" -"Fire TV" : "Numpad", "Settings" -"Chromecast" : -"Apple TV" : "Apple TV", "Settings", "IR Receiver" -*/ -std::string activeScene; -std::string activeGUIname; -int activeGUIlist; -int lastActiveGUIlistIndex; - -void init_preferences_HAL(void) { - // set some values for tests - activeScene = ""; // "Off", "TV", "Fire TV", "Chromecast", "Apple TV"; - activeGUIname = "Scene selection"; // "Scene selection", "Smart Home", "Settings", "IR Receiver" // "Numpad", "Apple TV" - activeGUIlist = MAIN_GUI_LIST; // MAIN_GUI_LIST, SCENE_GUI_LIST; - lastActiveGUIlistIndex = 0; -} -void save_preferences_HAL(void) { -} - -std::string get_activeScene_HAL() { - return activeScene; -} -void set_activeScene_HAL(std::string anActiveScene) { - activeScene = anActiveScene; -} -std::string get_activeGUIname_HAL(){ - return activeGUIname; -} -void set_activeGUIname_HAL(std::string anActiveGUIname) { - activeGUIname = anActiveGUIname; -} -int get_activeGUIlist_HAL() { - return activeGUIlist; -} -void set_activeGUIlist_HAL(int anActiveGUIlist) { - activeGUIlist = anActiveGUIlist; -} -int get_lastActiveGUIlistIndex_HAL() { - return lastActiveGUIlistIndex; -} -void set_lastActiveGUIlistIndex_HAL(int aGUIlistIndex) { - lastActiveGUIlistIndex = aGUIlistIndex; -} diff --git a/Platformio/hardware/windows_linux/preferencesStorage_hal_windows_linux.h b/Platformio/hardware/windows_linux/preferencesStorage_hal_windows_linux.h deleted file mode 100644 index e223648a..00000000 --- a/Platformio/hardware/windows_linux/preferencesStorage_hal_windows_linux.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include - -void init_preferences_HAL(void); -void save_preferences_HAL(void); - -std::string get_activeScene_HAL(); -void set_activeScene_HAL(std::string anActiveScene); -std::string get_activeGUIname_HAL(); -void set_activeGUIname_HAL(std::string anActiveGUIname); -int get_activeGUIlist_HAL(); -void set_activeGUIlist_HAL(int anActiveGUIlist); -int get_lastActiveGUIlistIndex_HAL(); -void set_lastActiveGUIlistIndex_HAL(int aGUIlistIndex); diff --git a/Platformio/hardware/windows_linux/sleep_hal_windows_linux.cpp b/Platformio/hardware/windows_linux/sleep_hal_windows_linux.cpp deleted file mode 100644 index 8a88139c..00000000 --- a/Platformio/hardware/windows_linux/sleep_hal_windows_linux.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include - -// is "lift to wake" enabled -bool wakeupByIMUEnabled = true; -// timeout before going to sleep -uint32_t sleepTimeout; - -void init_sleep_HAL() {} -void init_IMU_HAL(void) {} -void check_activity_HAL() {} -void setLastActivityTimestamp_HAL() {} - -uint32_t get_sleepTimeout_HAL() { - return sleepTimeout; -} -void set_sleepTimeout_HAL(uint32_t aSleepTimeout) { - sleepTimeout = aSleepTimeout; - printf("sleep timeout set to %u ms\r\n", aSleepTimeout); -} -bool get_wakeupByIMUEnabled_HAL() { - return wakeupByIMUEnabled; -} -void set_wakeupByIMUEnabled_HAL(bool aWakeupByIMUEnabled) { - wakeupByIMUEnabled = aWakeupByIMUEnabled; - printf("lift to wake set to %d\r\n", aWakeupByIMUEnabled); -} diff --git a/Platformio/hardware/windows_linux/sleep_hal_windows_linux.h b/Platformio/hardware/windows_linux/sleep_hal_windows_linux.h deleted file mode 100644 index 8e431641..00000000 --- a/Platformio/hardware/windows_linux/sleep_hal_windows_linux.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -void init_sleep_HAL(); -void init_IMU_HAL(); -void check_activity_HAL(); -void setLastActivityTimestamp_HAL(); - -uint32_t get_sleepTimeout_HAL(); -void set_sleepTimeout_HAL(uint32_t aSleepTimeout); -bool get_wakeupByIMUEnabled_HAL(); -void set_wakeupByIMUEnabled_HAL(bool aWakeupByIMUEnabled); diff --git a/Platformio/hardware/windows_linux/tft_hal_windows_linux.cpp b/Platformio/hardware/windows_linux/tft_hal_windows_linux.cpp deleted file mode 100644 index 0b321862..00000000 --- a/Platformio/hardware/windows_linux/tft_hal_windows_linux.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include - -uint8_t backlightBrightness = 255; - -void update_backligthBrighness_HAL(void) { - // nothing to do, we don't want to dim the simulator - -}; -uint8_t get_backlightBrightness_HAL() { - return backlightBrightness; -}; -void set_backlightBrightness_HAL(uint8_t aBacklightBrightness) { - backlightBrightness = aBacklightBrightness; - printf("backlight brightness set to %u\r\n", aBacklightBrightness); -}; diff --git a/Platformio/hardware/windows_linux/tft_hal_windows_linux.h b/Platformio/hardware/windows_linux/tft_hal_windows_linux.h deleted file mode 100644 index 247b09b3..00000000 --- a/Platformio/hardware/windows_linux/tft_hal_windows_linux.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -void update_backligthBrighness_HAL(void); -uint8_t get_backlightBrightness_HAL(); -void set_backlightBrightness_HAL(uint8_t aBacklightBrightness); diff --git a/Platformio/hardware/windows_linux/user_led_hal_windows_linux.cpp b/Platformio/hardware/windows_linux/user_led_hal_windows_linux.cpp deleted file mode 100644 index 083bdef3..00000000 --- a/Platformio/hardware/windows_linux/user_led_hal_windows_linux.cpp +++ /dev/null @@ -1,2 +0,0 @@ -void init_userled_HAL(void) {}; -void update_userled_HAL(void) {}; diff --git a/Platformio/hardware/windows_linux/user_led_hal_windows_linux.h b/Platformio/hardware/windows_linux/user_led_hal_windows_linux.h deleted file mode 100644 index 5a41e793..00000000 --- a/Platformio/hardware/windows_linux/user_led_hal_windows_linux.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -void init_userled_HAL(void); -void update_userled_HAL(void); diff --git a/Platformio/include/README b/Platformio/include/README new file mode 100644 index 00000000..194dcd43 --- /dev/null +++ b/Platformio/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/Platformio/include/lv_conf.h b/Platformio/include/lv_conf.h new file mode 100644 index 00000000..bc4f44f3 --- /dev/null +++ b/Platformio/include/lv_conf.h @@ -0,0 +1,762 @@ +/** + * @file lv_conf.h + * Configuration file for v8.3.5 + */ + +/* + * Copy this file as `lv_conf.h` + * 1. simply next to the `lvgl` folder + * 2. or any other places and + * - define `LV_CONF_INCLUDE_SIMPLE` + * - add the path as include path + */ + +/* clang-format off */ +#if 1 /*Set it to "1" to enable content*/ + +#ifndef LV_CONF_H +#define LV_CONF_H + +#include + +/*==================== + COLOR SETTINGS + *====================*/ + +/*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/ +#define LV_COLOR_DEPTH 16 + +/*Swap the 2 bytes of RGB565 color. Useful if the display has an 8-bit interface (e.g. SPI)*/ +#define LV_COLOR_16_SWAP 0 + +/*Enable features to draw on transparent background. + *It's required if opa, and transform_* style properties are used. + *Can be also used if the UI is above another layer, e.g. an OSD menu or video player.*/ +#define LV_COLOR_SCREEN_TRANSP 0 + +/* Adjust color mix functions rounding. GPUs might calculate color mix (blending) differently. + * 0: round down, 64: round up from x.75, 128: round up from half, 192: round up from x.25, 254: round up */ +#define LV_COLOR_MIX_ROUND_OFS 0 + +/*Images pixels with this color will not be drawn if they are chroma keyed)*/ +#define LV_COLOR_CHROMA_KEY lv_color_hex(0x00ff00) /*pure green*/ + +/*========================= + MEMORY SETTINGS + *=========================*/ + +/*1: use custom malloc/free, 0: use the built-in `lv_mem_alloc()` and `lv_mem_free()`*/ +#define LV_MEM_CUSTOM 0 +#if LV_MEM_CUSTOM == 0 + /*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/ + #define LV_MEM_SIZE (32U * 1024U) /*[bytes]*/ + + /*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/ + #define LV_MEM_ADR 0 /*0: unused*/ + /*Instead of an address give a memory allocator that will be called to get a memory pool for LVGL. E.g. my_malloc*/ + #if LV_MEM_ADR == 0 + #undef LV_MEM_POOL_INCLUDE + #undef LV_MEM_POOL_ALLOC + #endif + +#else /*LV_MEM_CUSTOM*/ + #define LV_MEM_CUSTOM_INCLUDE /*Header for the dynamic memory function*/ + #define LV_MEM_CUSTOM_ALLOC malloc + #define LV_MEM_CUSTOM_FREE free + #define LV_MEM_CUSTOM_REALLOC realloc +#endif /*LV_MEM_CUSTOM*/ + +/*Number of the intermediate memory buffer used during rendering and other internal processing mechanisms. + *You will see an error log message if there wasn't enough buffers. */ +#define LV_MEM_BUF_MAX_NUM 16 + +/*Use the standard `memcpy` and `memset` instead of LVGL's own functions. (Might or might not be faster).*/ +#define LV_MEMCPY_MEMSET_STD 0 + +/*==================== + HAL SETTINGS + *====================*/ + +/*Default display refresh period. LVG will redraw changed areas with this period time*/ +#define LV_DISP_DEF_REFR_PERIOD 30 /*[ms]*/ + +/*Input device read period in milliseconds*/ +#define LV_INDEV_DEF_READ_PERIOD 30 /*[ms]*/ + +/*Use a custom tick source that tells the elapsed time in milliseconds. + *It removes the need to manually update the tick with `lv_tick_inc()`)*/ +#define LV_TICK_CUSTOM 1 +#if LV_TICK_CUSTOM + #define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/ + #define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/ + /*If using lvgl as ESP32 component*/ + // #define LV_TICK_CUSTOM_INCLUDE "esp_timer.h" + // #define LV_TICK_CUSTOM_SYS_TIME_EXPR ((esp_timer_get_time() / 1000LL)) +#endif /*LV_TICK_CUSTOM*/ + +/*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings. + *(Not so important, you can adjust it to modify default sizes and spaces)*/ +#define LV_DPI_DEF 130 /*[px/inch]*/ + +/*======================= + * FEATURE CONFIGURATION + *=======================*/ + +/*------------- + * Drawing + *-----------*/ + +/*Enable complex draw engine. + *Required to draw shadow, gradient, rounded corners, circles, arc, skew lines, image transformations or any masks*/ +#define LV_DRAW_COMPLEX 1 +#if LV_DRAW_COMPLEX != 0 + + /*Allow buffering some shadow calculation. + *LV_SHADOW_CACHE_SIZE is the max. shadow size to buffer, where shadow size is `shadow_width + radius` + *Caching has LV_SHADOW_CACHE_SIZE^2 RAM cost*/ + #define LV_SHADOW_CACHE_SIZE 0 + + /* Set number of maximally cached circle data. + * The circumference of 1/4 circle are saved for anti-aliasing + * radius * 4 bytes are used per circle (the most often used radiuses are saved) + * 0: to disable caching */ + #define LV_CIRCLE_CACHE_SIZE 4 +#endif /*LV_DRAW_COMPLEX*/ + +/** + * "Simple layers" are used when a widget has `style_opa < 255` to buffer the widget into a layer + * and blend it as an image with the given opacity. + * Note that `bg_opa`, `text_opa` etc don't require buffering into layer) + * The widget can be buffered in smaller chunks to avoid using large buffers. + * + * - LV_LAYER_SIMPLE_BUF_SIZE: [bytes] the optimal target buffer size. LVGL will try to allocate it + * - LV_LAYER_SIMPLE_FALLBACK_BUF_SIZE: [bytes] used if `LV_LAYER_SIMPLE_BUF_SIZE` couldn't be allocated. + * + * Both buffer sizes are in bytes. + * "Transformed layers" (where transform_angle/zoom properties are used) use larger buffers + * and can't be drawn in chunks. So these settings affects only widgets with opacity. + */ +#define LV_LAYER_SIMPLE_BUF_SIZE (24 * 1024) +#define LV_LAYER_SIMPLE_FALLBACK_BUF_SIZE (3 * 1024) + +/*Default image cache size. Image caching keeps the images opened. + *If only the built-in image formats are used there is no real advantage of caching. (I.e. if no new image decoder is added) + *With complex image decoders (e.g. PNG or JPG) caching can save the continuous open/decode of images. + *However the opened images might consume additional RAM. + *0: to disable caching*/ +#define LV_IMG_CACHE_DEF_SIZE 0 + +/*Number of stops allowed per gradient. Increase this to allow more stops. + *This adds (sizeof(lv_color_t) + 1) bytes per additional stop*/ +#define LV_GRADIENT_MAX_STOPS 2 + +/*Default gradient buffer size. + *When LVGL calculates the gradient "maps" it can save them into a cache to avoid calculating them again. + *LV_GRAD_CACHE_DEF_SIZE sets the size of this cache in bytes. + *If the cache is too small the map will be allocated only while it's required for the drawing. + *0 mean no caching.*/ +#define LV_GRAD_CACHE_DEF_SIZE 0 + +/*Allow dithering the gradients (to achieve visual smooth color gradients on limited color depth display) + *LV_DITHER_GRADIENT implies allocating one or two more lines of the object's rendering surface + *The increase in memory consumption is (32 bits * object width) plus 24 bits * object width if using error diffusion */ +#define LV_DITHER_GRADIENT 0 +#if LV_DITHER_GRADIENT + /*Add support for error diffusion dithering. + *Error diffusion dithering gets a much better visual result, but implies more CPU consumption and memory when drawing. + *The increase in memory consumption is (24 bits * object's width)*/ + #define LV_DITHER_ERROR_DIFFUSION 0 +#endif + +/*Maximum buffer size to allocate for rotation. + *Only used if software rotation is enabled in the display driver.*/ +#define LV_DISP_ROT_MAX_BUF (10*1024) + +/*------------- + * GPU + *-----------*/ + +/*Use Arm's 2D acceleration library Arm-2D */ +#define LV_USE_GPU_ARM2D 0 + +/*Use STM32's DMA2D (aka Chrom Art) GPU*/ +#define LV_USE_GPU_STM32_DMA2D 0 +#if LV_USE_GPU_STM32_DMA2D + /*Must be defined to include path of CMSIS header of target processor + e.g. "stm32f769xx.h" or "stm32f429xx.h"*/ + #define LV_GPU_DMA2D_CMSIS_INCLUDE +#endif + +/*Use SWM341's DMA2D GPU*/ +#define LV_USE_GPU_SWM341_DMA2D 0 +#if LV_USE_GPU_SWM341_DMA2D + #define LV_GPU_SWM341_DMA2D_INCLUDE "SWM341.h" +#endif + +/*Use NXP's PXP GPU iMX RTxxx platforms*/ +#define LV_USE_GPU_NXP_PXP 0 +#if LV_USE_GPU_NXP_PXP + /*1: Add default bare metal and FreeRTOS interrupt handling routines for PXP (lv_gpu_nxp_pxp_osa.c) + * and call lv_gpu_nxp_pxp_init() automatically during lv_init(). Note that symbol SDK_OS_FREE_RTOS + * has to be defined in order to use FreeRTOS OSA, otherwise bare-metal implementation is selected. + *0: lv_gpu_nxp_pxp_init() has to be called manually before lv_init() + */ + #define LV_USE_GPU_NXP_PXP_AUTO_INIT 0 +#endif + +/*Use NXP's VG-Lite GPU iMX RTxxx platforms*/ +#define LV_USE_GPU_NXP_VG_LITE 0 + +/*Use SDL renderer API*/ +#define LV_USE_GPU_SDL 0 +#if LV_USE_GPU_SDL + #define LV_GPU_SDL_INCLUDE_PATH + /*Texture cache size, 8MB by default*/ + #define LV_GPU_SDL_LRU_SIZE (1024 * 1024 * 8) + /*Custom blend mode for mask drawing, disable if you need to link with older SDL2 lib*/ + #define LV_GPU_SDL_CUSTOM_BLEND_MODE (SDL_VERSION_ATLEAST(2, 0, 6)) +#endif + +/*------------- + * Logging + *-----------*/ + +/*Enable the log module*/ +#define LV_USE_LOG 0 +#if LV_USE_LOG + + /*How important log should be added: + *LV_LOG_LEVEL_TRACE A lot of logs to give detailed information + *LV_LOG_LEVEL_INFO Log important events + *LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem + *LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail + *LV_LOG_LEVEL_USER Only logs added by the user + *LV_LOG_LEVEL_NONE Do not log anything*/ + #define LV_LOG_LEVEL LV_LOG_LEVEL_WARN + + /*1: Print the log with 'printf'; + *0: User need to register a callback with `lv_log_register_print_cb()`*/ + #define LV_LOG_PRINTF 0 + + /*Enable/disable LV_LOG_TRACE in modules that produces a huge number of logs*/ + #define LV_LOG_TRACE_MEM 1 + #define LV_LOG_TRACE_TIMER 1 + #define LV_LOG_TRACE_INDEV 1 + #define LV_LOG_TRACE_DISP_REFR 1 + #define LV_LOG_TRACE_EVENT 1 + #define LV_LOG_TRACE_OBJ_CREATE 1 + #define LV_LOG_TRACE_LAYOUT 1 + #define LV_LOG_TRACE_ANIM 1 + +#endif /*LV_USE_LOG*/ + +/*------------- + * Asserts + *-----------*/ + +/*Enable asserts if an operation is failed or an invalid data is found. + *If LV_USE_LOG is enabled an error message will be printed on failure*/ +#define LV_USE_ASSERT_NULL 1 /*Check if the parameter is NULL. (Very fast, recommended)*/ +#define LV_USE_ASSERT_MALLOC 1 /*Checks is the memory is successfully allocated or no. (Very fast, recommended)*/ +#define LV_USE_ASSERT_STYLE 0 /*Check if the styles are properly initialized. (Very fast, recommended)*/ +#define LV_USE_ASSERT_MEM_INTEGRITY 0 /*Check the integrity of `lv_mem` after critical operations. (Slow)*/ +#define LV_USE_ASSERT_OBJ 0 /*Check the object's type and existence (e.g. not deleted). (Slow)*/ + +/*Add a custom handler when assert happens e.g. to restart the MCU*/ +#define LV_ASSERT_HANDLER_INCLUDE +#define LV_ASSERT_HANDLER while(1); /*Halt by default*/ + +/*------------- + * Others + *-----------*/ + +/*1: Show CPU usage and FPS count*/ +#define LV_USE_PERF_MONITOR 0 +#if LV_USE_PERF_MONITOR + #define LV_USE_PERF_MONITOR_POS LV_ALIGN_BOTTOM_RIGHT +#endif + +/*1: Show the used memory and the memory fragmentation + * Requires LV_MEM_CUSTOM = 0*/ +#define LV_USE_MEM_MONITOR 0 +#if LV_USE_MEM_MONITOR + #define LV_USE_MEM_MONITOR_POS LV_ALIGN_BOTTOM_LEFT +#endif + +/*1: Draw random colored rectangles over the redrawn areas*/ +#define LV_USE_REFR_DEBUG 0 + +/*Change the built in (v)snprintf functions*/ +#define LV_SPRINTF_CUSTOM 0 +#if LV_SPRINTF_CUSTOM + #define LV_SPRINTF_INCLUDE + #define lv_snprintf snprintf + #define lv_vsnprintf vsnprintf +#else /*LV_SPRINTF_CUSTOM*/ + #define LV_SPRINTF_USE_FLOAT 0 +#endif /*LV_SPRINTF_CUSTOM*/ + +#define LV_USE_USER_DATA 1 + +/*Garbage Collector settings + *Used if lvgl is bound to higher level language and the memory is managed by that language*/ +#define LV_ENABLE_GC 0 +#if LV_ENABLE_GC != 0 + #define LV_GC_INCLUDE "gc.h" /*Include Garbage Collector related things*/ +#endif /*LV_ENABLE_GC*/ + +/*===================== + * COMPILER SETTINGS + *====================*/ + +/*For big endian systems set to 1*/ +#define LV_BIG_ENDIAN_SYSTEM 0 + +/*Define a custom attribute to `lv_tick_inc` function*/ +#define LV_ATTRIBUTE_TICK_INC + +/*Define a custom attribute to `lv_timer_handler` function*/ +#define LV_ATTRIBUTE_TIMER_HANDLER + +/*Define a custom attribute to `lv_disp_flush_ready` function*/ +#define LV_ATTRIBUTE_FLUSH_READY + +/*Required alignment size for buffers*/ +#define LV_ATTRIBUTE_MEM_ALIGN_SIZE 1 + +/*Will be added where memories needs to be aligned (with -Os data might not be aligned to boundary by default). + * E.g. __attribute__((aligned(4)))*/ +#define LV_ATTRIBUTE_MEM_ALIGN + +/*Attribute to mark large constant arrays for example font's bitmaps*/ +#define LV_ATTRIBUTE_LARGE_CONST + +/*Compiler prefix for a big array declaration in RAM*/ +#define LV_ATTRIBUTE_LARGE_RAM_ARRAY + +/*Place performance critical functions into a faster memory (e.g RAM)*/ +#define LV_ATTRIBUTE_FAST_MEM + +/*Prefix variables that are used in GPU accelerated operations, often these need to be placed in RAM sections that are DMA accessible*/ +#define LV_ATTRIBUTE_DMA + +/*Export integer constant to binding. This macro is used with constants in the form of LV_ that + *should also appear on LVGL binding API such as Micropython.*/ +#define LV_EXPORT_CONST_INT(int_value) struct _silence_gcc_warning /*The default value just prevents GCC warning*/ + +/*Extend the default -32k..32k coordinate range to -4M..4M by using int32_t for coordinates instead of int16_t*/ +#define LV_USE_LARGE_COORD 0 + +/*================== + * FONT USAGE + *===================*/ + +/*Montserrat fonts with ASCII range and some symbols using bpp = 4 + *https://fonts.google.com/specimen/Montserrat*/ +#define LV_FONT_MONTSERRAT_8 0 +#define LV_FONT_MONTSERRAT_10 0 +#define LV_FONT_MONTSERRAT_12 1 +#define LV_FONT_MONTSERRAT_14 1 +#define LV_FONT_MONTSERRAT_16 1 +#define LV_FONT_MONTSERRAT_18 0 +#define LV_FONT_MONTSERRAT_20 0 +#define LV_FONT_MONTSERRAT_22 0 +#define LV_FONT_MONTSERRAT_24 1 +#define LV_FONT_MONTSERRAT_26 0 +#define LV_FONT_MONTSERRAT_28 0 +#define LV_FONT_MONTSERRAT_30 0 +#define LV_FONT_MONTSERRAT_32 0 +#define LV_FONT_MONTSERRAT_34 0 +#define LV_FONT_MONTSERRAT_36 0 +#define LV_FONT_MONTSERRAT_38 0 +#define LV_FONT_MONTSERRAT_40 0 +#define LV_FONT_MONTSERRAT_42 0 +#define LV_FONT_MONTSERRAT_44 0 +#define LV_FONT_MONTSERRAT_46 0 +#define LV_FONT_MONTSERRAT_48 0 + +/*Demonstrate special features*/ +#define LV_FONT_MONTSERRAT_12_SUBPX 0 +#define LV_FONT_MONTSERRAT_28_COMPRESSED 0 /*bpp = 3*/ +#define LV_FONT_DEJAVU_16_PERSIAN_HEBREW 0 /*Hebrew, Arabic, Persian letters and all their forms*/ +#define LV_FONT_SIMSUN_16_CJK 0 /*1000 most common CJK radicals*/ + +/*Pixel perfect monospace fonts*/ +#define LV_FONT_UNSCII_8 0 +#define LV_FONT_UNSCII_16 0 + +/*Optionally declare custom fonts here. + *You can use these fonts as default font too and they will be available globally. + *E.g. #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) LV_FONT_DECLARE(my_font_2)*/ +#define LV_FONT_CUSTOM_DECLARE + +/*Always set a default font*/ +#define LV_FONT_DEFAULT &lv_font_montserrat_14 + +/*Enable handling large font and/or fonts with a lot of characters. + *The limit depends on the font size, font face and bpp. + *Compiler error will be triggered if a font needs it.*/ +#define LV_FONT_FMT_TXT_LARGE 0 + +/*Enables/disables support for compressed fonts.*/ +#define LV_USE_FONT_COMPRESSED 0 + +/*Enable subpixel rendering*/ +#define LV_USE_FONT_SUBPX 0 +#if LV_USE_FONT_SUBPX + /*Set the pixel order of the display. Physical order of RGB channels. Doesn't matter with "normal" fonts.*/ + #define LV_FONT_SUBPX_BGR 0 /*0: RGB; 1:BGR order*/ +#endif + +/*Enable drawing placeholders when glyph dsc is not found*/ +#define LV_USE_FONT_PLACEHOLDER 1 + +/*================= + * TEXT SETTINGS + *=================*/ + +/** + * Select a character encoding for strings. + * Your IDE or editor should have the same character encoding + * - LV_TXT_ENC_UTF8 + * - LV_TXT_ENC_ASCII + */ +#define LV_TXT_ENC LV_TXT_ENC_UTF8 + +/*Can break (wrap) texts on these chars*/ +#define LV_TXT_BREAK_CHARS " ,.;:-_" + +/*If a word is at least this long, will break wherever "prettiest" + *To disable, set to a value <= 0*/ +#define LV_TXT_LINE_BREAK_LONG_LEN 0 + +/*Minimum number of characters in a long word to put on a line before a break. + *Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/ +#define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3 + +/*Minimum number of characters in a long word to put on a line after a break. + *Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/ +#define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 3 + +/*The control character to use for signalling text recoloring.*/ +#define LV_TXT_COLOR_CMD "#" + +/*Support bidirectional texts. Allows mixing Left-to-Right and Right-to-Left texts. + *The direction will be processed according to the Unicode Bidirectional Algorithm: + *https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/ +#define LV_USE_BIDI 0 +#if LV_USE_BIDI + /*Set the default direction. Supported values: + *`LV_BASE_DIR_LTR` Left-to-Right + *`LV_BASE_DIR_RTL` Right-to-Left + *`LV_BASE_DIR_AUTO` detect texts base direction*/ + #define LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_AUTO +#endif + +/*Enable Arabic/Persian processing + *In these languages characters should be replaced with an other form based on their position in the text*/ +#define LV_USE_ARABIC_PERSIAN_CHARS 0 + +/*================== + * WIDGET USAGE + *================*/ + +/*Documentation of the widgets: https://docs.lvgl.io/latest/en/html/widgets/index.html*/ + +#define LV_USE_ARC 1 + +#define LV_USE_BAR 1 + +#define LV_USE_BTN 1 + +#define LV_USE_BTNMATRIX 1 + +#define LV_USE_CANVAS 1 + +#define LV_USE_CHECKBOX 1 + +#define LV_USE_DROPDOWN 1 /*Requires: lv_label*/ + +#define LV_USE_IMG 1 /*Requires: lv_label*/ + +#define LV_USE_LABEL 1 +#if LV_USE_LABEL + #define LV_LABEL_TEXT_SELECTION 1 /*Enable selecting text of the label*/ + #define LV_LABEL_LONG_TXT_HINT 1 /*Store some extra info in labels to speed up drawing of very long texts*/ +#endif + +#define LV_USE_LINE 1 + +#define LV_USE_ROLLER 1 /*Requires: lv_label*/ +#if LV_USE_ROLLER + #define LV_ROLLER_INF_PAGES 7 /*Number of extra "pages" when the roller is infinite*/ +#endif + +#define LV_USE_SLIDER 1 /*Requires: lv_bar*/ + +#define LV_USE_SWITCH 1 + +#define LV_USE_TEXTAREA 1 /*Requires: lv_label*/ +#if LV_USE_TEXTAREA != 0 + #define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500 /*ms*/ +#endif + +#define LV_USE_TABLE 1 + +/*================== + * EXTRA COMPONENTS + *==================*/ + +/*----------- + * Widgets + *----------*/ +#define LV_USE_ANIMIMG 1 + +#define LV_USE_CALENDAR 0 +#if LV_USE_CALENDAR + #define LV_CALENDAR_WEEK_STARTS_MONDAY 0 + #if LV_CALENDAR_WEEK_STARTS_MONDAY + #define LV_CALENDAR_DEFAULT_DAY_NAMES {"Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"} + #else + #define LV_CALENDAR_DEFAULT_DAY_NAMES {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"} + #endif + + #define LV_CALENDAR_DEFAULT_MONTH_NAMES {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"} + #define LV_USE_CALENDAR_HEADER_ARROW 1 + #define LV_USE_CALENDAR_HEADER_DROPDOWN 1 +#endif /*LV_USE_CALENDAR*/ + +#define LV_USE_CHART 1 + +#define LV_USE_COLORWHEEL 1 + +#define LV_USE_IMGBTN 0 + +#define LV_USE_KEYBOARD 1 + +#define LV_USE_LED 1 + +#define LV_USE_LIST 1 + +#define LV_USE_MENU 1 + +#define LV_USE_METER 1 + +#define LV_USE_MSGBOX 1 + +#define LV_USE_SPAN 1 +#if LV_USE_SPAN + /*A line text can contain maximum num of span descriptor */ + #define LV_SPAN_SNIPPET_STACK_SIZE 64 +#endif + +#define LV_USE_SPINBOX 1 + +#define LV_USE_SPINNER 1 + +#define LV_USE_TABVIEW 1 + +#define LV_USE_TILEVIEW 1 + +#define LV_USE_WIN 0 + +/*----------- + * Themes + *----------*/ + +/*A simple, impressive and very complete theme*/ +#define LV_USE_THEME_DEFAULT 1 +#if LV_USE_THEME_DEFAULT + + /*0: Light mode; 1: Dark mode*/ + #define LV_THEME_DEFAULT_DARK 1 + + /*1: Enable grow on press*/ + #define LV_THEME_DEFAULT_GROW 1 + + /*Default transition time in [ms]*/ + #define LV_THEME_DEFAULT_TRANSITION_TIME 80 +#endif /*LV_USE_THEME_DEFAULT*/ + +/*A very simple theme that is a good starting point for a custom theme*/ +#define LV_USE_THEME_BASIC 1 + +/*A theme designed for monochrome displays*/ +#define LV_USE_THEME_MONO 1 + +/*----------- + * Layouts + *----------*/ + +/*A layout similar to Flexbox in CSS.*/ +#define LV_USE_FLEX 1 + +/*A layout similar to Grid in CSS.*/ +#define LV_USE_GRID 1 + +/*--------------------- + * 3rd party libraries + *--------------------*/ + +/*File system interfaces for common APIs */ + +/*API for fopen, fread, etc*/ +#define LV_USE_FS_STDIO 0 +#if LV_USE_FS_STDIO + #define LV_FS_STDIO_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ + #define LV_FS_STDIO_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/ + #define LV_FS_STDIO_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ +#endif + +/*API for open, read, etc*/ +#define LV_USE_FS_POSIX 0 +#if LV_USE_FS_POSIX + #define LV_FS_POSIX_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ + #define LV_FS_POSIX_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/ + #define LV_FS_POSIX_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ +#endif + +/*API for CreateFile, ReadFile, etc*/ +#define LV_USE_FS_WIN32 0 +#if LV_USE_FS_WIN32 + #define LV_FS_WIN32_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ + #define LV_FS_WIN32_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/ + #define LV_FS_WIN32_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ +#endif + +/*API for FATFS (needs to be added separately). Uses f_open, f_read, etc*/ +#define LV_USE_FS_FATFS 0 +#if LV_USE_FS_FATFS + #define LV_FS_FATFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ + #define LV_FS_FATFS_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ +#endif + +/*PNG decoder library*/ +#define LV_USE_PNG 0 + +/*BMP decoder library*/ +#define LV_USE_BMP 0 + +/* JPG + split JPG decoder library. + * Split JPG is a custom format optimized for embedded systems. */ +#define LV_USE_SJPG 0 + +/*GIF decoder library*/ +#define LV_USE_GIF 0 + +/*QR code library*/ +#define LV_USE_QRCODE 0 + +/*FreeType library*/ +#define LV_USE_FREETYPE 0 +#if LV_USE_FREETYPE + /*Memory used by FreeType to cache characters [bytes] (-1: no caching)*/ + #define LV_FREETYPE_CACHE_SIZE (16 * 1024) + #if LV_FREETYPE_CACHE_SIZE >= 0 + /* 1: bitmap cache use the sbit cache, 0:bitmap cache use the image cache. */ + /* sbit cache:it is much more memory efficient for small bitmaps(font size < 256) */ + /* if font size >= 256, must be configured as image cache */ + #define LV_FREETYPE_SBIT_CACHE 0 + /* Maximum number of opened FT_Face/FT_Size objects managed by this cache instance. */ + /* (0:use system defaults) */ + #define LV_FREETYPE_CACHE_FT_FACES 0 + #define LV_FREETYPE_CACHE_FT_SIZES 0 + #endif +#endif + +/*Rlottie library*/ +#define LV_USE_RLOTTIE 0 + +/*FFmpeg library for image decoding and playing videos + *Supports all major image formats so do not enable other image decoder with it*/ +#define LV_USE_FFMPEG 0 +#if LV_USE_FFMPEG + /*Dump input information to stderr*/ + #define LV_FFMPEG_DUMP_FORMAT 0 +#endif + +/*----------- + * Others + *----------*/ + +/*1: Enable API to take snapshot for object*/ +#define LV_USE_SNAPSHOT 0 + +/*1: Enable Monkey test*/ +#define LV_USE_MONKEY 0 + +/*1: Enable grid navigation*/ +#define LV_USE_GRIDNAV 0 + +/*1: Enable lv_obj fragment*/ +#define LV_USE_FRAGMENT 0 + +/*1: Support using images as font in label or span widgets */ +#define LV_USE_IMGFONT 0 + +/*1: Enable a published subscriber based messaging system */ +#define LV_USE_MSG 0 + +/*1: Enable Pinyin input method*/ +/*Requires: lv_keyboard*/ +#define LV_USE_IME_PINYIN 0 +#if LV_USE_IME_PINYIN + /*1: Use default thesaurus*/ + /*If you do not use the default thesaurus, be sure to use `lv_ime_pinyin` after setting the thesauruss*/ + #define LV_IME_PINYIN_USE_DEFAULT_DICT 1 + /*Set the maximum number of candidate panels that can be displayed*/ + /*This needs to be adjusted according to the size of the screen*/ + #define LV_IME_PINYIN_CAND_TEXT_NUM 6 + + /*Use 9 key input(k9)*/ + #define LV_IME_PINYIN_USE_K9_MODE 1 + #if LV_IME_PINYIN_USE_K9_MODE == 1 + #define LV_IME_PINYIN_K9_CAND_TEXT_NUM 3 + #endif // LV_IME_PINYIN_USE_K9_MODE +#endif + +/*================== +* EXAMPLES +*==================*/ + +/*Enable the examples to be built with the library*/ +#define LV_BUILD_EXAMPLES 0 + +/*=================== + * DEMO USAGE + ====================*/ + +/*Show some widget. It might be required to increase `LV_MEM_SIZE` */ +#define LV_USE_DEMO_WIDGETS 0 +#if LV_USE_DEMO_WIDGETS +#define LV_DEMO_WIDGETS_SLIDESHOW 0 +#endif + +/*Demonstrate the usage of encoder and keyboard*/ +#define LV_USE_DEMO_KEYPAD_AND_ENCODER 0 + +/*Benchmark your system*/ +#define LV_USE_DEMO_BENCHMARK 0 +#if LV_USE_DEMO_BENCHMARK +/*Use RGB565A8 images with 16 bit color depth instead of ARGB8565*/ +#define LV_DEMO_BENCHMARK_RGB565A8 0 +#endif + +/*Stress test for LVGL*/ +#define LV_USE_DEMO_STRESS 0 + +/*Music player demo*/ +#define LV_USE_DEMO_MUSIC 0 +#if LV_USE_DEMO_MUSIC + #define LV_DEMO_MUSIC_SQUARE 0 + #define LV_DEMO_MUSIC_LANDSCAPE 0 + #define LV_DEMO_MUSIC_ROUND 0 + #define LV_DEMO_MUSIC_LARGE 0 + #define LV_DEMO_MUSIC_AUTO_PLAY 0 +#endif + +/*--END OF LV_CONF_H--*/ + +#endif /*LV_CONF_H*/ + +#endif /*End of "Content enable"*/ diff --git a/Platformio/hardware/ESP32/lib/Keypad/LICENSE b/Platformio/lib/Keypad/LICENSE similarity index 100% rename from Platformio/hardware/ESP32/lib/Keypad/LICENSE rename to Platformio/lib/Keypad/LICENSE diff --git a/Platformio/hardware/ESP32/lib/Keypad/README.md b/Platformio/lib/Keypad/README.md similarity index 100% rename from Platformio/hardware/ESP32/lib/Keypad/README.md rename to Platformio/lib/Keypad/README.md diff --git a/Platformio/hardware/ESP32/lib/Keypad/examples/CustomKeypad/CustomKeypad.ino b/Platformio/lib/Keypad/examples/CustomKeypad/CustomKeypad.ino similarity index 100% rename from Platformio/hardware/ESP32/lib/Keypad/examples/CustomKeypad/CustomKeypad.ino rename to Platformio/lib/Keypad/examples/CustomKeypad/CustomKeypad.ino diff --git a/Platformio/hardware/ESP32/lib/Keypad/examples/DynamicKeypad/DynamicKeypad.ino b/Platformio/lib/Keypad/examples/DynamicKeypad/DynamicKeypad.ino similarity index 100% rename from Platformio/hardware/ESP32/lib/Keypad/examples/DynamicKeypad/DynamicKeypad.ino rename to Platformio/lib/Keypad/examples/DynamicKeypad/DynamicKeypad.ino diff --git a/Platformio/hardware/ESP32/lib/Keypad/examples/EventKeypad/EventKeypad.ino b/Platformio/lib/Keypad/examples/EventKeypad/EventKeypad.ino similarity index 100% rename from Platformio/hardware/ESP32/lib/Keypad/examples/EventKeypad/EventKeypad.ino rename to Platformio/lib/Keypad/examples/EventKeypad/EventKeypad.ino diff --git a/Platformio/hardware/ESP32/lib/Keypad/examples/HelloKeypad/HelloKeypad.ino b/Platformio/lib/Keypad/examples/HelloKeypad/HelloKeypad.ino similarity index 100% rename from Platformio/hardware/ESP32/lib/Keypad/examples/HelloKeypad/HelloKeypad.ino rename to Platformio/lib/Keypad/examples/HelloKeypad/HelloKeypad.ino diff --git a/Platformio/hardware/ESP32/lib/Keypad/examples/HelloKeypad3/HelloKeypad3.ino b/Platformio/lib/Keypad/examples/HelloKeypad3/HelloKeypad3.ino similarity index 100% rename from Platformio/hardware/ESP32/lib/Keypad/examples/HelloKeypad3/HelloKeypad3.ino rename to Platformio/lib/Keypad/examples/HelloKeypad3/HelloKeypad3.ino diff --git a/Platformio/hardware/ESP32/lib/Keypad/examples/MultiKey/MultiKey.ino b/Platformio/lib/Keypad/examples/MultiKey/MultiKey.ino similarity index 100% rename from Platformio/hardware/ESP32/lib/Keypad/examples/MultiKey/MultiKey.ino rename to Platformio/lib/Keypad/examples/MultiKey/MultiKey.ino diff --git a/Platformio/hardware/ESP32/lib/Keypad/examples/loopCounter/loopCounter.ino b/Platformio/lib/Keypad/examples/loopCounter/loopCounter.ino similarity index 93% rename from Platformio/hardware/ESP32/lib/Keypad/examples/loopCounter/loopCounter.ino rename to Platformio/lib/Keypad/examples/loopCounter/loopCounter.ino index b0470e72..695e4897 100644 --- a/Platformio/hardware/ESP32/lib/Keypad/examples/loopCounter/loopCounter.ino +++ b/Platformio/lib/Keypad/examples/loopCounter/loopCounter.ino @@ -15,7 +15,7 @@ byte colPins[COLS] = {8, 7, 6}; //connect to the column pinouts of the keypad Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS ); unsigned long loopCount = 0; -unsigned long timer_ms = 0; +unsigned long timer_t = 0; void setup(){ Serial.begin(9600); @@ -33,12 +33,12 @@ void loop(){ // you a relative idea of just how much the debounceTime has changed the // speed of your code. If you set a high debounceTime your loopCount will // look good but your keypresses will start to feel sluggish. - if ((millis() - timer_ms) > 1000) { + if ((millis() - timer_t) > 1000) { Serial.print("Your loop code ran "); Serial.print(loopCount); Serial.println(" times over the last second"); loopCount = 0; - timer_ms = millis(); + timer_t = millis(); } loopCount++; if(key) diff --git a/Platformio/hardware/ESP32/lib/Keypad/keywords.txt b/Platformio/lib/Keypad/keywords.txt similarity index 100% rename from Platformio/hardware/ESP32/lib/Keypad/keywords.txt rename to Platformio/lib/Keypad/keywords.txt diff --git a/Platformio/hardware/ESP32/lib/Keypad/library.properties b/Platformio/lib/Keypad/library.properties similarity index 100% rename from Platformio/hardware/ESP32/lib/Keypad/library.properties rename to Platformio/lib/Keypad/library.properties diff --git a/Platformio/hardware/ESP32/lib/Keypad/src/Key.cpp b/Platformio/lib/Keypad/src/Key.cpp similarity index 100% rename from Platformio/hardware/ESP32/lib/Keypad/src/Key.cpp rename to Platformio/lib/Keypad/src/Key.cpp diff --git a/Platformio/hardware/ESP32/lib/Keypad/src/Key.h b/Platformio/lib/Keypad/src/Key.h similarity index 100% rename from Platformio/hardware/ESP32/lib/Keypad/src/Key.h rename to Platformio/lib/Keypad/src/Key.h diff --git a/Platformio/hardware/ESP32/lib/Keypad/src/Keypad.cpp b/Platformio/lib/Keypad/src/Keypad.cpp similarity index 93% rename from Platformio/hardware/ESP32/lib/Keypad/src/Keypad.cpp rename to Platformio/lib/Keypad/src/Keypad.cpp index c4d8cfc3..96f9cbcb 100644 --- a/Platformio/hardware/ESP32/lib/Keypad/src/Keypad.cpp +++ b/Platformio/lib/Keypad/src/Keypad.cpp @@ -83,31 +83,18 @@ bool Keypad::getKeys() { void Keypad::scanKeys() { // Re-intialize the row pins. Allows sharing these pins with other hardware. for (byte r=0; r THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/Platformio/platformio.ini b/Platformio/platformio.ini index c02e86bf..965a35d0 100644 --- a/Platformio/platformio.ini +++ b/Platformio/platformio.ini @@ -8,76 +8,6 @@ ; Please visit documentation for the other options and examples ; https://docs.platformio.org/page/projectconf.html -[platformio] -default_envs = esp32 - -[env] -;-- platformio.ini custom options, reused by TFT_eSPI, SDL2 and in OMOTE code - -custom_screen_width = 240 -custom_screen_heigth = 320 -lib_deps = - lvgl/lvgl@^8.3.11 -build_flags = - ;-- OMOTE ----------------------------------------------------------------- - -D ENABLE_WIFI_AND_MQTT=1 - -D ENABLE_KEYBOARD_MQTT=0 - -D ENABLE_BLUETOOTH=1 - -D ENABLE_KEYBOARD_BLE=1 - -D USE_SCENE_SPECIFIC_GUI_LIST=1 - -D SCR_WIDTH=${env.custom_screen_width} - -D SCR_HEIGHT=${env.custom_screen_heigth} - ;-D OMOTE_LOG_LEVEL=OMOTE_LOG_LEVEL_NONE - ;-D OMOTE_LOG_LEVEL=OMOTE_LOG_LEVEL_ERROR - ;-D OMOTE_LOG_LEVEL=OMOTE_LOG_LEVEL_WARN - -D OMOTE_LOG_LEVEL=OMOTE_LOG_LEVEL_INFO - ;-D OMOTE_LOG_LEVEL=OMOTE_LOG_LEVEL_DEBUG - ;-D OMOTE_LOG_LEVEL=OMOTE_LOG_LEVEL_VERBOSE - ;-- lvgl ------------------------------------------------------------------ - ; lvgl variant 1: - ; Don't use lv_conf.h. Tweak params via platfom.ini. See lv_conf_internal.h line 31. Don't change this line. - -D LV_CONF_SKIP=1 - ; Set this in specific environments below. Will be different in Arduino and Windows/Linux - ;-D LV_TICK_CUSTOM=1 - ; dynamic memory. Takes as much as it gets from heap (DRAM). Needs approx. 25%-30% more memory than static memory. - ;-D LV_MEM_CUSTOM=1 - ; Set this in specific environments below. 32 bit and 64 bit need differenz sizes. - ;-D LV_MEM_CUSTOM=0 - ;-D LV_MEM_SIZE="(32U * 1024U)" - ; fonts and theme - -D LV_FONT_MONTSERRAT_10=1 - -D LV_FONT_MONTSERRAT_12=1 - -D LV_FONT_MONTSERRAT_16=1 - -D LV_FONT_MONTSERRAT_24=1 - -D LV_THEME_DEFAULT_DARK=1 - ; don't build examples - -D LV_BUILD_EXAMPLES=0 - ; Enable the log module - -D LV_USE_LOG=1 - -D LV_LOG_PRINTF=1 - ;-D LV_LOG_LEVEL=LV_LOG_LEVEL_NONE - ;-D LV_LOG_LEVEL=LV_LOG_LEVEL_USER - -D LV_LOG_LEVEL=LV_LOG_LEVEL_ERROR - ;-D LV_LOG_LEVEL=LV_LOG_LEVEL_WARN - ;-D LV_LOG_LEVEL=LV_LOG_LEVEL_INFO - ;-D LV_LOG_LEVEL=LV_LOG_LEVEL_TRACE - ; --- - ; Enable asserts if an operation is failed or an invalid data is found. - ; If LV_USE_LOG is enabled an error message will be printed on failure*/ - ; /*Check if the styles are properly initialized. (Very fast, recommended)*/ - -D LV_USE_ASSERT_STYLE=1 - ; /*Check the integrity of `lv_mem` after critical operations. (Slow)*/ - ;-D LV_USE_ASSERT_MEM_INTEGRITY=1 - ; /*Check the object's type and existence (e.g. not deleted). (Slow)*/ - ;-D LV_USE_ASSERT_OBJ=1 - ; --------- - ; lvgl variant 2: - ; or define where lv_conf.h is, relative to the `lvgl` folder - ;-D LV_CONF_PATH=../../../../src/gui_general_and_keys/lv_conf.h - ; --- interesting lvgl debug infos (OSD) - ;-D LV_USE_PERF_MONITOR=1 - ;-D LV_USE_MEM_MONITOR=1 - ;-D LV_USE_REFR_DEBUG=1 - [env:esp32] platform = espressif32 board = esp32dev @@ -88,52 +18,27 @@ board_build.f_cpu = 240000000L board_build.partitions = huge_app.csv upload_speed = 1000000 lib_deps = - ${env.lib_deps} - bodmer/TFT_eSPI@^2.5.43 - adafruit/Adafruit BusIO@^1.15.0 - adafruit/Adafruit FT6206 Library@^1.1.0 sparkfun/SparkFun LIS3DH Arduino Library@^1.0.3 - crankyoldgit/IRremoteESP8266@^2.8.6 - knolleary/PubSubClient@^2.8 - h2zero/NimBLE-Arduino@^1.4.1 + crankyoldgit/IRremoteESP8266@^2.8.4 + adafruit/Adafruit FT6206 Library@^1.0.6 + lvgl/lvgl@^8.3.4 + bodmer/TFT_eSPI@^2.5.23 sparkfun/SparkFun MAX1704x Fuel Gauge Arduino Library@^1.0.4 - ;chris--a/Keypad@^3.1.1 - ;t-vk/ESP32 BLE Keyboard@^0.3.2 -build_flags = - ${env.build_flags} - ;-- OMOTE ----------------------------------------------------------------- - ; 1: rev1 - Slowly charge the VSW voltage to prevent a brownout - ; 2: rev2 - no special handling needed - ; 3: rev3 - no special handling needed - ; 4: rev4 - Switched from ADC battery monitoring to i2c fuel gauge - -D OMOTE_HARDWARE_REV=3 - ;-- Arduino log ----------------------------------------------------------- - ;-D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE - ;-D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_ERROR - ;-D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_WARN - -D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_INFO - ;-D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG - ;-D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE - ;-- lvgl arduino ---------------------------------------------------------- - ; use millis() from "Arduino.h" to tell the elapsed time in milliseconds - -D LV_TICK_CUSTOM=1 - ; static memory, will be allocated in static DRAM - -D LV_MEM_CUSTOM=0 - -D LV_MEM_SIZE="(32U * 1024U)" - ;-- TFT_eSPI -------------------------------------------------------------- - -D DISABLE_ALL_LIBRARY_WARNINGS=1 +build_flags = + -D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG + -I include ; Include the folder containing lv_conf.h ; The following lines replace the TFT_eSPI User_setup.h-file -D USER_SETUP_LOADED=1 -D ILI9341_DRIVER=1 - -D TFT_WIDTH=${env.custom_screen_width} - -D TFT_HEIGHT=${env.custom_screen_heigth} - ;-D TFT_MISO not connected + -D TFT_WIDTH=240 + -D TFT_HEIGHT=320 -D TFT_MOSI=23 -D TFT_SCLK=18 -D TFT_CS=5 -D TFT_DC=9 -D TFT_RST=-1 -D SPI_FREQUENCY=40000000 ; 40MHz default, some displays might support 80MHz + -D SPI_TOUCH_FREQUENCY=2500000 ; TFT_eSPI fonts are disabled by default ;-D LOAD_GLCD=1 ;-D LOAD_FONT2=1 @@ -143,76 +48,3 @@ build_flags = ;-D LOAD_FONT8=1 ;-D LOAD_GFXFF=1 ;-D SMOOTH_FONT=1 - ;-- for BLE Keyboard. Don't change this line! ----------------------------- - -D USE_NIMBLE=1 - ;-- hardware abstraction, needed to find hardwareLayer.h ------------------ - -I hardware - -I hardware/ESP32/lib/Keypad/src - ;-I hardware/ESP32/lib/ESP32-BLE-Keyboard -build_src_filter = - +<*> - +<../hardware/ESP32/*> - ;+<../hardware/ESP32/lib/ESP32-BLE-Keyboard/*> - - - -; use this if you are using Ubuntu or WSL2 (64 bit compiler) -[env:linux_64bit] -platform = native@^1.2.1 -lib_deps = - ${env.lib_deps} - ;we need the master branch from github because of this commit https://github.com/lvgl/lv_drivers/commit/7b9dee11c93ad27e2591182457c1eba7677473be - lv_drivers=https://github.com/lvgl/lv_drivers - ;lvgl/lv_drivers@^8.3.0 -build_flags = - ${env.build_flags} - ;-- lvgl ------------------------------------------------------------------ - ; 64 bit needs a lot more static memory - -D LV_MEM_CUSTOM=0 - -D LV_MEM_SIZE="(64U * 1024U)" - ;SDL2 from msys64 - -l SDL2 - ; settings for lv_drivers - -D LV_LVGL_H_INCLUDE_SIMPLE - -D LV_DRV_NO_CONF - -D USE_SDL - -D SDL_INCLUDE_PATH="\"SDL2/SDL.h\"" - -D SDL_HOR_RES=${env.custom_screen_width} - -D SDL_VER_RES=${env.custom_screen_heigth} - -D SDL_ZOOM=2 - ;-- hardware abstraction, needed to find hardwareLayer.h ------------------ - -I hardware - -I hardware/windows_linux/lib/MQTT-C/include -build_src_filter = - +<*> - +<../hardware/windows_linux/*> - - - -; use this if you are using Windows MSYS2 MINGW64 (64 bit compiler) -[env:windows_64bit] -extends = env:linux_64bit -build_flags = - ${env:linux_64bit.build_flags} - ; winsock - -l ws2_32 - -; use this if you are using Windows MSYS2 MINGW32 (32 bit compiler) -[env:windows_32bit] -extends = env:windows_64bit -build_unflags = - ${env:windows_64bit.build_unflags} - ;-- lvgl ------------------------------------------------------------------ - -D LV_MEM_CUSTOM=0 - -D LV_MEM_SIZE="(64U * 1024U)" -build_flags = - ${env:windows_64bit.build_flags} - ;-- lvgl ------------------------------------------------------------------ - ; 32 bit needs exact the same lvgl memory as on ESP32 - -D LV_MEM_CUSTOM=0 - -D LV_MEM_SIZE="(32U * 1024U)" - ; Take care. If you have a 64 bit compiler, this setting will tell the compiler to cross compile to 32 bit. - ; Compiling is successfull, but linker fails. So use this env only with a 32 bit compiler. - ; Probably a custom linker script would be needed for cross compiling to work. - ; Ubuntu and WSL2 are using 64 bit compilers! So you can only build the 32 bit simulator with Windows MSYS2 MINGW32 - -m32 - ;linker option - -Wl,-mi386pe diff --git a/Platformio/src/applicationInternal/commandHandler.cpp b/Platformio/src/applicationInternal/commandHandler.cpp deleted file mode 100644 index f3d5439a..00000000 --- a/Platformio/src/applicationInternal/commandHandler.cpp +++ /dev/null @@ -1,292 +0,0 @@ -#include -#include -#include -#include -#include -#include "applicationInternal/commandHandler.h" -#include "applicationInternal/scenes/sceneHandler.h" -#include "applicationInternal/hardware/hardwarePresenter.h" -#include "applicationInternal/omote_log.h" -#include "devices/misc/device_specialCommands.h" -// show WiFi status -#include "applicationInternal/gui/guiBase.h" -// show received IR and MQTT messages -#include "guis/gui_irReceiver.h" - -uint16_t COMMAND_UNKNOWN; - -uint16_t KEYBOARD_DUMMY_UP ; //"Keyboard_dummy_up" -uint16_t KEYBOARD_DUMMY_DOWN ; //"Keyboard_dummy_down" -uint16_t KEYBOARD_DUMMY_RIGHT ; //"Keyboard_dummy_right" -uint16_t KEYBOARD_DUMMY_LEFT ; //"Keyboard_dummy_left" -uint16_t KEYBOARD_DUMMY_SELECT ; //"Keyboard_dummy_select" -uint16_t KEYBOARD_DUMMY_SENDSTRING ; //"Keyboard_dummy_sendstring" -uint16_t KEYBOARD_DUMMY_BACK ; //"Keyboard_dummy_back" -uint16_t KEYBOARD_DUMMY_HOME ; //"Keyboard_dummy_home" -uint16_t KEYBOARD_DUMMY_MENU ; //"Keyboard_dummy_menu" -uint16_t KEYBOARD_DUMMY_SCAN_PREVIOUS_TRACK ; //"Keyboard_dummy_scan_previous_track" -uint16_t KEYBOARD_DUMMY_REWIND_LONG ; //"Keyboard_dummy_rewind_long" -uint16_t KEYBOARD_DUMMY_REWIND ; //"Keyboard_dummy_rewind" -uint16_t KEYBOARD_DUMMY_PLAYPAUSE ; //"Keyboard_dummy_playpause" -uint16_t KEYBOARD_DUMMY_FASTFORWARD ; //"Keyboard_dummy_fastforward" -uint16_t KEYBOARD_DUMMY_FASTFORWARD_LONG ; //"Keyboard_dummy_fastforward_long" -uint16_t KEYBOARD_DUMMY_SCAN_NEXT_TRACK ; //"Keyboard_dummy_scan_next_track" -uint16_t KEYBOARD_DUMMY_MUTE ; //"Keyboard_dummy_mute" -uint16_t KEYBOARD_DUMMY_VOLUME_INCREMENT ; //"Keyboard_dummy_volume_increment" -uint16_t KEYBOARD_DUMMY_VOLUME_DECREMENT ; //"Keyboard_dummy_volume_decrement" - -uint16_t KEYBOARD_UP ; //PPCAT(KEYBOARD_PREFIX, UP) -uint16_t KEYBOARD_DOWN ; //PPCAT(KEYBOARD_PREFIX, DOWN) -uint16_t KEYBOARD_RIGHT ; //PPCAT(KEYBOARD_PREFIX, RIGHT) -uint16_t KEYBOARD_LEFT ; //PPCAT(KEYBOARD_PREFIX, LEFT) -uint16_t KEYBOARD_SELECT ; //PPCAT(KEYBOARD_PREFIX, SELECT) -uint16_t KEYBOARD_SENDSTRING ; //PPCAT(KEYBOARD_PREFIX, SENDSTRING) -uint16_t KEYBOARD_BACK ; //PPCAT(KEYBOARD_PREFIX, BACK) -uint16_t KEYBOARD_HOME ; //PPCAT(KEYBOARD_PREFIX, HOME) -uint16_t KEYBOARD_MENU ; //PPCAT(KEYBOARD_PREFIX, MENU) -uint16_t KEYBOARD_SCAN_PREVIOUS_TRACK ; //PPCAT(KEYBOARD_PREFIX, SCAN_PREVIOUS_TRACK) -uint16_t KEYBOARD_REWIND_LONG ; //PPCAT(KEYBOARD_PREFIX, REWIND_LONG) -uint16_t KEYBOARD_REWIND ; //PPCAT(KEYBOARD_PREFIX, REWIND) -uint16_t KEYBOARD_PLAYPAUSE ; //PPCAT(KEYBOARD_PREFIX, PLAYPAUSE) -uint16_t KEYBOARD_FASTFORWARD ; //PPCAT(KEYBOARD_PREFIX, FASTFORWARD) -uint16_t KEYBOARD_FASTFORWARD_LONG ; //PPCAT(KEYBOARD_PREFIX, FASTFORWARD_LONG) -uint16_t KEYBOARD_SCAN_NEXT_TRACK ; //PPCAT(KEYBOARD_PREFIX, SCAN_NEXT_TRACK) -uint16_t KEYBOARD_MUTE ; //PPCAT(KEYBOARD_PREFIX, MUTE) -uint16_t KEYBOARD_VOLUME_INCREMENT ; //PPCAT(KEYBOARD_PREFIX, VOLUME_INCREMENT) -uint16_t KEYBOARD_VOLUME_DECREMENT ; //PPCAT(KEYBOARD_PREFIX, VOLUME_DECREMENT) - -std::map commands; - -uint16_t uniqueCommandID = 0; - -// we don't yet have a command id -void register_command(uint16_t *command, commandData aCommandData) { - *command = uniqueCommandID; - uniqueCommandID++; - - commands[*command] = aCommandData; -} -// we already have a command id. Only used by BLE keyboard -void register_command_withID(uint16_t command, commandData aCommandData) { - commands[command] = aCommandData; -} -// only get a unique ID. used by KEYBOARD_DUMMY, COMMAND_UNKNOWN and BLE keyboard -void get_uniqueCommandID(uint16_t *command) { - *command = uniqueCommandID; - uniqueCommandID++; -} - -void register_keyboardCommands() { - get_uniqueCommandID(&KEYBOARD_DUMMY_UP ); - get_uniqueCommandID(&KEYBOARD_DUMMY_DOWN ); - get_uniqueCommandID(&KEYBOARD_DUMMY_RIGHT ); - get_uniqueCommandID(&KEYBOARD_DUMMY_LEFT ); - get_uniqueCommandID(&KEYBOARD_DUMMY_SELECT ); - get_uniqueCommandID(&KEYBOARD_DUMMY_SENDSTRING ); - get_uniqueCommandID(&KEYBOARD_DUMMY_BACK ); - get_uniqueCommandID(&KEYBOARD_DUMMY_HOME ); - get_uniqueCommandID(&KEYBOARD_DUMMY_MENU ); - get_uniqueCommandID(&KEYBOARD_DUMMY_SCAN_PREVIOUS_TRACK ); - get_uniqueCommandID(&KEYBOARD_DUMMY_REWIND_LONG ); - get_uniqueCommandID(&KEYBOARD_DUMMY_REWIND ); - get_uniqueCommandID(&KEYBOARD_DUMMY_PLAYPAUSE ); - get_uniqueCommandID(&KEYBOARD_DUMMY_FASTFORWARD ); - get_uniqueCommandID(&KEYBOARD_DUMMY_FASTFORWARD_LONG ); - get_uniqueCommandID(&KEYBOARD_DUMMY_SCAN_NEXT_TRACK ); - get_uniqueCommandID(&KEYBOARD_DUMMY_MUTE ); - get_uniqueCommandID(&KEYBOARD_DUMMY_VOLUME_INCREMENT ); - get_uniqueCommandID(&KEYBOARD_DUMMY_VOLUME_DECREMENT ); - -#if (ENABLE_KEYBOARD_BLE == 1) - KEYBOARD_UP = KEYBOARD_BLE_UP; - KEYBOARD_DOWN = KEYBOARD_BLE_DOWN; - KEYBOARD_RIGHT = KEYBOARD_BLE_RIGHT; - KEYBOARD_LEFT = KEYBOARD_BLE_LEFT; - KEYBOARD_SELECT = KEYBOARD_BLE_SELECT; - KEYBOARD_SENDSTRING = KEYBOARD_BLE_SENDSTRING; - KEYBOARD_BACK = KEYBOARD_BLE_BACK; - KEYBOARD_HOME = KEYBOARD_BLE_HOME; - KEYBOARD_MENU = KEYBOARD_BLE_MENU; - KEYBOARD_SCAN_PREVIOUS_TRACK = KEYBOARD_BLE_SCAN_PREVIOUS_TRACK; - KEYBOARD_REWIND_LONG = KEYBOARD_BLE_REWIND_LONG; - KEYBOARD_REWIND = KEYBOARD_BLE_REWIND; - KEYBOARD_PLAYPAUSE = KEYBOARD_BLE_PLAYPAUSE; - KEYBOARD_FASTFORWARD = KEYBOARD_BLE_FASTFORWARD; - KEYBOARD_FASTFORWARD_LONG = KEYBOARD_BLE_FASTFORWARD_LONG; - KEYBOARD_SCAN_NEXT_TRACK = KEYBOARD_BLE_SCAN_NEXT_TRACK; - KEYBOARD_MUTE = KEYBOARD_BLE_MUTE; - KEYBOARD_VOLUME_INCREMENT = KEYBOARD_BLE_VOLUME_INCREMENT; - KEYBOARD_VOLUME_DECREMENT = KEYBOARD_BLE_VOLUME_DECREMENT; -#elif (ENABLE_KEYBOARD_MQTT == 1) - KEYBOARD_UP = KEYBOARD_MQTT_UP; - KEYBOARD_DOWN = KEYBOARD_MQTT_DOWN; - KEYBOARD_RIGHT = KEYBOARD_MQTT_RIGHT; - KEYBOARD_LEFT = KEYBOARD_MQTT_LEFT; - KEYBOARD_SELECT = KEYBOARD_MQTT_SELECT; - KEYBOARD_SENDSTRING = KEYBOARD_MQTT_SENDSTRING; - KEYBOARD_BACK = KEYBOARD_MQTT_BACK; - KEYBOARD_HOME = KEYBOARD_MQTT_HOME; - KEYBOARD_MENU = KEYBOARD_MQTT_MENU; - KEYBOARD_SCAN_PREVIOUS_TRACK = KEYBOARD_MQTT_SCAN_PREVIOUS_TRACK; - KEYBOARD_REWIND_LONG = KEYBOARD_MQTT_REWIND_LONG; - KEYBOARD_REWIND = KEYBOARD_MQTT_REWIND; - KEYBOARD_PLAYPAUSE = KEYBOARD_MQTT_PLAYPAUSE; - KEYBOARD_FASTFORWARD = KEYBOARD_MQTT_FASTFORWARD; - KEYBOARD_FASTFORWARD_LONG = KEYBOARD_MQTT_FASTFORWARD_LONG; - KEYBOARD_SCAN_NEXT_TRACK = KEYBOARD_MQTT_SCAN_NEXT_TRACK; - KEYBOARD_MUTE = KEYBOARD_MQTT_MUTE; - KEYBOARD_VOLUME_INCREMENT = KEYBOARD_MQTT_VOLUME_INCREMENT; - KEYBOARD_VOLUME_DECREMENT = KEYBOARD_MQTT_VOLUME_DECREMENT; -#else - // Of course keyboard commands will not work if neither BLE nor MQTT keyboard is enabled, but at least code will compile. - // But you have to change keys.cpp, gui_numpad.cpp and commandHandler.cpp where keyboard commands are used so that a command can be executed successfully. - // Search for "executeCommand(Key" to find them. - KEYBOARD_UP = KEYBOARD_DUMMY_UP; - KEYBOARD_DOWN = KEYBOARD_DUMMY_DOWN; - KEYBOARD_RIGHT = KEYBOARD_DUMMY_RIGHT; - KEYBOARD_LEFT = KEYBOARD_DUMMY_LEFT; - KEYBOARD_SELECT = KEYBOARD_DUMMY_SELECT; - KEYBOARD_SENDSTRING = KEYBOARD_DUMMY_SENDSTRING; - KEYBOARD_BACK = KEYBOARD_DUMMY_BACK; - KEYBOARD_HOME = KEYBOARD_DUMMY_HOME; - KEYBOARD_MENU = KEYBOARD_DUMMY_MENU; - KEYBOARD_SCAN_PREVIOUS_TRACK = KEYBOARD_DUMMY_SCAN_PREVIOUS_TRACK; - KEYBOARD_REWIND_LONG = KEYBOARD_DUMMY_REWIND_LONG; - KEYBOARD_REWIND = KEYBOARD_DUMMY_REWIND; - KEYBOARD_PLAYPAUSE = KEYBOARD_DUMMY_PLAYPAUSE; - KEYBOARD_FASTFORWARD = KEYBOARD_DUMMY_FASTFORWARD; - KEYBOARD_FASTFORWARD_LONG = KEYBOARD_DUMMY_FASTFORWARD_LONG; - KEYBOARD_SCAN_NEXT_TRACK = KEYBOARD_DUMMY_SCAN_NEXT_TRACK; - KEYBOARD_MUTE = KEYBOARD_DUMMY_MUTE; - KEYBOARD_VOLUME_INCREMENT = KEYBOARD_DUMMY_VOLUME_INCREMENT; - KEYBOARD_VOLUME_DECREMENT = KEYBOARD_DUMMY_VOLUME_DECREMENT; -#endif - -} - -commandData makeCommandData(commandHandlers a, std::list b) { - commandData c = {a, b}; - return c; -} - -std::string convertStringListToString(std::list listOfStrings) { - std::string result; - for(const auto &word : listOfStrings) { - result += word + ","; - } - return result; -} - -void executeCommandWithData(uint16_t command, commandData commandData, std::string additionalPayload = "") { - switch (commandData.commandHandler) { - case IR: { - omote_log_v(" generic IR, payloads %s\r\n", convertStringListToString(commandData.commandPayloads).c_str()); - - // we received a comma separated list of strings - // the first string is the IR protocol, the second is the payload to be sent - std::list::iterator it = commandData.commandPayloads.begin(); - // get protocol and erase first element in list - std::string protocol = *it; - it = commandData.commandPayloads.erase(it); - omote_log_v(" protocol %s, payload %s\r\n", protocol.c_str(), convertStringListToString(commandData.commandPayloads).c_str()); - - sendIRcode((IRprotocols)std::stoi(protocol), commandData.commandPayloads, additionalPayload); - break; - } - - #if (ENABLE_WIFI_AND_MQTT == 1) - case MQTT: { - auto current = commandData.commandPayloads.begin(); - std::string topic = *current; - std::string payload; - if (additionalPayload == "") { - current = std::next(current, 1); - payload = *current; - } else { - payload = additionalPayload; - } - omote_log_d("execute: will send MQTT, topic '%s', payload '%s'\r\n", topic.c_str(), payload.c_str()); - publishMQTTMessage(topic.c_str(), payload.c_str()); - break; - } - #endif - - #if (ENABLE_KEYBOARD_BLE == 1) - case BLE_KEYBOARD: { - // the real command for the BLE keyboard is the first element in payload - auto current = commandData.commandPayloads.begin(); - uint16_t command = std::stoi(*current); - std::string payload = ""; - if (additionalPayload != "") { - payload = additionalPayload; - } - omote_log_d("execute: will send BLE keyboard command, command '%u', payload '%s'\r\n", command, payload.c_str()); - keyboard_ble_executeCommand(command, payload); - break; - } - #endif - - case SCENE: { - // let the sceneHandler do the scene stuff - omote_log_d("execute: will send scene command to the sceneHandler\r\n"); - handleScene(command, commandData, additionalPayload); - break; - } - - case GUI: { - // let the sceneHandler find and show the gui - omote_log_d("execute: will send gui command to the sceneHandler\r\n"); - handleGUI(command, commandData, additionalPayload); - break; - } - - case SPECIAL: { - if (command == MY_SPECIAL_COMMAND) { - // do your special command here - omote_log_d("execute: could execute a special command here, if you define one\r\n"); - - } - break; - } - } -} - -void executeCommand(uint16_t command, std::string additionalPayload) { - try { - if (commands.count(command) > 0) { - omote_log_d("command: will execute command '%u' with additionalPayload '%s'\r\n", command, additionalPayload.c_str()); - executeCommandWithData(command, commands.at(command), additionalPayload); - } else { - omote_log_w("command: command '%u' not found\r\n", command); - } - } - catch (const std::out_of_range& oor) { - omote_log_e("executeCommand: internal error, command not registered\r\n"); - } -} - -void receiveNewIRmessage_cb(std::string message) { - showNewIRmessage(message); -} -#if (ENABLE_WIFI_AND_MQTT == 1) -void receiveWiFiConnected_cb(bool connected) { - // show status in header - showWiFiConnected(connected); - - if (connected) { - // Here you could add sending a MQTT message. This message could be recognized by your home automation software. - // When receiving this message, your home automation software could send the states of the smart home devices known to OMOTE. - // With that, OMOTE could show on startup the correct status of the smart home devices. - // - // Remark: in your home automation software, maybe add a short delay (e.g. 100-200 ms) between receiving this message and sending out the status of the smart home devices. - // WiFi connection could be already available, but MQTT connection could be not completely ready. Just try what works for you. - - // executeCommand(TRIGGER_UPDATE_OF_OMOTE_SMART_HOME_DEVICES); - - } -} -void receiveMQTTmessage_cb(std::string topic, std::string payload) { - showMQTTmessage(topic, payload); -} - -#endif diff --git a/Platformio/src/applicationInternal/commandHandler.h b/Platformio/src/applicationInternal/commandHandler.h deleted file mode 100644 index 29bd0d6e..00000000 --- a/Platformio/src/applicationInternal/commandHandler.h +++ /dev/null @@ -1,128 +0,0 @@ -#pragma once - -#include -#include -#include - -#include "devices/keyboard/device_keyboard_mqtt/device_keyboard_mqtt.h" -#include "devices/keyboard/device_keyboard_ble/device_keyboard_ble.h" - -extern uint16_t COMMAND_UNKNOWN; - -/* - Depending on which keyboard is enabled (BLE or MQTT), we define KEYBOARD_UP, KEYBOARD_DOWN and so on. - These defines are used in keys.cpp, gui*.cpp and commandHandler.cpp - Example: - If BLE is enabled, then KEYBOARD_UP will be the same as KEYBOARD_BLE_UP - If MQTT is enabled, then KEYBOARD_UP will be the same as KEYBOARD_MQTT_UP - If none of them is enabled, then KEYBOARD_UP will be the same as KEYBOARD_UP_DUMMY - Doing so you can switch between the keyboards without changing the UI code (keys.cpp, gui*.cpp and commandHandler.cpp) - If you need something different than this behaviour, then you can change the code in 'register_keyboardCommands()' - or you can of course change keys.cpp, gui*.cpp and commandHandler.cpp so that they directly use KEYBOARD_BLE_UP or KEYBOARD_MQTT_UP etc. -*/ - -extern uint16_t KEYBOARD_DUMMY_UP; -extern uint16_t KEYBOARD_DUMMY_DOWN; -extern uint16_t KEYBOARD_DUMMY_RIGHT; -extern uint16_t KEYBOARD_DUMMY_LEFT; -extern uint16_t KEYBOARD_DUMMY_SELECT; -extern uint16_t KEYBOARD_DUMMY_SENDSTRING; -extern uint16_t KEYBOARD_DUMMY_BACK; -extern uint16_t KEYBOARD_DUMMY_HOME; -extern uint16_t KEYBOARD_DUMMY_MENU; -extern uint16_t KEYBOARD_DUMMY_SCAN_PREVIOUS_TRACK; -extern uint16_t KEYBOARD_DUMMY_REWIND_LONG; -extern uint16_t KEYBOARD_DUMMY_REWIND; -extern uint16_t KEYBOARD_DUMMY_PLAYPAUSE; -extern uint16_t KEYBOARD_DUMMY_FASTFORWARD; -extern uint16_t KEYBOARD_DUMMY_FASTFORWARD_LONG; -extern uint16_t KEYBOARD_DUMMY_SCAN_NEXT_TRACK; -extern uint16_t KEYBOARD_DUMMY_MUTE; -extern uint16_t KEYBOARD_DUMMY_VOLUME_INCREMENT; -extern uint16_t KEYBOARD_DUMMY_VOLUME_DECREMENT; - -#if (ENABLE_KEYBOARD_BLE == 1) - #define KEYBOARD_PREFIX KEYBOARD_BLE_ -#elif (ENABLE_KEYBOARD_MQTT == 1) - #define KEYBOARD_PREFIX KEYBOARD_MQTT_ -#else - // Of course keyboard commands will not work if neither BLE nor MQTT keyboard is enabled, but at least code will compile. - // But you have to change keys.cpp, gui_numpad.cpp and commandHandler.cpp where keyboard commands are used so that a command can be executed successfully. - // Search for "executeCommand(Key" to find them. - #define KEYBOARD_PREFIX KEYBOARD_DUMMY_ -#endif - -extern uint16_t KEYBOARD_UP; -extern uint16_t KEYBOARD_DOWN; -extern uint16_t KEYBOARD_RIGHT; -extern uint16_t KEYBOARD_LEFT; -extern uint16_t KEYBOARD_SELECT; -extern uint16_t KEYBOARD_SENDSTRING; -extern uint16_t KEYBOARD_BACK; -extern uint16_t KEYBOARD_HOME; -extern uint16_t KEYBOARD_MENU; -extern uint16_t KEYBOARD_SCAN_PREVIOUS_TRACK; -extern uint16_t KEYBOARD_REWIND_LONG; -extern uint16_t KEYBOARD_REWIND; -extern uint16_t KEYBOARD_PLAYPAUSE; -extern uint16_t KEYBOARD_FASTFORWARD; -extern uint16_t KEYBOARD_FASTFORWARD_LONG; -extern uint16_t KEYBOARD_SCAN_NEXT_TRACK; -extern uint16_t KEYBOARD_MUTE; -extern uint16_t KEYBOARD_VOLUME_INCREMENT; -extern uint16_t KEYBOARD_VOLUME_DECREMENT; - -// Not needed anymore, but maybe again in future -// /* -// * Concatenate preprocessor tokens A and B without expanding macro definitions -// * (however, if invoked from a macro, macro arguments are expanded). -// */ -// #define PPCAT_NX(A, B) A ## B -// /* -// * Concatenate preprocessor tokens A and B after macro-expanding them. -// */ -// #define PPCAT(A, B) PPCAT_NX(A, B) -// -// Test -// https://stackoverflow.com/questions/5256313/c-c-macro-string-concatenation -// #define STR(x) #x -// #define XSTR(x) STR(x) -// #pragma message "1 The value is: " XSTR(KEYBOARD_BLE_UP) -// #pragma message "2 The value is: " XSTR(KEYBOARD_MQTT_UP) -// #pragma message "3 The value is: " XSTR(KEYBOARD_UP) - -enum commandHandlers { - SPECIAL, - SCENE, - GUI, - IR, - #if (ENABLE_WIFI_AND_MQTT == 1) - MQTT, - #endif - #if (ENABLE_KEYBOARD_BLE == 1) - BLE_KEYBOARD, - #endif -}; - -struct commandData { - commandHandlers commandHandler; - std::list commandPayloads; -}; - -// we don't yet have a command id -void register_command(uint16_t *command, commandData aCommandData); -// we already have a command id. Only used by BLE keyboard -void register_command_withID(uint16_t command, commandData aCommandData); -// only get a unique ID. used by KEYBOARD_DUMMY, COMMAND_UNKNOWN and BLE keyboard -void get_uniqueCommandID(uint16_t *command); - -void register_keyboardCommands(); -commandData makeCommandData(commandHandlers a, std::list b); -void executeCommand(uint16_t command, std::string additionalPayload = ""); - -void receiveNewIRmessage_cb(std::string message); -#if (ENABLE_WIFI_AND_MQTT == 1) -// used as callbacks from hardware -void receiveWiFiConnected_cb(bool connected); -void receiveMQTTmessage_cb(std::string topic, std::string payload); -#endif diff --git a/Platformio/src/applicationInternal/gui/guiBase.cpp b/Platformio/src/applicationInternal/gui/guiBase.cpp deleted file mode 100644 index 4cc33347..00000000 --- a/Platformio/src/applicationInternal/gui/guiBase.cpp +++ /dev/null @@ -1,360 +0,0 @@ -#include -#include "applicationInternal/hardware/hardwarePresenter.h" -#include "applicationInternal/memoryUsage.h" -#include "applicationInternal/gui/guiMemoryOptimizer.h" -// for changing to scene Selection gui -#include "applicationInternal/commandHandler.h" -#include "applicationInternal/omote_log.h" -#include "scenes/scene__default.h" - -lv_color_t color_primary = lv_color_hex(0x303030); // gray -lv_obj_t* MemoryUsageLabel = NULL; -lv_obj_t* WifiLabel = NULL; -lv_obj_t* BluetoothLabel = NULL; -lv_obj_t* BattPercentageLabel = NULL; -lv_obj_t* BattIconLabel = NULL; -lv_obj_t* SceneLabel = NULL; - -lv_obj_t* tabview = NULL; -// page indicator -lv_obj_t* panel = NULL; -lv_obj_t* img1 = NULL; -lv_obj_t* img2 = NULL; - -static bool global_styles_already_initialized = false; -lv_style_t panel_style; -#ifdef drawRedBorderAroundMainWidgets -lv_style_t style_red_border; -#endif - -void guis_doTabCreationOnStartup(); -void guis_doTabCreationAfterSliding(int newTabID); - -// Helper Functions ----------------------------------------------------------------------------------------------------------------------- - -// callback when pageIndicator prev or next was clicked -void pageIndicator_navigate_event_cb(lv_event_t* e) { - lv_obj_t* target = lv_event_get_target(e); - - int user_data = (intptr_t)(target->user_data); - if (user_data == 0) { - executeCommand(GUI_PREV); - } else if (user_data == 1) { - executeCommand(GUI_NEXT); - } -} - -// callback when sceneLabel or pageIndicator was clicked -void sceneLabel_or_pageIndicator_event_cb(lv_event_t* e) { - omote_log_d("- Scene selection: sceneLabel or pageIndicator clicked received for navigating to scene selection page\r\n"); - executeCommand(SCENE_SELECTION); -} - -// callback for swipe down event to navigate to the scene selection page -void screen_gesture_event_cb(lv_event_t* e) { - lv_obj_t* screen = lv_event_get_current_target(e); - lv_dir_t dir = lv_indev_get_gesture_dir(lv_indev_get_act()); - if (dir == LV_DIR_BOTTOM) { - omote_log_d("- Scene selection: swipe down received for navigating to scene selection page\r\n"); - executeCommand(SCENE_SELECTION); - } -} - -// Set the page indicator (panel) scroll position relative to the tabview content scroll position -// this is a callback if the CONTENT of the tabview is scrolled (LV_EVENT_SCROLL) -void tabview_content_is_scrolling_event_cb(lv_event_t* e){ - if (panel == NULL) { return;} - - float bias = float(150.0 + 8.0) / SCR_WIDTH; - // screenwidth indicator ?? 2 small hidden buttons ?? - int offset = SCR_WIDTH / 2 - 150 / 2 - 8 - 2*50 / 2 -4; - // get the object to which the event is sent - lv_obj_t* tabviewContent = lv_event_get_target(e); - - // Get the x coordinate of object and scroll panel accordingly - int16_t tabviewX = lv_obj_get_scroll_x(tabviewContent); - // the last events we receive are 0, 238 and 476. But should be 0, 240 and 480. Otherwise page indicator jumps a litte bit after recreation of tabs. - if ((tabviewX >= 237) && (tabviewX <= 240)) {tabviewX = 240;} - if ((tabviewX >= 475) && (tabviewX <= 480)) {tabviewX = 480;} - // we need 158 more (the size of one page indicator), because we always have one more page indicator at the beginning and at the end (so normally 5 when having 3 tabs) - int16_t panelX = tabviewX * bias - offset + 158; - omote_log_v("scroll %d to %d\r\n", tabviewX, panelX); - lv_obj_scroll_to_x(panel, panelX, LV_ANIM_OFF); - // lv_obj_scroll_to_x(panel, lv_obj_get_scroll_x(tabviewContent) * bias - offset, LV_ANIM_OFF); -} - -// ----------------------- -static bool waitBeforeActionAfterSlidingAnimationEnded = false; -static unsigned long waitBeforeActionAfterSlidingAnimationEnded_timerStart; -static int newTabID_forLateTabCreation; -// This is the callback when the animation of the tab sliding ended -static void tabview_animation_ready_cb(lv_anim_t* a) { - // Unfortunately, the animation has not completely ended here. We cannot do the recreation of the tabs here. - // We have to wait some more milliseconds or at least one cycle of lv_timer_handler(); - // calling lv_timer_handler(); here does not help - // lv_timer_handler(); - // guis_doTabCreationAfterSliding(newTabID_forLateTabCreation); - - waitBeforeActionAfterSlidingAnimationEnded = true; - waitBeforeActionAfterSlidingAnimationEnded_timerStart = millis(); -} - -// Update gui when a new tab is selected -// this is a callback if the tabview is changed (LV_EVENT_VALUE_CHANGED) -// Sent when a new tab is selected by sliding or clicking the tab button. lv_tabview_get_tab_act(tabview) returns the zero based index of the current tab. -void tabview_tab_changed_event_cb(lv_event_t* e) { - if (lv_event_get_code(e) == LV_EVENT_VALUE_CHANGED) { - - int newTabID = lv_tabview_get_tab_act((lv_obj_t*)lv_event_get_target(e)); - - // Wait until the animation ended, then call "guis_doTabCreationAfterSliding(newTabID);" - // https://forum.lvgl.io/t/delete-a-tab-after-the-tabview-scroll-animation-is-complete/3155/4 - lv_obj_t* myTabview = lv_event_get_target(e); - lv_obj_t* tabContainer = lv_tabview_get_content(myTabview); - lv_anim_t* anim = lv_anim_get(tabContainer, NULL); - if(anim) { - // Swipe is not yet complete. User released the touch screen, an animation will bring it to the end. - // That's the normal (and only?) case for the tft touchscreen - newTabID_forLateTabCreation = newTabID; - lv_anim_set_ready_cb(anim, tabview_animation_ready_cb); - } else { - // Swipe is complete, no additional animation is needed. Most likely only possible in simulator - omote_log_d("Change of tab detected, without animation at the end. Will directly do my job after sliding.\r\n"); - guis_doTabCreationAfterSliding(newTabID); - } - } -} - -void setMainWidgetsHeightAndPosition(); -void init_gui_status_bar(); -void init_gui_memoryUsage_bar(); -void init_gui(void) { - - // Setup LVGL --------------------------------------------------------------------------------------------- - lv_init(); - - init_lvgl_hardware(); - - // -- draw red border around the main widgets ------------------------------------------------------------- - if (!global_styles_already_initialized) { - // Style the panel background. Will be initialized only once and reused in fillPanelWithPageIndicator_strategyMax3 - lv_style_init(&panel_style); - lv_style_set_pad_all(&panel_style, 3); - lv_style_set_border_width(&panel_style, 0); - lv_style_set_bg_opa(&panel_style, LV_OPA_TRANSP); - #ifdef drawRedBorderAroundMainWidgets - lv_style_init(&style_red_border); - lv_style_set_border_side(&style_red_border, LV_BORDER_SIDE_FULL); - lv_style_set_border_color(&style_red_border, lv_color_hex(0xff0000)); - lv_style_set_border_width(&style_red_border, 1); - global_styles_already_initialized = true; - #endif - } - // Set the background color ------------------------------------------------------------------------------- - lv_obj_set_style_bg_color(lv_scr_act(), lv_color_black(), LV_PART_MAIN); - // set default height and position of main widgets - setMainWidgetsHeightAndPosition(); - // On startup, set current GUIname and GUIlist according to last state before going to sleep - guis_doTabCreationOnStartup(); - // memoryUsage bar - init_gui_memoryUsage_bar(); - // status bar - init_gui_status_bar(); - - // register callback for swipe down event to navigate to the scene selection page - lv_obj_add_event_cb(lv_scr_act(), screen_gesture_event_cb, LV_EVENT_GESTURE, NULL); - -} - -int panelHeight; -int memoryUsageBarTop; -int memoryUsageBarHeight; -int statusbarTop; -int statusbarHeight; -int tabviewTop; -int tabviewHeight; -int labelsPositionTop; - -void setMainWidgetsHeightAndPosition() { - panelHeight = 30; - memoryUsageBarTop = 0; - memoryUsageBarHeight = getShowMemoryUsage() ? 14 : 0; - statusbarTop = memoryUsageBarTop + memoryUsageBarHeight; - statusbarHeight = 20; - tabviewTop = statusbarTop + statusbarHeight; - tabviewHeight = SCR_HEIGHT - memoryUsageBarHeight - statusbarHeight - panelHeight; - labelsPositionTop = -2; -} - -lv_obj_t* memoryUsageBar; -lv_obj_t* statusbar; - -void showMemoryUsageBar(bool showBar) { - setMainWidgetsHeightAndPosition(); - - lv_obj_set_size(memoryUsageBar, SCR_WIDTH, memoryUsageBarHeight); - lv_obj_align(memoryUsageBar, LV_ALIGN_TOP_MID, 0, memoryUsageBarTop); - lv_obj_set_size(statusbar, SCR_WIDTH, statusbarHeight); - lv_obj_align(statusbar, LV_ALIGN_TOP_MID, 0, statusbarTop); - lv_obj_set_size(tabview, SCR_WIDTH, tabviewHeight); - lv_obj_align(tabview, LV_ALIGN_TOP_MID, 0, tabviewTop); - - return; - - if (showBar) { - // lv_obj_clear_flag(memoryUsageBar, LV_OBJ_FLAG_HIDDEN); - lv_obj_set_size(memoryUsageBar, SCR_WIDTH, memoryUsageBarHeight); - lv_obj_align(memoryUsageBar, LV_ALIGN_TOP_MID, 0, memoryUsageBarTop); - lv_obj_set_size(statusbar, SCR_WIDTH, statusbarHeight); - lv_obj_align(statusbar, LV_ALIGN_TOP_MID, 0, statusbarTop); - lv_obj_set_size(tabview, SCR_WIDTH, tabviewHeight); - lv_obj_align(tabview, LV_ALIGN_TOP_MID, 0, tabviewTop); - } else { - // lv_obj_add_flag(memoryUsageBar, LV_OBJ_FLAG_HIDDEN); - - } -} - -void init_gui_memoryUsage_bar() { - // Create a memory status text bar at the top ------------------------------------------------------------- - memoryUsageBar = lv_btn_create(lv_scr_act()); - lv_obj_set_size(memoryUsageBar, SCR_WIDTH, memoryUsageBarHeight); - lv_obj_set_style_shadow_width(memoryUsageBar, 0, LV_PART_MAIN); - lv_obj_set_style_bg_color(memoryUsageBar, lv_color_black(), LV_PART_MAIN); - #ifdef drawRedBorderAroundMainWidgets - lv_obj_add_style(memoryUsageBar, &style_red_border, LV_PART_MAIN); - #endif - lv_obj_set_style_radius(memoryUsageBar, 0, LV_PART_MAIN); - lv_obj_set_style_pad_all(memoryUsageBar, 0, LV_PART_MAIN); - lv_obj_align(memoryUsageBar, LV_ALIGN_TOP_MID, 0, memoryUsageBarTop); - - MemoryUsageLabel = lv_label_create(memoryUsageBar); - lv_label_set_text(MemoryUsageLabel, ""); - lv_obj_align(MemoryUsageLabel, LV_ALIGN_TOP_LEFT, 0, labelsPositionTop); - lv_obj_set_style_text_font(MemoryUsageLabel, &lv_font_montserrat_12, LV_PART_MAIN); - lv_label_set_recolor(MemoryUsageLabel, true); -} - -void init_gui_status_bar() { - // Create a status bar at the top ------------------------------------------------------------------------- - statusbar = lv_btn_create(lv_scr_act()); - lv_obj_clear_flag(statusbar, LV_OBJ_FLAG_CLICKABLE); - lv_obj_set_size(statusbar, SCR_WIDTH, statusbarHeight); - lv_obj_set_style_shadow_width(statusbar, 0, LV_PART_MAIN); - lv_obj_set_style_bg_color(statusbar, lv_color_black(), LV_PART_MAIN); - #ifdef drawRedBorderAroundMainWidgets - lv_obj_add_style(statusbar, &style_red_border, LV_PART_MAIN); - #endif - lv_obj_set_style_radius(statusbar, 0, LV_PART_MAIN); - lv_obj_set_style_pad_all(statusbar, 0, LV_PART_MAIN); - lv_obj_align(statusbar, LV_ALIGN_TOP_MID, 0, statusbarTop); - - int labelsPositionTopStatusbar = labelsPositionTop + 3; - // WiFi ------------------------------------------------------------------------- - WifiLabel = lv_label_create(statusbar); - lv_label_set_text(WifiLabel, ""); - lv_obj_align(WifiLabel, LV_ALIGN_TOP_LEFT, 0, labelsPositionTopStatusbar); - lv_obj_set_style_text_font(WifiLabel, &lv_font_montserrat_12, LV_PART_MAIN); - // Bluetooth -------------------------------------------------------------------- - BluetoothLabel = lv_label_create(statusbar); - lv_label_set_text(BluetoothLabel, ""); - lv_obj_align(BluetoothLabel, LV_ALIGN_TOP_LEFT, 20, labelsPositionTopStatusbar); - lv_obj_set_style_text_font(BluetoothLabel, &lv_font_montserrat_12, LV_PART_MAIN); - // Scene ------------------------------------------------------------------------ - SceneLabel = lv_label_create(statusbar); - lv_label_set_text(SceneLabel, ""); - lv_obj_align(SceneLabel, LV_ALIGN_TOP_MID, 0, labelsPositionTopStatusbar); - lv_obj_set_style_text_font(SceneLabel, &lv_font_montserrat_12, LV_PART_MAIN); - lv_obj_add_flag(SceneLabel, LV_OBJ_FLAG_CLICKABLE); - lv_obj_set_user_data(SceneLabel,(void *)(intptr_t)0); - lv_obj_add_event_cb(SceneLabel, sceneLabel_or_pageIndicator_event_cb, LV_EVENT_CLICKED, NULL); - - // Battery ---------------------------------------------------------------------- - BattPercentageLabel = lv_label_create(statusbar); - lv_label_set_text(BattPercentageLabel, ""); - lv_obj_align(BattPercentageLabel, LV_ALIGN_TOP_RIGHT, -28, labelsPositionTopStatusbar); - lv_obj_set_style_text_font(BattPercentageLabel, &lv_font_montserrat_12, LV_PART_MAIN); - BattIconLabel = lv_label_create(statusbar); - lv_label_set_text(BattIconLabel, LV_SYMBOL_BATTERY_EMPTY); - lv_obj_align(BattIconLabel, LV_ALIGN_TOP_RIGHT, 0, labelsPositionTopStatusbar -1); - lv_obj_set_style_text_font(BattIconLabel, &lv_font_montserrat_16, LV_PART_MAIN); - -} - -static bool waitOneLoop = false; -void gui_loop(void) { - // after the sliding animation ended, we have to wait one cycle of gui_loop() before we can do the recreation of the tabs - if (waitBeforeActionAfterSlidingAnimationEnded) { - waitOneLoop = true; - waitBeforeActionAfterSlidingAnimationEnded = false; - } else if (waitOneLoop) { - waitOneLoop = false; - guis_doTabCreationAfterSliding(newTabID_forLateTabCreation); - }; - // // as alternative, we could wait some milliseconds. But one cycle of gui_loop() works well. - // if (waitBeforeActionAfterSlidingAnimationEnded) { - // if (millis() - waitBeforeActionAfterSlidingAnimationEnded_timerStart >= 5) { - // guis_doTabCreationAfterSliding(newTabID_forLateTabCreation); - // waitBeforeActionAfterSlidingAnimationEnded = false; - // } - // } - - lv_timer_handler(); -} - -// ------------------------------------------------------------------------------------------------------------ -// There are several reasons why the tabs could get recreated. All are going through these functions in "guiBase.cpp", which are calling functions in "guiMemoryOptimizer.cpp" -// 1. tab creation on startup (called by init_gui()) -void guis_doTabCreationOnStartup() { - gui_memoryOptimizer_onStartup(&tabview, &panel, &img1, &img2); - doLogMemoryUsage(); -} -// 2. tab creation after sliding (called by tabview_tab_changed_event_cb()) -void guis_doTabCreationAfterSliding(int newTabID) { - gui_memoryOptimizer_afterSliding(&tabview, &panel, &img1, &img2, newTabID); - doLogMemoryUsage(); -} -// 3. after gui list has changed (called by handleScene()), when switching between main_gui_list and scene specific list. Will show first GUi in list -void guis_doTabCreationAfterGUIlistChanged(GUIlists newGUIlist) { - gui_memoryOptimizer_afterGUIlistChanged(&tabview, &panel, &img1, &img2, newGUIlist); - doLogMemoryUsage(); -} -// 4. navigate to a specific GUI in gui_list -void guis_doTabCreationForSpecificGUI(GUIlists GUIlist, int gui_list_index) { - gui_memoryOptimizer_navigateToGUI(&tabview, &panel, &img1, &img2, GUIlist, gui_list_index); - doLogMemoryUsage(); -} -// 5. navigate back to last active gui of previous gui_list -void guis_doTabCreationForNavigateToLastActiveGUIofPreviousGUIlist() { - gui_memoryOptimizer_navigateToLastActiveGUIofPreviousGUIlist(&tabview, &panel, &img1, &img2); - doLogMemoryUsage(); -} - -// ------------------------------------------------------------------------------------------------------------ - -void setActiveTab(uint32_t index, lv_anim_enable_t anim_en, bool send_tab_changed_event) { - // unsigned long startTime = millis(); - if (anim_en == LV_ANIM_ON) { - lv_tabview_set_act(tabview, index, LV_ANIM_ON); - // startTime = millis(); - // while (millis() - startTime < 1000) { - // lv_timer_handler(); - // } - } else { - lv_tabview_set_act(tabview, index, LV_ANIM_OFF); - // lv_timer_handler(); - // log_memory(); - } - - if (send_tab_changed_event) { - lv_event_send(tabview, LV_EVENT_VALUE_CHANGED, NULL); - } -} - -void showWiFiConnected(bool connected) { - if (connected) { - if (WifiLabel != NULL) {lv_label_set_text(WifiLabel, LV_SYMBOL_WIFI);} - } else { - if (WifiLabel != NULL) {lv_label_set_text(WifiLabel, "");} - } -} diff --git a/Platformio/src/applicationInternal/gui/guiBase.h b/Platformio/src/applicationInternal/gui/guiBase.h deleted file mode 100644 index ffaade28..00000000 --- a/Platformio/src/applicationInternal/gui/guiBase.h +++ /dev/null @@ -1,45 +0,0 @@ -#pragma once - -#include -#include "applicationInternal/gui/guiMemoryOptimizer.h" - -// used by memoryUsage.cpp -extern lv_obj_t* MemoryUsageLabel; -// used by guiStatusUpdate.cpp -extern lv_obj_t* BluetoothLabel; -extern lv_obj_t* BattPercentageLabel; -extern lv_obj_t* BattIconLabel; -// used by sceneHandler.cpp -extern lv_obj_t* SceneLabel; -// used by guiMemoryOptimizer.cpp -extern lv_style_t panel_style; -extern int tabviewTop; -extern int tabviewHeight; -extern int panelHeight; -// used by almost all gui_*.cpp -extern lv_color_t color_primary; - -//#define drawRedBorderAroundMainWidgets -#ifdef drawRedBorderAroundMainWidgets -extern lv_style_t style_red_border; -#endif - -// used by main.cpp -void init_gui(void); -// used by main.cpp and sceneHandler.cpp -void gui_loop(void); -// used by guiMemoryOptimizer.cpp -void tabview_content_is_scrolling_event_cb(lv_event_t* e); -void tabview_tab_changed_event_cb(lv_event_t* e); -void sceneLabel_or_pageIndicator_event_cb(lv_event_t* e); -void pageIndicator_navigate_event_cb(lv_event_t* e); -// used by sceneHandler.cpp -void guis_doTabCreationAfterGUIlistChanged(GUIlists newGUIlist); -void guis_doTabCreationForSpecificGUI(GUIlists GUIlist, int gui_list_index); -void guis_doTabCreationForNavigateToLastActiveGUIofPreviousGUIlist(); -// used by guiMemoryOptimizer.cpp and sceneHandler.cpp -void setActiveTab(uint32_t index, lv_anim_enable_t anim_en, bool send_tab_changed_event = false); -// used by memoryUsage.cpp -void showMemoryUsageBar(bool showBar); -// used by commandHandler to show WiFi status -void showWiFiConnected(bool connected); diff --git a/Platformio/src/applicationInternal/gui/guiBase_assets.c b/Platformio/src/applicationInternal/gui/guiBase_assets.c deleted file mode 100644 index 0a57cbf3..00000000 --- a/Platformio/src/applicationInternal/gui/guiBase_assets.c +++ /dev/null @@ -1,42 +0,0 @@ -#include - -#ifndef LV_ATTRIBUTE_MEM_ALIGN -#define LV_ATTRIBUTE_MEM_ALIGN -#endif - -#ifndef LV_ATTRIBUTE_IMG_GRADIENTLEFT -#define LV_ATTRIBUTE_IMG_GRADIENTLEFT -#endif - -const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_GRADIENTLEFT uint8_t gradientLeft_map[] = { - 0xfa, 0xf2, 0xea, 0xe2, 0xda, 0xd1, 0xc7, 0xbe, 0xb7, 0xae, 0xa6, 0x9e, 0x95, 0x8d, 0x84, 0x7d, 0x74, 0x6c, 0x62, 0x5a, 0x51, 0x48, 0x41, 0x38, 0x2f, 0x28, 0x1f, 0x17, 0x0f, 0x07, -}; - -const lv_img_dsc_t gradientLeft = { - .header.cf = LV_IMG_CF_ALPHA_8BIT, - .header.always_zero = 0, - .header.reserved = 0, - .header.w = 30, - .header.h = 1, - .data_size = 30, - .data = gradientLeft_map, -}; - - -#ifndef LV_ATTRIBUTE_IMG_GRADIENTRIGHT -#define LV_ATTRIBUTE_IMG_GRADIENTRIGHT -#endif - -const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_GRADIENTRIGHT uint8_t gradientRight_map[] = { - 0x07, 0x0f, 0x17, 0x1f, 0x28, 0x2f, 0x38, 0x41, 0x48, 0x51, 0x5a, 0x62, 0x6c, 0x74, 0x7d, 0x84, 0x8d, 0x95, 0x9e, 0xa6, 0xae, 0xb7, 0xbe, 0xc7, 0xd1, 0xda, 0xe2, 0xea, 0xf2, 0xfa, -}; - -const lv_img_dsc_t gradientRight = { - .header.cf = LV_IMG_CF_ALPHA_8BIT, - .header.always_zero = 0, - .header.reserved = 0, - .header.w = 30, - .header.h = 1, - .data_size = 30, - .data = gradientRight_map, -}; diff --git a/Platformio/src/applicationInternal/gui/guiMemoryOptimizer.cpp b/Platformio/src/applicationInternal/gui/guiMemoryOptimizer.cpp deleted file mode 100644 index 520d9cac..00000000 --- a/Platformio/src/applicationInternal/gui/guiMemoryOptimizer.cpp +++ /dev/null @@ -1,712 +0,0 @@ -#include -#include "applicationInternal/gui/guiBase.h" -#include "applicationInternal/gui/guiMemoryOptimizer.h" -#include "applicationInternal/gui/guiRegistry.h" -#include "applicationInternal/hardware/hardwarePresenter.h" -#include "applicationInternal/scenes/sceneRegistry.h" -#include "applicationInternal/omote_log.h" - -struct t_gui_on_tab { - lv_obj_t* tab; - std::string GUIname; - int gui_list_index; - int gui_list_index_previous; -}; -struct t_gui_state { - // the next three and the last are saved in the preferenceStorage every time they change - std::string activeScene_internalDontUse; - std::string activeGUIname_internalDontUse; - GUIlists activeGUIlist_internalDontUse; - // --- - int activeTabID = -1; // id of the active tab (one of 0,1,2) - int oldTabID = -1; // id of the tab before swiping (one of 0,1,2) - t_gui_on_tab gui_on_tab[3] = {{NULL, "", -1, -1}, {NULL, "", -1, -1}, {NULL, "", -1, -1}}; - // the last active gui of scene. Will be stored to easily navigate back to it with guis_doTabCreationForNavigateToLastActiveGUIofPreviousGUIlist() - GUIlists last_active_gui_list = (GUIlists)-1; - int last_active_gui_list_index_internalDontUse = -1; -}; -t_gui_state gui_state; - -// Both the gui_state and the preferenceStorage should know at any time the current state (scene, GUIname, and GUIlist) -// preferenceStorage should know it because when going to sleep, it should persist the state in NVM. -// So whenever values change, it should be done through these functions. -// On startup, the gui_state is set by gui_memoryOptimizer_onStartup() -std::string gui_memoryOptimizer_getActiveSceneName() { - gui_state.activeScene_internalDontUse = get_activeScene(); - return gui_state.activeScene_internalDontUse; -} -void gui_memoryOptimizer_setActiveSceneName(std::string aSceneName) { - gui_state.activeScene_internalDontUse = aSceneName; - set_activeScene(aSceneName); -} -std::string gui_memoryOptimizer_getActiveGUIname() { - gui_state.activeGUIname_internalDontUse = get_activeGUIname(); - return gui_state.activeGUIname_internalDontUse; -} -void gui_memoryOptimizer_setActiveGUIname(std::string aGUIname) { - gui_state.activeGUIname_internalDontUse = aGUIname; - set_activeGUIname(aGUIname); -} -GUIlists gui_memoryOptimizer_getActiveGUIlist() { - gui_state.activeGUIlist_internalDontUse = (GUIlists)get_activeGUIlist(); - return gui_state.activeGUIlist_internalDontUse; -} -void gui_memoryOptimizer_setActiveGUIlist(GUIlists aGUIlist) { - gui_state.activeGUIlist_internalDontUse = aGUIlist; - set_activeGUIlist(aGUIlist); -} -int gui_memoryOptimizer_getLastActiveGUIlistIndex() { - gui_state.last_active_gui_list_index_internalDontUse = get_lastActiveGUIlistIndex(); - return gui_state.last_active_gui_list_index_internalDontUse; -} -void gui_memoryOptimizer_setLastActiveGUIlistIndex(int aGUIlistIndex) { - gui_state.last_active_gui_list_index_internalDontUse = aGUIlistIndex; - set_lastActiveGUIlistIndex(aGUIlistIndex); -} - -int gui_memoryOptimizer_getActiveTabID() { - return gui_state.activeTabID; -} - -bool gui_memoryOptimizer_isTabIDInMemory(int tabID) { - // range check - if ((tabID < 0) || (tabID >= 3)) { - return false; - } - return (gui_state.gui_on_tab[tabID].gui_list_index != -1); -} - -bool gui_memoryOptimizer_isGUInameInMemory(std::string GUIname) { - for (uint8_t index=0; index <= 2; index++) { - if (gui_state.gui_on_tab[index].GUIname == GUIname) { - return true; - } - } - return false; -} - -void notify_active_tabs_before_delete(t_gui_state *gui_state) { - omote_log_d(" Will notify tabs about deletion\r\n"); - std::string nameOfTab; - for (int index=0; index <= 2; index++) { - if (gui_state->gui_on_tab[index].gui_list_index == -1) { - omote_log_d(" Will not notify tab %d about deletion because it does not exist\r\n", index); - continue; - } - - // For deletion, do not use the gui_list_index, but the name of the gui. - // The gui_list might have changed (when switching from a scene specific list to the main list or vice versa), so index could have changed as well. - nameOfTab = gui_state->gui_on_tab[index].GUIname; - if (nameOfTab == "") { - omote_log_w(" Will not notify tab %d about deletion because it is not set\r\n", index); - } else if (registered_guis_byName_map.count(nameOfTab) == 0) { - omote_log_w(" Can not notify tab %d about deletion because name \"%s\" was not found in registry\r\n", index, nameOfTab.c_str()); - } else { - omote_log_d(" Will notify tab %d with name \"%s\" about deletion\r\n", index, nameOfTab.c_str()); - registered_guis_byName_map.at(nameOfTab).this_notify_tab_before_delete(); - } - } -} - -void clear_tabview(lv_obj_t* tabview, t_gui_state *gui_state) { - if (tabview != NULL) { - // first remove events for the tabview - lv_obj_remove_event_cb(tabview, tabview_tab_changed_event_cb); - lv_obj_remove_event_cb(tabview, tabview_content_is_scrolling_event_cb); - // delete tabview - lv_obj_del(tabview); - tabview = NULL; - } - - // the gui_list_index_previous is needed for setGUIlistIndicesToBeShown_afterSlide(); - gui_state->gui_on_tab[0] = {NULL, "", -1, gui_state->gui_on_tab[0].gui_list_index}; - gui_state->gui_on_tab[1] = {NULL, "", -1, gui_state->gui_on_tab[1].gui_list_index}; - gui_state->gui_on_tab[2] = {NULL, "", -1, gui_state->gui_on_tab[2].gui_list_index}; - -} - -void clear_panel(lv_obj_t* panel, lv_obj_t* img1, lv_obj_t* img2) { - if (panel != NULL) { - lv_obj_del(panel); - panel = NULL; - } - if (img1 != NULL) { - lv_obj_del(img1); - img1 = NULL; - } - if (img2 != NULL) { - lv_obj_del(img2); - img2 = NULL; - } - -} - -lv_obj_t* create_tabview() { - // Setup a scrollable tabview for devices and settings ---------------------------------------------------- - lv_obj_t* tabview = lv_tabview_create(lv_scr_act(), LV_DIR_TOP, 0); // Hide tab labels by setting their height to 0 - #ifdef drawRedBorderAroundMainWidgets - lv_obj_add_style(tabview, &style_red_border, LV_PART_MAIN); - #endif - lv_obj_set_style_bg_color(tabview, lv_color_black(), LV_PART_MAIN); - lv_obj_set_size(tabview, SCR_WIDTH, tabviewHeight); - lv_obj_align(tabview, LV_ALIGN_TOP_MID, 0, tabviewTop); - return tabview; -} - -lv_obj_t* create_panel() { - // Create a page indicator at the bottom ------------------------------------------------------------------ - lv_obj_t* panel = lv_obj_create(lv_scr_act()); - lv_obj_clear_flag(panel, LV_OBJ_FLAG_CLICKABLE); // This indicator will not be clickable - lv_obj_clear_flag(panel, LV_OBJ_FLAG_SCROLLABLE); // This indicator will not be scrollable - lv_obj_set_size(panel, SCR_WIDTH, panelHeight); - lv_obj_set_flex_flow(panel, LV_FLEX_FLOW_ROW); - lv_obj_align(panel, LV_ALIGN_BOTTOM_MID, 0, 0); - lv_obj_set_scrollbar_mode(panel, LV_SCROLLBAR_MODE_OFF); - - return panel; -} - -std::string get_name_of_gui_to_be_shown(int index) { - if (index == -1) { - return ""; - } else if (index <= get_gui_list_active_withFallback()->size() -1) { - return get_gui_list_active_withFallback()->at(index); - } else { - return ""; - } -} - -void create_new_tab(lv_obj_t* tabview, t_gui_on_tab *gui_on_tab) { - std::string nameOfTab = get_name_of_gui_to_be_shown(gui_on_tab->gui_list_index); - - if (nameOfTab == "") { - omote_log_d(" Will not create new tab because no name was provided\r\n"); - } else if (registered_guis_byName_map.count(nameOfTab) == 0) { - omote_log_w(" Will not create new tab because name %s was not found in registry\r\n", nameOfTab.c_str()); - } else { - omote_log_d(" Will create tab with name \"%s\" \r\n", nameOfTab.c_str()); - // save name of tab for deletion later - gui_on_tab->GUIname = nameOfTab; - // create tab and save pointer to tab in gui_on_tab - gui_on_tab->tab = lv_tabview_add_tab(tabview, nameOfTab.c_str()); - // let the gui create it's content - registered_guis_byName_map.at(nameOfTab).this_create_tab_content(gui_on_tab->tab); - } -} - -// create up to three tabs and the content of the tabs -/* -example: gui_list: 0 1 2 3 4 -in memory active -0 1 -1 0 <- first state, special case - also the initial state -0 1 2 1 -1 2 3 1 -2 3 4 1 -3 4 -1 1 <- last state, special case -*/ -void setGUIlistIndicesToBeShown_forSpecificGUIlistIndex(int gui_list_index, t_gui_state *gui_state) { - // Set the gui_list_indeces to be shown for a specific gui_list_index - if (gui_list_index == 0) { - // first state - omote_log_d(" GUIlistIndices: will resume at specific index with \"first state\"\r\n"); - gui_state->gui_on_tab[0] = {NULL, "", 0}; - // take care if there is only one gui in list - gui_state->gui_on_tab[1] = {NULL, "", get_gui_list_active_withFallback()->size() >= 2 ? 1 : -1}; - gui_state->gui_on_tab[2] = {NULL, "", -1}; - gui_state->activeTabID = 0; - } else if (gui_list_index == get_gui_list_active_withFallback()->size() -1) { - // last state - omote_log_d(" GUIlistIndices: will resume at specific index with \"last state\"\r\n"); - gui_state->gui_on_tab[0] = {NULL, "", gui_list_index -1}; - gui_state->gui_on_tab[1] = {NULL, "", gui_list_index}; - gui_state->gui_on_tab[2] = {NULL, "", -1}; - gui_state->activeTabID = 1; - } else { - // any other state - omote_log_d(" GUIlistIndices: will resume at specific index with \"state between\"\r\n"); - gui_state->gui_on_tab[0] = {NULL, "", gui_list_index -1}; - gui_state->gui_on_tab[1] = {NULL, "", gui_list_index}; - gui_state->gui_on_tab[2] = {NULL, "", gui_list_index +1}; - gui_state->activeTabID = 1; - } -} - -void setGUIlistIndicesToBeShown_forFirstGUIinGUIlist(t_gui_state *gui_state) { - omote_log_d(" GUIlistIndices: will show the first gui from \"gui_list\" as initial state\r\n"); - // take care if there is no gui in list - gui_state->gui_on_tab[0] = {NULL, "", get_gui_list_active_withFallback()->size() != 0 ? 0 : -1}; - // take care if there is only one gui in list - gui_state->gui_on_tab[1] = {NULL, "", get_gui_list_active_withFallback()->size() >= 2 ? 1 : -1}; - gui_state->gui_on_tab[2] = {NULL, "", -1}; - gui_state->activeTabID = 0; -} - -void setGUIlistIndicesToBeShown_afterSlide(t_gui_state *gui_state) { - int oldListIndex = -1; - - if (gui_state->oldTabID > gui_state->activeTabID) { - // swipe to previous item in list - omote_log_d(" Will swipe to previous item in list\r\n"); - oldListIndex = gui_state->gui_on_tab[1].gui_list_index_previous; - if ((oldListIndex == 1)) { - // next state is the "first state" - gui_state->gui_on_tab[0] = {NULL, "", 0}; - gui_state->gui_on_tab[1] = {NULL, "", 1}; - gui_state->gui_on_tab[2] = {NULL, "", -1}; - gui_state->activeTabID = 0; - } else { - gui_state->gui_on_tab[0] = {NULL, "", oldListIndex -2}; - gui_state->gui_on_tab[1] = {NULL, "", oldListIndex -1}; - gui_state->gui_on_tab[2] = {NULL, "", oldListIndex}; - gui_state->activeTabID = 1; - } - } else { - // swipe to next item in list - omote_log_d(" Will swipe to next item in list\r\n"); - if (gui_state->gui_on_tab[2].gui_list_index_previous == -1) { - // last state was the first state - oldListIndex = gui_state->gui_on_tab[0].gui_list_index_previous; // is always 0 - } else { - oldListIndex = gui_state->gui_on_tab[1].gui_list_index_previous; - } - if (oldListIndex == get_gui_list_active_withFallback()->size() -2) { - // next state is the "last state" - gui_state->gui_on_tab[0] = {NULL, "", oldListIndex}; - gui_state->gui_on_tab[1] = {NULL, "", oldListIndex +1}; - gui_state->gui_on_tab[2] = {NULL, "", -1}; - gui_state->activeTabID = 1; - } else { - gui_state->gui_on_tab[0] = {NULL, "", oldListIndex}; - gui_state->gui_on_tab[1] = {NULL, "", oldListIndex +1}; - gui_state->gui_on_tab[2] = {NULL, "", oldListIndex +2}; - gui_state->activeTabID = 1; - } - } - -} - -void doTabCreation_strategyMax3(lv_obj_t* tabview, t_gui_state *gui_state) { - - // create the tabs - omote_log_d(" Will create tabs. List indices of the three tabs are %d, %d, %d, tab nr %d will be activated\r\n", gui_state->gui_on_tab[0].gui_list_index, gui_state->gui_on_tab[1].gui_list_index, gui_state->gui_on_tab[2].gui_list_index, gui_state->activeTabID); - for (int i=0; i<3; i++) { - create_new_tab(tabview, &gui_state->gui_on_tab[i]); - } - - if (get_gui_list_active_withFallback()->size() > 0) { - std::string nameOfNewActiveTab = get_gui_list_active_withFallback()->at(gui_state->gui_on_tab[gui_state->activeTabID].gui_list_index); - omote_log_d(" New visible tab is \"%s\"\r\n", nameOfNewActiveTab.c_str()); - - // set active tab - setActiveTab(gui_state->activeTabID, LV_ANIM_OFF); - gui_memoryOptimizer_setActiveGUIname(nameOfNewActiveTab); - } -} - -LV_IMG_DECLARE(gradientLeft); -LV_IMG_DECLARE(gradientRight); - -void fillPanelWithPageIndicator_strategyMax3(lv_obj_t* panel, lv_obj_t* img1, lv_obj_t* img2, t_gui_state *gui_state) { - omote_log_d(" Will fill panel with page indicators\r\n"); - - if (get_gui_list_active_withFallback()->size() == 0) { - omote_log_d(" no tab available, so no page indicators\r\n"); - // at least add the style - lv_obj_add_style(panel, &panel_style, 0); - #ifdef drawRedBorderAroundMainWidgets - lv_obj_add_style(panel, &style_red_border, LV_PART_MAIN); - #endif - return; - } - - // This small hidden button enables the page indicator to scroll further - lv_obj_t* btn = lv_btn_create(panel); - lv_obj_set_size(btn, 50, lv_pct(100)); - lv_obj_set_style_shadow_width(btn, 0, LV_PART_MAIN); - lv_obj_set_style_opa(btn, LV_OPA_TRANSP, LV_PART_MAIN); - -/* - There needs to be two more screen indicators because of their different size (158 for page indicator, 240 for whole tab) - In some cases they need to have color black, if they are before the first tab or after the last tab. - In all other cases, they have color "color_primary". See this list: - example: gui_list: 0 1 2 3 4 - in memory color active - 0 1 -1 b p p p 0 <- first state, special case - also the initial state - 0 1 2 b p p p p 1 - 1 2 3 p p p p p 1 - 2 3 4 p p p p b 1 - 3 4 -1 p p p b 1 <- last state, special case -*/ - // first page indicator before the first tab - btn = lv_btn_create(panel); - lv_obj_clear_flag(btn, LV_OBJ_FLAG_CLICKABLE); - lv_obj_set_size(btn, 150, lv_pct(100)); - if (gui_state->gui_on_tab[0].gui_list_index == 0) { - lv_obj_set_style_bg_color(btn, lv_color_black(), LV_PART_MAIN); - } else { - lv_obj_set_style_bg_color(btn, color_primary, LV_PART_MAIN); - } - - uint8_t breadcrumpDotSize = 8; // should be an even number - uint8_t breadcrumpDotDistance = 2; // should be an even number - uint8_t breadcrumpMainGuiListLength = get_gui_list_withFallback(MAIN_GUI_LIST)->size(); - int8_t breadcrumpMainGuiListStartPositionX = (-1) * (breadcrumpMainGuiListLength -1) * (breadcrumpDotSize + breadcrumpDotDistance) / 2; - uint8_t breadcrumpSceneGuiListLength = get_gui_list_withFallback(SCENE_GUI_LIST)->size(); - int8_t breadcrumpSceneGuiListStartPositionX = (-1) * (breadcrumpSceneGuiListLength -1) * (breadcrumpDotSize + breadcrumpDotDistance) / 2; - #if (USE_SCENE_SPECIFIC_GUI_LIST != 0) - bool show_scene_gui_list = get_scene_has_gui_list(gui_memoryOptimizer_getActiveSceneName()); - #else - bool show_scene_gui_list = false; - #endif - int8_t breadcrumpMainGuiList_yPos; - int8_t breadcrumpSceneGuiList_yPos; - int8_t nameOfGUI_yPos; - if (!show_scene_gui_list) { - breadcrumpMainGuiList_yPos = -6; - nameOfGUI_yPos = 6; - } else { - breadcrumpMainGuiList_yPos = -8; - breadcrumpSceneGuiList_yPos = -1; - nameOfGUI_yPos = 8; - } - - // create the panel content for the three guis (or less) which are currently in memory - std::string nameOfGUI; - uint8_t breadcrumpPosition; - for (int i=0; i<3; i++) { - if (gui_state->gui_on_tab[i].gui_list_index != -1) { - nameOfGUI = gui_state->gui_on_tab[i].GUIname; - breadcrumpPosition = gui_state->gui_on_tab[i].gui_list_index +1; - - // Create actual buttons for every tab - lv_obj_t* btn = lv_btn_create(panel); - if (i == gui_state->activeTabID) { - // only if this is the button for the currently active tab, make it clickable to get to scene selection gui - lv_obj_add_flag(btn, LV_OBJ_FLAG_CLICKABLE); - lv_obj_set_user_data(btn,(void *)(intptr_t)2); - lv_obj_add_event_cb(btn, sceneLabel_or_pageIndicator_event_cb, LV_EVENT_CLICKED, NULL); - - } else if ((i==0 || i==1) && (gui_state->gui_on_tab[i+1].gui_list_index != -1)) { - // this is the button on the previous tab, which can be seen on the active tab - // activate click to prev tab - lv_obj_add_flag(btn, LV_OBJ_FLAG_CLICKABLE); - lv_obj_set_user_data(btn,(void *)(intptr_t)0); - lv_obj_add_event_cb(btn, pageIndicator_navigate_event_cb, LV_EVENT_CLICKED, NULL); - - } else if (i==1 || i==2) { - // this is the button on the next tab, which can be seen on the active tab - // activate click to next tab - lv_obj_add_flag(btn, LV_OBJ_FLAG_CLICKABLE); - lv_obj_set_user_data(btn,(void *)(intptr_t)1); - lv_obj_add_event_cb(btn, pageIndicator_navigate_event_cb, LV_EVENT_CLICKED, NULL); - - } - lv_obj_set_size(btn, 150, lv_pct(100)); - lv_obj_remove_style(btn, NULL, LV_STATE_PRESSED); - lv_obj_set_style_shadow_width(btn, 0, LV_PART_MAIN); - lv_obj_set_style_bg_color(btn, color_primary, LV_PART_MAIN); - - // create a breadcrump dot for each gui in the main_gui_list - for (int j=0; jgui_on_tab[2].gui_list_index == get_gui_list_active_withFallback()->size()-1) || (gui_state->gui_on_tab[1].gui_list_index == get_gui_list_active_withFallback()->size()-1) || (gui_state->gui_on_tab[1].gui_list_index == -1)) { - lv_obj_set_style_bg_color(btn, lv_color_black(), LV_PART_MAIN); - } else { - lv_obj_set_style_bg_color(btn, color_primary, LV_PART_MAIN); - } - - // This small hidden button enables the page indicator to scroll further - btn = lv_btn_create(panel); - lv_obj_set_size(btn, 50, lv_pct(100)); - lv_obj_set_style_shadow_width(btn, 0, LV_PART_MAIN); - lv_obj_set_style_opa(btn, LV_OPA_TRANSP, LV_PART_MAIN); - - // creation of style was moved to init_gui(void) - // otherwise repeated calls of lv_style_init will lead to a memory leak of about 46 bytes each time - // https://docs.lvgl.io/8.3/overview/style.html?highlight=lv_style_t#initialize-styles-and-set-get-properties - lv_obj_add_style(panel, &panel_style, 0); - #ifdef drawRedBorderAroundMainWidgets - lv_obj_add_style(panel, &style_red_border, LV_PART_MAIN); - #endif - - // Make the indicator fade out at the sides using gradient bitmaps - // Bitmaps are above the buttons and labels - // don't create it here - // img1 = lv_img_create(lv_scr_act()); - lv_img_set_src(img1, &gradientLeft); - lv_obj_align(img1, LV_ALIGN_BOTTOM_LEFT, 0, 0); - lv_obj_set_size(img1, panelHeight, panelHeight); // stretch the 1-pixel high image to 30px - #ifdef drawRedBorderAroundMainWidgets - lv_obj_add_style(img1, &style_red_border, LV_PART_MAIN); - #endif - // don't create it here - // img2 = lv_img_create(lv_scr_act()); - lv_img_set_src(img2, &gradientRight); - lv_obj_align(img2, LV_ALIGN_BOTTOM_RIGHT, 0, 0); - lv_obj_set_size(img2, panelHeight, panelHeight); - #ifdef drawRedBorderAroundMainWidgets - lv_obj_add_style(img2, &style_red_border, LV_PART_MAIN); - #endif - -} - -void gui_memoryOptimizer_notifyAndClear(lv_obj_t** tabview, lv_obj_t** panel, lv_obj_t** img1, lv_obj_t** img2, t_gui_state *gui_state) { - - // 1. notify old guis that they will be deleted so that they can persist their state if needed - notify_active_tabs_before_delete(gui_state); - // 2. clear current tabview and save gui_list_index_previous (needed for swipe) - clear_tabview(*tabview, gui_state); - // 3. clear current panel for page indicator - clear_panel(*panel, *img1, *img2); - -} - -void gui_memoryOptimizer_doContentCreation(lv_obj_t** tabview, lv_obj_t** panel, lv_obj_t** img1, lv_obj_t** img2, t_gui_state *gui_state); - -// 1. tab creation on startup (called by init_gui()) -// find the position of the current GUI in the gui list which was active last (both were automatically saved in the preferences) -void gui_memoryOptimizer_onStartup(lv_obj_t** tabview, lv_obj_t** panel, lv_obj_t** img1, lv_obj_t** img2) { - - omote_log_i("Startup: try to resume at scene \"%s\" with GUI \"%s\"\r\n", gui_memoryOptimizer_getActiveSceneName().c_str(), gui_memoryOptimizer_getActiveGUIname().c_str()); - - // Get last state from preferences and save it in gui_state - // So it is ok to call them without using the return values. - gui_memoryOptimizer_getActiveSceneName(); - gui_memoryOptimizer_getActiveGUIname(); - gui_memoryOptimizer_getActiveGUIlist(); - gui_memoryOptimizer_getLastActiveGUIlistIndex(); - - // 1. find last used gui - int gui_list_index = -1; - // find index of gui_memoryOptimizer_getActiveGUIname() in gui_list_active - for (int i=0; isize(); i++) { - if (get_gui_list_active_withFallback()->at(i) == gui_memoryOptimizer_getActiveGUIname()) { - omote_log_i("Startup: found GUI with name \"%s\" in \"gui_list_active\" at position %d\r\n", gui_memoryOptimizer_getActiveGUIname().c_str(), i); - gui_list_index = i; - break; - } - } - - // 2. set gui_list_indices and the tab to be activated - if ((gui_list_index >= 0) && (gui_list_index < get_gui_list_active_withFallback()->size())) { - // gui was found - setGUIlistIndicesToBeShown_forSpecificGUIlistIndex(gui_list_index, &gui_state); - - } else { - // gui was not found - omote_log_w("Startup: GUI with name \"%s\" was not found. Will start with first GUI of main_gui_list\r\n", gui_memoryOptimizer_getActiveGUIname().c_str()); - gui_memoryOptimizer_setActiveGUIlist(MAIN_GUI_LIST); - setGUIlistIndicesToBeShown_forFirstGUIinGUIlist(&gui_state); - - } - - // 3. create content - gui_memoryOptimizer_doContentCreation(tabview, panel, img1, img2, &gui_state); - -} - -// 2. tab creation after sliding (called by tabview_tab_changed_event_cb()) -void gui_memoryOptimizer_afterSliding(lv_obj_t** tabview, lv_obj_t** panel, lv_obj_t** img1, lv_obj_t** img2, int newTabID) { - - // Here the magic for dynamic creation and deletion of lvgl objects happens to keep memory usage low. - // The next and previous tab must always be available in the tabview, because they can already been seen during the animation. - // And you always need 3 tabs, otherwise you even could not slide to the next or previous tab. - // So we always have 3 tabs. - // After the animation, the tabview and hence all tabs are deleted and recreated. - - omote_log_d("--- Start of tab deletion and creation\r\n"); - - gui_state.oldTabID = gui_state.activeTabID; - gui_state.activeTabID = newTabID; - - omote_log_d("Changing from oldTabID %d \"%s\" to newTabID %d \"%s\"\r\n", - gui_state.oldTabID, gui_state.gui_on_tab[gui_state.oldTabID].GUIname.c_str(), - gui_state.activeTabID, gui_state.gui_on_tab[gui_state.activeTabID].GUIname.c_str()); - - // 1. notify old guis and clear tabview and panel - gui_memoryOptimizer_notifyAndClear(tabview, panel, img1, img2, &gui_state); - - // only optional: delete and create the whole screen. Not necessary. - // Only used for a test. init_gui_status_bar() would need to be called again at a suitable place, because the status bar would also be deleted. - // lv_obj_t* oldscr = lv_scr_act(); - // // create new screen - // lv_obj_t* newscr = lv_obj_create(NULL); - // // load this new screen - // lv_scr_load(newscr); - // lv_obj_del(oldscr); - - // 2. set gui_list_indices and the tab to be activated - setGUIlistIndicesToBeShown_afterSlide(&gui_state); - - // 3. create content - gui_memoryOptimizer_doContentCreation(tabview, panel, img1, img2, &gui_state); - -} - -// 3. after gui list has changed (called by handleScene()), when switching between main_gui_list and scene specific list. Will show first GUi in list -void gui_memoryOptimizer_afterGUIlistChanged(lv_obj_t** tabview, lv_obj_t** panel, lv_obj_t** img1, lv_obj_t** img2, GUIlists newGUIlist) { - - omote_log_d("--- Will change to new gui_list\r\n"); - - if (gui_state.last_active_gui_list != newGUIlist) { - // we are changing the gui_list, so save the last_active_gui_list_index - gui_memoryOptimizer_setLastActiveGUIlistIndex(gui_state.gui_on_tab[gui_state.activeTabID].gui_list_index); - } - - // 1. notify old guis and clear tabview and panel - gui_memoryOptimizer_notifyAndClear(tabview, panel, img1, img2, &gui_state); - - // 2. set gui_list_indices and the tab to be activated - gui_memoryOptimizer_setActiveGUIlist(newGUIlist); - setGUIlistIndicesToBeShown_forFirstGUIinGUIlist(&gui_state); - - // 3. create content - gui_memoryOptimizer_doContentCreation(tabview, panel, img1, img2, &gui_state); - -} - -// 4. navigate to a specific GUI in gui_list -void gui_memoryOptimizer_navigateToGUI(lv_obj_t** tabview, lv_obj_t** panel, lv_obj_t** img1, lv_obj_t** img2, GUIlists GUIlist, int gui_list_index) { - - omote_log_d("--- Will navigate to specific GUI\r\n"); - - if ( !((gui_list_index >= 0) && (gui_list_index < get_gui_list_withFallback(GUIlist)->size()))) { - omote_log_w(" cannot navigate to GUI because gui_list_index \"%d\" is out of range\r\n", gui_list_index); - return; - } - - if (gui_state.last_active_gui_list != GUIlist) { - // we are changing the gui_list, so save the last_active_gui_list_index - gui_memoryOptimizer_setLastActiveGUIlistIndex(gui_state.gui_on_tab[gui_state.activeTabID].gui_list_index); - } - - // 1. notify old guis and clear tabview and panel - gui_memoryOptimizer_notifyAndClear(tabview, panel, img1, img2, &gui_state); - - // 2. set gui_list_indices and the tab to be activated - gui_memoryOptimizer_setActiveGUIlist(GUIlist); - setGUIlistIndicesToBeShown_forSpecificGUIlistIndex(gui_list_index, &gui_state); - - // 3. create content - gui_memoryOptimizer_doContentCreation(tabview, panel, img1, img2, &gui_state); - -} - -// 5. navigate back to last gui in scene -void gui_memoryOptimizer_navigateToLastActiveGUIofPreviousGUIlist(lv_obj_t** tabview, lv_obj_t** panel, lv_obj_t** img1, lv_obj_t** img2) { - - #if (USE_SCENE_SPECIFIC_GUI_LIST == 0) - omote_log_w("--- Cannot navigate to last GUI from scene, because scene specific gui lists are not enabled\r\n"); - return; - #endif - - if (gui_memoryOptimizer_getLastActiveGUIlistIndex() == -1) { - omote_log_w("--- Cannot navigate to last GUI from scene, because it is not set\r\n"); - return; - } else { - omote_log_d("--- Will navigate to last GUI from scene\r\n"); - } - - // navigate to the other gui_list - if (gui_memoryOptimizer_getActiveGUIlist() == MAIN_GUI_LIST) { - gui_memoryOptimizer_navigateToGUI(tabview, panel, img1, img2, SCENE_GUI_LIST, gui_memoryOptimizer_getLastActiveGUIlistIndex()); - } else { - gui_memoryOptimizer_navigateToGUI(tabview, panel, img1, img2, MAIN_GUI_LIST, gui_memoryOptimizer_getLastActiveGUIlistIndex()); - } - -} - - -void gui_memoryOptimizer_doContentCreation(lv_obj_t** tabview, lv_obj_t** panel, lv_obj_t** img1, lv_obj_t** img2, t_gui_state *gui_state) { - // recreate the tabview - lv_obj_t* newTabview = create_tabview(); - *tabview = newTabview; - - // Create the tabs. Use strategy "3 tabs at maximum" to keep memory usage low. - // Set the tab we swiped to as active - doTabCreation_strategyMax3(*tabview, gui_state); - - // Create the panel for the page indicator. Panel itself takes about 2136 bytes for three tabs. - lv_obj_t* newPanel = create_panel(); - *panel = newPanel; - *img1 = lv_img_create(lv_scr_act()); - *img2 = lv_img_create(lv_scr_act()); - fillPanelWithPageIndicator_strategyMax3(*panel, *img1, *img2, gui_state); - - // now, as the correct tab is active, register again the events for the tabview - lv_obj_add_event_cb(*tabview, tabview_tab_changed_event_cb, LV_EVENT_VALUE_CHANGED, NULL); - lv_obj_add_event_cb(lv_tabview_get_content(*tabview), tabview_content_is_scrolling_event_cb, LV_EVENT_SCROLL, NULL); - // Initialize scroll position of the page indicator - lv_event_send(lv_tabview_get_content(*tabview), LV_EVENT_SCROLL, NULL); - - // gui_memoryOptimizer_doContentCreation() is called as last step every time the 3 tabs are recreated. - // Save here the last_active_gui_list. If the used list changes in a future navigation, save the last_active_gui_list_index - // so that we can use SCENE_BACK_TO_PREVIOUS_GUI_LIST - gui_state->last_active_gui_list = gui_memoryOptimizer_getActiveGUIlist(); - - omote_log_d("------------ End of tab deletion and creation\r\n"); - -} diff --git a/Platformio/src/applicationInternal/gui/guiMemoryOptimizer.h b/Platformio/src/applicationInternal/gui/guiMemoryOptimizer.h deleted file mode 100644 index f163c546..00000000 --- a/Platformio/src/applicationInternal/gui/guiMemoryOptimizer.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once -#include -#include - -enum GUIlists { -// MAIN_GUI_LIST: we are in the main_gui_list (with the scene selector as first gui), either if a scene is active or not -// SCENE_GUI_LIST: a scene is active and we are not in the main_gui_list. In that case, we try to use the scene specific gui list, if the scene defined one. - MAIN_GUI_LIST, - SCENE_GUI_LIST -}; - -void gui_memoryOptimizer_onStartup(lv_obj_t** tabview, lv_obj_t** panel, lv_obj_t** img1, lv_obj_t** img2); -void gui_memoryOptimizer_afterSliding(lv_obj_t** tabview, lv_obj_t** panel, lv_obj_t** img1, lv_obj_t** img2, int newTabID); -void gui_memoryOptimizer_afterGUIlistChanged(lv_obj_t** tabview, lv_obj_t** panel, lv_obj_t** img1, lv_obj_t** img2, GUIlists newGUIlist); -void gui_memoryOptimizer_navigateToGUI(lv_obj_t** tabview, lv_obj_t** panel, lv_obj_t** img1, lv_obj_t** img2, GUIlists GUIlist, int gui_list_index); -void gui_memoryOptimizer_navigateToLastActiveGUIofPreviousGUIlist(lv_obj_t** tabview, lv_obj_t** panel, lv_obj_t** img1, lv_obj_t** img2); - -int gui_memoryOptimizer_getActiveTabID(); -bool gui_memoryOptimizer_isTabIDInMemory(int tabID); -bool gui_memoryOptimizer_isGUInameInMemory(std::string GUIname); - -std::string gui_memoryOptimizer_getActiveSceneName(); -void gui_memoryOptimizer_setActiveSceneName(std::string aSceneName); -std::string gui_memoryOptimizer_getActiveGUIname(); -void gui_memoryOptimizer_setActiveGUIname(std::string aGUIname); -GUIlists gui_memoryOptimizer_getActiveGUIlist(); -void gui_memoryOptimizer_setActiveGUIlist(GUIlists aGUIlist); - diff --git a/Platformio/src/applicationInternal/gui/guiRegistry.cpp b/Platformio/src/applicationInternal/gui/guiRegistry.cpp deleted file mode 100644 index 51b06db8..00000000 --- a/Platformio/src/applicationInternal/gui/guiRegistry.cpp +++ /dev/null @@ -1,73 +0,0 @@ -#include -#include -#include -#include -#include -#include "guiRegistry.h" -#include "applicationInternal/gui/guiBase.h" -#include "applicationInternal/hardware/hardwarePresenter.h" -#include "applicationInternal/scenes/sceneRegistry.h" -#include "applicationInternal/omote_log.h" -#include "scenes/scene__default.h" - -// ------------------------------------------------------------------------------------ -// this is a map of the registered_guis that can be accessed by name -std::map registered_guis_byName_map; - -// ------------------------------------------------------------------------------------ - - -void register_gui( - std::string a_name, - create_tab_content a_create_tab_content, - notify_tab_before_delete a_notify_tab_before_delete, - gui_setKeys a_gui_setKeys, - key_repeatModes a_key_repeatModes, - key_commands_short a_key_commands_short, - key_commands_long a_key_commands_long - ) { - - if (registered_guis_byName_map.count(a_name) > 0) { - omote_log_e("ERROR!!!: you cannot register two guis having the same name '%s'\r\n", a_name.c_str()); - return; - } - - gui_definition new_gui_definition = gui_definition{ - a_name, - a_create_tab_content, - a_notify_tab_before_delete, - a_gui_setKeys, - a_key_repeatModes, - a_key_commands_short, - a_key_commands_long - }; - - // put the gui_definition in a map that can be accessed by name - registered_guis_byName_map[a_name] = new_gui_definition; - - // By default, put all registered guis in the sequence of guis to be shown of the default scene - // Can be overwritten by scenes to have their own gui_list. - main_gui_list.insert(main_gui_list.end(), {std::string(a_name)}); - - setKeysForAllRegisteredGUIsAndScenes(); - -} - -void setKeysForAllRegisteredGUIsAndScenes() { - // Whenever a new gui or scene is registered, a new gui or scene command could have been defined in the gui or scene. - // But this new command could have already been used before in the key definition of another gui or scene. The command at this time was 0, which is undefined. - // So we have to set the keys again for all guis and scenes that have been registered before. - // 1. set again the defaultKeys - register_scene_defaultKeys(); - // 2. loop over all registered scenes and call setKeys() - for (std::map::iterator it = registered_scenes.begin(); it != registered_scenes.end(); ++it) { - it->second.this_scene_setKeys(); - } - // 3. loop over all registered guis and call setKeys() - for (std::map::iterator it = registered_guis_byName_map.begin(); it != registered_guis_byName_map.end(); ++it) { - if (it->second.this_gui_setKeys != NULL) { - it->second.this_gui_setKeys(); - } - } - -} diff --git a/Platformio/src/applicationInternal/gui/guiRegistry.h b/Platformio/src/applicationInternal/gui/guiRegistry.h deleted file mode 100644 index 26b81a68..00000000 --- a/Platformio/src/applicationInternal/gui/guiRegistry.h +++ /dev/null @@ -1,54 +0,0 @@ -#pragma once - -/* - If you want to create a new GUI (tab in terms of lvgl) for the touch screen, then - - copy one of the existing GUIs, e.g. gui_numpad.cpp and gui_numpad.h - - place the files in the right folder: - - in folder "gui_general_and_keys" if they are of general purpose, not only for a specific device - - in the device folder, if the GUI is specific for a certain device - - in folder "scenes" if the GUI is intended for a specific scene - It does not really matter where the files are placed, but doing so helps to keep a clean structure - - rename the functions, they must not have the same name as the ones in the file you copied from - - call "register_gui_();" in main.cpp - - register_gui(std::string(tabName), & create_tab_content_settings, & notify_tab_before_delete_settings); - - Technically spoken, to register a GUI, you need to provide several function pointers: - - one for creating the content of the tab - - one to persist the state of the gui before it will be deleted, if needed - - and the name of the tab -*/ -#include -#include -#include -#include -#include "applicationInternal/keys.h" - -typedef void (*create_tab_content)(lv_obj_t* tab); -typedef void (*notify_tab_before_delete)(void); -typedef void (*gui_setKeys)(void); - -// https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work -struct gui_definition { - std::string this_name; - create_tab_content this_create_tab_content; - notify_tab_before_delete this_notify_tab_before_delete; - gui_setKeys this_gui_setKeys; - key_repeatModes this_key_repeatModes; - key_commands_short this_key_commands_short; - key_commands_long this_key_commands_long; -}; - -extern std::map registered_guis_byName_map; - -void register_gui( - std::string a_name, - create_tab_content a_create_tab_content, - notify_tab_before_delete a_notify_tab_before_delete, - gui_setKeys a_gui_setKeys = NULL, - key_repeatModes a_key_repeatModes = NULL, - key_commands_short a_key_commands_short = NULL, - key_commands_long a_key_commands_long = NULL - ); - -void setKeysForAllRegisteredGUIsAndScenes(); \ No newline at end of file diff --git a/Platformio/src/applicationInternal/gui/guiStatusUpdate.cpp b/Platformio/src/applicationInternal/gui/guiStatusUpdate.cpp deleted file mode 100644 index e7c7408c..00000000 --- a/Platformio/src/applicationInternal/gui/guiStatusUpdate.cpp +++ /dev/null @@ -1,93 +0,0 @@ -#include -#include "applicationInternal/hardware/hardwarePresenter.h" -#include "applicationInternal/memoryUsage.h" -#include "guis/gui_settings.h" -#include "applicationInternal/gui/guiBase.h" - -// --- regularly update hardware values and update GUI, used by "main.cpp" ---- -void updateBatteryStatusOnGUI() { - int battery_voltage; - int battery_percentage; - bool battery_ischarging; - get_battery_status(&battery_voltage, &battery_percentage, &battery_ischarging); - - char buffer1[20]; - sprintf(buffer1, "Voltage: %.2f V", (float)battery_voltage / 1000); - - // GUI settings - if (objBattSettingsVoltage != NULL) {lv_label_set_text_fmt(objBattSettingsVoltage, "%s", buffer1);} - if (objBattSettingsPercentage != NULL) {lv_label_set_text_fmt(objBattSettingsPercentage, "Percentage: %d%%", battery_percentage);} - //lv_label_set_text_fmt(objBattSettingsIscharging, "Is charging: %s", battery_ischarging ? "yes" : "no"); - - // GUI status bar at the top - char buffer2[12]; - // Voltage and percentage - // sprintf(buffer2, "%.1fV, %d%%", (float)getBatteryVoltage() / 1000, battery_percentage); - // only percentage - sprintf(buffer2, "%d%%", battery_percentage); - for (int i=0; i= 4) - if (battery_ischarging /*|| (!battery_ischarging && getBatteryVoltage() > 4350)*/){ - // if (BattPercentageLabel != NULL) {lv_label_set_text(BattPercentageLabel, "");} - // lv_label_set_text_fmt(BattPercentageLabel, "%d%%", battery_percentage); - // lv_label_set_text_fmt(BattPercentageLabel, "%.1f, %d%%", (float)getBatteryVoltage() / 1000, battery_percentage); - if (BattPercentageLabel != NULL) {lv_label_set_text(BattPercentageLabel, buffer2);} - if (BattIconLabel != NULL) {lv_label_set_text(BattIconLabel, LV_SYMBOL_USB);} - } else - #endif - { - // Update status bar battery indicator - // lv_label_set_text_fmt(BattPercentageLabel, "%.1f, %d%%", (float)getBatteryVoltage() / 1000, battery_percentage); - if (BattPercentageLabel != NULL) {lv_label_set_text(BattPercentageLabel, buffer2);} - if (BattIconLabel != NULL) { - if(battery_percentage > 95) lv_label_set_text(BattIconLabel, LV_SYMBOL_BATTERY_FULL); - else if(battery_percentage > 75) lv_label_set_text(BattIconLabel, LV_SYMBOL_BATTERY_3); - else if(battery_percentage > 50) lv_label_set_text(BattIconLabel, LV_SYMBOL_BATTERY_2); - else if(battery_percentage > 25) lv_label_set_text(BattIconLabel, LV_SYMBOL_BATTERY_1); - else lv_label_set_text(BattIconLabel, LV_SYMBOL_BATTERY_EMPTY); - } - } - -} - -#if (ENABLE_KEYBOARD_BLE == 1) -// if bluetooth is in pairing mode (pairing mode is always on, if not connected), but not connected, then blink -bool blinkBluetoothLabelIsOn = false; -void updateKeyboardBLEstatusOnGUI() { - if (!keyboardBLE_isConnected()) { - blinkBluetoothLabelIsOn = !blinkBluetoothLabelIsOn; - if (blinkBluetoothLabelIsOn) { - if (BluetoothLabel != NULL) {lv_label_set_text(BluetoothLabel, LV_SYMBOL_BLUETOOTH);} - } else { - if (BluetoothLabel != NULL) {lv_label_set_text(BluetoothLabel, "");} - } - } else { - if (!blinkBluetoothLabelIsOn) { - blinkBluetoothLabelIsOn = true; - if (BluetoothLabel != NULL) {lv_label_set_text(BluetoothLabel, LV_SYMBOL_BLUETOOTH);} - } - } -} -#endif - -// update user_led, battery, BLE, memoryUsage on GUI -void updateHardwareStatusAndShowOnGUI(void) { - - update_userled(); - - updateBatteryStatusOnGUI(); - #if (ENABLE_BLUETOOTH == 1) - // adjust this if you implement other bluetooth devices than the BLE keyboard - #if (ENABLE_KEYBOARD_BLE == 1) - updateKeyboardBLEstatusOnGUI(); - #endif - #endif - - doLogMemoryUsage(); - -} diff --git a/Platformio/src/applicationInternal/gui/guiStatusUpdate.h b/Platformio/src/applicationInternal/gui/guiStatusUpdate.h deleted file mode 100644 index b7679b02..00000000 --- a/Platformio/src/applicationInternal/gui/guiStatusUpdate.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -void updateHardwareStatusAndShowOnGUI(void); diff --git a/Platformio/src/applicationInternal/hardware/arduinoLayer.cpp b/Platformio/src/applicationInternal/hardware/arduinoLayer.cpp deleted file mode 100644 index 1fd97c13..00000000 --- a/Platformio/src/applicationInternal/hardware/arduinoLayer.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#if defined(WIN32) || defined(__linux__) - -#include "applicationInternal/hardware/arduinoLayer.h" -#include -#include -#include -//#include "sdl/sdl.h" - -long long current_timestamp() { - struct timeval te; - gettimeofday(&te, NULL); // get current time - long long milliseconds = te.tv_sec*1000LL + te.tv_usec/1000; // calculate milliseconds - // printf("milliseconds: %lld\r\n", milliseconds); - return milliseconds; -} - -void delay(uint32_t ms) { - // we don't use this blackbox - // SDL_Delay(ms); - unsigned long startTimer = millis(); - while ((millis() - startTimer) < ms) { - } -} - -// we have to simulate millis() -// the first call sets firstTimestampAtProgramstart and is the reference from that on -bool millisAlreadyInitialized = false; -long long firstTimestampAtProgramstart = 0; -unsigned long millis() { - unsigned long res; - if (!millisAlreadyInitialized) { - firstTimestampAtProgramstart = current_timestamp(); - millisAlreadyInitialized = true; - res = 0; - } else { - res = current_timestamp() - firstTimestampAtProgramstart; - } - // printf("millis(): %lu\r\n", res); - return res; -} - -SerialClass Serial; -void SerialClass::begin(unsigned long) { - // Serial.begin is one of the first methods called in main.cpp - // So we use this to initialize the timer - unsigned long dummy = millis(); -} - -size_t SerialClass::printf(const char * format, ...) { - // see how they are doing it in lv_log.c - va_list args; - va_start(args, format); - int ret = vprintf(format, args); - va_end(args); - return ret; -} - -size_t SerialClass::println(const char c[]) { - return printf("%s\r\n", c); -} - -size_t SerialClass::println(int nr) { - return printf("%d\r\n", nr); -} - -#endif \ No newline at end of file diff --git a/Platformio/src/applicationInternal/hardware/arduinoLayer.h b/Platformio/src/applicationInternal/hardware/arduinoLayer.h deleted file mode 100644 index 1ca5b464..00000000 --- a/Platformio/src/applicationInternal/hardware/arduinoLayer.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#include - -#if defined(ARDUINO) - // for env:esp32 we need "Arduino.h" e.g. for Serial, delay(), millis() - #include - -#elif defined(WIN32) || defined(__linux__) - #include - // For Windows and Linux there is no Arduino framework available. So we have to simulate at least those very few calls to Arduino functions which are left in the code. - // Note: Of course there is a lot more Arduino code in folder "hardware/ESP32/*", but this code is only active in case of esp32, so we don't have to simulate this in the Arduino layer if Windows/Linux is active. - void delay(uint32_t ms); - unsigned long millis(); - class SerialClass { - public: - void begin(unsigned long); - size_t printf(const char * format, ...) __attribute__ ((format (printf, 2, 3))); - size_t println(const char c[]); - size_t println(int nr); - }; - extern SerialClass Serial; - -#endif diff --git a/Platformio/src/applicationInternal/hardware/hardwarePresenter.cpp b/Platformio/src/applicationInternal/hardware/hardwarePresenter.cpp deleted file mode 100644 index d2f4e124..00000000 --- a/Platformio/src/applicationInternal/hardware/hardwarePresenter.cpp +++ /dev/null @@ -1,208 +0,0 @@ -#include -#include -#include "applicationInternal/hardware/hardwarePresenter.h" -// for registering the callback to show received IR messages -#include "guis/gui_irReceiver.h" -// for registering the callback to receive MQTT messages -#include "../commandHandler.h" -// for registering the callback to show WiFi status -#include "applicationInternal/gui/guiBase.h" - -// This include of "hardwareLayer.h" is the one and only link to folder "hardware". The file "hardwareLayer.h" does the differentiation between ESP32 and Windows/Linux. -// "hardwareLayer.h" includes all the other hardware header files as well. So everything from all hardware header files is available here - and only here. -// This include has to be here in "hardwarePresenter.cpp" and not in "hardwarePresenter.h". Otherwise the whole rest of the code would have access to the hardware too. -// The rest of the code is only allowed to use "hardwarePresenter.h". -#include "hardwareLayer.h" - -// --- hardware general ------------------------------------------------------- -void init_hardware_general(void) { - init_hardware_general_HAL(); -} - -// --- preferences ------------------------------------------------------------ -void init_preferences(void) { - init_preferences_HAL(); -}; -void save_preferences(void) { - save_preferences_HAL(); -}; -std::string get_activeScene() { - return get_activeScene_HAL(); -} -void set_activeScene(std::string anActiveScene) { - set_activeScene_HAL(anActiveScene); -} -std::string get_activeGUIname() { - return get_activeGUIname_HAL(); -} -void set_activeGUIname(std::string anActiveGUIname) { - set_activeGUIname_HAL(anActiveGUIname); -} -int get_activeGUIlist() { - return get_activeGUIlist_HAL(); -} -void set_activeGUIlist(int anActiveGUIlist) { - set_activeGUIlist_HAL(anActiveGUIlist); -} -int get_lastActiveGUIlistIndex() { - return get_lastActiveGUIlistIndex_HAL(); -} -void set_lastActiveGUIlistIndex(int aGUIlistIndex) { - set_lastActiveGUIlistIndex_HAL(aGUIlistIndex); -} - -// --- user led --------------------------------------------------------------- -void init_userled(void) { - init_userled_HAL(); -} -void update_userled() { - update_userled_HAL(); -} - -// --- battery ---------------------------------------------------------------- -void init_battery(void) { - init_battery_HAL(); -} -void get_battery_status(int *battery_voltage, int *battery_percentage, bool *battery_ischarging) { - get_battery_status_HAL(battery_voltage, battery_percentage, battery_ischarging); -} - -// --- sleep / IMU ------------------------------------------------------------ -void init_sleep() { - init_sleep_HAL(); -}; -void init_IMU() { - init_IMU_HAL(); -}; -void check_activity() { - check_activity_HAL(); -}; -void setLastActivityTimestamp() { - setLastActivityTimestamp_HAL(); -}; -uint32_t get_sleepTimeout() { - return get_sleepTimeout_HAL(); -} -void set_sleepTimeout(uint32_t aSleepTimeout) { - set_sleepTimeout_HAL(aSleepTimeout); -} -bool get_wakeupByIMUEnabled() { - return get_wakeupByIMUEnabled_HAL(); -} -void set_wakeupByIMUEnabled(bool aWakeupByIMUEnabled) { - set_wakeupByIMUEnabled_HAL(aWakeupByIMUEnabled); -} - -// --- keypad ----------------------------------------------------------------- -void init_keys(void) { - init_keys_HAL(); -} -keypad_key keypad_keys[keypad_maxkeys]; -void getKeys(keypad_key *keys) { - keys_getKeys_HAL(keys); -} - -// --- IR sender -------------------------------------------------------------- -void init_infraredSender(void) { - init_infraredSender_HAL(); -} -void sendIRcode(IRprotocols protocol, std::list commandPayloads, std::string additionalPayload) { - sendIRcode_HAL(protocol, commandPayloads, additionalPayload); -} - -// --- IR receiver ------------------------------------------------------------ -void start_infraredReceiver(void) { - start_infraredReceiver_HAL(); -}; -void shutdown_infraredReceiver(void) { - shutdown_infraredReceiver_HAL(); -}; -void infraredReceiver_loop(void) { - infraredReceiver_loop_HAL(); -}; -bool get_irReceiverEnabled() { - return get_irReceiverEnabled_HAL(); -} -void set_irReceiverEnabled(bool aIrReceiverEnabled) { - if (aIrReceiverEnabled) { - set_announceNewIRmessage_cb_HAL(&receiveNewIRmessage_cb); - } else { - set_announceNewIRmessage_cb_HAL(NULL); - } - set_irReceiverEnabled_HAL(aIrReceiverEnabled); -} - -// --- BLE keyboard ----------------------------------------------------------- -#if (ENABLE_KEYBOARD_BLE == 1) -void init_keyboardBLE() { - init_keyboardBLE_HAL(); -} -// used by "device_keyboard_ble.cpp", "sleep.cpp" -bool keyboardBLE_isConnected() { - return keyboardBLE_isConnected_HAL(); -} -void keyboardBLE_end() { - keyboardBLE_end_HAL(); -} -void keyboardBLE_write(uint8_t c) { - keyboardBLE_write_HAL(c); -} -void keyboardBLE_longpress(uint8_t c) { - keyboardBLE_longpress_HAL(c); -} -void keyboardBLE_home() { - keyboardBLE_home_HAL(); -} -void keyboardBLE_sendString(const std::string &s) { - keyboardBLE_sendString_HAL(s); -} -void consumerControlBLE_write(const MediaKeyReport value) { - consumerControlBLE_write_HAL(value); -} -void consumerControlBLE_longpress(const MediaKeyReport value) { - consumerControlBLE_longpress_HAL(value); -} -#endif - -// --- tft -------------------------------------------------------------------- -void update_backligthBrighness(void) { - update_backligthBrighness_HAL(); -}; -uint8_t get_backlightBrightness() { - return get_backlightBrightness_HAL(); -} -void set_backlightBrightness(uint8_t aBacklightBrightness){ - set_backlightBrightness_HAL(aBacklightBrightness); -} - -// --- lvgl ------------------------------------------------------------------- -void init_lvgl_hardware() { - init_lvgl_HAL(); -}; - -// --- WiFi / MQTT ------------------------------------------------------------ -#if (ENABLE_WIFI_AND_MQTT == 1) -void init_mqtt(void) { - set_announceWiFiconnected_cb_HAL(&receiveWiFiConnected_cb); - set_announceSubscribedTopics_cb_HAL(receiveMQTTmessage_cb); - init_mqtt_HAL(); -} -// used by "commandHandler.cpp", "sleep.cpp" -bool getIsWifiConnected() { - return getIsWifiConnected_HAL(); -} -void mqtt_loop() { - mqtt_loop_HAL(); -} -bool publishMQTTMessage(const char *topic, const char *payload) { - return publishMQTTMessage_HAL(topic, payload); -} -void wifiStop() { - wifiStop_HAL(); -} -#endif - -// --- memory usage ----------------------------------------------------------- -void get_heapUsage(unsigned long *heapSize, unsigned long *freeHeap, unsigned long *maxAllocHeap, unsigned long *minFreeHeap) { - get_heapUsage_HAL(heapSize, freeHeap, maxAllocHeap, minFreeHeap); -} diff --git a/Platformio/src/applicationInternal/hardware/hardwarePresenter.h b/Platformio/src/applicationInternal/hardware/hardwarePresenter.h deleted file mode 100644 index 144eff95..00000000 --- a/Platformio/src/applicationInternal/hardware/hardwarePresenter.h +++ /dev/null @@ -1,122 +0,0 @@ -#pragma once - -#include -#include -#include "applicationInternal/hardware/arduinoLayer.h" - -// --- hardware general ------------------------------------------------------- -void init_hardware_general(void); - -// --- preferences ------------------------------------------------------------ -void init_preferences(void); -void save_preferences(void); -std::string get_activeScene(); -void set_activeScene(std::string anActiveScene); -std::string get_activeGUIname(); -void set_activeGUIname(std::string anActiveGUIname); -int get_activeGUIlist(); -void set_activeGUIlist(int anActiveGUIlist); -int get_lastActiveGUIlistIndex(); -void set_lastActiveGUIlistIndex(int aGUIlistIndex); - -// --- user led --------------------------------------------------------------- -void init_userled(void); -void update_userled(); - -// --- battery ---------------------------------------------------------------- -void init_battery(void); -void get_battery_status(int *battery_voltage, int *battery_percentage, bool *battery_ischarging); - -// --- sleep / IMU ------------------------------------------------------------ -void init_sleep(); -void init_IMU(); -void check_activity(); -void setLastActivityTimestamp(); -uint32_t get_sleepTimeout(); -void set_sleepTimeout(uint32_t aSleepTimeout); -bool get_wakeupByIMUEnabled(); -void set_wakeupByIMUEnabled(bool aWakeupByIMUEnabled); - -// --- keypad ----------------------------------------------------------------- -void init_keys(void); -enum keypad_keyStates {IDLE, PRESSED, HOLD, RELEASED}; -struct keypad_key { - char kchar; - int kcode; - keypad_keyStates kstate; - bool stateChanged; -}; -const uint8_t keypad_maxkeys = 10; -extern keypad_key keypad_keys[keypad_maxkeys]; -void getKeys(keypad_key *keypad_keys); - -// --- IR sender -------------------------------------------------------------- -void init_infraredSender(void); -enum IRprotocols { - IR_PROTOCOL_GC = 0, - IR_PROTOCOL_NEC = 1, - IR_PROTOCOL_SAMSUNG = 2, - IR_PROTOCOL_SONY = 3, - IR_PROTOCOL_RC5 = 4, - IR_PROTOCOL_DENON = 5, - IR_PROTOCOL_SAMSUNG36 = 6 -}; -void sendIRcode(IRprotocols protocol, std::list commandPayloads, std::string additionalPayload); - -// --- IR receiver ------------------------------------------------------------ -void start_infraredReceiver(void); -void shutdown_infraredReceiver(void); -void infraredReceiver_loop(void); -bool get_irReceiverEnabled(); -void set_irReceiverEnabled(bool aIrReceiverEnabled); - -// --- BLE keyboard ----------------------------------------------------------- -#if (ENABLE_KEYBOARD_BLE == 1) -void init_keyboardBLE(); -// used by "device_keyboard_ble.cpp", "sleep.cpp" -typedef uint8_t MediaKeyReport[2]; -const uint8_t BLE_KEY_UP_ARROW = 0xDA; -const uint8_t BLE_KEY_DOWN_ARROW = 0xD9; -const uint8_t BLE_KEY_RIGHT_ARROW = 0xD7; -const uint8_t BLE_KEY_LEFT_ARROW = 0xD8; -const uint8_t BLE_KEY_RETURN = 0xB0; -const MediaKeyReport BLE_KEY_MEDIA_WWW_BACK = {0, 32}; -const MediaKeyReport BLE_KEY_MEDIA_WWW_HOME = {128, 0}; -const MediaKeyReport BLE_KEY_MEDIA_PREVIOUS_TRACK = {2, 0}; -const MediaKeyReport BLE_KEY_MEDIA_REWIND = {0, 128}; -const MediaKeyReport BLE_KEY_MEDIA_PLAY_PAUSE = {8, 0}; -const MediaKeyReport BLE_KEY_MEDIA_FASTFORWARD = {0, 2}; -const MediaKeyReport BLE_KEY_MEDIA_NEXT_TRACK = {1, 0}; -const MediaKeyReport BLE_KEY_MEDIA_MUTE = {16, 0}; -const MediaKeyReport BLE_KEY_MEDIA_VOLUME_UP = {32, 0}; -const MediaKeyReport BLE_KEY_MEDIA_VOLUME_DOWN = {64, 0}; -bool keyboardBLE_isConnected(); -void keyboardBLE_end(); -void keyboardBLE_write(uint8_t c); -void keyboardBLE_longpress(uint8_t c); -void keyboardBLE_home(); -void keyboardBLE_sendString(const std::string &s); -void consumerControlBLE_write(const MediaKeyReport value); -void consumerControlBLE_longpress(const MediaKeyReport value); -#endif - -// --- tft -------------------------------------------------------------------- -void update_backligthBrighness(void); -uint8_t get_backlightBrightness(); -void set_backlightBrightness(uint8_t aBacklightBrightness); - -// --- lvgl ------------------------------------------------------------------- -void init_lvgl_hardware(); - -// --- WiFi / MQTT ------------------------------------------------------------ -#if (ENABLE_WIFI_AND_MQTT == 1) -void init_mqtt(void); -// used by "commandHandler.cpp", "sleep.cpp" -bool getIsWifiConnected(); -void mqtt_loop(); -bool publishMQTTMessage(const char *topic, const char *payload); -void wifiStop(); -#endif - -// --- memory usage ----------------------------------------------------------- -void get_heapUsage(unsigned long *heapSize, unsigned long *freeHeap, unsigned long *maxAllocHeap, unsigned long *minFreeHeap); diff --git a/Platformio/src/applicationInternal/keys.cpp b/Platformio/src/applicationInternal/keys.cpp deleted file mode 100644 index 422a2719..00000000 --- a/Platformio/src/applicationInternal/keys.cpp +++ /dev/null @@ -1,123 +0,0 @@ -#include -#include "applicationInternal/gui/guiMemoryOptimizer.h" -#include "applicationInternal/hardware/hardwarePresenter.h" -#include "applicationInternal/scenes/sceneRegistry.h" -#include "applicationInternal/commandHandler.h" -#include "applicationInternal/omote_log.h" - -const uint8_t ROWS = 5; //five rows -const uint8_t COLS = 5; //five columns -keypad_keyStates lastKeyState[ROWS][COLS] = { - {IDLE,IDLE,IDLE,IDLE,IDLE}, - {IDLE,IDLE,IDLE,IDLE,IDLE}, - {IDLE,IDLE,IDLE,IDLE,IDLE}, - {IDLE,IDLE,IDLE,IDLE,IDLE}, - {IDLE,IDLE,IDLE,IDLE,IDLE}, -}; -unsigned long lastTimeSent[ROWS][COLS] ={ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, -}; -bool keyIsHold[ROWS][COLS] = { - {false,false,false,false,false}, - {false,false,false,false,false}, - {false,false,false,false,false}, - {false,false,false,false,false}, - {false,false,false,false,false} -}; -int repeatRate = 125; // in milliseconds - -void doShortPress(char keyChar, int keyCode){ - unsigned long currentMillis = millis(); - if ((currentMillis - lastTimeSent[keyCode/ROWS][keyCode%ROWS]) > repeatRate) { - lastTimeSent[keyCode/ROWS][keyCode%ROWS] = currentMillis; - - uint16_t command = get_command_short(gui_memoryOptimizer_getActiveSceneName(), keyChar); - if (command != COMMAND_UNKNOWN) { - omote_log_d("key: key '%c', will use command '%u'\r\n", keyChar, command); - executeCommand(command); - } else { - omote_log_w("key: key '%c', but no command defined\r\n", keyChar); - } - } -} - -void doLongPress(char keyChar, int keyCode){ - uint16_t command = get_command_long(gui_memoryOptimizer_getActiveSceneName(), keyChar); - if (command != COMMAND_UNKNOWN) { - omote_log_d("key: key '%c' (long press), will use command '%u'\r\n", keyChar, command); - executeCommand(command); - } else { - omote_log_w("key: key '%c' (long press), but no command defined\r\n", keyChar); - } -} - -void keypad_loop(void) { - // we have to ignore the result, because in case of SINGLE_REPEATED we want to send the command again and again, but the keypad would give us only one single HOLD state, not repeatedly - getKeys(keypad_keys); - - for(int i=0; i < keypad_maxkeys; i++) { - if (!keypad_keys[i].stateChanged) { - // we are not allowed to do this, because of the same reason as above - // continue; - } else { - setLastActivityTimestamp(); // Reset the sleep timer when a button is pressed - } - char keyChar = keypad_keys[i].kchar; - int keyCode = keypad_keys[i].kcode; - - if (keypad_keys[i].kstate == PRESSED) { - omote_log_v("pressed\r\n"); - - if ((get_key_repeatMode(gui_memoryOptimizer_getActiveSceneName(), keyChar) == SHORT) && (lastKeyState[keyCode/ROWS][keyCode%ROWS] != PRESSED)) { - omote_log_v("key: PRESSED of SHORT key %c (%d)\r\n", keyChar, keyCode); - doShortPress(keyChar, keyCode); - - } else if ((get_key_repeatMode(gui_memoryOptimizer_getActiveSceneName(), keyChar) == SHORT_REPEATED) && (lastKeyState[keyCode/ROWS][keyCode%ROWS] != PRESSED)) { // here do not repeat it too early, do the repeat only in HOLD - omote_log_v("key: PRESSED of SHORT_REPEATED key %c (%d)\r\n", keyChar, keyCode); - doShortPress(keyChar, keyCode); - - } - lastKeyState[keyCode/ROWS][keyCode%ROWS] = PRESSED; - - } else if (keypad_keys[i].kstate == HOLD) { - omote_log_v("hold\r\n"); - - if ((get_key_repeatMode(gui_memoryOptimizer_getActiveSceneName(), keyChar) == SHORTorLONG) && (lastKeyState[keyCode/ROWS][keyCode%ROWS] != HOLD)) { - omote_log_v("key: HOLD of SHORTorLONG key %c (%d)\r\n", keyChar, keyCode); - omote_log_v("will set keyIsHold to TRUE for keycode %d\r\n", keyCode); - keyIsHold[keyCode/ROWS][keyCode%ROWS] = true; - doLongPress(keyChar, keyCode); - - } else if (get_key_repeatMode(gui_memoryOptimizer_getActiveSceneName(), keyChar) == SHORT_REPEATED) { // this is the only case where we do not check the lastKeyState, because here it is intended to repeat the action - omote_log_v("key: HOLD of SHORT_REPEATED key %c (%d)\r\n", keyChar, keyCode); - doShortPress(keyChar, keyCode); - - } - lastKeyState[keyCode/ROWS][keyCode%ROWS] = HOLD; - - } else if (keypad_keys[i].kstate == RELEASED) { - omote_log_v("released\r\n"); - if ((get_key_repeatMode(gui_memoryOptimizer_getActiveSceneName(), keyChar) == SHORTorLONG) && !keyIsHold[keyCode/ROWS][keyCode%ROWS] && (lastKeyState[keyCode/ROWS][keyCode%ROWS] != RELEASED)) { - omote_log_v("value of keyIsHold for keycode %d is %d\r\n", keyCode, keyIsHold[keyCode/ROWS][keyCode%ROWS]); - omote_log_v("key: RELEASED of SHORTorLONG key %c (%d)\r\n", keyChar, keyCode); - doShortPress(keyChar, keyCode); - } - omote_log_v("will set keyIsHold to FALSE for keycode %d\r\n", keyCode); - keyIsHold[keyCode/ROWS][keyCode%ROWS] = false; - - omote_log_v("key: press of key %c (%d)\r\n", keyChar, keyCode); - lastKeyState[keyCode/ROWS][keyCode%ROWS] = RELEASED; - - } else if (keypad_keys[i].kstate == IDLE) { - omote_log_v("idle\r\n"); - - omote_log_v("key: idle of key %c (%d)\r\n", keyChar, keyCode); - lastKeyState[keyCode/ROWS][keyCode%ROWS] = IDLE; - - } - } -} diff --git a/Platformio/src/applicationInternal/keys.h b/Platformio/src/applicationInternal/keys.h deleted file mode 100644 index f2004f57..00000000 --- a/Platformio/src/applicationInternal/keys.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#include -#include - -enum repeatModes { - // only as fallback - REPEAT_MODE_UNKNOWN, - // if you short press or hold a key on the keypad, only one single command from keyCommands_short is sent - // -> best used if you do not want a command to be sent more than once, even if you press the key (too) long, e.g. when toggling power - SHORT, - // if you hold a key on the keypad, a command from keyCommands_short is sent repeatedly - // -> best used e.g. for holding the key for "volume up" - SHORT_REPEATED, - // if you short press a key, a command from keyCommands_short is sent once. - // if you hold a key on the keypad, a command from keyCommands_long is sent (no command from keyCommands_short before) - // -> best used if a long key press should send a different command than a short press - SHORTorLONG, -}; - -typedef std::map *key_repeatModes; -typedef std::map *key_commands_short; -typedef std::map *key_commands_long; - -void keypad_loop(void); diff --git a/Platformio/src/applicationInternal/memoryUsage.cpp b/Platformio/src/applicationInternal/memoryUsage.cpp deleted file mode 100644 index 8f02da42..00000000 --- a/Platformio/src/applicationInternal/memoryUsage.cpp +++ /dev/null @@ -1,128 +0,0 @@ -#include -#include "applicationInternal/gui/guiBase.h" -#include "applicationInternal/hardware/hardwarePresenter.h" -#include "applicationInternal/omote_log.h" - -bool showMemoryUsage = 0; - -#if LV_MEM_CUSTOM == 0 -lv_mem_monitor_t mon; -#endif - -static unsigned long updateSerialLogTimer = 0; - -bool getShowMemoryUsage() { - return showMemoryUsage; -} -// forward declaration -void doLogMemoryUsage(); -void setShowMemoryUsage(bool aShowMemoryUsage) { - showMemoryUsage = aShowMemoryUsage; - showMemoryUsageBar(showMemoryUsage); - doLogMemoryUsage(); -} - -void doLogMemoryUsage() { - omote_log_v("inside doLogMemoryUsage\r\n"); - unsigned long systemHeapSize; - unsigned long freeSystemHeap; - unsigned long maxAllocSystemHeap; - unsigned long minfreeSystemHeap; - get_heapUsage(&systemHeapSize, &freeSystemHeap, &maxAllocSystemHeap, &minfreeSystemHeap); - - int thresholdForESP32HeapFreeWarning; // in bytes free in heap - #if (ENABLE_WIFI_AND_MQTT == 1) && (ENABLE_BLUETOOTH == 1) - thresholdForESP32HeapFreeWarning = 15000; - #elif ENABLE_WIFI_AND_MQTT == 1 - thresholdForESP32HeapFreeWarning = 11000; - #elif ENABLE_BLUETOOTH == 1 - thresholdForESP32HeapFreeWarning = 5000; - #elif ENABLE_WIFI_AND_MQTT == 1 - thresholdForESP32HeapFreeWarning = 5000; - #endif - bool doESPHeapWarning = (freeSystemHeap < thresholdForESP32HeapFreeWarning); - - bool doLVGLMemoryWarning = false; - #if LV_MEM_CUSTOM == 0 - int thresholdForLVGLmemoryFreeWarning = 20; // in percentage free - lv_mem_monitor(&mon); - doLVGLMemoryWarning = ((100 - mon.used_pct) < thresholdForLVGLmemoryFreeWarning); - #endif - - #if defined(SHOW_LOG_ON_SERIAL) - // Serial log every 5 sec - if(millis() - updateSerialLogTimer >= 5000) { - omote_log_v("inside doLogMemoryUsage: will do serial log\r\n"); - updateSerialLogTimer = millis(); - - if (doESPHeapWarning) { - omote_log_w("WARNING: ESP heap is getting low. You might encounter weird behaviour of your OMOTE, especially when using WiFi and/or BLE.\r\n"); - } - omote_log_d( - "ESP32 heap: size: %6lu, used: %6lu (%2.0f%%), free: %6lu (%2.0f%%), heapMax: %6lu, heapMin: %6lu\r\n", - systemHeapSize, - systemHeapSize - freeSystemHeap, float(systemHeapSize - freeSystemHeap) / systemHeapSize * 100, - freeSystemHeap, float(freeSystemHeap) / systemHeapSize * 100, - maxAllocSystemHeap, minfreeSystemHeap); - - #if LV_MEM_CUSTOM == 0 - if (doLVGLMemoryWarning) { - omote_log_w("WARNING: LVGL memory is getting low. You GUI might stop working. In that case, increase \"-D LV_MEM_SIZE\" in platformio.ini\r\n"); - } - omote_log_d( - "lvgl memory: size: %6lu, used: %6lu (%2d%%), free: %6lu (%2d%%), max_used: %6lu, free_biggest: %6lu, frag_pct: %2d%%\r\n", - mon.total_size, - mon.total_size - mon.free_size, mon.used_pct, - mon.free_size, 100-mon.used_pct, - mon.max_used, mon.free_biggest_size, mon.frag_pct); - #endif - } else { - omote_log_v("inside doLogMemoryUsage: serial log skipped\r\n"); - } - #endif - - if (showMemoryUsage) { - char buffer[80]; - std::string ESP32HeapWarnBegin = "#00ff00 "; // green - std::string ESP32HeapWarnEnd = "#"; - std::string LVGLMemorWarnBegin = "#00ff00 "; // green - std::string LVGLMemorWarnEnd = "#"; - if (doESPHeapWarning) { - ESP32HeapWarnBegin = "#ff0000 "; // red - ESP32HeapWarnEnd = "#"; - } - if (doLVGLMemoryWarning) { - LVGLMemorWarnBegin = "#ff0000 "; // red - LVGLMemorWarnEnd = "#"; - } - #if LV_MEM_CUSTOM != 0 - #ifdef SHOW_USED_MEMORY_INSTEAD_OF_FREE_IN_GUI - - sprintf(buffer, ESP32HeapWarnBegin.append("%lu/%lu (%.0f%%)").append(ESP32HeapWarnEnd).c_str() , systemHeapSize-freeSystemHeap, systemHeapSize, float(systemHeapSize-freeSystemHeap) / systemHeapSize * 100); - #else - sprintf(buffer, ESP32HeapWarnBegin.append("%lu/%lu (%.0f%%)").append(ESP32HeapWarnEnd).c_str() , freeSystemHeap, systemHeapSize, float(freeSystemHeap) / systemHeapSize * 100); - #endif - #else - #ifdef SHOW_USED_MEMORY_INSTEAD_OF_FREE_IN_GUI - sprintf(buffer, ESP32HeapWarnBegin.append("%lu/%lu (%.0f%%)").append(ESP32HeapWarnEnd).append(" / ").append(LVGLMemorWarnBegin).append("%lu/%lu (%d%%)").append(LVGLMemorWarnEnd).c_str(), systemHeapSize-freeSystemHeap, systemHeapSize, float(systemHeapSize-freeSystemHeap) / systemHeapSize * 100, mon.total_size - mon.free_size, mon.total_size, mon.used_pct); - #else - sprintf(buffer, ESP32HeapWarnBegin.append("%lu/%lu (%.0f%%)").append(ESP32HeapWarnEnd).append(" / ").append(LVGLMemorWarnBegin).append("%lu/%lu (%d%%)").append(LVGLMemorWarnEnd).c_str(), freeSystemHeap, systemHeapSize, float(freeSystemHeap) / systemHeapSize * 100, mon.free_size, mon.total_size, 100-mon.used_pct); - #endif - #endif - - for (int i=0; i= OMOTE_LOG_LEVEL_VERBOSE -#define omote_log_v(format, ...) Serial.printf(OMOTE_LOG_FORMAT(V, format), ##__VA_ARGS__) -#else -#define omote_log_v(format, ...) do {} while(0) -#endif - -#if OMOTE_LOG_LEVEL >= OMOTE_LOG_LEVEL_DEBUG -#define omote_log_d(format, ...) Serial.printf(OMOTE_LOG_FORMAT(D, format), ##__VA_ARGS__) -#else -#define omote_log_d(format, ...) do {} while(0) -#endif - -#if OMOTE_LOG_LEVEL >= OMOTE_LOG_LEVEL_INFO -#define omote_log_i(format, ...) Serial.printf(OMOTE_LOG_FORMAT(I, format), ##__VA_ARGS__) -#else -#define omote_log_i(format, ...) do {} while(0) -#endif - -#if OMOTE_LOG_LEVEL >= OMOTE_LOG_LEVEL_WARN -#define omote_log_w(format, ...) Serial.printf(OMOTE_LOG_FORMAT(W, format), ##__VA_ARGS__) -#else -#define omote_log_w(format, ...) do {} while(0) -#endif - -#if OMOTE_LOG_LEVEL >= OMOTE_LOG_LEVEL_ERROR -#define omote_log_e(format, ...) Serial.printf(OMOTE_LOG_FORMAT(E, format), ##__VA_ARGS__) -#else -#define omote_log_e(format, ...) do {} while(0) -#endif - -#if OMOTE_LOG_LEVEL >= OMOTE_LOG_LEVEL_NONE -#define omote_log_n(format, ...) Serial.printf(OMOTE_LOG_FORMAT(E, format), ##__VA_ARGS__) -#else -#define omote_log_n(format, ...) do {} while(0) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* __OMOTE_LOG_H__ */ diff --git a/Platformio/src/applicationInternal/scenes/sceneHandler.cpp b/Platformio/src/applicationInternal/scenes/sceneHandler.cpp deleted file mode 100644 index 64f468f4..00000000 --- a/Platformio/src/applicationInternal/scenes/sceneHandler.cpp +++ /dev/null @@ -1,166 +0,0 @@ -#include -#include -#include "applicationInternal/gui/guiBase.h" -#include "applicationInternal/gui/guiMemoryOptimizer.h" -#include "applicationInternal/scenes/sceneRegistry.h" -#include "applicationInternal/hardware/hardwarePresenter.h" -#include "applicationInternal/commandHandler.h" -#include "applicationInternal/omote_log.h" -#include "guis/gui_sceneSelection.h" -#include "scenes/scene__default.h" - -void setLabelActiveScene() { - if ((SceneLabel != NULL) && sceneExists(gui_memoryOptimizer_getActiveSceneName())) { - lv_label_set_text(SceneLabel, gui_memoryOptimizer_getActiveSceneName().c_str()); - } -} - -void showSpecificGUI(GUIlists GUIlist, std::string GUIname); - -void handleScene(uint16_t command, commandData commandData, std::string additionalPayload = "") { - - auto current = commandData.commandPayloads.begin(); - std::string scene_name = *current; - - // --- do not switch scene, but show scene selection gui. From that on, we are in the main_gui_list. ---------------- - if (scene_name == scene_name_selection) { - omote_log_d("scene: will show scene selection gui\r\n"); - showSpecificGUI(MAIN_GUI_LIST, tabName_sceneSelection); - return; - } - - // --- do not switch scene, but navigate to the prev or next gui in the currently active list of guis --------------- - if ((scene_name == scene_gui_next) || (scene_name == scene_gui_prev)) { - if (scene_name == scene_gui_prev) { - if (gui_memoryOptimizer_getActiveTabID() == 0) { - omote_log_d("scene: cannot navigate to prev gui, because there is none\r\n"); - } else { - omote_log_d("scene: will navigate to prev gui\r\n"); - setActiveTab(gui_memoryOptimizer_getActiveTabID() -1, LV_ANIM_ON, true); - } - - } else if (scene_name == scene_gui_next) { - if (!gui_memoryOptimizer_isTabIDInMemory(gui_memoryOptimizer_getActiveTabID() +1)) { - omote_log_d("scene: cannot navigate to next gui, because there is none\r\n"); - } else { - omote_log_d("scene: will navigate to next gui\r\n"); - setActiveTab(gui_memoryOptimizer_getActiveTabID() +1, LV_ANIM_ON, true); - } - - } - return; - } - - // --- do not switch scene. Switch to the other gui list ------------------------------------------------------------ - if (scene_name == scene_back_to_previous_gui_list) { - - if (get_scene_has_gui_list(gui_memoryOptimizer_getActiveSceneName())) { - omote_log_d("scene: will navigate back to last active gui from previous gui list\r\n"); - guis_doTabCreationForNavigateToLastActiveGUIofPreviousGUIlist(); - } else { - omote_log_d("scene: cannot navigate back to last active gui from previous gui list, because no scene specific gui list was defined\r\n"); - } - - return; - } - - // --- This is the normal case. We navigate to a new scene ---------------------------------------------------------- - - // FORCE can be either as second payload in commandData - // e.g. register_command(&SCENE_TV_FORCE , makeCommandData(SCENE, {scene_name_TV, "FORCE"})); - // or as additionalPayload, used by gui_sceneSelection.cpp - // e.g. executeCommand(activate_scene_command, "FORCE"); - - // we can have a second payload - std::string isForcePayload = ""; - ++current; - if (current != commandData.commandPayloads.end()) { - isForcePayload = *current; - } - - // check if we know the new scene - if (!sceneExists(scene_name)) { - omote_log_w("scene: cannot start scene %s, because it is unknown\r\n", scene_name.c_str()); - return; - } else { - omote_log_d("scene: will switch from old scene %s to new scene %s\r\n", gui_memoryOptimizer_getActiveSceneName().c_str(), scene_name.c_str()); - } - - // do not activate the same scene again, only when forced to do so (e.g. by long press on the gui or when selected by hardware key) - bool callEndAndStartSequences; - if ((scene_name == gui_memoryOptimizer_getActiveSceneName()) && ((isForcePayload != "FORCE") && (additionalPayload != "FORCE"))) { - omote_log_d("scene: will not start scene again, because it is already active\r\n"); - callEndAndStartSequences = false; - } else if ((scene_name == gui_memoryOptimizer_getActiveSceneName()) && ((isForcePayload == "FORCE") || (additionalPayload == "FORCE"))) { - omote_log_d("scene: scene is already active, but FORCE was set, so start scene again\r\n"); - callEndAndStartSequences = true; - } else { - // this is the default when switching to a different scene - callEndAndStartSequences = true; - } - - if (SceneLabel != NULL) {lv_label_set_text(SceneLabel, "changing...");} - gui_loop(); - - if (callEndAndStartSequences) { - // end old scene - if (!sceneExists(gui_memoryOptimizer_getActiveSceneName()) && (gui_memoryOptimizer_getActiveSceneName() != "")) { - omote_log_w("scene: WARNING: cannot end scene %s, because it is unknown\r\n", gui_memoryOptimizer_getActiveSceneName().c_str()); - - } else { - if (gui_memoryOptimizer_getActiveSceneName() != "") { - omote_log_d("scene: will call end sequence for scene %s\r\n", gui_memoryOptimizer_getActiveSceneName().c_str()); - scene_end_sequence_from_registry(gui_memoryOptimizer_getActiveSceneName()); - } - - } - - // start new scene - omote_log_d("scene: will call start sequence for scene %s\r\n", scene_name.c_str()); - scene_start_sequence_from_registry(scene_name); - } - - gui_memoryOptimizer_setActiveSceneName(scene_name); - - if (SceneLabel != NULL) {lv_label_set_text(SceneLabel, gui_memoryOptimizer_getActiveSceneName().c_str());} - - omote_log_d("scene: scene handling finished, new scene %s is active\r\n", gui_memoryOptimizer_getActiveSceneName().c_str()); - - guis_doTabCreationAfterGUIlistChanged(SCENE_GUI_LIST); -} - -void showSpecificGUI(GUIlists GUIlist, std::string GUIname) { - gui_list gui_list_for_search = get_gui_list_withFallback(GUIlist); - - // 1. search for gui in the gui list - int gui_list_index = -1; - for (int i=0; i < gui_list_for_search->size(); i++) { - if (gui_list_for_search->at(i) == GUIname) { - omote_log_d("showSpecificGUI: found GUI with name \"%s\" in %s at position %d\r\n", GUIname.c_str(), GUIlist == MAIN_GUI_LIST ? "\"main_gui_list\"" : "\"scene gui list\"", i); - gui_list_index = i; - break; - } - } - - // 2. call guiBase.cpp - if ((gui_list_index >= 0) && (gui_list_index < gui_list_for_search->size())) { - guis_doTabCreationForSpecificGUI(GUIlist, gui_list_index); - - } else { - // gui was not found - omote_log_w("showSpecificGUI: GUI with name \"%s\" was not found in gui list %s. Cannot navigate to that GUI\r\n", GUIname.c_str(), GUIlist == MAIN_GUI_LIST ? "\"main_gui_list\"" : "\"scene gui list\""); - return; - } -} - -void handleGUI(uint16_t command, commandData commandData, std::string additionalPayload = "") { - - auto current = commandData.commandPayloads.begin(); - GUIlists GUIlist = (GUIlists)std::stoi(*current); - - current = std::next(current, 1); - std::string GUIname = *current; - - showSpecificGUI(GUIlist, GUIname); - -} diff --git a/Platformio/src/applicationInternal/scenes/sceneHandler.h b/Platformio/src/applicationInternal/scenes/sceneHandler.h deleted file mode 100644 index 5aba73db..00000000 --- a/Platformio/src/applicationInternal/scenes/sceneHandler.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#include -#include "applicationInternal/commandHandler.h" - -void setLabelActiveScene(); -void handleScene(uint16_t command, commandData commandData, std::string additionalPayload = ""); -void handleGUI (uint16_t command, commandData commandData, std::string additionalPayload = ""); diff --git a/Platformio/src/applicationInternal/scenes/sceneRegistry.cpp b/Platformio/src/applicationInternal/scenes/sceneRegistry.cpp deleted file mode 100644 index 7fecf660..00000000 --- a/Platformio/src/applicationInternal/scenes/sceneRegistry.cpp +++ /dev/null @@ -1,267 +0,0 @@ -#include -#include -#include "applicationInternal/gui/guiMemoryOptimizer.h" -#include "applicationInternal/gui/guiRegistry.h" -#include "applicationInternal/hardware/hardwarePresenter.h" -#include "applicationInternal/scenes/sceneRegistry.h" -#include "applicationInternal/commandHandler.h" -#include "applicationInternal/omote_log.h" -// scenes -#include "scenes/scene__default.h" - -std::map registered_scenes; -t_scene_list scenes_on_sceneSelectionGUI; - -void register_scene( - std::string a_scene_name, - scene_setKeys a_scene_setKeys, - scene_start_sequence a_scene_start_sequence, - scene_end_sequence a_scene_end_sequence, - key_repeatModes a_key_repeatModes, - key_commands_short a_key_commands_short, - key_commands_long a_key_commands_long, - gui_list a_gui_list, - uint16_t a_activate_scene_command) { - - // put the scene_definition in a map that can be accessed by name - registered_scenes[a_scene_name] = scene_definition{ - a_scene_setKeys, - a_scene_start_sequence, - a_scene_end_sequence, - a_key_repeatModes, - a_key_commands_short, - a_key_commands_long, - a_gui_list, - a_activate_scene_command - }; - - // Additionally, put all registered scenes in a sequence of scenes to be shown in the sceneSelection gui. - // Exactly in the order they have been registered. - // Can be overwritten in main.cpp - scenes_on_sceneSelectionGUI.insert(scenes_on_sceneSelectionGUI.end(), {std::string(a_scene_name)}); - - setKeysForAllRegisteredGUIsAndScenes(); - -} - -bool sceneExists(std::string sceneName) { - return (registered_scenes.count(sceneName) > 0); -} - -void scene_start_sequence_from_registry(std::string sceneName) { - try { - registered_scenes.at(sceneName).this_scene_start_sequence(); - } - catch (const std::out_of_range& oor) { - omote_log_e("scene_start_sequence_from_registry: internal error, sceneName not registered\r\n"); - } -} - -void scene_end_sequence_from_registry(std::string sceneName) { - try { - registered_scenes.at(sceneName).this_scene_end_sequence(); - } - catch (const std::out_of_range& oor) { - omote_log_e("scene_end_sequence_from_registry: internal error, sceneName not registered\r\n"); - } -} - -repeatModes get_key_repeatMode(std::string sceneName, char keyChar) { - try { - // look if the map of the active gui has a definition for it - std::string GUIname = gui_memoryOptimizer_getActiveGUIname(); - if ((registered_guis_byName_map.count(GUIname) > 0) && (registered_guis_byName_map.at(GUIname).this_key_repeatModes != NULL) && (registered_guis_byName_map.at(GUIname).this_key_repeatModes->count(keyChar) > 0)) { - omote_log_v("get_key_repeatMode: will use key from gui %s\r\n", GUIname.c_str()); - return registered_guis_byName_map.at(GUIname).this_key_repeatModes->at(keyChar); - - // look if the map of the active scene has a definition for it - } else if ((registered_scenes.count(sceneName) > 0) && (registered_scenes.at(sceneName).this_key_repeatModes->count(keyChar) > 0)) { - omote_log_v("get_key_repeatMode: will use key from scene %s\r\n", sceneName.c_str()); - return registered_scenes.at(sceneName).this_key_repeatModes->at(keyChar); - - // look if there is a default definition - } else if (key_repeatModes_default.count(keyChar) > 0) { - omote_log_v("get_key_repeatMode: will use default key\r\n"); - return key_repeatModes_default.at(keyChar); - - // no key definition found - } else { - omote_log_v("get_key_repeatMode: WARNING no key definition found\r\n"); - return REPEAT_MODE_UNKNOWN; - } - } - catch (const std::out_of_range& oor) { - omote_log_e("get_key_repeatMode: internal error, sceneName not registered\r\n"); - return REPEAT_MODE_UNKNOWN; - } -} - -uint16_t get_command_short(std::string sceneName, char keyChar) { - try { - // look if the map of the active gui has a definition for it - std::string GUIname = gui_memoryOptimizer_getActiveGUIname(); - if ((registered_guis_byName_map.count(GUIname) > 0) && (registered_guis_byName_map.at(GUIname).this_key_commands_short != NULL) && (registered_guis_byName_map.at(GUIname).this_key_commands_short->count(keyChar) > 0)) { - omote_log_v("get_command_short: will use key from gui %s\r\n", GUIname.c_str()); - return registered_guis_byName_map.at(GUIname).this_key_commands_short->at(keyChar); - - // look if the map of the active scene has a definition for it - } else if ((registered_scenes.count(sceneName) > 0) && (registered_scenes.at(sceneName).this_key_commands_short->count(keyChar) > 0)) { - omote_log_v("get_command_short: will use key from scene %s\r\n", sceneName.c_str()); - return registered_scenes.at(sceneName).this_key_commands_short->at(keyChar); - - // look if there is a default definition - } else if (key_commands_short_default.count(keyChar) > 0) { - omote_log_v("get_command_short: will use default key\r\n"); - return key_commands_short_default.at(keyChar); - - // no key definition found - } else { - omote_log_v("get_command_short: WARNING no key definition found\r\n"); - return COMMAND_UNKNOWN; - } - } - catch (const std::out_of_range& oor) { - omote_log_e("get_command_short: internal error, sceneName not registered\r\n"); - return COMMAND_UNKNOWN; - } - -} - -uint16_t get_command_long(std::string sceneName, char keyChar) { - try { - // look if the map of the active gui has a definition for it - std::string GUIname = gui_memoryOptimizer_getActiveGUIname(); - if ((registered_guis_byName_map.count(GUIname) > 0) && (registered_guis_byName_map.at(GUIname).this_key_commands_long != NULL) && (registered_guis_byName_map.at(GUIname).this_key_commands_long->count(keyChar) > 0)) { - omote_log_v("get_command_long: will use key from gui %s\r\n", GUIname.c_str()); - return registered_guis_byName_map.at(GUIname).this_key_commands_long->at(keyChar); - - // look if the map of the active scene has a definition for it - } else if ((registered_scenes.count(sceneName) > 0) && (registered_scenes.at(sceneName).this_key_commands_long->count(keyChar) > 0)) { - omote_log_v("get_command_long: will use key from scene %s\r\n", sceneName.c_str()); - return registered_scenes.at(sceneName).this_key_commands_long->at(keyChar); - - // look if there is a default definition - } else if (key_commands_long_default.count(keyChar) > 0) { - omote_log_v("get_command_long: will use default key\r\n"); - return key_commands_long_default.at(keyChar); - - // no key definition found - } else { - omote_log_v("get_command_long: WARNING no key definition found\r\n"); - return COMMAND_UNKNOWN; - } - } - catch (const std::out_of_range& oor) { - omote_log_e("get_command_long: internal error, sceneName not registered\r\n"); - return COMMAND_UNKNOWN; - } - -} - -gui_list get_gui_list_withFallback(GUIlists gui_list) { - try { - // If gui_list == MAIN_GUI_LIST, then we want the main_gui_list, either if a scene is active or not. - // If gui_list == SCENE_GUI_LIST, then we want the scene gui list. If none is defined, return main_gui_list as fallback. - - if (gui_list == MAIN_GUI_LIST) { - return &main_gui_list; - - } else { - #if (USE_SCENE_SPECIFIC_GUI_LIST != 0) - // look if the active scene has a definition for a gui list - if ((registered_scenes.count(gui_memoryOptimizer_getActiveSceneName()) > 0) && (registered_scenes.at(gui_memoryOptimizer_getActiveSceneName()).this_gui_list != NULL)) { - omote_log_v("get_gui_list: will use gui_list from scene %s\r\n", sceneName.c_str()); - return registered_scenes.at(gui_memoryOptimizer_getActiveSceneName()).this_gui_list; - } else { - // no scene specific gui list was defined - return &main_gui_list; - } - #else - // never use scene specific gui list - return &main_gui_list; - #endif - } - } - catch (const std::out_of_range& oor) { - omote_log_e("get_gui_list: internal error, sceneName not registered\r\n"); - return NULL; - } -} - -gui_list get_gui_list_active_withFallback() { - return get_gui_list_withFallback(gui_memoryOptimizer_getActiveGUIlist()); -} - -bool get_scene_has_gui_list(std::string sceneName) { - try { - // look if the scene is known - if ((registered_scenes.count(sceneName) > 0)) { - return (registered_scenes.at(sceneName).this_gui_list != NULL); - } else { - return false; - } - } - catch (const std::out_of_range& oor) { - omote_log_e("get_scene_has_gui_list: internal error, sceneName not registered\r\n"); - return false; - } -} - -uint16_t get_activate_scene_command(std::string sceneName) { - try { - // look if the scene is known - if ((registered_scenes.count(sceneName) > 0)) { - omote_log_v("get_activate_scene_command: will use activate_scene_command from scene %s\r\n", sceneName.c_str()); - return registered_scenes.at(sceneName).this_activate_scene_command; - - // if the scene is not know, simply return 0 - } else { - omote_log_v("get_activate_scene_command: will return 0\r\n"); - return 0; - - } - } - catch (const std::out_of_range& oor) { - omote_log_e("get_activate_scene_command: internal error, sceneName not registered\r\n"); - return 0; - } - -} - -scene_list get_scenes_on_sceneSelectionGUI() { - return &scenes_on_sceneSelectionGUI; -} - -void set_scenes_on_sceneSelectionGUI(t_scene_list a_scene_list) { - scenes_on_sceneSelectionGUI.clear(); - for (int i=0; i -#include -#include "applicationInternal/keys.h" -#include "applicationInternal/gui/guiMemoryOptimizer.h" - -typedef std::vector t_gui_list; -typedef std::vector t_scene_list; - -typedef void (*scene_setKeys)(void); -typedef void (*scene_start_sequence)(void); -typedef void (*scene_end_sequence)(void); -typedef t_gui_list *gui_list; -typedef t_scene_list *scene_list; - -// https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work -struct scene_definition { - scene_setKeys this_scene_setKeys; - scene_start_sequence this_scene_start_sequence; - scene_end_sequence this_scene_end_sequence; - key_repeatModes this_key_repeatModes; - key_commands_short this_key_commands_short; - key_commands_long this_key_commands_long; - gui_list this_gui_list; - uint16_t this_activate_scene_command; -}; - -extern std::map registered_scenes; - -void register_scene( - std::string a_scene_name, - scene_setKeys a_scene_setKeys, - scene_start_sequence a_scene_start_sequence, - scene_end_sequence a_scene_end_sequence, - key_repeatModes a_key_repeatModes, - key_commands_short a_key_commands_short, - key_commands_long a_key_commands_long, - gui_list a_gui_list = NULL, - uint16_t a_activate_scene_command = 0); - -bool sceneExists(std::string sceneName); -void scene_start_sequence_from_registry(std::string sceneName); -void scene_end_sequence_from_registry(std::string sceneName); -repeatModes get_key_repeatMode(std::string sceneName, char keyChar); -uint16_t get_command_short(std::string sceneName, char keyChar); -uint16_t get_command_long(std::string sceneName, char keyChar); -gui_list get_gui_list_withFallback(GUIlists gui_list); -gui_list get_gui_list_active_withFallback(); -bool get_scene_has_gui_list(std::string sceneName); -uint16_t get_activate_scene_command(std::string sceneName); -scene_list get_scenes_on_sceneSelectionGUI(); -void set_scenes_on_sceneSelectionGUI(t_scene_list a_scene_list); - -extern char KEY_OFF ; -extern char KEY_STOP ; -extern char KEY_REWI ; -extern char KEY_PLAY ; -extern char KEY_FORW ; -extern char KEY_CONF ; -extern char KEY_INFO ; -extern char KEY_UP ; -extern char KEY_DOWN ; -extern char KEY_LEFT ; -extern char KEY_RIGHT; -extern char KEY_OK ; -extern char KEY_BACK ; -extern char KEY_SRC ; -extern char KEY_VOLUP; -extern char KEY_VOLDO; -extern char KEY_MUTE ; -extern char KEY_REC ; -extern char KEY_CHUP ; -extern char KEY_CHDOW; -extern char KEY_RED ; -extern char KEY_GREEN; -extern char KEY_YELLO; -extern char KEY_BLUE ; diff --git a/Platformio/src/devices/AVreceiver/device_yamahaAmp/device_yamahaAmp.cpp b/Platformio/src/devices/AVreceiver/device_yamahaAmp/device_yamahaAmp.cpp deleted file mode 100644 index a7333ab4..00000000 --- a/Platformio/src/devices/AVreceiver/device_yamahaAmp/device_yamahaAmp.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include -#include "applicationInternal/commandHandler.h" -#include "applicationInternal/hardware/hardwarePresenter.h" -#include "device_yamahaAmp.h" - - // Only activate the commands that are used. Every command takes 100 bytes, wether used or not. - uint16_t YAMAHA_INPUT_DVD ; //"Yamaha_input_dvd"; - uint16_t YAMAHA_INPUT_DTV ; //"Yamaha_input_dtv"; - // uint16_t YAMAHA_INPUT_VCR ; //"Yamaha_input_vcr"; - // uint16_t YAMAHA_POWER_TOGGLE ; //"Yamaha_power_toggle"; - // uint16_t YAMAHA_INPUT_CD ; //"Yamaha_input_cd"; - // uint16_t YAMAHA_INPUT_MD ; //"Yamaha_input_md"; - // uint16_t YAMAHA_INPUT_VAUX ; //"Yamaha_input_vaux"; - // uint16_t YAMAHA_MULTICHANNEL ; //"Yamaha_multichannel"; - // uint16_t YAMAHA_INPUT_TUNER ; //"Yamaha_input_tuner"; - // uint16_t YAMAHA_PRESETGROUP ; //"Yamaha_presetgroup"; - // uint16_t YAMAHA_PRESETSTATION_MINUS ; //"Yamaha_presetstation-"; - // uint16_t YAMAHA_PRESETSTATION_PLUS ; //"Yamaha_presetstation+"; - uint16_t YAMAHA_STANDARD ; //"Yamaha_standard"; - // uint16_t YAMAHA_5CHSTEREO ; //"Yamaha_5chstereo"; - // uint16_t YAMAHA_NIGHT ; //"Yamaha_night"; - // uint16_t YAMAHA_SLEEP ; //"Yamaha_sleep"; - // uint16_t YAMAHA_TEST ; //"Yamaha_test"; - // uint16_t YAMAHA_STRAIGHT ; //"Yamaha_straight"; - uint16_t YAMAHA_VOL_MINUS ; //"Yamaha_vol-"; - uint16_t YAMAHA_VOL_PLUS ; //"Yamaha_vol+"; - // uint16_t YAMAHA_PROG_MINUS ; //"Yamaha_prog-"; - // uint16_t YAMAHA_PROG_PLUS ; //"Yamaha_prog+"; - uint16_t YAMAHA_MUTE_TOGGLE ; //"Yamaha_mute_toggle"; - // uint16_t YAMAHA_LEVEL ; //"Yamaha_level"; - // uint16_t YAMAHA_SETMENU ; //"Yamaha_setmenu"; - // uint16_t YAMAHA_SETMENU_UP ; //"Yamaha_setmenu_up"; - // uint16_t YAMAHA_SETMENU_DOWN ; //"Yamaha_setmenu_down"; - // uint16_t YAMAHA_SETMENU_MINUS ; //"Yamaha_setmenu_-"; - // uint16_t YAMAHA_SETMENU_PLUS ; //"Yamaha_setmenu_+"; - uint16_t YAMAHA_POWER_OFF ; //"Yamaha_power_off"; - uint16_t YAMAHA_POWER_ON ; //"Yamaha_power_on"; - -void register_device_yamahaAmp() { - // tested with Yamaha RX-V359, works also with others - - // Only activate the commands that are used. Every command takes 100 bytes, wether used or not. - register_command(&YAMAHA_INPUT_DVD , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA1837C"})); - register_command(&YAMAHA_INPUT_DTV , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA12AD5"})); - // register_command(&YAMAHA_INPUT_VCR , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA1F00F"})); - // register_command(&YAMAHA_POWER_TOGGLE , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA1F807"})); - // register_command(&YAMAHA_INPUT_CD , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA1A857"})); - // register_command(&YAMAHA_INPUT_MD , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA1936C"})); - // register_command(&YAMAHA_INPUT_VAUX , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA1AA55"})); - // register_command(&YAMAHA_MULTICHANNEL , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA1E11E"})); - // register_command(&YAMAHA_INPUT_TUNER , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA16897"})); - // register_command(&YAMAHA_PRESETGROUP , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA148B7"})); - // register_command(&YAMAHA_PRESETSTATION_MINUS , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA18877"})); - // register_command(&YAMAHA_PRESETSTATION_PLUS , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA108F7"})); - register_command(&YAMAHA_STANDARD , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA109F6"})); - // register_command(&YAMAHA_5CHSTEREO , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA1E916"})); - // register_command(&YAMAHA_NIGHT , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA1A956"})); - // register_command(&YAMAHA_SLEEP , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA1EA15"})); - // register_command(&YAMAHA_TEST , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA1A15E"})); - // register_command(&YAMAHA_STRAIGHT , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA16A95"})); - register_command(&YAMAHA_VOL_MINUS , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA1D827"})); - register_command(&YAMAHA_VOL_PLUS , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA158A7"})); - // register_command(&YAMAHA_PROG_MINUS , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA19A65"})); - // register_command(&YAMAHA_PROG_PLUS , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA11AE5"})); - register_command(&YAMAHA_MUTE_TOGGLE , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA138C7"})); - // register_command(&YAMAHA_LEVEL , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA1619E"})); - // register_command(&YAMAHA_SETMENU , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA139C6"})); - // register_command(&YAMAHA_SETMENU_UP , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA119E6"})); - // register_command(&YAMAHA_SETMENU_DOWN , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA19966"})); - // register_command(&YAMAHA_SETMENU_MINUS , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA1CA35"})); - // register_command(&YAMAHA_SETMENU_PLUS , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA14AB5"})); - register_command(&YAMAHA_POWER_OFF , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA17887"})); - register_command(&YAMAHA_POWER_ON , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x5EA1B847"})); - - // GC seems not to work - //register_command(&YAMAHA_POWER_TOGGLE , makeCommandData(IR, {std::to_string(IR_PROTOCOL_GC), "38000,1,69,341,170,21,21,21,64,21,64,21,64,21,64,21,64,21,64,21,21,21,64,21,21,21,21,21,21,21,21,21,21,21,21,21,64,21,21,21,64,21,21,21,64,21,21,21,64,21,21,21,21,21,64,21,21,21,64,21,21,21,64,21,21,21,64,21,64,21,1517,341,85,21,3655"})); - //register_command(&YAMAHA_POWER_OFF , makeCommandData(IR, {std::to_string(IR_PROTOCOL_GC), "38000,1,69,341,170,21,21,21,64,21,64,21,64,21,64,21,64,21,64,21,21,21,64,21,21,21,21,21,21,21,21,21,21,21,21,21,64,21,64,21,64,21,64,21,64,21,64,21,64,21,64,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,64,21,1517,341,85,21,3655"})); - //register_command(&YAMAHA_POWER_ON , makeCommandData(IR, {std::to_string(IR_PROTOCOL_GC), "38000,1,69,341,170,21,21,21,64,21,64,21,64,21,64,21,64,21,64,21,21,21,64,21,21,21,21,21,21,21,21,21,21,21,21,21,64,21,21,21,64,21,64,21,64,21,64,21,64,21,64,21,21,21,64,21,21,21,21,21,21,21,21,21,21,21,21,21,64,21,1517,341,85,21,3655"})); - //register_command(&YAMAHA_INPUT_DVD , makeCommandData(IR, {std::to_string(IR_PROTOCOL_GC), "38000,1,69,341,170,21,21,21,64,21,21,21,64,21,64,21,64,21,64,21,21,21,64,21,21,21,64,21,21,21,21,21,21,21,21,21,64,21,64,21,21,21,21,21,21,21,21,21,21,21,64,21,64,21,21,21,64,21,64,21,64,21,64,21,64,21,21,21,21,21,1517,341,85,21,3655"})); - //register_command(&YAMAHA_INPUT_DTV , makeCommandData(IR, {std::to_string(IR_PROTOCOL_GC), "38000,1,69,341,170,21,21,21,64,21,21,21,64,21,64,21,64,21,64,21,21,21,64,21,21,21,64,21,21,21,21,21,21,21,21,21,64,21,21,21,21,21,64,21,21,21,64,21,21,21,64,21,21,21,64,21,64,21,21,21,64,21,21,21,64,21,21,21,64,21,1517,341,85,21,3655"})); - //register_command(&YAMAHA_STANDARD , makeCommandData(IR, {std::to_string(IR_PROTOCOL_GC), "38000,1,69,341,170,21,21,21,64,21,64,21,64,21,64,21,64,21,64,21,21,21,64,21,21,21,21,21,21,21,21,21,21,21,21,21,64,21,21,21,64,21,64,21,64,21,64,21,64,21,64,21,64,21,64,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,1517,341,85,21,3655"})); -} diff --git a/Platformio/src/devices/AVreceiver/device_yamahaAmp/device_yamahaAmp.h b/Platformio/src/devices/AVreceiver/device_yamahaAmp/device_yamahaAmp.h deleted file mode 100644 index baaed0c5..00000000 --- a/Platformio/src/devices/AVreceiver/device_yamahaAmp/device_yamahaAmp.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -// Only activate the commands that are used. Every command takes 100 bytes, wether used or not. -extern uint16_t YAMAHA_INPUT_DVD; -extern uint16_t YAMAHA_INPUT_DTV; -// extern uint16_t YAMAHA_INPUT_VCR; -// extern uint16_t YAMAHA_POWER_TOGGLE; -// extern uint16_t YAMAHA_INPUT_CD; -// extern uint16_t YAMAHA_INPUT_MD; -// extern uint16_t YAMAHA_INPUT_VAUX; -// extern uint16_t YAMAHA_MULTICHANNEL; -// extern uint16_t YAMAHA_INPUT_TUNER; -// extern uint16_t YAMAHA_PRESETGROUP; -// extern uint16_t YAMAHA_PRESETSTATION_MINUS; -// extern uint16_t YAMAHA_PRESETSTATION_PLUS; -extern uint16_t YAMAHA_STANDARD; -// extern uint16_t YAMAHA_5CHSTEREO; -// extern uint16_t YAMAHA_NIGHT; -// extern uint16_t YAMAHA_SLEEP; -// extern uint16_t YAMAHA_TEST; -// extern uint16_t YAMAHA_STRAIGHT; -extern uint16_t YAMAHA_VOL_MINUS; -extern uint16_t YAMAHA_VOL_PLUS; -// extern uint16_t YAMAHA_PROG_MINUS; -// extern uint16_t YAMAHA_PROG_PLUS; -extern uint16_t YAMAHA_MUTE_TOGGLE; -// extern uint16_t YAMAHA_LEVEL; -// extern uint16_t YAMAHA_SETMENU; -// extern uint16_t YAMAHA_SETMENU_UP; -// extern uint16_t YAMAHA_SETMENU_DOWN; -// extern uint16_t YAMAHA_SETMENU_MINUS; -// extern uint16_t YAMAHA_SETMENU_PLUS; -extern uint16_t YAMAHA_POWER_OFF; -extern uint16_t YAMAHA_POWER_ON; - -void register_device_yamahaAmp(); diff --git a/Platformio/src/devices/AVreceiver/device_yamahaAmp/gui_yamahaAmp.cpp b/Platformio/src/devices/AVreceiver/device_yamahaAmp/gui_yamahaAmp.cpp deleted file mode 100644 index 0d357626..00000000 --- a/Platformio/src/devices/AVreceiver/device_yamahaAmp/gui_yamahaAmp.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include -#include "applicationInternal/gui/guiBase.h" -#include "applicationInternal/gui/guiRegistry.h" -#include "applicationInternal/commandHandler.h" -#include "devices/AVreceiver/device_yamahaAmp/device_yamahaAmp.h" -#include "devices/AVreceiver/device_yamahaAmp/gui_yamahaAmp.h" - -static void button_clicked_event_cb(lv_event_t* e) { - int user_data = (intptr_t)(e->user_data); - - if (user_data == 0) { - executeCommand(YAMAHA_STANDARD); - } - -} - -void create_tab_content_yamahaAmp(lv_obj_t* tab) { - - // Add content to the sceneSelection tab - - lv_obj_set_layout(tab, LV_LAYOUT_FLEX); - lv_obj_set_flex_flow(tab, LV_FLEX_FLOW_COLUMN); - lv_obj_set_scrollbar_mode(tab, LV_SCROLLBAR_MODE_ACTIVE); - - // -- create a button for "standard" ---------------------------------------- - lv_obj_t* button = lv_btn_create(tab); - lv_obj_set_size(button, 80, 40); - lv_obj_set_style_radius(button, 10, LV_PART_MAIN); - lv_obj_set_style_bg_color(button, color_primary, LV_PART_MAIN); - lv_obj_add_event_cb(button, button_clicked_event_cb, LV_EVENT_CLICKED, (void *)(intptr_t) 0); - - lv_obj_t* label = lv_label_create(button); - lv_label_set_text(label, "Standard"); - lv_obj_center(label); - -} - -void notify_tab_before_delete_yamahaAmp(void) { - // remember to set all pointers to lvgl objects to NULL if they might be accessed from outside. - // They must check if object is NULL and must not use it if so - -} - -void register_gui_yamahaAmp(void){ - register_gui(std::string(tabName_yamahaAmp), & create_tab_content_yamahaAmp, & notify_tab_before_delete_yamahaAmp); -} diff --git a/Platformio/src/devices/AVreceiver/device_yamahaAmp/gui_yamahaAmp.h b/Platformio/src/devices/AVreceiver/device_yamahaAmp/gui_yamahaAmp.h deleted file mode 100644 index 776653c3..00000000 --- a/Platformio/src/devices/AVreceiver/device_yamahaAmp/gui_yamahaAmp.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -const char * const tabName_yamahaAmp = "Yamaha Amp"; -void register_gui_yamahaAmp(void); diff --git a/Platformio/src/devices/TV/device_samsungTV/device_samsungTV.cpp b/Platformio/src/devices/TV/device_samsungTV/device_samsungTV.cpp deleted file mode 100644 index e94271c0..00000000 --- a/Platformio/src/devices/TV/device_samsungTV/device_samsungTV.cpp +++ /dev/null @@ -1,139 +0,0 @@ -#include -#include "applicationInternal/commandHandler.h" -#include "applicationInternal/hardware/hardwarePresenter.h" -#include "device_samsungTV.h" - -// Only activate the commands that are used. Every command takes 100 bytes, wether used or not. -// uint16_t SAMSUNG_POWER_TOGGLE ; //"Samsung_power_toggle"; -// uint16_t SAMSUNG_SOURCE ; //"Samsung_source"; -// uint16_t SAMSUNG_HDMI ; //"Samsung_hdmi"; -uint16_t SAMSUNG_NUM_1 ; //"Samsung_num_1"; -uint16_t SAMSUNG_NUM_2 ; //"Samsung_num_2"; -uint16_t SAMSUNG_NUM_3 ; //"Samsung_num_3"; -uint16_t SAMSUNG_NUM_4 ; //"Samsung_num_4"; -uint16_t SAMSUNG_NUM_5 ; //"Samsung_num_5"; -uint16_t SAMSUNG_NUM_6 ; //"Samsung_num_6"; -uint16_t SAMSUNG_NUM_7 ; //"Samsung_num_7"; -uint16_t SAMSUNG_NUM_8 ; //"Samsung_num_8"; -uint16_t SAMSUNG_NUM_9 ; //"Samsung_num_9"; -uint16_t SAMSUNG_NUM_0 ; //"Samsung_num_0"; -// uint16_t SAMSUNG_TTXMIX ; //"Samsung_ttxmix"; -// uint16_t SAMSUNG_PRECH ; //"Samsung_prech"; -// uint16_t SAMSUNG_VOL_MINUS ; //"Samsung_vol_minus"; -// uint16_t SAMSUNG_VOL_PLUS ; //"Samsung_vol_plus"; -// uint16_t SAMSUNG_MUTE_TOGGLE ; //"Samsung_mute_toggle"; -// uint16_t SAMSUNG_CHLIST ; //"Samsung_chlist"; -uint16_t SAMSUNG_CHANNEL_UP ; //"Samsung_channel_up"; -uint16_t SAMSUNG_CHANNEL_DOWN ; //"Samsung_channel_down"; -uint16_t SAMSUNG_MENU ; //"Samsung_menu"; -// uint16_t SAMSUNG_APPS ; //"Samsung_apps"; -uint16_t SAMSUNG_GUIDE ; //"Samsung_guide"; -// uint16_t SAMSUNG_TOOLS ; //"Samsung_tools"; -// uint16_t SAMSUNG_INFO ; //"Samsung_info"; -uint16_t SAMSUNG_UP ; //"Samsung_up"; -uint16_t SAMSUNG_DOWN ; //"Samsung_down"; -uint16_t SAMSUNG_LEFT ; //"Samsung_left"; -uint16_t SAMSUNG_RIGHT ; //"Samsung_right"; -uint16_t SAMSUNG_SELECT ; //"Samsung_select"; -// uint16_t SAMSUNG_RETURN ; //"Samsung_return"; -uint16_t SAMSUNG_EXIT ; //"Samsung_exit"; -// uint16_t SAMSUNG_KEY_A ; //"Samsung_key_a"; -// uint16_t SAMSUNG_KEY_B ; //"Samsung_key_b"; -// uint16_t SAMSUNG_KEY_C ; //"Samsung_key_c"; -// uint16_t SAMSUNG_KEY_D ; //"Samsung_key_d"; -// uint16_t SAMSUNG_FAMILYSTORY ; //"Samsung_familystory"; -// uint16_t SAMSUNG_SEARCH ; //"Samsung_search"; -// uint16_t SAMSUNG_DUALI_II ; //"Samsung_duali-ii"; -// uint16_t SAMSUNG_SUPPORT ; //"Samsung_support"; -// uint16_t SAMSUNG_PSIZE ; //"Samsung_psize"; -// uint16_t SAMSUNG_ADSUBT ; //"Samsung_adsubt"; -uint16_t SAMSUNG_REWIND ; //"Samsung_rewind"; -uint16_t SAMSUNG_PAUSE ; //"Samsung_pause"; -uint16_t SAMSUNG_FASTFORWARD ; //"Samsung_fastforward"; -// uint16_t SAMSUNG_RECORD ; //"Samsung_record"; -uint16_t SAMSUNG_PLAY ; //"Samsung_play"; -// uint16_t SAMSUNG_STOP ; //"Samsung_stop"; -uint16_t SAMSUNG_POWER_OFF ; //"Samsung_power_off"; -uint16_t SAMSUNG_POWER_ON ; //"Samsung_power_on"; -uint16_t SAMSUNG_INPUT_HDMI_1 ; //"Samsung_input_hdmi_1"; -uint16_t SAMSUNG_INPUT_HDMI_2 ; //"Samsung_input_hdmi_2"; -uint16_t SAMSUNG_INPUT_HDMI_3 ; //"Samsung_input_hdmi_3"; -// uint16_t SAMSUNG_INPUT_HDMI_4 ; //"Samsung_input_hdmi_4"; -// uint16_t SAMSUNG_INPUT_COMPONENT ; //"Samsung_input_component"; -uint16_t SAMSUNG_INPUT_TV ; //"Samsung_input_tv"; - -void register_device_samsungTV() { - // tested with Samsung UE32EH5300, works also with others - // both GC and SAMSUNG work well - - // https://github.com/natcl/studioimaginaire/blob/master/arduino_remote/ircodes.py - // Only activate the commands that are used. Every command takes 100 bytes, wether used or not. - // register_command(&SAMSUNG_POWER_TOGGLE , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E040BF"})); - // register_command(&SAMSUNG_SOURCE , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E0807F"})); - // register_command(&SAMSUNG_HDMI , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E0D12E"})); - register_command(&SAMSUNG_NUM_1 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E020DF"})); - register_command(&SAMSUNG_NUM_2 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E0A05F"})); - register_command(&SAMSUNG_NUM_3 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E0609F"})); - register_command(&SAMSUNG_NUM_4 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E010EF"})); - register_command(&SAMSUNG_NUM_5 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E0906F"})); - register_command(&SAMSUNG_NUM_6 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E050AF"})); - register_command(&SAMSUNG_NUM_7 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E030CF"})); - register_command(&SAMSUNG_NUM_8 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E0B04F"})); - register_command(&SAMSUNG_NUM_9 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E0708F"})); - register_command(&SAMSUNG_NUM_0 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E08877"})); - // register_command(&SAMSUNG_TTXMIX , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E034CB"})); - // register_command(&SAMSUNG_PRECH , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E0C837"})); - // register_command(&SAMSUNG_VOL_MINUS , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E0D02F"})); - // register_command(&SAMSUNG_VOL_PLUS , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E0E01F"})); - // register_command(&SAMSUNG_MUTE_TOGGLE , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E0F00F"})); - // register_command(&SAMSUNG_CHLIST , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E0D629"})); - register_command(&SAMSUNG_CHANNEL_UP , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E048B7"})); - register_command(&SAMSUNG_CHANNEL_DOWN , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E008F7"})); - register_command(&SAMSUNG_MENU , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E058A7"})); - // register_command(&SAMSUNG_APPS , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E09E61"})); - register_command(&SAMSUNG_GUIDE , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E0F20D"})); - // register_command(&SAMSUNG_TOOLS , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E0D22D"})); - // register_command(&SAMSUNG_INFO , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E0F807"})); - register_command(&SAMSUNG_UP , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E006F9"})); - register_command(&SAMSUNG_DOWN , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E08679"})); - register_command(&SAMSUNG_LEFT , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E0A659"})); - register_command(&SAMSUNG_RIGHT , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E046B9"})); - register_command(&SAMSUNG_SELECT , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E016E9"})); - // register_command(&SAMSUNG_RETURN , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E01AE5"})); - register_command(&SAMSUNG_EXIT , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E0B44B"})); - // register_command(&SAMSUNG_KEY_A , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E036C9"})); - // register_command(&SAMSUNG_KEY_B , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E028D7"})); - // register_command(&SAMSUNG_KEY_C , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E0A857"})); - // register_command(&SAMSUNG_KEY_D , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E06897"})); - // register_command(&SAMSUNG_FAMILYSTORY , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E0639C"})); - // register_command(&SAMSUNG_SEARCH , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E0CE31"})); - // register_command(&SAMSUNG_DUALI_II , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E000FF"})); - // register_command(&SAMSUNG_SUPPORT , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E0FC03"})); - // register_command(&SAMSUNG_PSIZE , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E07C83"})); - // register_command(&SAMSUNG_ADSUBT , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E0A45B"})); - register_command(&SAMSUNG_REWIND , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E0A25D"})); - register_command(&SAMSUNG_PAUSE , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E052AD"})); - register_command(&SAMSUNG_FASTFORWARD , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E012ED"})); - // register_command(&SAMSUNG_RECORD , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E0926D"})); - register_command(&SAMSUNG_PLAY , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E0E21D"})); - // register_command(&SAMSUNG_STOP , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E0629D"})); - register_command(&SAMSUNG_POWER_OFF , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E019E6"})); - register_command(&SAMSUNG_POWER_ON , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E09966"})); - register_command(&SAMSUNG_INPUT_HDMI_1 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E09768"})); - register_command(&SAMSUNG_INPUT_HDMI_2 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E07D82"})); - register_command(&SAMSUNG_INPUT_HDMI_3 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E043BC"})); - // register_command(&SAMSUNG_INPUT_HDMI_4 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E0A35C"})); - // register_command(&SAMSUNG_INPUT_COMPONENT , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E0619E"})); - register_command(&SAMSUNG_INPUT_TV , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E0D827"})); - // unknown commands. Not on my remote - // register_command(&- , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E0C43B"})); - // register_command(&favorite_channel , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), "0xE0E022DD"})); - - // GC also works well - //register_command(&SAMSUNG_POWER_TOGGLE , makeCommandData(IR, {std::to_string(IR_PROTOCOL_GC), "38000,1,1,170,170,20,63,20,63,20,63,20,20,20,20,20,20,20,20,20,20,20,63,20,63,20,63,20,20,20,20,20,20,20,20,20,20,20,20,20,63,20,20,20,20,20,20,20,20,20,20,20,20,20,63,20,20,20,63,20,63,20,63,20,63,20,63,20,63,20,1798"})); - //register_command(&SAMSUNG_POWER_OFF , makeCommandData(IR, {std::to_string(IR_PROTOCOL_GC), "38000,1,1,173,173,21,65,21,65,21,65,21,21,21,21,21,21,21,21,21,21,21,65,21,65,21,65,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,65,21,65,21,21,21,21,21,65,21,65,21,65,21,65,21,21,21,21,21,65,21,65,21,21,21,1832"})); - //register_command(&SAMSUNG_POWER_ON , makeCommandData(IR, {std::to_string(IR_PROTOCOL_GC), "38000,1,1,172,172,22,64,22,64,22,64,22,21,22,21,22,21,22,21,22,21,22,64,22,64,22,64,22,21,22,21,22,21,22,21,22,21,22,64,22,21,22,21,22,64,22,64,22,21,22,21,22,64,22,21,22,64,22,64,22,21,22,21,22,64,22,64,22,21,22,1820"})); - //register_command(&SAMSUNG_INPUT_HDMI_1 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_GC), "38000,1,1,173,173,21,65,21,65,21,65,21,21,21,21,21,21,21,21,21,21,21,65,21,65,21,65,21,21,21,21,21,21,21,21,21,21,21,65,21,21,21,21,21,65,21,21,21,65,21,65,21,65,21,21,21,65,21,65,21,21,21,65,21,21,21,21,21,21,21,1832"})); - //register_command(&SAMSUNG_INPUT_HDMI_2 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_GC), "38000,1,1,173,173,21,65,21,65,21,65,21,21,21,21,21,21,21,21,21,21,21,65,21,65,21,65,21,21,21,21,21,21,21,21,21,21,21,21,21,65,21,65,21,65,21,65,21,65,21,21,21,65,21,65,21,21,21,21,21,21,21,21,21,21,21,65,21,21,21,1832"})); - //register_command(&SAMSUNG_INPUT_TV , makeCommandData(IR, {std::to_string(IR_PROTOCOL_GC), "38000,1,1,172,172,21,64,21,64,21,64,21,21,21,21,21,21,21,21,21,21,21,64,21,64,21,64,21,21,21,21,21,21,21,21,21,21,21,64,21,64,21,21,21,64,21,64,21,21,21,21,21,21,21,21,21,21,21,64,21,21,21,21,21,64,21,64,21,64,21,1673"})); -} diff --git a/Platformio/src/devices/TV/device_samsungTV/device_samsungTV.h b/Platformio/src/devices/TV/device_samsungTV/device_samsungTV.h deleted file mode 100644 index 39baeb9f..00000000 --- a/Platformio/src/devices/TV/device_samsungTV/device_samsungTV.h +++ /dev/null @@ -1,62 +0,0 @@ -#pragma once - -// Only activate the commands that are used. Every command takes 100 bytes, wether used or not. -// extern uint16_t SAMSUNG_POWER_TOGGLE; -// extern uint16_t SAMSUNG_SOURCE; -// extern uint16_t SAMSUNG_HDMI; -extern uint16_t SAMSUNG_NUM_1; -extern uint16_t SAMSUNG_NUM_2; -extern uint16_t SAMSUNG_NUM_3; -extern uint16_t SAMSUNG_NUM_4; -extern uint16_t SAMSUNG_NUM_5; -extern uint16_t SAMSUNG_NUM_6; -extern uint16_t SAMSUNG_NUM_7; -extern uint16_t SAMSUNG_NUM_8; -extern uint16_t SAMSUNG_NUM_9; -extern uint16_t SAMSUNG_NUM_0; -// extern uint16_t SAMSUNG_TTXMIX; -// extern uint16_t SAMSUNG_PRECH; -// extern uint16_t SAMSUNG_VOL_MINUS; -// extern uint16_t SAMSUNG_VOL_PLUS; -// extern uint16_t SAMSUNG_MUTE_TOGGLE; -// extern uint16_t SAMSUNG_CHLIST; -extern uint16_t SAMSUNG_CHANNEL_UP; -extern uint16_t SAMSUNG_CHANNEL_DOWN; -extern uint16_t SAMSUNG_MENU; -// extern uint16_t SAMSUNG_APPS; -extern uint16_t SAMSUNG_GUIDE; -// extern uint16_t SAMSUNG_TOOLS; -// extern uint16_t SAMSUNG_INFO; -extern uint16_t SAMSUNG_UP; -extern uint16_t SAMSUNG_DOWN; -extern uint16_t SAMSUNG_LEFT; -extern uint16_t SAMSUNG_RIGHT; -extern uint16_t SAMSUNG_SELECT; -// extern uint16_t SAMSUNG_RETURN; -extern uint16_t SAMSUNG_EXIT; -// extern uint16_t SAMSUNG_KEY_A; -// extern uint16_t SAMSUNG_KEY_B; -// extern uint16_t SAMSUNG_KEY_C; -// extern uint16_t SAMSUNG_KEY_D; -// extern uint16_t SAMSUNG_FAMILYSTORY; -// extern uint16_t SAMSUNG_SEARCH; -// extern uint16_t SAMSUNG_DUALI_II; -// extern uint16_t SAMSUNG_SUPPORT; -// extern uint16_t SAMSUNG_PSIZE; -// extern uint16_t SAMSUNG_ADSUBT; -extern uint16_t SAMSUNG_REWIND; -extern uint16_t SAMSUNG_PAUSE; -extern uint16_t SAMSUNG_FASTFORWARD; -// extern uint16_t SAMSUNG_RECORD; -extern uint16_t SAMSUNG_PLAY; -// extern uint16_t SAMSUNG_STOP; -extern uint16_t SAMSUNG_POWER_OFF; -extern uint16_t SAMSUNG_POWER_ON; -extern uint16_t SAMSUNG_INPUT_HDMI_1; -extern uint16_t SAMSUNG_INPUT_HDMI_2; -extern uint16_t SAMSUNG_INPUT_HDMI_3; -// extern uint16_t SAMSUNG_INPUT_HDMI_4; -// extern uint16_t SAMSUNG_INPUT_COMPONENT; -extern uint16_t SAMSUNG_INPUT_TV; - -void register_device_samsungTV(); diff --git a/Platformio/src/devices/keyboard/device_keyboard_ble/device_keyboard_ble.cpp b/Platformio/src/devices/keyboard/device_keyboard_ble/device_keyboard_ble.cpp deleted file mode 100644 index 7e2739b4..00000000 --- a/Platformio/src/devices/keyboard/device_keyboard_ble/device_keyboard_ble.cpp +++ /dev/null @@ -1,205 +0,0 @@ -#include "applicationInternal/commandHandler.h" -#include "applicationInternal/omote_log.h" -#include "device_keyboard_ble.h" -#include "applicationInternal/hardware/hardwarePresenter.h" - -#if (ENABLE_KEYBOARD_BLE == 1) - -uint16_t KEYBOARD_BLE_UP ; //"Keyboard_ble_up"; -uint16_t KEYBOARD_BLE_DOWN ; //"Keyboard_ble_down"; -uint16_t KEYBOARD_BLE_RIGHT ; //"Keyboard_ble_right"; -uint16_t KEYBOARD_BLE_LEFT ; //"Keyboard_ble_left"; -uint16_t KEYBOARD_BLE_SELECT ; //"Keyboard_ble_select"; -uint16_t KEYBOARD_BLE_SENDSTRING ; //"Keyboard_ble_sendstring"; -uint16_t KEYBOARD_BLE_BACK ; //"Keyboard_ble_back"; -uint16_t KEYBOARD_BLE_HOME ; //"Keyboard_ble_home"; -uint16_t KEYBOARD_BLE_MENU ; //"Keyboard_ble_menu"; -uint16_t KEYBOARD_BLE_SCAN_PREVIOUS_TRACK ; //"Keyboard_ble_scan_previous_track"; -uint16_t KEYBOARD_BLE_REWIND_LONG ; //"Keyboard_ble_rewind_long"; -uint16_t KEYBOARD_BLE_REWIND ; //"Keyboard_ble_rewind"; -uint16_t KEYBOARD_BLE_PLAYPAUSE ; //"Keyboard_ble_playpause"; -uint16_t KEYBOARD_BLE_FASTFORWARD ; //"Keyboard_ble_fastforward"; -uint16_t KEYBOARD_BLE_FASTFORWARD_LONG ; //"Keyboard_ble_fastforward_long"; -uint16_t KEYBOARD_BLE_SCAN_NEXT_TRACK ; //"Keyboard_ble_scan_next_track"; -uint16_t KEYBOARD_BLE_MUTE ; //"Keyboard_ble_mute"; -uint16_t KEYBOARD_BLE_VOLUME_INCREMENT ; //"Keyboard_ble_volume_increment"; -uint16_t KEYBOARD_BLE_VOLUME_DECREMENT ; //"Keyboard_ble_volume_decrement"; - -void register_device_keyboard_ble() { - // here with the BLE keyboard, we first need to get the unique ID, because this ID has to be used when calling register_command() itself, so we need to already have the id - get_uniqueCommandID(&KEYBOARD_BLE_UP) ; - get_uniqueCommandID(&KEYBOARD_BLE_DOWN) ; - get_uniqueCommandID(&KEYBOARD_BLE_RIGHT) ; - get_uniqueCommandID(&KEYBOARD_BLE_LEFT) ; - get_uniqueCommandID(&KEYBOARD_BLE_SELECT) ; - get_uniqueCommandID(&KEYBOARD_BLE_SENDSTRING) ; - get_uniqueCommandID(&KEYBOARD_BLE_BACK) ; - get_uniqueCommandID(&KEYBOARD_BLE_HOME) ; - get_uniqueCommandID(&KEYBOARD_BLE_MENU) ; - get_uniqueCommandID(&KEYBOARD_BLE_SCAN_PREVIOUS_TRACK); - get_uniqueCommandID(&KEYBOARD_BLE_REWIND_LONG) ; - get_uniqueCommandID(&KEYBOARD_BLE_REWIND) ; - get_uniqueCommandID(&KEYBOARD_BLE_PLAYPAUSE) ; - get_uniqueCommandID(&KEYBOARD_BLE_FASTFORWARD) ; - get_uniqueCommandID(&KEYBOARD_BLE_FASTFORWARD_LONG) ; - get_uniqueCommandID(&KEYBOARD_BLE_SCAN_NEXT_TRACK) ; - get_uniqueCommandID(&KEYBOARD_BLE_MUTE) ; - get_uniqueCommandID(&KEYBOARD_BLE_VOLUME_INCREMENT) ; - get_uniqueCommandID(&KEYBOARD_BLE_VOLUME_DECREMENT) ; - - register_command_withID( KEYBOARD_BLE_UP , makeCommandData(BLE_KEYBOARD, {std::to_string(KEYBOARD_BLE_UP) })); - register_command_withID( KEYBOARD_BLE_DOWN , makeCommandData(BLE_KEYBOARD, {std::to_string(KEYBOARD_BLE_DOWN) })); - register_command_withID( KEYBOARD_BLE_RIGHT , makeCommandData(BLE_KEYBOARD, {std::to_string(KEYBOARD_BLE_RIGHT) })); - register_command_withID( KEYBOARD_BLE_LEFT , makeCommandData(BLE_KEYBOARD, {std::to_string(KEYBOARD_BLE_LEFT) })); - register_command_withID( KEYBOARD_BLE_SELECT , makeCommandData(BLE_KEYBOARD, {std::to_string(KEYBOARD_BLE_SELECT) })); - register_command_withID( KEYBOARD_BLE_SENDSTRING , makeCommandData(BLE_KEYBOARD, {std::to_string(KEYBOARD_BLE_SENDSTRING) })); // payload must be set when calling commandHandler - register_command_withID( KEYBOARD_BLE_BACK , makeCommandData(BLE_KEYBOARD, {std::to_string(KEYBOARD_BLE_BACK) })); - register_command_withID( KEYBOARD_BLE_HOME , makeCommandData(BLE_KEYBOARD, {std::to_string(KEYBOARD_BLE_HOME) })); - register_command_withID( KEYBOARD_BLE_MENU , makeCommandData(BLE_KEYBOARD, {std::to_string(KEYBOARD_BLE_MENU) })); - register_command_withID( KEYBOARD_BLE_SCAN_PREVIOUS_TRACK , makeCommandData(BLE_KEYBOARD, {std::to_string(KEYBOARD_BLE_SCAN_PREVIOUS_TRACK)})); - register_command_withID( KEYBOARD_BLE_REWIND_LONG , makeCommandData(BLE_KEYBOARD, {std::to_string(KEYBOARD_BLE_REWIND_LONG) })); - register_command_withID( KEYBOARD_BLE_REWIND , makeCommandData(BLE_KEYBOARD, {std::to_string(KEYBOARD_BLE_REWIND) })); - register_command_withID( KEYBOARD_BLE_PLAYPAUSE , makeCommandData(BLE_KEYBOARD, {std::to_string(KEYBOARD_BLE_PLAYPAUSE) })); - register_command_withID( KEYBOARD_BLE_FASTFORWARD , makeCommandData(BLE_KEYBOARD, {std::to_string(KEYBOARD_BLE_FASTFORWARD) })); - register_command_withID( KEYBOARD_BLE_FASTFORWARD_LONG , makeCommandData(BLE_KEYBOARD, {std::to_string(KEYBOARD_BLE_FASTFORWARD_LONG) })); - register_command_withID( KEYBOARD_BLE_SCAN_NEXT_TRACK , makeCommandData(BLE_KEYBOARD, {std::to_string(KEYBOARD_BLE_SCAN_NEXT_TRACK) })); - register_command_withID( KEYBOARD_BLE_MUTE , makeCommandData(BLE_KEYBOARD, {std::to_string(KEYBOARD_BLE_MUTE) })); - register_command_withID( KEYBOARD_BLE_VOLUME_INCREMENT , makeCommandData(BLE_KEYBOARD, {std::to_string(KEYBOARD_BLE_VOLUME_INCREMENT) })); - register_command_withID( KEYBOARD_BLE_VOLUME_DECREMENT , makeCommandData(BLE_KEYBOARD, {std::to_string(KEYBOARD_BLE_VOLUME_DECREMENT) })); -} - -void keyboard_ble_executeCommand(uint16_t command, std::string additionalPayload) { - bool doLog = false; - - if (doLog) { - if (keyboardBLE_isConnected()) { - omote_log_d("BLE keyboard connected, can send key\r\n"); - } else { - omote_log_d("BLE keyboard NOT connected, cannot send key\r\n"); - } - } - - if (command == KEYBOARD_BLE_UP) { - if (doLog) {omote_log_d("UP received\r\n");} - keyboardBLE_write(BLE_KEY_UP_ARROW); - - } else if (command == KEYBOARD_BLE_DOWN) { - if (doLog) {omote_log_d("DOWN received\r\n");} - keyboardBLE_write(BLE_KEY_DOWN_ARROW); - - } else if (command == KEYBOARD_BLE_RIGHT) { - if (doLog) {omote_log_d("RIGHT received\r\n");} - keyboardBLE_write(BLE_KEY_RIGHT_ARROW); - - } else if (command == KEYBOARD_BLE_LEFT) { - if (doLog) {omote_log_d("LEFT received\r\n");} - keyboardBLE_write(BLE_KEY_LEFT_ARROW); - - } else if (command == KEYBOARD_BLE_SELECT) { - if (doLog) {omote_log_d("SELECT received\r\n");} - keyboardBLE_write(BLE_KEY_RETURN); - - } else if (command == KEYBOARD_BLE_SENDSTRING) { - if (doLog) {omote_log_d("SENDSTRING received\r\n");} - if (additionalPayload != "") { - keyboardBLE_sendString(additionalPayload.c_str()); - } - - - - } else if (command == KEYBOARD_BLE_BACK) { - if (doLog) {omote_log_d("BACK received\r\n");} - // test which one works best for your device - // keyboardBLE_write(KEY_ESC); - consumerControlBLE_write(BLE_KEY_MEDIA_WWW_BACK); - - } else if (command == KEYBOARD_BLE_HOME) { - if (doLog) {omote_log_d("HOME received\r\n");} - // test which one works best for your device - // keyboardBLE_home(); - consumerControlBLE_write(BLE_KEY_MEDIA_WWW_HOME); - - } else if (command == KEYBOARD_BLE_MENU) { - if (doLog) {omote_log_d("MENU received\r\n");} - keyboardBLE_write(0xED); // 0xDA + 13 = 0xED - - - - // for more consumerControl codes see - // https://github.com/espressif/arduino-esp32/blob/master/libraries/USB/src/USBHIDConsumerControl.h - // https://github.com/adafruit/Adafruit_CircuitPython_HID/blob/main/adafruit_hid/consumer_control_code.py - } else if (command == KEYBOARD_BLE_SCAN_PREVIOUS_TRACK) { - if (doLog) {omote_log_d("SCAN_PREVIOUS_TRACK received\r\n");} - consumerControlBLE_write(BLE_KEY_MEDIA_PREVIOUS_TRACK); - - } else if (command == KEYBOARD_BLE_REWIND_LONG) { - if (doLog) {omote_log_d("REWIND_LONG received\r\n");} - //keyboardBLE_longpress(KEY_LEFT_ARROW); - consumerControlBLE_longpress(BLE_KEY_MEDIA_REWIND); - - } else if (command == KEYBOARD_BLE_REWIND) { - if (doLog) {omote_log_d("REWIND received\r\n");} - //keyboardBLE_write(KEY_LEFT_ARROW); - consumerControlBLE_write(BLE_KEY_MEDIA_REWIND); - - } else if (command == KEYBOARD_BLE_PLAYPAUSE) { - if (doLog) {omote_log_d("PLAYPAUSE received\r\n");} - consumerControlBLE_write(BLE_KEY_MEDIA_PLAY_PAUSE); - - } else if (command == KEYBOARD_BLE_FASTFORWARD) { - if (doLog) {omote_log_d("FASTFORWARD received\r\n");} - //keyboardBLE_write(KEY_RIGHT_ARROW); - consumerControlBLE_write(BLE_KEY_MEDIA_FASTFORWARD); - - } else if (command == KEYBOARD_BLE_FASTFORWARD_LONG) { - if (doLog) {omote_log_d("FASTFORWARD_LONG received\r\n");} - //keyboardBLE_longpress(KEY_RIGHT_ARROW); - consumerControlBLE_longpress(BLE_KEY_MEDIA_FASTFORWARD); - - } else if (command == KEYBOARD_BLE_SCAN_NEXT_TRACK) { - if (doLog) {omote_log_d("SCAN_NEXT_TRACK received\r\n");} - consumerControlBLE_write(BLE_KEY_MEDIA_NEXT_TRACK); - - - - } else if (command == KEYBOARD_BLE_MUTE) { - if (doLog) {omote_log_d("MUTE received\r\n");} - consumerControlBLE_write(BLE_KEY_MEDIA_MUTE); - - } else if (command == KEYBOARD_BLE_VOLUME_INCREMENT) { - if (doLog) {omote_log_d("VOLUME_INCREMENT received\r\n");} - consumerControlBLE_write(BLE_KEY_MEDIA_VOLUME_UP); - - } else if (command == KEYBOARD_BLE_VOLUME_DECREMENT) { - if (doLog) {omote_log_d("VOLUME_DECREMENT received\r\n");} - consumerControlBLE_write(BLE_KEY_MEDIA_VOLUME_DOWN); - - } -} - -/* -const MediaKeyReport KEY_MEDIA_NEXT_TRACK = {1, 0}; -const MediaKeyReport KEY_MEDIA_PREVIOUS_TRACK = {2, 0}; -const MediaKeyReport KEY_MEDIA_STOP = {4, 0}; -const MediaKeyReport KEY_MEDIA_PLAY_PAUSE = {8, 0}; -const MediaKeyReport KEY_MEDIA_MUTE = {16, 0}; -const MediaKeyReport KEY_MEDIA_VOLUME_UP = {32, 0}; -const MediaKeyReport KEY_MEDIA_VOLUME_DOWN = {64, 0}; -const MediaKeyReport KEY_MEDIA_WWW_HOME = {128, 0}; -const MediaKeyReport KEY_MEDIA_LOCAL_MACHINE_BROWSER = {0, 1}; // Opens "My Computer" on Windows -// original from BLE-Keyboard -// const MediaKeyReport KEY_MEDIA_CALCULATOR = {0, 2}; -// changed for usage in OMOTE -const MediaKeyReport KEY_MEDIA_FASTFORWARD = {0, 2}; -const MediaKeyReport KEY_MEDIA_WWW_BOOKMARKS = {0, 4}; -const MediaKeyReport KEY_MEDIA_WWW_SEARCH = {0, 8}; -const MediaKeyReport KEY_MEDIA_WWW_STOP = {0, 16}; -const MediaKeyReport KEY_MEDIA_WWW_BACK = {0, 32}; -const MediaKeyReport KEY_MEDIA_CONSUMER_CONTROL_CONFIGURATION = {0, 64}; // Media Selection -// original from BLE-Keyboard -// const MediaKeyReport KEY_MEDIA_EMAIL_READER = {0, 128}; -// changed for usage in OMOTE -const MediaKeyReport KEY_MEDIA_REWIND = {0, 128}; -*/ - -#endif \ No newline at end of file diff --git a/Platformio/src/devices/keyboard/device_keyboard_ble/device_keyboard_ble.h b/Platformio/src/devices/keyboard/device_keyboard_ble/device_keyboard_ble.h deleted file mode 100644 index fa0013eb..00000000 --- a/Platformio/src/devices/keyboard/device_keyboard_ble/device_keyboard_ble.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once -#include - -// Advertising is started automatically. -// As soon as a device is connected, a small indicator in the top left corner of the screen will appear - -#if (ENABLE_KEYBOARD_BLE == 1) - -#if (ENABLE_KEYBOARD_BLE == 1) && !(ENABLE_BLUETOOTH == 1) -static_assert(false, "You have to use \"-D ENABLE_BLUETOOTH=1\" in \"platformio.ini\" when having \"-D ENABLE_KEYBOARD_BLE=1\""); -#endif - -extern uint16_t KEYBOARD_BLE_UP; -extern uint16_t KEYBOARD_BLE_DOWN; -extern uint16_t KEYBOARD_BLE_RIGHT; -extern uint16_t KEYBOARD_BLE_LEFT; -extern uint16_t KEYBOARD_BLE_SELECT; -extern uint16_t KEYBOARD_BLE_SENDSTRING; -extern uint16_t KEYBOARD_BLE_BACK; -extern uint16_t KEYBOARD_BLE_HOME; -extern uint16_t KEYBOARD_BLE_MENU; -extern uint16_t KEYBOARD_BLE_SCAN_PREVIOUS_TRACK; -extern uint16_t KEYBOARD_BLE_REWIND_LONG; -extern uint16_t KEYBOARD_BLE_REWIND; -extern uint16_t KEYBOARD_BLE_PLAYPAUSE; -extern uint16_t KEYBOARD_BLE_FASTFORWARD; -extern uint16_t KEYBOARD_BLE_FASTFORWARD_LONG; -extern uint16_t KEYBOARD_BLE_SCAN_NEXT_TRACK; -extern uint16_t KEYBOARD_BLE_MUTE; -extern uint16_t KEYBOARD_BLE_VOLUME_INCREMENT; -extern uint16_t KEYBOARD_BLE_VOLUME_DECREMENT; - -void register_device_keyboard_ble(); -void keyboard_ble_executeCommand(uint16_t, std::string additionalPayload = ""); - -#endif diff --git a/Platformio/src/devices/keyboard/device_keyboard_mqtt/device_keyboard_mqtt.cpp b/Platformio/src/devices/keyboard/device_keyboard_mqtt/device_keyboard_mqtt.cpp deleted file mode 100644 index 4e50a9b0..00000000 --- a/Platformio/src/devices/keyboard/device_keyboard_mqtt/device_keyboard_mqtt.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "applicationInternal/commandHandler.h" -#include "device_keyboard_mqtt.h" - -#if (ENABLE_KEYBOARD_MQTT == 1) - -uint16_t KEYBOARD_MQTT_UP ; //"Keyboard_mqtt_up"; -uint16_t KEYBOARD_MQTT_DOWN ; //"Keyboard_mqtt_down"; -uint16_t KEYBOARD_MQTT_RIGHT ; //"Keyboard_mqtt_right"; -uint16_t KEYBOARD_MQTT_LEFT ; //"Keyboard_mqtt_left"; -uint16_t KEYBOARD_MQTT_SELECT ; //"Keyboard_mqtt_select"; -uint16_t KEYBOARD_MQTT_SENDSTRING ; //"Keyboard_mqtt_sendstring"; -uint16_t KEYBOARD_MQTT_BACK ; //"Keyboard_mqtt_back"; -uint16_t KEYBOARD_MQTT_HOME ; //"Keyboard_mqtt_home"; -uint16_t KEYBOARD_MQTT_MENU ; //"Keyboard_mqtt_menu"; -uint16_t KEYBOARD_MQTT_SCAN_PREVIOUS_TRACK ; //"Keyboard_mqtt_scan_previous_track"; -uint16_t KEYBOARD_MQTT_REWIND_LONG ; //"Keyboard_mqtt_rewind_long"; -uint16_t KEYBOARD_MQTT_REWIND ; //"Keyboard_mqtt_rewind"; -uint16_t KEYBOARD_MQTT_PLAYPAUSE ; //"Keyboard_mqtt_playpause"; -uint16_t KEYBOARD_MQTT_FASTFORWARD ; //"Keyboard_mqtt_fastforward"; -uint16_t KEYBOARD_MQTT_FASTFORWARD_LONG ; //"Keyboard_mqtt_fastforward_long"; -uint16_t KEYBOARD_MQTT_SCAN_NEXT_TRACK ; //"Keyboard_mqtt_scan_next_track"; -uint16_t KEYBOARD_MQTT_MUTE ; //"Keyboard_mqtt_mute"; -uint16_t KEYBOARD_MQTT_VOLUME_INCREMENT ; //"Keyboard_mqtt_volume_increment"; -uint16_t KEYBOARD_MQTT_VOLUME_DECREMENT ; //"Keyboard_mqtt_volume_decrement"; - -void register_device_keyboard_mqtt() { - register_command(&KEYBOARD_MQTT_UP , makeCommandData(MQTT, {"esp32_keyboard_firetv/cmnd/UP", "PRESS"})); - register_command(&KEYBOARD_MQTT_DOWN , makeCommandData(MQTT, {"esp32_keyboard_firetv/cmnd/DOWN", "PRESS"})); - register_command(&KEYBOARD_MQTT_RIGHT , makeCommandData(MQTT, {"esp32_keyboard_firetv/cmnd/RIGHT", "PRESS"})); - register_command(&KEYBOARD_MQTT_LEFT , makeCommandData(MQTT, {"esp32_keyboard_firetv/cmnd/LEFT", "PRESS"})); - register_command(&KEYBOARD_MQTT_SELECT , makeCommandData(MQTT, {"esp32_keyboard_firetv/cmnd/SELECT", "PRESS"})); - register_command(&KEYBOARD_MQTT_SENDSTRING , makeCommandData(MQTT, {"esp32_keyboard_firetv/cmnd/SENDSTRING" })); // payload must be set when calling commandHandler - register_command(&KEYBOARD_MQTT_BACK , makeCommandData(MQTT, {"esp32_keyboard_firetv/cmnd/BACK", "PRESS"})); - register_command(&KEYBOARD_MQTT_HOME , makeCommandData(MQTT, {"esp32_keyboard_firetv/cmnd/HOME", "PRESS"})); - register_command(&KEYBOARD_MQTT_MENU , makeCommandData(MQTT, {"esp32_keyboard_firetv/cmnd/MENU", "PRESS"})); - register_command(&KEYBOARD_MQTT_SCAN_PREVIOUS_TRACK , makeCommandData(MQTT, {"esp32_keyboard_firetv/cmnd/SCAN_PREVIOUS_TRACK", "PRESS"})); - register_command(&KEYBOARD_MQTT_REWIND_LONG , makeCommandData(MQTT, {"esp32_keyboard_firetv/cmnd/REWIND_LONG", "PRESS"})); - register_command(&KEYBOARD_MQTT_REWIND , makeCommandData(MQTT, {"esp32_keyboard_firetv/cmnd/REWIND", "PRESS"})); - register_command(&KEYBOARD_MQTT_PLAYPAUSE , makeCommandData(MQTT, {"esp32_keyboard_firetv/cmnd/PLAYPAUSE", "PRESS"})); - register_command(&KEYBOARD_MQTT_FASTFORWARD , makeCommandData(MQTT, {"esp32_keyboard_firetv/cmnd/FASTFORWARD", "PRESS"})); - register_command(&KEYBOARD_MQTT_FASTFORWARD_LONG , makeCommandData(MQTT, {"esp32_keyboard_firetv/cmnd/FASTFORWARD_LONG", "PRESS"})); - register_command(&KEYBOARD_MQTT_SCAN_NEXT_TRACK , makeCommandData(MQTT, {"esp32_keyboard_firetv/cmnd/SCAN_NEXT_TRACK", "PRESS"})); - register_command(&KEYBOARD_MQTT_MUTE , makeCommandData(MQTT, {"esp32_keyboard_firetv/cmnd/MUTE", "PRESS"})); - register_command(&KEYBOARD_MQTT_VOLUME_INCREMENT , makeCommandData(MQTT, {"esp32_keyboard_firetv/cmnd/VOLUME_INCREMENT", "PRESS"})); - register_command(&KEYBOARD_MQTT_VOLUME_DECREMENT , makeCommandData(MQTT, {"esp32_keyboard_firetv/cmnd/VOLUME_DECREMENT", "PRESS"})); -} - -#endif \ No newline at end of file diff --git a/Platformio/src/devices/keyboard/device_keyboard_mqtt/device_keyboard_mqtt.h b/Platformio/src/devices/keyboard/device_keyboard_mqtt/device_keyboard_mqtt.h deleted file mode 100644 index 70c6a1a7..00000000 --- a/Platformio/src/devices/keyboard/device_keyboard_mqtt/device_keyboard_mqtt.h +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once - -#include - -// The "MQTT keyboard" simply sends MQTT commands to a remote keyboard, which is connected via USB to a device -// https://github.com/KlausMu/esp32-mqtt-keyboard -// if you activate the MQTT keyboard, consider changing the mapping of the keyboard commands to the MQTT keyboard in file "commandHandler.h" - -#if (ENABLE_KEYBOARD_MQTT == 1) - -#if (ENABLE_KEYBOARD_MQTT == 1) && !(ENABLE_WIFI_AND_MQTT == 1) -static_assert(false, "You have to use \"-D ENABLE_WIFI_AND_MQTT=1\" in \"platformio.ini\" when having \"-D ENABLE_KEYBOARD_MQTT=1\""); -#endif - -extern uint16_t KEYBOARD_MQTT_UP; -extern uint16_t KEYBOARD_MQTT_DOWN; -extern uint16_t KEYBOARD_MQTT_RIGHT; -extern uint16_t KEYBOARD_MQTT_LEFT; -extern uint16_t KEYBOARD_MQTT_SELECT; -extern uint16_t KEYBOARD_MQTT_SENDSTRING; -extern uint16_t KEYBOARD_MQTT_BACK; -extern uint16_t KEYBOARD_MQTT_HOME; -extern uint16_t KEYBOARD_MQTT_MENU; -extern uint16_t KEYBOARD_MQTT_SCAN_PREVIOUS_TRACK; -extern uint16_t KEYBOARD_MQTT_REWIND_LONG; -extern uint16_t KEYBOARD_MQTT_REWIND; -extern uint16_t KEYBOARD_MQTT_PLAYPAUSE; -extern uint16_t KEYBOARD_MQTT_FASTFORWARD; -extern uint16_t KEYBOARD_MQTT_FASTFORWARD_LONG; -extern uint16_t KEYBOARD_MQTT_SCAN_NEXT_TRACK; -extern uint16_t KEYBOARD_MQTT_MUTE; -extern uint16_t KEYBOARD_MQTT_VOLUME_INCREMENT; -extern uint16_t KEYBOARD_MQTT_VOLUME_DECREMENT; - -void register_device_keyboard_mqtt(); - -#endif diff --git a/Platformio/src/devices/mediaPlayer/device_appleTV/device_appleTV.cpp b/Platformio/src/devices/mediaPlayer/device_appleTV/device_appleTV.cpp deleted file mode 100644 index e5abf2d6..00000000 --- a/Platformio/src/devices/mediaPlayer/device_appleTV/device_appleTV.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include "applicationInternal/commandHandler.h" -#include "applicationInternal/hardware/hardwarePresenter.h" -#include "device_appleTV.h" - -uint16_t APPLETV_GUI_EVENT_USER_DATA; //"AppleTV_gui_event_user_data"; - -void register_device_appleTV() { - register_command(&APPLETV_GUI_EVENT_USER_DATA , makeCommandData(IR, {std::to_string(IR_PROTOCOL_SONY)})); // payload must be set when calling commandHandler -} diff --git a/Platformio/src/devices/mediaPlayer/device_appleTV/device_appleTV.h b/Platformio/src/devices/mediaPlayer/device_appleTV/device_appleTV.h deleted file mode 100644 index 12fab376..00000000 --- a/Platformio/src/devices/mediaPlayer/device_appleTV/device_appleTV.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -extern uint16_t APPLETV_GUI_EVENT_USER_DATA; - -void register_device_appleTV(); diff --git a/Platformio/src/devices/mediaPlayer/device_appleTV/gui_appleTV.cpp b/Platformio/src/devices/mediaPlayer/device_appleTV/gui_appleTV.cpp deleted file mode 100644 index cbe63345..00000000 --- a/Platformio/src/devices/mediaPlayer/device_appleTV/gui_appleTV.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include -#include "applicationInternal/hardware/hardwarePresenter.h" -#include "applicationInternal/gui/guiBase.h" -#include "applicationInternal/gui/guiRegistry.h" -#include "applicationInternal/omote_log.h" -#include "devices/mediaPlayer/device_appleTV/gui_appleTV.h" - -#include "applicationInternal/commandHandler.h" -#include "devices/mediaPlayer/device_appleTV/device_appleTV.h" - -// LVGL declarations -LV_IMG_DECLARE(appleTvIcon); -LV_IMG_DECLARE(appleDisplayIcon); -LV_IMG_DECLARE(appleBackIcon); - -// Apple Key Event handler -static void appleKey_event_cb(lv_event_t* e) { - // Send IR command based on the event user data - int user_data = *((int*)(&(e->user_data))); - executeCommand(APPLETV_GUI_EVENT_USER_DATA, std::to_string(50 + user_data)); - omote_log_v("%d\r\n", 50 + user_data); -} - -void create_tab_content_appleTV(lv_obj_t* tab) { - - // Add content to the Apple TV tab - // Add a nice apple tv logo - lv_obj_t* appleImg = lv_img_create(tab); - lv_img_set_src(appleImg, &appleTvIcon); - lv_obj_align(appleImg, LV_ALIGN_CENTER, 0, -60); - // create two buttons and add their icons accordingly - lv_obj_t* button = lv_btn_create(tab); - lv_obj_align(button, LV_ALIGN_BOTTOM_LEFT, 10, 0); - lv_obj_set_size(button, 60, 60); - lv_obj_set_style_radius(button, 30, LV_PART_MAIN); - lv_obj_set_style_bg_color(button, color_primary, LV_PART_MAIN); - lv_obj_add_event_cb(button, appleKey_event_cb, LV_EVENT_CLICKED, (void*)1); - - appleImg = lv_img_create(button); - lv_img_set_src(appleImg, &appleBackIcon); - lv_obj_set_style_img_recolor(appleImg, lv_color_white(), LV_PART_MAIN); - lv_obj_set_style_img_recolor_opa(appleImg, LV_OPA_COVER, LV_PART_MAIN); - lv_obj_align(appleImg, LV_ALIGN_CENTER, -3, 0); - - button = lv_btn_create(tab); - lv_obj_align(button, LV_ALIGN_BOTTOM_RIGHT, -10, 0); - lv_obj_set_size(button, 60, 60); - lv_obj_set_style_radius(button, 30, LV_PART_MAIN); - lv_obj_set_style_bg_color(button, color_primary, LV_PART_MAIN); - lv_obj_add_event_cb(button, appleKey_event_cb, LV_EVENT_CLICKED, (void*)2); - - appleImg = lv_img_create(button); - lv_img_set_src(appleImg, &appleDisplayIcon); - lv_obj_set_style_img_recolor(appleImg, lv_color_white(), LV_PART_MAIN); - lv_obj_set_style_img_recolor_opa(appleImg, LV_OPA_COVER, LV_PART_MAIN); - lv_obj_align(appleImg, LV_ALIGN_CENTER, 0, 0); - -} - -void notify_tab_before_delete_appleTV(void) { - // remember to set all pointers to lvgl objects to NULL if they might be accessed from outside. - // They must check if object is NULL and must not use it if so - -} - -void register_gui_appleTV(void){ - register_gui(std::string(tabName_appleTV), & create_tab_content_appleTV, & notify_tab_before_delete_appleTV); -} diff --git a/Platformio/src/devices/mediaPlayer/device_appleTV/gui_appleTV.h b/Platformio/src/devices/mediaPlayer/device_appleTV/gui_appleTV.h deleted file mode 100644 index 3eaa3c92..00000000 --- a/Platformio/src/devices/mediaPlayer/device_appleTV/gui_appleTV.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -#include - -const char * const tabName_appleTV = "Apple TV"; -void register_gui_appleTV(void); diff --git a/Platformio/src/devices/mediaPlayer/device_appleTV/gui_appleTV_assets.c b/Platformio/src/devices/mediaPlayer/device_appleTV/gui_appleTV_assets.c deleted file mode 100644 index 6f76c160..00000000 --- a/Platformio/src/devices/mediaPlayer/device_appleTV/gui_appleTV_assets.c +++ /dev/null @@ -1,146 +0,0 @@ -#include - -#ifndef LV_ATTRIBUTE_MEM_ALIGN -#define LV_ATTRIBUTE_MEM_ALIGN -#endif - -#ifndef LV_ATTRIBUTE_IMG_APPLETVICON -#define LV_ATTRIBUTE_IMG_APPLETVICON -#endif - -const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST uint8_t appleTvIcon_map[] = { - /*Pixel format: Red: 5 bit, Green: 6 bit, Blue: 5 bit*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x42, 0x55, 0xad, 0xdb, 0xde, 0x1c, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xad, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0x5d, 0xef, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79, 0xce, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdb, 0xde, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x21, 0x34, 0xa5, 0x55, 0xad, 0x55, 0xad, 0x55, 0xad, 0x55, 0xad, 0x55, 0xad, 0x55, 0xad, 0xcf, 0x7b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0xc6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x76, 0xb5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe7, 0x39, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x71, 0x8c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x69, 0x4a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe7, 0x39, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe7, 0x39, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcf, 0x7b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x5d, 0xef, 0x65, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe7, 0x39, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb6, 0xb5, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7d, 0xef, 0x8a, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe7, 0x39, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, 0xce, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9a, 0xd6, 0x08, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe7, 0x39, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xad, 0x9a, 0xd6, 0xd7, 0xbd, 0x8e, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe7, 0x39, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6e, 0x73, 0xd7, 0xbd, 0xbb, 0xde, 0x3c, 0xe7, 0xfc, 0xe6, 0x39, 0xce, 0x72, 0x94, 0xa7, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa3, 0x18, 0x8e, 0x73, 0xd7, 0xbd, 0x1c, 0xe7, 0x9e, 0xf7, 0xbe, 0xf7, 0x5d, 0xef, 0x9a, 0xd6, 0x34, 0xa5, 0x28, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe7, 0x39, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4d, 0x6b, 0xfb, 0xde, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff, 0x7a, 0xd6, 0x71, 0x8c, 0xa6, 0x31, 0x2d, 0x6b, 0xb6, 0xb5, 0x7d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff, 0xd7, 0xbd, 0xa3, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa7, 0x39, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb3, 0x9c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3c, 0xe7, 0x49, 0x4a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x38, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x69, 0x4a, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x59, 0xce, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff, 0x14, 0xa5, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb3, 0x9c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3d, 0xef, 0x24, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x39, 0xce, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdb, 0xde, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbe, 0xf7, 0x45, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x83, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1c, 0xe7, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x0c, 0x63, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x5d, 0xef, 0xeb, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x39, 0xce, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb3, 0x9c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x10, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0xc6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x14, 0xa5, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xdb, 0xde, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdb, 0xde, 0x86, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x39, 0xce, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0x31, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x39, 0xce, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff, 0xe7, 0x39, 0x00, 0x00, - 0x00, 0x00, 0x8e, 0x73, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3d, 0xef, 0x86, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x39, 0xce, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, 0xce, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbe, 0xf7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8e, 0x73, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9a, 0xd6, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x79, 0xce, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6d, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7a, 0xd6, 0x3c, 0xe7, 0x3c, 0xe7, 0x3d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9e, 0xf7, 0x3c, 0xe7, 0x3c, 0xe7, 0x3c, 0xe7, 0x3c, 0xe7, 0x3c, 0xe7, 0x96, 0xb5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x83, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x83, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd7, 0xbd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x8c, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x9e, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7a, 0xd6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa7, 0x39, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x18, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9e, 0xf7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xec, 0x62, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x8c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe7, 0x39, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb7, 0xbd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7d, 0xef, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6e, 0x73, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xc5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x31, 0x8c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x49, 0x4a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe7, 0x39, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x63, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x4d, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd7, 0xbd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6e, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xd3, 0x9c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbf, 0xff, 0xe4, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe7, 0x39, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd7, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x5d, 0xef, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x55, 0xad, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbf, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe7, 0x39, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0xa5, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x5d, 0xef, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xeb, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x76, 0xb5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x34, 0xa5, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff, 0x28, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe7, 0x39, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa7, 0x39, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x2d, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x96, 0xb5, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x29, 0x4a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x92, 0x94, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xae, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe7, 0x39, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9a, 0xd6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x96, 0xb5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbb, 0xde, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xf0, 0x83, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xc5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe7, 0x39, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0x94, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1c, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xeb, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x8a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbf, 0xff, 0x28, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe7, 0x39, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbe, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8a, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xad, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff, 0x45, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x9e, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7a, 0xd6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe7, 0x39, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0xc6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x75, 0xad, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xe6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x59, 0xce, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x9a, 0xd6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe7, 0x39, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x6b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, 0x4a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf, 0x7b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xf4, 0xa4, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x59, 0xce, 0x86, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe7, 0x39, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x49, 0x4a, 0x00, 0x00, 0x00, 0x00, 0x55, 0xad, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7d, 0xef, 0xa3, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xa6, 0x31, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9e, 0xf7, 0xef, 0x7b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe7, 0x39, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x96, 0xb5, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x14, 0xa5, 0x00, 0x00, 0x00, 0x00, 0xfb, 0xde, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd7, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x9a, 0xd6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0c, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe7, 0x39, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x4a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdb, 0xde, 0x00, 0x00, 0x29, 0x4a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xeb, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x51, 0x8c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdb, 0xde, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe7, 0x39, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x39, 0xce, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdb, 0xde, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0x39, 0xf3, 0x9c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x10, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe7, 0x39, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7d, 0xef, 0x24, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0x31, 0x29, 0x4a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x9c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x9c, 0xbb, 0xde, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x14, 0xa5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x51, 0x8c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa7, 0x39, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xe6, 0xd3, 0x9c, 0x51, 0x8c, 0x34, 0xa5, 0x9a, 0xd6, 0xdf, 0xff, 0xf7, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0x31, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdb, 0xde, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff, 0x08, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xe6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf, 0x7b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1c, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, 0xce, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9a, 0xd6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xec, 0x62, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x79, 0xce, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff, 0xe7, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcf, 0x7b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x51, 0x8c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xad, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9e, 0xf7, 0xe7, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb7, 0xbd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x30, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9e, 0xf7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, 0xce, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x10, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe8, 0x41, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd7, 0xbd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x18, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9a, 0xd6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb2, 0x94, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x51, 0x8c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x39, 0xce, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x63, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8e, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0xc6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9e, 0xf7, 0x39, 0xce, 0x72, 0x94, 0xcb, 0x5a, 0xa3, 0x18, 0x4d, 0x6b, 0x34, 0xa5, 0xfb, 0xde, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbe, 0xf7, 0x72, 0x94, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaf, 0x7b, 0x3c, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7d, 0xef, 0xd7, 0xbd, 0xeb, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x5d, 0xef, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6e, 0x73, 0xf8, 0xc5, 0xba, 0xd6, 0xd7, 0xbd, 0xf0, 0x83, 0xa3, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x4a, 0xf3, 0x9c, 0xf8, 0xc5, 0x59, 0xce, 0x55, 0xad, 0x08, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xae, 0x73, 0x76, 0xb5, 0x39, 0xce, 0x7a, 0xd6, 0x39, 0xce, 0xd7, 0xbd, 0xd3, 0x9c, 0xec, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, 0x4a, 0x0c, 0x63, 0x0c, 0x63, 0x0c, 0x63, 0x0c, 0x63, 0x0c, 0x63, 0x0c, 0x63, 0x0c, 0x63, 0x49, 0x4a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -const lv_img_dsc_t appleTvIcon = { - .header.cf = LV_IMG_CF_TRUE_COLOR, - .header.always_zero = 0, - .header.reserved = 0, - .header.w = 91, - .header.h = 42, - .data_size = 3822 * LV_COLOR_SIZE / 8, - .data = appleTvIcon_map, -}; - - -#ifndef LV_ATTRIBUTE_IMG_APPLEDISPLAYICON -#define LV_ATTRIBUTE_IMG_APPLEDISPLAYICON -#endif - -const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST uint8_t appleDisplayIcon_map[] = { - 0x23, 0xc6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd8, 0x3d, - 0xaa, 0xfd, 0xad, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0xa1, 0xf7, 0xd8, - 0xd0, 0xd1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa1, 0xff, - 0xd2, 0xcb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9a, 0xff, - 0xd2, 0xcb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9a, 0xff, - 0xd2, 0xcb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9a, 0xff, - 0xd2, 0xcb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9a, 0xff, - 0xd2, 0xcb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9a, 0xff, - 0xd2, 0xcb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9a, 0xff, - 0xd2, 0xcb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9a, 0xff, - 0xd2, 0xcb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9a, 0xff, - 0xd2, 0xcb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9a, 0xff, - 0xd2, 0xcb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9a, 0xff, - 0xd2, 0xcb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9a, 0xff, - 0xc6, 0xea, 0x2a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1f, 0xcc, 0xf6, - 0x6c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x98, - 0x00, 0x44, 0x7b, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x7d, 0x56, 0x03, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0xb7, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc0, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0xd3, 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xdb, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -const lv_img_dsc_t appleDisplayIcon = { - .header.cf = LV_IMG_CF_ALPHA_8BIT, - .header.always_zero = 0, - .header.reserved = 0, - .header.w = 25, - .header.h = 20, - .data_size = 500, - .data = appleDisplayIcon_map, -}; - - -#ifndef LV_ATTRIBUTE_IMG_APPLEBACKICON -#define LV_ATTRIBUTE_IMG_APPLEBACKICON -#endif - -const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_APPLEBACKICON uint8_t appleBackIcon_map[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0f, 0x07, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3d, 0xbe, 0x94, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3b, 0xe7, 0xff, 0xf0, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3b, 0xfa, 0xff, 0xf5, 0x31, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x43, 0xfc, 0xff, 0xea, 0x3e, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4d, 0xee, 0xff, 0xe6, 0x48, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x50, 0xed, 0xff, 0xe9, 0x39, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x55, 0xfc, 0xff, 0xe7, 0x25, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x59, 0xff, 0xff, 0xe0, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x5e, 0xf6, 0xff, 0xdb, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x64, 0xf4, 0xff, 0xd9, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x4d, 0xff, 0xff, 0xce, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x6b, 0xff, 0xff, 0x9e, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x9c, 0xff, 0xff, 0xa8, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x04, 0x8f, 0xff, 0xff, 0xb5, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x03, 0x91, 0xff, 0xff, 0xba, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x93, 0xff, 0xff, 0xbb, 0x0a, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x87, 0xfc, 0xff, 0xbf, 0x14, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xfb, 0xff, 0xc5, 0x22, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x78, 0xff, 0xff, 0xca, 0x1e, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0xff, 0xff, 0xd0, 0x11, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x6e, 0xfb, 0xff, 0xcc, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0xea, 0xca, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x28, 0x18, -}; - -const lv_img_dsc_t appleBackIcon = { - .header.cf = LV_IMG_CF_ALPHA_8BIT, - .header.always_zero = 0, - .header.reserved = 0, - .header.w = 13, - .header.h = 25, - .data_size = 325, - .data = appleBackIcon_map, -}; diff --git a/Platformio/src/devices/misc/device_smarthome/device_smarthome.cpp b/Platformio/src/devices/misc/device_smarthome/device_smarthome.cpp deleted file mode 100644 index 2ff6a5a8..00000000 --- a/Platformio/src/devices/misc/device_smarthome/device_smarthome.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "applicationInternal/commandHandler.h" -#include "device_smarthome.h" - -uint16_t SMARTHOME_MQTT_BULB1_SET ; //"Smarthome_mqtt_bulb1_set"; -uint16_t SMARTHOME_MQTT_BULB2_SET ; //"Smarthome_mqtt_bulb2_set"; -uint16_t SMARTHOME_MQTT_BULB1_BRIGHTNESS_SET ; //"Smarthome_mqtt_bulb1_brightness_set"; -uint16_t SMARTHOME_MQTT_BULB2_BRIGHTNESS_SET ; //"Smarthome_mqtt_bulb2_brightness_set"; - -void register_device_smarthome() { - #if (ENABLE_WIFI_AND_MQTT == 1) - register_command(&SMARTHOME_MQTT_BULB1_SET , makeCommandData(MQTT, {"bulb1_set" })); // payload must be set when calling commandHandler - register_command(&SMARTHOME_MQTT_BULB2_SET , makeCommandData(MQTT, {"bulb2_set" })); // payload must be set when calling commandHandler - register_command(&SMARTHOME_MQTT_BULB1_BRIGHTNESS_SET , makeCommandData(MQTT, {"bulb1_setbrightness" })); // payload must be set when calling commandHandler - register_command(&SMARTHOME_MQTT_BULB2_BRIGHTNESS_SET , makeCommandData(MQTT, {"bulb2_setbrightness" })); // payload must be set when calling commandHandler - #endif -} diff --git a/Platformio/src/devices/misc/device_smarthome/device_smarthome.h b/Platformio/src/devices/misc/device_smarthome/device_smarthome.h deleted file mode 100644 index 88a4e162..00000000 --- a/Platformio/src/devices/misc/device_smarthome/device_smarthome.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -extern uint16_t SMARTHOME_MQTT_BULB1_SET; -extern uint16_t SMARTHOME_MQTT_BULB2_SET; -extern uint16_t SMARTHOME_MQTT_BULB1_BRIGHTNESS_SET; -extern uint16_t SMARTHOME_MQTT_BULB2_BRIGHTNESS_SET; - -void register_device_smarthome(); diff --git a/Platformio/src/devices/misc/device_smarthome/gui_smarthome.cpp b/Platformio/src/devices/misc/device_smarthome/gui_smarthome.cpp deleted file mode 100644 index f736070b..00000000 --- a/Platformio/src/devices/misc/device_smarthome/gui_smarthome.cpp +++ /dev/null @@ -1,188 +0,0 @@ -#include -#include "applicationInternal/gui/guiBase.h" -#include "applicationInternal/gui/guiRegistry.h" -#include "applicationInternal/hardware/hardwarePresenter.h" -#include "applicationInternal/scenes/sceneRegistry.h" -#include "applicationInternal/commandHandler.h" -#include "applicationInternal/keys.h" -#include "devices/misc/device_smarthome/gui_smarthome.h" -#include "devices/misc/device_smarthome/device_smarthome.h" -#include "scenes/scene__default.h" - -// LVGL declarations -LV_IMG_DECLARE(lightbulb); - -static lv_obj_t* lightToggleA; -static lv_obj_t* lightToggleB; -static lv_obj_t* sliderA; -static lv_obj_t* sliderB; - -static bool lightToggleAstate = false; -static bool lightToggleBstate = false; -static int32_t sliderAvalue = 0; -static int32_t sliderBvalue = 0; - -uint16_t GUI_SMARTHOME_ACTIVATE; - -std::map key_repeatModes_smarthome = {}; -std::map key_commands_short_smarthome = {}; -std::map key_commands_long_smarthome = {}; - -// Smart Home Toggle Event handler -static void smartHomeToggle_event_cb(lv_event_t* e){ - std::string payload; - if (lv_obj_has_state(lv_event_get_target(e), LV_STATE_CHECKED)) payload = "true"; - else payload = "false"; - // Publish an MQTT message based on the event user data - #if (ENABLE_WIFI_AND_MQTT == 1) - int user_data = *((int*)(&(e->user_data))); - if(user_data == 1) executeCommand(SMARTHOME_MQTT_BULB1_SET, payload); - if(user_data == 2) executeCommand(SMARTHOME_MQTT_BULB2_SET, payload); - #endif -} - -// Smart Home Slider Event handler -static void smartHomeSlider_event_cb(lv_event_t* e){ - lv_obj_t* slider = lv_event_get_target(e); - char payload[8]; - sprintf(payload, "%.2f", float(lv_slider_get_value(slider))); - std::string payload_str(payload); - // Publish an MQTT message based on the event user data - #if (ENABLE_WIFI_AND_MQTT == 1) - int user_data = *((int*)(&(e->user_data))); - if(user_data == 1) executeCommand(SMARTHOME_MQTT_BULB1_BRIGHTNESS_SET, payload_str); - if(user_data == 2) executeCommand(SMARTHOME_MQTT_BULB2_BRIGHTNESS_SET, payload_str); - #endif -} - -void create_tab_content_smarthome(lv_obj_t* tab) { - - // Add content to the smart home tab - lv_obj_set_layout(tab, LV_LAYOUT_FLEX); - lv_obj_set_flex_flow(tab, LV_FLEX_FLOW_COLUMN); - lv_obj_set_scrollbar_mode(tab, LV_SCROLLBAR_MODE_ACTIVE); - - // Add a label, then a box for the light controls - lv_obj_t* menuLabel = lv_label_create(tab); - lv_label_set_text(menuLabel, "Living Room"); - - lv_obj_t* menuBox = lv_obj_create(tab); - lv_obj_set_size(menuBox, lv_pct(100), 79); - lv_obj_set_style_bg_color(menuBox, color_primary, LV_PART_MAIN); - lv_obj_set_style_border_width(menuBox, 0, LV_PART_MAIN); - - lv_obj_t* bulbIcon = lv_img_create(menuBox); - lv_img_set_src(bulbIcon, &lightbulb); - lv_obj_set_style_img_recolor(bulbIcon, lv_color_white(), LV_PART_MAIN); - lv_obj_set_style_img_recolor_opa(bulbIcon, LV_OPA_COVER, LV_PART_MAIN); - lv_obj_align(bulbIcon, LV_ALIGN_TOP_LEFT, 0, 0); - - menuLabel = lv_label_create(menuBox); - lv_label_set_text(menuLabel, "Floor Lamp"); - lv_obj_align(menuLabel, LV_ALIGN_TOP_LEFT, 22, 3); - lightToggleA = lv_switch_create(menuBox); - if (lightToggleAstate) { - lv_obj_add_state(lightToggleA, LV_STATE_CHECKED); - } else { - // lv_obj_clear_state(lightToggleA, LV_STATE_CHECKED); - } - lv_obj_set_size(lightToggleA, 40, 22); - lv_obj_align(lightToggleA, LV_ALIGN_TOP_RIGHT, 0, 0); - lv_obj_set_style_bg_color(lightToggleA, lv_color_lighten(color_primary, 50), LV_PART_MAIN); - lv_obj_set_style_bg_color(lightToggleA, color_primary, LV_PART_INDICATOR); - lv_obj_add_event_cb(lightToggleA, smartHomeToggle_event_cb, LV_EVENT_VALUE_CHANGED, (void*)1); - - sliderA = lv_slider_create(menuBox); - lv_slider_set_range(sliderA, 0, 100); - lv_obj_set_style_bg_color(sliderA, lv_color_lighten(lv_color_black(), 30), LV_PART_INDICATOR); - lv_obj_set_style_bg_grad_color(sliderA, lv_color_lighten(lv_palette_main(LV_PALETTE_AMBER), 180), LV_PART_INDICATOR); - lv_obj_set_style_bg_grad_dir(sliderA, LV_GRAD_DIR_HOR, LV_PART_INDICATOR); - lv_obj_set_style_bg_color(sliderA, lv_color_white(), LV_PART_KNOB); - lv_obj_set_style_bg_opa(sliderA, 255, LV_PART_MAIN); - lv_obj_set_style_bg_color(sliderA, lv_color_lighten(color_primary, 50), LV_PART_MAIN); - lv_slider_set_value(sliderA, sliderAvalue, LV_ANIM_OFF); - lv_obj_set_size(sliderA, lv_pct(90), 10); - lv_obj_align(sliderA, LV_ALIGN_TOP_MID, 0, 37); - lv_obj_add_event_cb(sliderA, smartHomeSlider_event_cb, LV_EVENT_VALUE_CHANGED, (void*)1); - - // Add another menu box for a second appliance - menuBox = lv_obj_create(tab); - lv_obj_set_size(menuBox, lv_pct(100), 79); - lv_obj_set_style_bg_color(menuBox, color_primary, LV_PART_MAIN); - lv_obj_set_style_border_width(menuBox, 0, LV_PART_MAIN); - - bulbIcon = lv_img_create(menuBox); - lv_img_set_src(bulbIcon, &lightbulb); - lv_obj_set_style_img_recolor(bulbIcon, lv_color_white(), LV_PART_MAIN); - lv_obj_set_style_img_recolor_opa(bulbIcon, LV_OPA_COVER, LV_PART_MAIN); - lv_obj_align(bulbIcon, LV_ALIGN_TOP_LEFT, 0, 0); - - menuLabel = lv_label_create(menuBox); - lv_label_set_text(menuLabel, "Ceiling Light"); - lv_obj_align(menuLabel, LV_ALIGN_TOP_LEFT, 22, 3); - lightToggleB = lv_switch_create(menuBox); - if (lightToggleBstate) { - lv_obj_add_state(lightToggleB, LV_STATE_CHECKED); - } else { - // lv_obj_clear_state(lightToggleB, LV_STATE_CHECKED); - } - lv_obj_set_size(lightToggleB, 40, 22); - lv_obj_align(lightToggleB, LV_ALIGN_TOP_RIGHT, 0, 0); - lv_obj_set_style_bg_color(lightToggleB, lv_color_lighten(color_primary, 50), LV_PART_MAIN); - lv_obj_set_style_bg_color(lightToggleB, color_primary, LV_PART_INDICATOR); - lv_obj_add_event_cb(lightToggleB, smartHomeToggle_event_cb, LV_EVENT_VALUE_CHANGED, (void*)2); - - sliderB = lv_slider_create(menuBox); - lv_slider_set_range(sliderB, 0, 100); - lv_obj_set_style_bg_color(sliderB, lv_color_lighten(lv_color_black(), 30), LV_PART_INDICATOR); - lv_obj_set_style_bg_grad_color(sliderB, lv_color_lighten(lv_palette_main(LV_PALETTE_AMBER), 180), LV_PART_INDICATOR); - lv_obj_set_style_bg_grad_dir(sliderB, LV_GRAD_DIR_HOR, LV_PART_INDICATOR); - lv_obj_set_style_bg_color(sliderB, lv_color_white(), LV_PART_KNOB); - lv_obj_set_style_bg_opa(sliderB, 255, LV_PART_MAIN); - lv_obj_set_style_bg_color(sliderB, lv_color_lighten(color_primary, 50), LV_PART_MAIN); - lv_slider_set_value(sliderB, sliderBvalue, LV_ANIM_OFF); - lv_obj_set_size(sliderB, lv_pct(90), 10); - lv_obj_align(sliderB, LV_ALIGN_TOP_MID, 0, 37); - lv_obj_add_event_cb(sliderB, smartHomeSlider_event_cb, LV_EVENT_VALUE_CHANGED, (void*)2); - - - // Add another room (empty for now) - menuLabel = lv_label_create(tab); - lv_label_set_text(menuLabel, "Kitchen"); - - menuBox = lv_obj_create(tab); - lv_obj_set_size(menuBox, lv_pct(100), 79); - lv_obj_set_style_bg_color(menuBox, color_primary, LV_PART_MAIN); - lv_obj_set_style_border_width(menuBox, 0, LV_PART_MAIN); - -} - -void notify_tab_before_delete_smarthome(void) { - // remember to set all pointers to lvgl objects to NULL if they might be accessed from outside. - // They must check if object is NULL and must not use it if so - lightToggleAstate = lv_obj_has_state(lightToggleA, LV_STATE_CHECKED); - lightToggleBstate = lv_obj_has_state(lightToggleB, LV_STATE_CHECKED); - sliderAvalue = lv_slider_get_value(sliderA); - sliderBvalue = lv_slider_get_value(sliderB); -} - -void gui_setKeys_smarthome() { - key_commands_short_smarthome = { - {KEY_STOP, SCENE_SELECTION}, - }; -} - -void register_gui_smarthome(void){ - - register_gui( - std::string(tabName_smarthome), - & create_tab_content_smarthome, - & notify_tab_before_delete_smarthome, - & gui_setKeys_smarthome, - & key_repeatModes_smarthome, - & key_commands_short_smarthome, - & key_commands_long_smarthome - ); - - register_command(&GUI_SMARTHOME_ACTIVATE, makeCommandData(GUI, {std::to_string(MAIN_GUI_LIST), std::string(tabName_smarthome)})); -} diff --git a/Platformio/src/devices/misc/device_smarthome/gui_smarthome.h b/Platformio/src/devices/misc/device_smarthome/gui_smarthome.h deleted file mode 100644 index 3c1a58c8..00000000 --- a/Platformio/src/devices/misc/device_smarthome/gui_smarthome.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include - -const char * const tabName_smarthome = "Smart Home"; -extern uint16_t GUI_SMARTHOME_ACTIVATE; -void register_gui_smarthome(void); diff --git a/Platformio/src/devices/misc/device_smarthome/gui_smarthome_assets.c b/Platformio/src/devices/misc/device_smarthome/gui_smarthome_assets.c deleted file mode 100644 index b671b8b6..00000000 --- a/Platformio/src/devices/misc/device_smarthome/gui_smarthome_assets.c +++ /dev/null @@ -1,42 +0,0 @@ -#include - -#ifndef LV_ATTRIBUTE_MEM_ALIGN -#define LV_ATTRIBUTE_MEM_ALIGN -#endif - -#ifndef LV_ATTRIBUTE_IMG_LIGHTBULB -#define LV_ATTRIBUTE_IMG_LIGHTBULB -#endif - -const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_LIGHTBULB uint8_t lightbulb_map[] = { - 0x00, 0x00, 0x00, 0x00, 0x04, 0x1c, 0x1c, 0x04, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x16, 0x95, 0xee, 0xff, 0xff, 0xee, 0x94, 0x15, 0x00, 0x00, - 0x00, 0x27, 0xe3, 0xff, 0xcc, 0x8d, 0x8d, 0xcd, 0xff, 0xe1, 0x26, 0x00, - 0x07, 0xd9, 0xfa, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x5f, 0xfa, 0xd7, 0x06, - 0x65, 0xff, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7a, 0xff, 0x63, - 0xb1, 0xf8, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0xf8, 0xaf, - 0xcc, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdb, 0xcd, - 0xb1, 0xf5, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0xf1, 0xbd, - 0x73, 0xff, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x71, 0xff, 0x74, - 0x0b, 0xd5, 0xfb, 0x40, 0x00, 0x00, 0x00, 0x00, 0x41, 0xfb, 0xd9, 0x0b, - 0x00, 0x24, 0xef, 0xdc, 0x01, 0x00, 0x00, 0x01, 0xdd, 0xee, 0x24, 0x00, - 0x00, 0x00, 0x83, 0xff, 0x30, 0x00, 0x00, 0x30, 0xff, 0x81, 0x00, 0x00, - 0x00, 0x00, 0x12, 0x6c, 0x06, 0x00, 0x00, 0x06, 0x6c, 0x12, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x25, 0xc7, 0xcc, 0xcc, 0xcc, 0xcc, 0xc7, 0x25, 0x00, 0x00, - 0x00, 0x00, 0x25, 0xc7, 0xcc, 0xcc, 0xcc, 0xcc, 0xc7, 0x25, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x1c, 0x76, 0x77, 0x77, 0x76, 0x1c, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x69, 0xff, 0xff, 0xff, 0xff, 0x69, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x21, 0x22, 0x22, 0x21, 0x01, 0x00, 0x00, 0x00, -}; - -const lv_img_dsc_t lightbulb = { - .header.cf = LV_IMG_CF_ALPHA_8BIT, - .header.always_zero = 0, - .header.reserved = 0, - .header.w = 12, - .header.h = 20, - .data_size = 240, - .data = lightbulb_map, -}; diff --git a/Platformio/src/devices/misc/device_specialCommands.cpp b/Platformio/src/devices/misc/device_specialCommands.cpp deleted file mode 100644 index b3cb6009..00000000 --- a/Platformio/src/devices/misc/device_specialCommands.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "applicationInternal/commandHandler.h" -#include "device_specialCommands.h" - -uint16_t MY_SPECIAL_COMMAND; //"My_special_command"; -// uint16_t TRIGGER_UPDATE_OF_OMOTE_SMART_HOME_DEVICES; - -void register_specialCommands() { - get_uniqueCommandID(&COMMAND_UNKNOWN); - - // command to trigger your home automation software to send the states of the smart home devices known to OMOTE - // register_command(&TRIGGER_UPDATE_OF_OMOTE_SMART_HOME_DEVICES, makeCommandData(MQTT, {"put_here_your_topic_to_trigger_update_of_omote_smart_home_devices", "PRESS"})); - - // put SPECIAL commands here if you want - register_command(&MY_SPECIAL_COMMAND, makeCommandData(SPECIAL, {""})); - -} diff --git a/Platformio/src/devices/misc/device_specialCommands.h b/Platformio/src/devices/misc/device_specialCommands.h deleted file mode 100644 index 9c5e8a6a..00000000 --- a/Platformio/src/devices/misc/device_specialCommands.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#include - -extern uint16_t MY_SPECIAL_COMMAND; -// extern uint16_t TRIGGER_UPDATE_OF_OMOTE_SMART_HOME_DEVICES; - -void register_specialCommands(); diff --git a/Platformio/src/devices_pool/AVreceiver/device_denonAvr/device_denonAvr.cpp b/Platformio/src/devices_pool/AVreceiver/device_denonAvr/device_denonAvr.cpp deleted file mode 100644 index 084fab1e..00000000 --- a/Platformio/src/devices_pool/AVreceiver/device_denonAvr/device_denonAvr.cpp +++ /dev/null @@ -1,95 +0,0 @@ -#include -#include "applicationInternal/commandHandler.h" -#include "applicationInternal/hardware/hardwarePresenter.h" -#include "device_denonAvr.h" - -// Only activate the commands that are used. Every command takes 100 bytes, wether used or not. -// uint16_t DENON_POWER_TOGGLE ; //"DENON_POWER_TOGGLE"; -// uint16_t DENON_POWER_SLEEP ; //"DENON_POWER_SLEEP"; -// uint16_t DENON_VOL_MINUS ; //"DENON_VOL_MINUS"; -// uint16_t DENON_VOL_PLUS ; //"DENON_VOL_PLUS"; -// uint16_t DENON_VOL_MUTE ; //"DENON_VOL_MUTE"; -// uint16_t DENON_CHAN_PLUS ; //"DENON_CHAN_PLUS"; -// uint16_t DENON_CHAN_MINUS ; //"DENON_CHAN_MINUS"; -// uint16_t DENON_INPUT_CABLESAT ; //"DENON_INPUT_CABLESAT"; -// uint16_t DENON_INPUT_MEDIAPLAYER ; //"DENON_INPUT_MEDIAPLAYER"; -// uint16_t DENON_INPUT_BLURAY ; //"DENON_INPUT_BLURAY"; -// uint16_t DENON_INPUT_GAME ; //"DENON_INPUT_GAME"; -// uint16_t DENON_INPUT_AUX1 ; //"DENON_INPUT_AUX1"; -// uint16_t DENON_INPUT_AUX2 ; //"DENON_INPUT_AUX2"; -// uint16_t DENON_INPUT_PHONO ; //"DENON_INPUT_PHONO"; -// uint16_t DENON_INPUT_TUNER ; //"DENON_INPUT_TUNER"; -// uint16_t DENON_INPUT_TV ; //"DENON_INPUT_TV"; -// uint16_t DENON_INPUT_USB ; //"DENON_INPUT_USB"; -// uint16_t DENON_INPUT_BLUETOOTH ; //"DENON_INPUT_BLUETOOTH"; -// uint16_t DENON_INPUT_INTERNET ; //"DENON_INPUT_INTERNET"; -// uint16_t DENON_INPUT_HEOS ; //"DENON_INPUT_HEOS"; -// uint16_t DENON_POWER_ECO ; //"DENON_POWER_ECO"; -// uint16_t DENON_INFO ; //"DENON_INFO"; -// uint16_t DENON_OPTION ; //"DENON_OPTION"; -// uint16_t DENON_BACK ; //"DENON_BACK"; -// uint16_t DENON_SETUP ; //"DENON_SETUP"; -// uint16_t DENON_MENU_ENTER ; //"DENON_MENU_ENTER"; -// uint16_t DENON_MENU_UP ; //"DENON_MENU_UP"; -// uint16_t DENON_MENU_LEFT ; //"DENON_MENU_LEFT"; -// uint16_t DENON_MENU_RIGHT ; //"DENON_MENU_RIGHT"; -// uint16_t DENON_MENU_DOWN ; //"DENON_MENU_DOWN"; -// uint16_t DENON_SOUNDMODE_MOVIE ; //"DENON_SOUNDMODE_MOVIE"; -// uint16_t DENON_SOUNDMODE_MUSIC ; //"DENON_SOUNDMODE_MUSIC"; -// uint16_t DENON_SOUNDMODE_GAME ; //"DENON_SOUNDMODE_GAME"; -// uint16_t DENON_SOUNDMODE_PURE ; //"DENON_SOUNDMODE_PURE"; -// uint16_t DENON_QUICKSELECT_1 ; //"DENON_QUICKSELECT_1"; -// uint16_t DENON_QUICKSELECT_2 ; //"DENON_QUICKSELECT_2"; -// uint16_t DENON_QUICKSELECT_3 ; //"DENON_QUICKSELECT_3"; -// uint16_t DENON_QUICKSELECT_4 ; //"DENON_QUICKSELECT_4"; -// uint16_t DENON_MEDIA_PREV ; //"DENON_MEDIA_PREV"; -// uint16_t DENON_MEDIA_PLAYPAUSE ; //"DENON_MEDIA_PLAYPAUSE"; -// uint16_t DENON_MEDIA_NEXT ; //"DENON_MEDIA_NEXT"; - -void register_device_denonAvr() { - // tested with Denon AVR-S660H, works also with others - - // Only activate the commands that are used. Every command takes 100 bytes, wether used or not. - // register_command(&DENON_POWER_TOGGLE , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C028A0088"})); - // register_command(&DENON_POWER_SLEEP , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C02822CAC"})); - // register_command(&DENON_VOL_MINUS , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C0288E862"})); - // register_command(&DENON_VOL_PLUS , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C0280E86A"})); - // register_command(&DENON_VOL_MUTE , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C0284E86E"})); - // register_command(&DENON_CHAN_PLUS , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C0288DC56"})); - // register_command(&DENON_CHAN_MINUS , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C0284DC5A"})); - // register_command(&DENON_INPUT_CABLESAT , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C028CB43A"})); - // register_command(&DENON_INPUT_MEDIAPLAYER , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C0286B430"})); - // register_command(&DENON_INPUT_BLURAY , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C0288B43E"})); - // register_command(&DENON_INPUT_GAME , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C028AB43C"})); - // register_command(&DENON_INPUT_AUX1 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C0289B43F"})); - // register_command(&DENON_INPUT_AUX2 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C0285B433"})); - // register_command(&DENON_INPUT_PHONO , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C028034B6"})); - // register_command(&DENON_INPUT_TUNER , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C028F34B9"})); - // register_command(&DENON_INPUT_TV , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C0284B432"})); - // register_command(&DENON_INPUT_USB , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C028734B1"})); - // register_command(&DENON_INPUT_BLUETOOTH , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C028F74F9"})); - // register_command(&DENON_INPUT_INTERNET , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C028A74FC"})); - // register_command(&DENON_INPUT_HEOS , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C028E34B8"})); - // register_command(&DENON_POWER_ECO , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C02816CEF"})); - // register_command(&DENON_INFO , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C0280E466"})); - // register_command(&DENON_OPTION , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C028ADC54"})); - // register_command(&DENON_BACK , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C028440C6"})); - // register_command(&DENON_SETUP , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C028C40CE"})); - // register_command(&DENON_MENU_ENTER , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C028F800D"})); - // register_command(&DENON_MENU_UP , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C028D800F"})); - // register_command(&DENON_MENU_LEFT , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C028B8009"})); - // register_command(&DENON_MENU_RIGHT , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C02878005"})); - // register_command(&DENON_MENU_DOWN , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C02838001"})); - // register_command(&DENON_SOUNDMODE_MOVIE , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C028928A3"})); - // register_command(&DENON_SOUNDMODE_MUSIC , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C028528AF"})); - // register_command(&DENON_SOUNDMODE_GAME , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C028D28A7"})); - // register_command(&DENON_SOUNDMODE_PURE , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C028AC840"})); - // register_command(&DENON_QUICKSELECT_1 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C028248C8"})); - // register_command(&DENON_QUICKSELECT_2 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C028A48C0"})); - // register_command(&DENON_QUICKSELECT_3 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C028648CC"})); - // register_command(&DENON_QUICKSELECT_4 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C028E48C4"})); - // register_command(&DENON_MEDIA_PREV , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C028C7CF2"})); - // register_command(&DENON_MEDIA_PLAYPAUSE , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C02807CFE"})); - // register_command(&DENON_MEDIA_NEXT , makeCommandData(IR, {std::to_string(IR_PROTOCOL_DENON), "0x2A4C02827CFC"})); - -} diff --git a/Platformio/src/devices_pool/AVreceiver/device_denonAvr/device_denonAvr.h b/Platformio/src/devices_pool/AVreceiver/device_denonAvr/device_denonAvr.h deleted file mode 100644 index cfc5490c..00000000 --- a/Platformio/src/devices_pool/AVreceiver/device_denonAvr/device_denonAvr.h +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once - -// Only activate the commands that are used. Every command takes 100 bytes, wether used or not. -// extern uint16_t DENON_POWER_TOGGLE; -// extern uint16_t DENON_POWER_SLEEP; -// extern uint16_t DENON_VOL_MINUS; -// extern uint16_t DENON_VOL_PLUS; -// extern uint16_t DENON_VOL_MUTE; -// extern uint16_t DENON_CHAN_PLUS; -// extern uint16_t DENON_CHAN_MINUS; -// extern uint16_t DENON_INPUT_CABLESAT; -// extern uint16_t DENON_INPUT_MEDIAPLAYER; -// extern uint16_t DENON_INPUT_BLURAY; -// extern uint16_t DENON_INPUT_GAME; -// extern uint16_t DENON_INPUT_AUX1; -// extern uint16_t DENON_INPUT_AUX2; -// extern uint16_t DENON_INPUT_PHONO; -// extern uint16_t DENON_INPUT_TUNER; -// extern uint16_t DENON_INPUT_TV; -// extern uint16_t DENON_INPUT_USB; -// extern uint16_t DENON_INPUT_BLUETOOTH; -// extern uint16_t DENON_INPUT_INTERNET; -// extern uint16_t DENON_INPUT_HEOS; -// extern uint16_t DENON_POWER_ECO; -// extern uint16_t DENON_INFO; -// extern uint16_t DENON_OPTION; -// extern uint16_t DENON_BACK; -// extern uint16_t DENON_SETUP; -// extern uint16_t DENON_MENU_ENTER; -// extern uint16_t DENON_MENU_UP; -// extern uint16_t DENON_MENU_LEFT; -// extern uint16_t DENON_MENU_RIGHT; -// extern uint16_t DENON_MENU_DOWN; -// extern uint16_t DENON_SOUNDMODE_MOVIE; -// extern uint16_t DENON_SOUNDMODE_MUSIC; -// extern uint16_t DENON_SOUNDMODE_GAME; -// extern uint16_t DENON_SOUNDMODE_PURE; -// extern uint16_t DENON_QUICKSELECT_1; -// extern uint16_t DENON_QUICKSELECT_2; -// extern uint16_t DENON_QUICKSELECT_3; -// extern uint16_t DENON_QUICKSELECT_4; -// extern uint16_t DENON_MEDIA_PREV; -// extern uint16_t DENON_MEDIA_PLAYPAUSE; -// extern uint16_t DENON_MEDIA_NEXT; - -void register_device_denonAvr(); diff --git a/Platformio/src/devices_pool/AVreceiver/device_lgsoundbar/device_lgsoundbar.cpp b/Platformio/src/devices_pool/AVreceiver/device_lgsoundbar/device_lgsoundbar.cpp deleted file mode 100644 index 93ca1ee6..00000000 --- a/Platformio/src/devices_pool/AVreceiver/device_lgsoundbar/device_lgsoundbar.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include -#include "applicationInternal/commandHandler.h" -#include "applicationInternal/hardware/hardwarePresenter.h" -#include "device_lgsoundbar.h" - -uint16_t LGSOUNDBAR_POWER; -//uint16_t LGSOUNDBAR_FUNCTION; -//uint16_t LGSOUNDBAR_FOLDER_UP; -//uint16_t LGSOUNDBAR_FOLDER_DOWN; -//uint16_t LGSOUNDBAR_OPTICAL; -//uint16_t LGSOUNDBAR_MUTE; -//uint16_t LGSOUNDBAR_VOLUME_UP; -//uint16_t LGSOUNDBAR_VOLUME_DOWN; -//uint16_t LGSOUNDBAR_AUTOPOWER; -//uint16_t LGSOUNDBAR_AV_SYNC; -//uint16_t LGSOUNDBAR_INFO; -//uint16_t LGSOUNDBAR_CURSOR_UP; -//uint16_t LGSOUNDBAR_LEFT; -//uint16_t LGSOUNDBAR_ENTER; -//uint16_t LGSOUNDBAR_RIGHT; -//uint16_t LGSOUNDBAR_CURSOR_DOWN; -//uint16_t LGSOUNDBAR_SOUND_EFFECT; -//uint16_t LGSOUNDBAR_AUTOVOLUME; -uint16_t LGSOUNDBAR_WOOFER_LEVEL; -//uint16_t LGSOUNDBAR_1; -//uint16_t LGSOUNDBAR_2; -//uint16_t LGSOUNDBAR_3; -//uint16_t LGSOUNDBAR_4; -//uint16_t LGSOUNDBAR_5; -//uint16_t LGSOUNDBAR_6; -//uint16_t LGSOUNDBAR_7; -//uint16_t LGSOUNDBAR_8; -//uint16_t LGSOUNDBAR_9; -//uint16_t LGSOUNDBAR_0; -//uint16_t LGSOUNDBAR_DOBLY_DRC; -//uint16_t LGSOUNDBAR_SLEEP; - -void register_device_lgsoundbar() { - // LG SOUNDBAR Remote AKB73575421 - register_command(&LGSOUNDBAR_POWER, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x34347887"}})); - //register_command(&LGSOUNDBAR_FUNCTION, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x343451AE"}})); - //register_command(&LGSOUNDBAR_FOLDER_UP, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x343430CF"}})); - //register_command(&LGSOUNDBAR_FOLDER_DOWN, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x3434B04F"}})); - //register_command(&LGSOUNDBAR_OPTICAL, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x34346D92"}})); - //register_command(&LGSOUNDBAR_MUTE, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x3434F807"}})); - //register_command(&LGSOUNDBAR_VOLUME_UP, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x3434E817"}})); - //register_command(&LGSOUNDBAR_VOLUME_DOWN, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x34346897"}})); - //register_command(&LGSOUNDBAR_AUTOPOWER, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x3434C936"}})); - //register_command(&LGSOUNDBAR_AV_SYNC, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x34349B64"}})); - //register_command(&LGSOUNDBAR_INFO, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x3434C53A"}})); - //register_command(&LGSOUNDBAR_CURSOR_UP, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x3434728D"}})); - //register_command(&LGSOUNDBAR_LEFT, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x3434609F"}})); - //register_command(&LGSOUNDBAR_ENTER, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x3434A05F"}})); - //register_command(&LGSOUNDBAR_RIGHT, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x3434E01F"}})); - //register_command(&LGSOUNDBAR_CURSOR_DOWN, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x3434F20D"}})); - //register_command(&LGSOUNDBAR_SOUND_EFFECT, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x3434F40B"}})); - //register_command(&LGSOUNDBAR_AUTOVOLUME, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x343438C7"}})); - register_command(&LGSOUNDBAR_WOOFER_LEVEL, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x34346699"}})); - //register_command(&LGSOUNDBAR_1, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x3434827D"}})); - //register_command(&LGSOUNDBAR_2, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x343442BD"}})); - //register_command(&LGSOUNDBAR_3, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x3434C23D"}})); - //register_command(&LGSOUNDBAR_4, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x343422DD"}})); - //register_command(&LGSOUNDBAR_5, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x3434A25D"}})); - //register_command(&LGSOUNDBAR_6, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x3434629D"}})); - //register_command(&LGSOUNDBAR_7, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x3434E21D"}})); - //register_command(&LGSOUNDBAR_8, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x343412ED"}})); - //register_command(&LGSOUNDBAR_9, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x3434926D"}})); - //register_command(&LGSOUNDBAR_0, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x3434D22D"}})); - //register_command(&LGSOUNDBAR_DOBLY_DRC, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x343446B9"}})); - //register_command(&LGSOUNDBAR_SLEEP, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0x343443BC"}})); -} \ No newline at end of file diff --git a/Platformio/src/devices_pool/AVreceiver/device_lgsoundbar/device_lgsoundbar.h b/Platformio/src/devices_pool/AVreceiver/device_lgsoundbar/device_lgsoundbar.h deleted file mode 100644 index 8e256222..00000000 --- a/Platformio/src/devices_pool/AVreceiver/device_lgsoundbar/device_lgsoundbar.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -extern uint16_t LGSOUNDBAR_POWER; -//extern uint16_t LGSOUNDBAR_FUNCTION; -//extern uint16_t LGSOUNDBAR_FOLDER_UP; -//extern uint16_t LGSOUNDBAR_FOLDER_DOWN; -//extern uint16_t LGSOUNDBAR_OPTICAL; -//extern uint16_t LGSOUNDBAR_MUTE; -//extern uint16_t LGSOUNDBAR_VOLUME_UP; -//extern uint16_t LGSOUNDBAR_VOLUME_DOWN; -//extern uint16_t LGSOUNDBAR_AUTOPOWER; -//extern uint16_t LGSOUNDBAR_AV_SYNC; -//extern uint16_t LGSOUNDBAR_INFO; -//extern uint16_t LGSOUNDBAR_CURSOR_UP; -//extern uint16_t LGSOUNDBAR_LEFT; -//extern uint16_t LGSOUNDBAR_ENTER; -//extern uint16_t LGSOUNDBAR_RIGHT; -//extern uint16_t LGSOUNDBAR_CURSOR_DOWN; -//extern uint16_t LGSOUNDBAR_SOUND_EFFECT; -//extern uint16_t LGSOUNDBAR_AUTOVOLUME; -extern uint16_t LGSOUNDBAR_WOOFER_LEVEL; -//extern uint16_t LGSOUNDBAR_1; -//extern uint16_t LGSOUNDBAR_2; -//extern uint16_t LGSOUNDBAR_3; -//extern uint16_t LGSOUNDBAR_4; -//extern uint16_t LGSOUNDBAR_5; -//extern uint16_t LGSOUNDBAR_6; -//extern uint16_t LGSOUNDBAR_7; -//extern uint16_t LGSOUNDBAR_8; -//extern uint16_t LGSOUNDBAR_9; -//extern uint16_t LGSOUNDBAR_0; -//extern uint16_t LGSOUNDBAR_DOBLY_DRC; -//extern uint16_t LGSOUNDBAR_SLEEP; - -void register_device_lgsoundbar(); \ No newline at end of file diff --git a/Platformio/src/devices_pool/README b/Platformio/src/devices_pool/README deleted file mode 100644 index cb92c1c0..00000000 --- a/Platformio/src/devices_pool/README +++ /dev/null @@ -1,8 +0,0 @@ - -This directory is intended for a pool of devices already contributed by the community of OMOTE. -Files in this directory won't get compiled by default. - -If you want to use one of these devices, then -- copy the corresponding device folder from "/src/devices_pool/..." to "/src/devices/..." -- add the corresponding call to "register_device_*()" into "/src/main.cpp" (and include the device header file in "/src/main.cpp" as well) -- start using the commands defined by the device, e.g. by putting them in the hardware key map of "scene__default.cpp" or of a specific scene diff --git a/Platformio/src/devices_pool/TV/device_lgTV/device_lgTV.cpp b/Platformio/src/devices_pool/TV/device_lgTV/device_lgTV.cpp deleted file mode 100644 index b7933a00..00000000 --- a/Platformio/src/devices_pool/TV/device_lgTV/device_lgTV.cpp +++ /dev/null @@ -1,119 +0,0 @@ -#include -#include "applicationInternal/commandHandler.h" -#include "applicationInternal/hardware/hardwarePresenter.h" -#include "device_lgTV.h" - -// Only activate the commands that are used. Every command takes 100 bytes, wether used or not. -uint16_t LGTV_POWER_TOGGLE; -uint16_t LGTV_SOURCE; -uint16_t LGTV_NUM_1; -uint16_t LGTV_NUM_2; -uint16_t LGTV_NUM_3; -uint16_t LGTV_NUM_4; -uint16_t LGTV_NUM_5; -uint16_t LGTV_NUM_6; -uint16_t LGTV_NUM_7; -uint16_t LGTV_NUM_8; -uint16_t LGTV_NUM_9; -uint16_t LGTV_NUM_0; -uint16_t LGTV_PRECH; -uint16_t LGTV_VOL_MINUS; -uint16_t LGTV_VOL_PLUS; -uint16_t LGTV_MUTE_TOGGLE; -//uint16_t LGTV_CHLIST; -uint16_t LGTV_CHANNEL_UP; -uint16_t LGTV_CHANNEL_DOWN; -uint16_t LGTV_MENU; // Q-Menu -//uint16_t LGTV_APPS; -uint16_t LGTV_GUIDE; -uint16_t LGTV_SETUP; -uint16_t LGTV_INFO; -uint16_t LGTV_UP; -uint16_t LGTV_DOWN; -uint16_t LGTV_LEFT; -uint16_t LGTV_RIGHT; -uint16_t LGTV_OK; -uint16_t LGTV_RETURN; -uint16_t LGTV_EXIT; -uint16_t LGTV_KEY_A; -uint16_t LGTV_KEY_B; -uint16_t LGTV_KEY_C; -uint16_t LGTV_KEY_D; -//uint16_t LGTV_PSIZE; -//uint16_t LGTV_ADSUBT; -//uint16_t LGTV_REWIND; -//uint16_t LGTV_PAUSE; -//uint16_t LGTV_FASTFORWARD; -//uint16_t LGTV_RECORD; -//uint16_t LGTV_PLAY; -//uint16_t LGTV_STOP; -//uint16_t LGTV_POWER_OFF; -//uint16_t LGTV_POWER_ON; -uint16_t LGTV_INPUT_HDMI_1; -uint16_t LGTV_INPUT_HDMI_2; -uint16_t LGTV_INPUT_HDMI_3; -//uint16_t LGTV_INPUT_COMPONENT; -uint16_t LGTV_INPUT_TV; -//uint16_t LGTV_SLEEP; -uint16_t LGTV_3D; -uint16_t LGTV_HOME; - -void register_device_lgTV() -{ - // https://github.com/natcl/studioimaginaire/blob/master/arduino_remote/ircodes.py - // https://tasmota.github.io/docs/Codes-for-IR-Remotes/#lg-55uh8509-tv - // Tested on LG 42LA6208-ZA - - register_command(&LGTV_POWER_TOGGLE , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF10EF"})); - register_command(&LGTV_SOURCE , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DFD02F"})); - register_command(&LGTV_NUM_1 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF8877"})); - register_command(&LGTV_NUM_2 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF48B7"})); - register_command(&LGTV_NUM_3 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DFC837"})); - register_command(&LGTV_NUM_4 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF28D7"})); - register_command(&LGTV_NUM_5 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DFA857"})); - register_command(&LGTV_NUM_6 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF6897"})); - register_command(&LGTV_NUM_7 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DFE817"})); - register_command(&LGTV_NUM_8 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF18E7"})); - register_command(&LGTV_NUM_9 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF9867"})); - register_command(&LGTV_NUM_0 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF08F7"})); - register_command(&LGTV_PRECH , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF5BA7"})); - register_command(&LGTV_VOL_MINUS , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DFC03F"})); - register_command(&LGTV_VOL_PLUS , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF40BF"})); - register_command(&LGTV_MUTE_TOGGLE , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF906F"})); - //register_command(&LGTV_CHLIST , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DFCA35"})); - register_command(&LGTV_CHANNEL_UP , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF00FF"})); - register_command(&LGTV_CHANNEL_DOWN , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF807F"})); - register_command(&LGTV_MENU , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DFA25D"})); - register_command(&LGTV_GUIDE , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DFD52A"})); - register_command(&LGTV_SETUP , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DFC23D"})); - register_command(&LGTV_INFO , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF55AA"})); - register_command(&LGTV_UP , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF02FD"})); - register_command(&LGTV_DOWN , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF827D"})); - register_command(&LGTV_LEFT , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DFE01F"})); - register_command(&LGTV_RIGHT , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF609F"})); - register_command(&LGTV_OK , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF22DD"})); - register_command(&LGTV_RETURN , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF14EB"})); - register_command(&LGTV_EXIT , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DFDA25"})); - register_command(&LGTV_KEY_A , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF4EB1"})); // Red - register_command(&LGTV_KEY_B , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF8E71"})); // Green - register_command(&LGTV_KEY_C , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DFC639"})); // Yellow - register_command(&LGTV_KEY_D , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF8679"})); // Blue - //register_command(&LGTV_PSIZE , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF0EF1"})); - //register_command(&LGTV_ADSUBT , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF8976"})); - //register_command(&LGTV_REWIND , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DFF10E"})); - //register_command(&LGTV_PAUSE , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF5DA2"})); - //register_command(&LGTV_FASTFORWARD , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF718E"})); - //register_command(&LGTV_RECORD , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DFBD42"})); - //register_command(&LGTV_PLAY , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF0DF2"})); - //register_command(&LGTV_STOP , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF8D72"})); - //register_command(&LGTV_POWER_OFF , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DFA35C"})); - //register_command(&LGTV_POWER_ON , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF23DC"})); - register_command(&LGTV_INPUT_HDMI_1 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF738C"})); - register_command(&LGTV_INPUT_HDMI_2 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF33CC"})); - register_command(&LGTV_INPUT_HDMI_3 , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF9768"})); - //register_command(&LGTV_INPUT_COMPONENT, makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DFFD02"})); - register_command(&LGTV_INPUT_TV , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF6B94"})); - //register_command(&LGTV_SLEEP , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF58A7"})); - register_command(&LGTV_3D , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF3BC4"})); - register_command(&LGTV_HOME , makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x20DF3EC1"})); -} \ No newline at end of file diff --git a/Platformio/src/devices_pool/TV/device_lgTV/device_lgTV.h b/Platformio/src/devices_pool/TV/device_lgTV/device_lgTV.h deleted file mode 100644 index e9d150fb..00000000 --- a/Platformio/src/devices_pool/TV/device_lgTV/device_lgTV.h +++ /dev/null @@ -1,58 +0,0 @@ -#pragma once - -// Only activate the commands that are used. Every command takes 100 bytes, wether used or not. -extern uint16_t LGTV_POWER_TOGGLE; -extern uint16_t LGTV_SOURCE; -extern uint16_t LGTV_NUM_1; -extern uint16_t LGTV_NUM_2; -extern uint16_t LGTV_NUM_3; -extern uint16_t LGTV_NUM_4; -extern uint16_t LGTV_NUM_5; -extern uint16_t LGTV_NUM_6; -extern uint16_t LGTV_NUM_7; -extern uint16_t LGTV_NUM_8; -extern uint16_t LGTV_NUM_9; -extern uint16_t LGTV_NUM_0; -extern uint16_t LGTV_PRECH; -extern uint16_t LGTV_VOL_MINUS; -extern uint16_t LGTV_VOL_PLUS; -extern uint16_t LGTV_MUTE_TOGGLE; -//extern uint16_t LGTV_CHLIST; -extern uint16_t LGTV_CHANNEL_UP; -extern uint16_t LGTV_CHANNEL_DOWN; -extern uint16_t LGTV_MENU; // Q-Menu -//extern uint16_t LGTV_APPS; -extern uint16_t LGTV_GUIDE; -extern uint16_t LGTV_SETUP; -extern uint16_t LGTV_INFO; -extern uint16_t LGTV_UP; -extern uint16_t LGTV_DOWN; -extern uint16_t LGTV_LEFT; -extern uint16_t LGTV_RIGHT; -extern uint16_t LGTV_OK; -extern uint16_t LGTV_RETURN; -extern uint16_t LGTV_EXIT; -extern uint16_t LGTV_KEY_A; -extern uint16_t LGTV_KEY_B; -extern uint16_t LGTV_KEY_C; -extern uint16_t LGTV_KEY_D; -//extern uint16_t LGTV_PSIZE; -//extern uint16_t LGTV_ADSUBT; -//extern uint16_t LGTV_REWIND; -//extern uint16_t LGTV_PAUSE; -//extern uint16_t LGTV_FASTFORWARD; -//extern uint16_t LGTV_RECORD; -//extern uint16_t LGTV_PLAY; -//extern uint16_t LGTV_STOP; -//extern uint16_t LGTV_POWER_OFF; -//extern uint16_t LGTV_POWER_ON; -extern uint16_t LGTV_INPUT_HDMI_1; -extern uint16_t LGTV_INPUT_HDMI_2; -extern uint16_t LGTV_INPUT_HDMI_3; -extern uint16_t LGTV_INPUT_TV; -//extern uint16_t LGTV_INPUT_COMPONENT; -//extern uint16_t LGTV_SLEEP; -extern uint16_t LGTV_3D; -extern uint16_t LGTV_HOME; - -void register_device_lgTV(); \ No newline at end of file diff --git a/Platformio/src/devices_pool/mediaPlayer/device_lgbluray/device_lgbluray.cpp b/Platformio/src/devices_pool/mediaPlayer/device_lgbluray/device_lgbluray.cpp deleted file mode 100644 index ebf2726b..00000000 --- a/Platformio/src/devices_pool/mediaPlayer/device_lgbluray/device_lgbluray.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#include -#include "applicationInternal/commandHandler.h" -#include "applicationInternal/hardware/hardwarePresenter.h" -#include "device_lgbluray.h" - -uint16_t LGBLURAY_POWER; -uint16_t LGBLURAY_OPEN_CLOSE; -//uint16_t LGBLURAY_1; -//uint16_t LGBLURAY_2; -//uint16_t LGBLURAY_3; -//uint16_t LGBLURAY_4; -//uint16_t LGBLURAY_5; -//uint16_t LGBLURAY_6; -//uint16_t LGBLURAY_7; -//uint16_t LGBLURAY_8; -//uint16_t LGBLURAY_9; -//uint16_t LGBLURAY_0; -//uint16_t LGBLURAY_TITLE_POPUP; -//uint16_t LGBLURAY_REPEAT; -uint16_t LGBLURAY_REW; -uint16_t LGBLURAY_FF; -uint16_t LGBLURAY_PREVIOUS; -uint16_t LGBLURAY_SKIP; -uint16_t LGBLURAY_PAUSE; -uint16_t LGBLURAY_PLAY; -uint16_t LGBLURAY_STOP; -uint16_t LGBLURAY_HOME; -uint16_t LGBLURAY_INFO; -uint16_t LGBLURAY_CURSOR_UP; -uint16_t LGBLURAY_LEFT; -uint16_t LGBLURAY_ENTER; -uint16_t LGBLURAY_RIGHT; -uint16_t LGBLURAY_CURSOR_DOWN; -uint16_t LGBLURAY_BACK; -uint16_t LGBLURAY_DISC_MENU; -uint16_t LGBLURAY_KEY_A; -uint16_t LGBLURAY_KEY_B; -uint16_t LGBLURAY_KEY_C; -uint16_t LGBLURAY_KEY_D; - -void register_device_lgbluray() { - // LG BLURAY Remote AKB73896401 - register_command(&LGBLURAY_POWER, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B40CF3"}})); - register_command(&LGBLURAY_OPEN_CLOSE, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B46C93"}})); - //register_command(&LGBLURAY_1, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B4DC23"}})); - //register_command(&LGBLURAY_2, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B43CC3"}})); - //register_command(&LGBLURAY_3, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B4BC43"}})); - //register_command(&LGBLURAY_4, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B47C83"}})); - //register_command(&LGBLURAY_5, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B4FC03"}})); - //register_command(&LGBLURAY_6, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B402FD"}})); - //register_command(&LGBLURAY_7, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B4827D"}})); - //register_command(&LGBLURAY_8, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B442BD"}})); - //register_command(&LGBLURAY_9, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B4C23D"}})); - //register_command(&LGBLURAY_0, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B422DD"}})); - //register_command(&LGBLURAY_TITLE_POPUP, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B452AD"}})); - //register_command(&LGBLURAY_REPEAT, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B4CA35"}})); - register_command(&LGBLURAY_REW, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B44CB3"}})); - register_command(&LGBLURAY_FF, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B4CC33"}})); - register_command(&LGBLURAY_PREVIOUS, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B4AC53"}})); - register_command(&LGBLURAY_SKIP, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B42CD3"}})); - register_command(&LGBLURAY_PAUSE, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B41CE3"}})); - register_command(&LGBLURAY_PLAY, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B48C73"}})); - register_command(&LGBLURAY_STOP, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B49C63"}})); - register_command(&LGBLURAY_HOME, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B4E619"}})); - register_command(&LGBLURAY_INFO, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B45CA3"}})); - register_command(&LGBLURAY_CURSOR_UP, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B4E21D"}})); - register_command(&LGBLURAY_LEFT, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B49A65"}})); - register_command(&LGBLURAY_ENTER, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B41AE5"}})); - register_command(&LGBLURAY_RIGHT, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B45AA5"}})); - register_command(&LGBLURAY_CURSOR_DOWN, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B412ED"}})); - register_command(&LGBLURAY_BACK, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B4A25D"}})); - register_command(&LGBLURAY_DISC_MENU, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B4D22D"}})); - register_command(&LGBLURAY_KEY_A, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B43EC1"}})); - register_command(&LGBLURAY_KEY_B, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B4BE41"}})); - register_command(&LGBLURAY_KEY_C, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B47E81"}})); - register_command(&LGBLURAY_KEY_D, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG), {"0xB4B4FE01"}})); -} \ No newline at end of file diff --git a/Platformio/src/devices_pool/mediaPlayer/device_lgbluray/device_lgbluray.h b/Platformio/src/devices_pool/mediaPlayer/device_lgbluray/device_lgbluray.h deleted file mode 100644 index 6620abeb..00000000 --- a/Platformio/src/devices_pool/mediaPlayer/device_lgbluray/device_lgbluray.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once - -extern uint16_t LGBLURAY_POWER; -extern uint16_t LGBLURAY_OPEN_CLOSE; -//extern uint16_t LGBLURAY_1; -//extern uint16_t LGBLURAY_2; -//extern uint16_t LGBLURAY_3; -//extern uint16_t LGBLURAY_4; -//extern uint16_t LGBLURAY_5; -//extern uint16_t LGBLURAY_6; -//extern uint16_t LGBLURAY_7; -//extern uint16_t LGBLURAY_8; -//extern uint16_t LGBLURAY_9; -//extern uint16_t LGBLURAY_0; -//extern uint16_t LGBLURAY_TITLE_POPUP; -extern uint16_t LGBLURAY_REPEAT; -extern uint16_t LGBLURAY_REW; -extern uint16_t LGBLURAY_FF; -extern uint16_t LGBLURAY_PREVIOUS; -extern uint16_t LGBLURAY_SKIP; -extern uint16_t LGBLURAY_PAUSE; -extern uint16_t LGBLURAY_PLAY; -extern uint16_t LGBLURAY_STOP; -extern uint16_t LGBLURAY_HOME; -extern uint16_t LGBLURAY_INFO; -extern uint16_t LGBLURAY_CURSOR_UP; -extern uint16_t LGBLURAY_LEFT; -extern uint16_t LGBLURAY_ENTER; -extern uint16_t LGBLURAY_RIGHT; -extern uint16_t LGBLURAY_CURSOR_DOWN; -extern uint16_t LGBLURAY_BACK; -extern uint16_t LGBLURAY_DISC_MENU; -extern uint16_t LGBLURAY_KEY_A; -extern uint16_t LGBLURAY_KEY_B; -extern uint16_t LGBLURAY_KEY_C; -extern uint16_t LGBLURAY_KEY_D; - -void register_device_lgbluray(); \ No newline at end of file diff --git a/Platformio/src/devices_pool/mediaPlayer/device_samsungbluray/device_samsungbluray.cpp b/Platformio/src/devices_pool/mediaPlayer/device_samsungbluray/device_samsungbluray.cpp deleted file mode 100644 index 40a6ef0d..00000000 --- a/Platformio/src/devices_pool/mediaPlayer/device_samsungbluray/device_samsungbluray.cpp +++ /dev/null @@ -1,92 +0,0 @@ -#include -#include "applicationInternal/commandHandler.h" -#include "applicationInternal/hardware/hardwarePresenter.h" -#include "device_samsungbluray.h" - -uint16_t SAMSUNGBLURAY_POWER; -uint16_t SAMSUNGBLURAY_OPEN_CLOSE; -//uint16_t SAMSUNGBLURAY_1; -//uint16_t SAMSUNGBLURAY_2; -//uint16_t SAMSUNGBLURAY_3; -//uint16_t SAMSUNGBLURAY_4; -//uint16_t SAMSUNGBLURAY_5; -//uint16_t SAMSUNGBLURAY_6; -//uint16_t SAMSUNGBLURAY_7; -//uint16_t SAMSUNGBLURAY_8; -//uint16_t SAMSUNGBLURAY_9; -//uint16_t SAMSUNGBLURAY_0; -uint16_t SAMSUNGBLURAY_DISC_MENU; -//uint16_t SAMSUNGBLURAY_TITLE_POPUP; -uint16_t SAMSUNGBLURAY_PREVIOUS; -uint16_t SAMSUNGBLURAY_SKIP; -uint16_t SAMSUNGBLURAY_REW; -uint16_t SAMSUNGBLURAY_FF; -uint16_t SAMSUNGBLURAY_STOP; -uint16_t SAMSUNGBLURAY_PLAY; -uint16_t SAMSUNGBLURAY_PAUSE; -uint16_t SAMSUNGBLURAY_AUDIO; -uint16_t SAMSUNGBLURAY_HOME; -uint16_t SAMSUNGBLURAY_SUBTITLE; -uint16_t SAMSUNGBLURAY_TOOLS; -uint16_t SAMSUNGBLURAY_INFO; -uint16_t SAMSUNGBLURAY_CURSOR_UP; -uint16_t SAMSUNGBLURAY_LEFT; -uint16_t SAMSUNGBLURAY_ENTER; -uint16_t SAMSUNGBLURAY_RIGHT; -uint16_t SAMSUNGBLURAY_CURSOR_DOWN; -uint16_t SAMSUNGBLURAY_BACK; -uint16_t SAMSUNGBLURAY_EXIT; -uint16_t SAMSUNGBLURAY_KEY_A; -uint16_t SAMSUNGBLURAY_KEY_B; -uint16_t SAMSUNGBLURAY_KEY_C; -uint16_t SAMSUNGBLURAY_KEY_D; -//uint16_t SAMSUNGBLURAY_VIEW; -//uint16_t SAMSUNGBLURAY_A_B; -//uint16_t SAMSUNGBLURAY_REPEAT; -//uint16_t SAMSUNGBLURAY_SCREEN; - -void register_device_samsungbluray() -{ - // SAMSUNG BLURAY AKB73896401 - register_command(&SAMSUNGBLURAY_POWER, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400E00FF"}})); - register_command(&SAMSUNGBLURAY_OPEN_CLOSE, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400E807F"}})); - //register_command(&SAMSUNGBLURAY_1, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400E40BF"}})); - //register_command(&SAMSUNGBLURAY_2, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400EC03F"}})); - //register_command(&SAMSUNGBLURAY_3, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400E20DF"}})); - //register_command(&SAMSUNGBLURAY_4, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400EA05F"}})); - //register_command(&SAMSUNGBLURAY_5, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400E609F"}})); - //register_command(&SAMSUNGBLURAY_6, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400EE01F"}})); - //register_command(&SAMSUNGBLURAY_7, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400E10EF"}})); - //register_command(&SAMSUNGBLURAY_8, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400E906F"}})); - //register_command(&SAMSUNGBLURAY_9, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400E50AF"}})); - //register_command(&SAMSUNGBLURAY_0, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400ED02F"}})); - register_command(&SAMSUNGBLURAY_DISC_MENU, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400EB847"}})); - //register_command(&SAMSUNGBLURAY_TITLE_POPUP, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400E04FB"}})); - register_command(&SAMSUNGBLURAY_PREVIOUS, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400EB04F"}})); - register_command(&SAMSUNGBLURAY_SKIP, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400E8877"}})); - register_command(&SAMSUNGBLURAY_REW, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400E48B7"}})); - register_command(&SAMSUNGBLURAY_FF, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400EA857"}})); - register_command(&SAMSUNGBLURAY_STOP, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400EC837"}})); - register_command(&SAMSUNGBLURAY_PLAY, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400E28D7"}})); - register_command(&SAMSUNGBLURAY_PAUSE, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400E4CB3"}})); - register_command(&SAMSUNGBLURAY_AUDIO, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400EA45B"}})); - register_command(&SAMSUNGBLURAY_HOME, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400E6897"}})); - register_command(&SAMSUNGBLURAY_SUBTITLE, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400E649B"}})); - register_command(&SAMSUNGBLURAY_TOOLS, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400E5CA3"}})); - register_command(&SAMSUNGBLURAY_INFO, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400E7887"}})); - register_command(&SAMSUNGBLURAY_CURSOR_UP, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400E18E7"}})); - register_command(&SAMSUNGBLURAY_LEFT, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400ED827"}})); - register_command(&SAMSUNGBLURAY_ENTER, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400E38C7"}})); - register_command(&SAMSUNGBLURAY_RIGHT, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400E58A7"}})); - register_command(&SAMSUNGBLURAY_CURSOR_DOWN, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400E9867"}})); - register_command(&SAMSUNGBLURAY_BACK, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400EE817"}})); - register_command(&SAMSUNGBLURAY_EXIT, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400ED42B"}})); - register_command(&SAMSUNGBLURAY_KEY_A, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400E847B"}})); - register_command(&SAMSUNGBLURAY_KEY_B, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400E44BB"}})); - register_command(&SAMSUNGBLURAY_KEY_C, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400EC43B"}})); - register_command(&SAMSUNGBLURAY_KEY_D, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400E24DB"}})); - //register_command(&SAMSUNGBLURAY_VIEW, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400ECC33"}})); - //register_command(&SAMSUNGBLURAY_A_B, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400E05C8"}})); - //register_command(&SAMSUNGBLURAY_REPEAT, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400EE41B"}})); - //register_command(&SAMSUNGBLURAY_SCREEN, makeCommandData(IR, {std::to_string(IR_PROTOCOL_SAMSUNG36), {"0x400E9C63"}})); -} \ No newline at end of file diff --git a/Platformio/src/devices_pool/mediaPlayer/device_samsungbluray/device_samsungbluray.h b/Platformio/src/devices_pool/mediaPlayer/device_samsungbluray/device_samsungbluray.h deleted file mode 100644 index 3af68b50..00000000 --- a/Platformio/src/devices_pool/mediaPlayer/device_samsungbluray/device_samsungbluray.h +++ /dev/null @@ -1,45 +0,0 @@ -#pragma once - -extern uint16_t SAMSUNGBLURAY_POWER; -extern uint16_t SAMSUNGBLURAY_OPEN_CLOSE; -//extern uint16_t SAMSUNGBLURAY_1; -//extern uint16_t SAMSUNGBLURAY_2; -//extern uint16_t SAMSUNGBLURAY_3; -//extern uint16_t SAMSUNGBLURAY_4; -//extern uint16_t SAMSUNGBLURAY_5; -//extern uint16_t SAMSUNGBLURAY_6; -//extern uint16_t SAMSUNGBLURAY_7; -//extern uint16_t SAMSUNGBLURAY_8; -//extern uint16_t SAMSUNGBLURAY_9; -//extern uint16_t SAMSUNGBLURAY_0; -extern uint16_t SAMSUNGBLURAY_DISC_MENU; -//extern uint16_t SAMSUNGBLURAY_TITLE_POPUP; -extern uint16_t SAMSUNGBLURAY_PREVIOUS; -extern uint16_t SAMSUNGBLURAY_SKIP; -extern uint16_t SAMSUNGBLURAY_REW; -extern uint16_t SAMSUNGBLURAY_FF; -extern uint16_t SAMSUNGBLURAY_STOP; -extern uint16_t SAMSUNGBLURAY_PLAY; -extern uint16_t SAMSUNGBLURAY_PAUSE; -extern uint16_t SAMSUNGBLURAY_AUDIO; -extern uint16_t SAMSUNGBLURAY_HOME; -extern uint16_t SAMSUNGBLURAY_SUBTITLE; -extern uint16_t SAMSUNGBLURAY_TOOLS; -extern uint16_t SAMSUNGBLURAY_INFO; -extern uint16_t SAMSUNGBLURAY_CURSOR_UP; -extern uint16_t SAMSUNGBLURAY_LEFT; -extern uint16_t SAMSUNGBLURAY_ENTER; -extern uint16_t SAMSUNGBLURAY_RIGHT; -extern uint16_t SAMSUNGBLURAY_CURSOR_DOWN; -extern uint16_t SAMSUNGBLURAY_BACK; -extern uint16_t SAMSUNGBLURAY_EXIT; -extern uint16_t SAMSUNGBLURAY_KEY_A; -extern uint16_t SAMSUNGBLURAY_KEY_B; -extern uint16_t SAMSUNGBLURAY_KEY_C; -extern uint16_t SAMSUNGBLURAY_KEY_D; -//extern uint16_t SAMSUNGBLURAY_VIEW; -//extern uint16_t SAMSUNGBLURAY_A_B; -//extern uint16_t SAMSUNGBLURAY_REPEAT; -//extern uint16_t SAMSUNGBLURAY_SCREEN; - -void register_device_samsungbluray(); \ No newline at end of file diff --git a/Platformio/src/devices_pool/mediaPlayer/device_shield/device_shield.cpp b/Platformio/src/devices_pool/mediaPlayer/device_shield/device_shield.cpp deleted file mode 100644 index 70e7e9b0..00000000 --- a/Platformio/src/devices_pool/mediaPlayer/device_shield/device_shield.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include -#include "applicationInternal/commandHandler.h" -#include "applicationInternal/hardware/hardwarePresenter.h" -#include "device_shield.h" - -uint16_t SHIELD_POWER_TOGGLE; -uint16_t SHIELD_MENU; // -uint16_t SHIELD_EXIT; // ESC -uint16_t SHIELD_STOP; // x -uint16_t SHIELD_PLAY; // space -uint16_t SHIELD_FORWARD; // f -uint16_t SHIELD_REVERSE; // r -uint16_t SHIELD_UP; // up -uint16_t SHIELD_DOWN; // down -uint16_t SHIELD_LEFT; // left -uint16_t SHIELD_RIGHT; // right -uint16_t SHIELD_OK; // return -uint16_t SHIELD_SHIELD; // ? - -void register_device_shield() { -// http://www.hifi-remote.com/wiki/index.php/Infrared_Protocol_Primer -// https://www.avsforum.com/threads/discrete-ir-code-list-for-nvidia-shield-tv.2126570/ - register_command(&SHIELD_POWER_TOGGLE, makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x017E609F"})); - register_command(&SHIELD_MENU, makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x017E906F"})); - register_command(&SHIELD_EXIT, makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x017E40BF"})); - register_command(&SHIELD_STOP, makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x017EE01F"})); - register_command(&SHIELD_PLAY, makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x017E8877"})); - register_command(&SHIELD_FORWARD, makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x017EF00F"})); - register_command(&SHIELD_REVERSE, makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x017E50AF"})); - register_command(&SHIELD_UP, makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x017E30CF"})); - register_command(&SHIELD_DOWN, makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x017E708F"})); - register_command(&SHIELD_LEFT, makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x017ED02F"})); - register_command(&SHIELD_RIGHT, makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x017EB04F"})); - register_command(&SHIELD_OK, makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x017EC03F"})); - register_command(&SHIELD_SHIELD, makeCommandData(IR, {std::to_string(IR_PROTOCOL_NEC), "0x017E847B"})); -} \ No newline at end of file diff --git a/Platformio/src/devices_pool/mediaPlayer/device_shield/device_shield.h b/Platformio/src/devices_pool/mediaPlayer/device_shield/device_shield.h deleted file mode 100644 index 79e2958c..00000000 --- a/Platformio/src/devices_pool/mediaPlayer/device_shield/device_shield.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -extern uint16_t SHIELD_POWER_TOGGLE; -extern uint16_t SHIELD_MENU; -extern uint16_t SHIELD_EXIT; -extern uint16_t SHIELD_STOP; -extern uint16_t SHIELD_PLAY; -extern uint16_t SHIELD_FORWARD; -extern uint16_t SHIELD_REVERSE; -extern uint16_t SHIELD_UP; -extern uint16_t SHIELD_DOWN; -extern uint16_t SHIELD_LEFT; -extern uint16_t SHIELD_RIGHT; -extern uint16_t SHIELD_OK; -extern uint16_t SHIELD_SHIELD; - -void register_device_shield(); \ No newline at end of file diff --git a/Platformio/src/guis/gui_irReceiver.cpp b/Platformio/src/guis/gui_irReceiver.cpp deleted file mode 100644 index 8e2a5935..00000000 --- a/Platformio/src/guis/gui_irReceiver.cpp +++ /dev/null @@ -1,184 +0,0 @@ -#include -#include -#include "applicationInternal/hardware/hardwarePresenter.h" -#include "applicationInternal/gui/guiBase.h" -#include "applicationInternal/gui/guiRegistry.h" -#include "applicationInternal/omote_log.h" -#include "guis/gui_irReceiver.h" - -lv_obj_t* menuBoxToggle; -lv_obj_t* menuBoxMessages; -int16_t boxHeightDeactivated = 0; -int16_t boxHeightActivated = 200; -const int maxCountMessages = 15; -lv_obj_t* irReceivedMessage[maxCountMessages]; -std::string IRmessages[maxCountMessages]; -int messagePos = 0; -int messageCount = 0; -bool tabIsInMemory = false; - -lv_obj_t* objMQTTmessageReceivedTopic; -lv_obj_t* objMQTTmessageReceivedPayload; -std::string lastTopic, lastPayload; - -void printMQTTmessage() { - if (!tabIsInMemory) {return;} - - if (objMQTTmessageReceivedTopic != NULL) { - lv_label_set_text(objMQTTmessageReceivedTopic, lastTopic.c_str()); - } - if (objMQTTmessageReceivedPayload != NULL) { - lv_label_set_text(objMQTTmessageReceivedPayload, lastPayload.c_str()); - } -} - -void showMQTTmessage(std::string topic, std::string payload) { - lastTopic = topic; - lastPayload = payload; - printMQTTmessage(); -} - -void printIRMessages(bool clearMessages = false) { - if (!tabIsInMemory) {return;} - - omote_log_v("\r\n"); - int messagePosLoop; - if (messageCount < maxCountMessages) { - messagePosLoop = 0; - } else { - messagePosLoop = messagePos; - } - - omote_log_v("will start printing messages, beginning at position %d\r\n", messagePosLoop); - for (int i=0; i -#include - -const char * const tabName_irReceiver = "IR Receiver"; -void register_gui_irReceiver(void); - -// used by commandHandler to show WiFi status -void showNewIRmessage(std::string); -void showMQTTmessage(std::string topic, std::string payload); \ No newline at end of file diff --git a/Platformio/src/guis/gui_numpad.cpp b/Platformio/src/guis/gui_numpad.cpp deleted file mode 100644 index 78cadc46..00000000 --- a/Platformio/src/guis/gui_numpad.cpp +++ /dev/null @@ -1,98 +0,0 @@ -#include -#include "applicationInternal/hardware/hardwarePresenter.h" -#include "applicationInternal/gui/guiBase.h" -#include "applicationInternal/gui/guiRegistry.h" -#include "applicationInternal/omote_log.h" -#include "guis/gui_numpad.h" - -#include "applicationInternal/commandHandler.h" -#include "applicationInternal/scenes/sceneHandler.h" -#include "scenes/scene_TV.h" -#include "scenes/scene_fireTV.h" -#include "devices/TV/device_samsungTV/device_samsungTV.h" - -// Virtual Keypad Event handler -static void virtualKeypad_event_cb(lv_event_t* e) { - lv_obj_t* target = lv_event_get_target(e); - lv_obj_t* cont = lv_event_get_current_target(e); - if (target == cont) return; // stop if container was clicked - - int user_data = (intptr_t)(target->user_data); - // send corrensponding number - if (gui_memoryOptimizer_getActiveSceneName() == scene_name_TV) { - uint16_t 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}; - uint16_t command = virtualKeyMapTVNumbers[user_data]; - executeCommand(command); - - } else if (gui_memoryOptimizer_getActiveSceneName() == scene_name_fireTV) { - int virtualKeyMapFireTVNumbers[10] = {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x0}; - int number = virtualKeyMapFireTVNumbers[user_data]; - std::string numberStr = std::to_string(number); - executeCommand(KEYBOARD_SENDSTRING, numberStr); - } else { - omote_log_w("gui_numpad: no known scene is active, don't know what to do with user_data %d\r\n", user_data); - } -} - -void create_tab_content_numpad(lv_obj_t* tab) { - - // Configure number button grid - // A variable declared static inside a function is visible only inside that function, exists only once (not created/destroyed for each call) and is permanent. It is in a sense a private global variable. - static lv_coord_t col_dsc[] = { LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST }; // equal x distribution - static lv_coord_t row_dsc[] = { 52, 52, 52, 52, LV_GRID_TEMPLATE_LAST }; // manual y distribution to compress the grid a bit - - // Create a container with grid for tab - lv_obj_set_style_pad_all(tab, 0, LV_PART_MAIN); - lv_obj_t* cont = lv_obj_create(tab); - lv_obj_set_style_shadow_width(cont, 0, LV_PART_MAIN); - lv_obj_set_style_bg_color(cont, lv_color_black(), LV_PART_MAIN); - lv_obj_set_style_border_width(cont, 0, LV_PART_MAIN); - lv_obj_set_style_grid_column_dsc_array(cont, col_dsc, 0); - lv_obj_set_style_grid_row_dsc_array(cont, row_dsc, 0); - lv_obj_set_size(cont, SCR_WIDTH, 270); - lv_obj_set_layout(cont, LV_LAYOUT_GRID); - lv_obj_align(cont, LV_ALIGN_TOP_MID, 0, 0); - lv_obj_set_style_radius(cont, 0, LV_PART_MAIN); - - lv_obj_t* buttonLabel; - lv_obj_t* obj; - - // Iterate through grid buttons configure them - for (int i = 0; i < 12; i++) { - uint8_t col = i % 3; - uint8_t row = i / 3; - // Create the button object - if ((row == 3) && ((col == 0) || (col == 2))) continue; // Do not create a complete fourth row, only a 0 button - obj = lv_btn_create(cont); - lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_STRETCH, col, 1, LV_GRID_ALIGN_STRETCH, row, 1); - lv_obj_set_style_bg_color(obj, color_primary, LV_PART_MAIN); - lv_obj_set_style_radius(obj, 14, LV_PART_MAIN); - lv_obj_set_style_shadow_color(obj, lv_color_hex(0x404040), LV_PART_MAIN); - lv_obj_add_flag(obj, LV_OBJ_FLAG_EVENT_BUBBLE); // Clicking a button causes a event in its container - // Create Labels for each button - buttonLabel = lv_label_create(obj); - if(i < 9){ - lv_label_set_text(buttonLabel, std::to_string(i+1).c_str()); - lv_obj_set_user_data(obj,(void *)(intptr_t)i); // Add user data so we can identify which button caused the container event - } - else{ - lv_label_set_text(buttonLabel, "0"); - lv_obj_set_user_data(obj, (void *)(intptr_t)9); - } - lv_obj_set_style_text_font(buttonLabel, &lv_font_montserrat_24, LV_PART_MAIN); - lv_obj_center(buttonLabel); - } - // Create a shared event for all button inside container - lv_obj_add_event_cb(cont, virtualKeypad_event_cb, LV_EVENT_CLICKED, NULL); - -} - -void notify_tab_before_delete_numpad(void) { - // remember to set all pointers to lvgl objects to NULL if they might be accessed from outside. - // They must check if object is NULL and must not use it if so - -} - -void register_gui_numpad(void){ - register_gui(std::string(tabName_numpad), & create_tab_content_numpad, & notify_tab_before_delete_numpad); -} diff --git a/Platformio/src/guis/gui_numpad.h b/Platformio/src/guis/gui_numpad.h deleted file mode 100644 index 0648f120..00000000 --- a/Platformio/src/guis/gui_numpad.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -#include - -const char * const tabName_numpad = "Numpad"; -void register_gui_numpad(void); diff --git a/Platformio/src/guis/gui_sceneSelection.cpp b/Platformio/src/guis/gui_sceneSelection.cpp deleted file mode 100644 index 44848f2b..00000000 --- a/Platformio/src/guis/gui_sceneSelection.cpp +++ /dev/null @@ -1,131 +0,0 @@ -#include -#include "applicationInternal/hardware/hardwarePresenter.h" -#include "applicationInternal/gui/guiBase.h" -#include "applicationInternal/gui/guiRegistry.h" -#include "applicationInternal/scenes/sceneRegistry.h" -#include "applicationInternal/commandHandler.h" -#include "applicationInternal/omote_log.h" -#include "guis/gui_sceneSelection.h" - -static uint16_t activate_scene_command; -static bool doForceScene; -//void activate_scene_async(void *command) { -// executeCommand(activate_scene_command); -//} -void activate_scene_cb(lv_timer_t *timer) { - uint16_t scene_command_including_force = (uintptr_t)(timer->user_data); - // get the force flag from the highest bit - uint16_t activate_scene_command = scene_command_including_force & 0x7FFF; - bool doForceScene = (scene_command_including_force & 0x8000) == 0x8000; - if (doForceScene) { - executeCommand(activate_scene_command, "FORCE"); - } else { - executeCommand(activate_scene_command); - } -} - -static int lastShortClickedReceived; -static unsigned long int lastShortClickedReceivedTime; - -static void sceneSelection_event_cb(lv_event_t* e) { - - int user_data = (intptr_t)(e->user_data); - - // we will receive the following events in that order: - // LV_EVENT_PRESSED - // LV_EVENT_RELEASED - // only on short press: LV_EVENT_SHORT_CLICKED - // both on short press and long press: LV_EVENT_CLICKED - // if (lv_event_get_code(e) == LV_EVENT_PRESSED) { - // omote_log_v("pressed\r\n"); - // } - // if (lv_event_get_code(e) == LV_EVENT_RELEASED) { - // omote_log_v("released\r\n"); - // } - if (lv_event_get_code(e) == LV_EVENT_SHORT_CLICKED) { - lastShortClickedReceived = user_data; - lastShortClickedReceivedTime = millis(); - omote_log_v("short clicked, will see what happens next\r\n"); - return; - - } else if (lv_event_get_code(e) == LV_EVENT_CLICKED) { - if ((lastShortClickedReceived == user_data) && (millis() - lastShortClickedReceivedTime < 10)) { - omote_log_v("clicked, will send short click\r\n"); - doForceScene = false; - } else { - omote_log_v("clicked, will send long click\r\n"); - doForceScene = true; - } - } else { - return; - } - - std::string scene_name = get_scenes_on_sceneSelectionGUI()->at(user_data); - - activate_scene_command = get_activate_scene_command(scene_name); - if (activate_scene_command != 0) { - // this line is needed - if (SceneLabel != NULL) {lv_label_set_text(SceneLabel, "changing...");} - // Problem: screen will not get updated and show "changing..." if "executeCommand(activate_scene_command);" is called here - // test 1 (does not work): call lv_timer_handler(); - // lv_timer_handler(); - // test 2 (does not work): async_call - // lv_async_call(activate_scene_async, &activate_scene_command); - // test 3: lv_timer_create() - // needs to run only once, and a very short period of 5 ms to wait until first run is enough - - uint16_t scene_command_including_force; - if (doForceScene) { - // put the force flag into the highest bit - scene_command_including_force = activate_scene_command | 0x8000; - omote_log_d("Scene with index %d and name %s was FORCE selected\r\n", user_data, scene_name.c_str()); - } else { - scene_command_including_force = activate_scene_command; - omote_log_d("Scene with index %d and name %s was selected\r\n", user_data, scene_name.c_str()); - } - lv_timer_t *my_timer = lv_timer_create(activate_scene_cb, 50, (void *)(uintptr_t) scene_command_including_force); - lv_timer_set_repeat_count(my_timer, 1); - - } else { - omote_log_w("Cannot activate scene %s, because command was not found\r\n", scene_name.c_str()); - } -} - -void create_tab_content_sceneSelection(lv_obj_t* tab) { - - // Add content to the sceneSelection tab - - lv_obj_set_layout(tab, LV_LAYOUT_FLEX); - lv_obj_set_flex_flow(tab, LV_FLEX_FLOW_COLUMN); - lv_obj_set_scrollbar_mode(tab, LV_SCROLLBAR_MODE_ACTIVE); - - // -- create a button for each scene ---------------------------------------- - scene_list scenes = get_scenes_on_sceneSelectionGUI(); - if ((scenes != NULL) && (scenes->size() > 0)) { - for (int i=0; isize(); i++) { - lv_obj_t* button = lv_btn_create(tab); - lv_obj_set_size(button, lv_pct(100), 42); - lv_obj_set_style_radius(button, 30, LV_PART_MAIN); - lv_obj_set_style_bg_color(button, color_primary, LV_PART_MAIN); - lv_obj_add_event_cb(button, sceneSelection_event_cb, LV_EVENT_CLICKED, (void *)(intptr_t)i); - lv_obj_add_event_cb(button, sceneSelection_event_cb, LV_EVENT_SHORT_CLICKED, (void *)(intptr_t)i); - //lv_obj_add_event_cb(button, sceneSelection_event_cb, LV_EVENT_PRESSED, (void *)(intptr_t)i); - //lv_obj_add_event_cb(button, sceneSelection_event_cb, LV_EVENT_RELEASED, (void *)(intptr_t)i); - - lv_obj_t* label = lv_label_create(button); - lv_label_set_text(label, scenes->at(i).c_str()); - lv_obj_center(label); - } - } - -} - -void notify_tab_before_delete_sceneSelection(void) { - // remember to set all pointers to lvgl objects to NULL if they might be accessed from outside. - // They must check if object is NULL and must not use it if so - -} - -void register_gui_sceneSelection(void){ - register_gui(std::string(tabName_sceneSelection), & create_tab_content_sceneSelection, & notify_tab_before_delete_sceneSelection); -} diff --git a/Platformio/src/guis/gui_sceneSelection.h b/Platformio/src/guis/gui_sceneSelection.h deleted file mode 100644 index 5829d4bb..00000000 --- a/Platformio/src/guis/gui_sceneSelection.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -#include - -const char * const tabName_sceneSelection = "Scene selection"; -void register_gui_sceneSelection(void); diff --git a/Platformio/src/guis/gui_settings.cpp b/Platformio/src/guis/gui_settings.cpp deleted file mode 100644 index a77b2ad2..00000000 --- a/Platformio/src/guis/gui_settings.cpp +++ /dev/null @@ -1,209 +0,0 @@ -#include -#include "applicationInternal/hardware/hardwarePresenter.h" -#include "applicationInternal/memoryUsage.h" -#include "applicationInternal/gui/guiBase.h" -#include "applicationInternal/gui/guiRegistry.h" -#include "applicationInternal/omote_log.h" -#include "guis/gui_settings.h" - -// LVGL declarations -LV_IMG_DECLARE(high_brightness); -LV_IMG_DECLARE(low_brightness); - -lv_obj_t* objBattSettingsVoltage; -lv_obj_t* objBattSettingsPercentage; -//lv_obj_t* objBattSettingsIscharging; - -// Slider Event handler -static void bl_slider_event_cb(lv_event_t* e){ - lv_obj_t* slider = lv_event_get_target(e); - int32_t slider_value = lv_slider_get_value(slider); - if (slider_value < 60) {slider_value = 60;} - if (slider_value > 255) {slider_value = 255;} - set_backlightBrightness(slider_value); -} - -// Wakeup by IMU Switch Event handler -static void WakeEnableSetting_event_cb(lv_event_t* e){ - set_wakeupByIMUEnabled(lv_obj_has_state(lv_event_get_target(e), LV_STATE_CHECKED)); -} - -// timout event handler -static void timout_event_cb(lv_event_t* e){ - lv_obj_t* drop = lv_event_get_target(e); - uint16_t selected = lv_dropdown_get_selected(drop); - switch (selected) { - case 0: {set_sleepTimeout( 10000); break;} - case 1: {set_sleepTimeout( 20000); break;} - case 2: {set_sleepTimeout( 40000); break;} - case 3: {set_sleepTimeout( 60000); break;} - case 4: {set_sleepTimeout( 180000); break;} - case 5: {set_sleepTimeout( 600000); break;} - case 6: {set_sleepTimeout(3600000); break;} - } - omote_log_v("New timeout: %lu ms\r\n", actualSleepTimeout); - setLastActivityTimestamp(); - // save preferences now, otherwise if you set a very big timeout and upload your firmware again, it never got saved - save_preferences(); -} - -// show memory usage event handler -static void showMemoryUsage_event_cb(lv_event_t* e) { - setShowMemoryUsage(lv_obj_has_state(lv_event_get_target(e), LV_STATE_CHECKED)); -} - -void create_tab_content_settings(lv_obj_t* tab) { - - // Add content to the settings tab - // With a flex layout, setting groups/boxes will position themselves automatically - lv_obj_set_layout(tab, LV_LAYOUT_FLEX); - lv_obj_set_flex_flow(tab, LV_FLEX_FLOW_COLUMN); - lv_obj_set_scrollbar_mode(tab, LV_SCROLLBAR_MODE_ACTIVE); - - // Add a label, then a box for the display settings ----------------------------------------- - lv_obj_t* menuLabel = lv_label_create(tab); - lv_label_set_text(menuLabel, "Display"); - - lv_obj_t* menuBox = lv_obj_create(tab); - lv_obj_set_size(menuBox, lv_pct(100), 109); - lv_obj_set_style_bg_color(menuBox, color_primary, LV_PART_MAIN); - lv_obj_set_style_border_width(menuBox, 0, LV_PART_MAIN); - - lv_obj_t* brightnessIcon = lv_img_create(menuBox); - lv_img_set_src(brightnessIcon, &low_brightness); - lv_obj_set_style_img_recolor(brightnessIcon, lv_color_white(), LV_PART_MAIN); - lv_obj_set_style_img_recolor_opa(brightnessIcon, LV_OPA_COVER, LV_PART_MAIN); - lv_obj_align(brightnessIcon, LV_ALIGN_TOP_LEFT, 0, 0); - lv_obj_t* slider = lv_slider_create(menuBox); - lv_slider_set_range(slider, 60, 255); - lv_obj_set_style_bg_color(slider, lv_color_white(), LV_PART_KNOB); - lv_obj_set_style_bg_opa(slider, LV_OPA_COVER, LV_PART_MAIN); - lv_obj_set_style_bg_color(slider, lv_color_lighten(color_primary, 50), LV_PART_MAIN); - lv_slider_set_value(slider, get_backlightBrightness(), LV_ANIM_OFF); - lv_obj_set_size(slider, lv_pct(66), 10); - lv_obj_align(slider, LV_ALIGN_TOP_MID, 0, 3); - brightnessIcon = lv_img_create(menuBox); - lv_img_set_src(brightnessIcon, &high_brightness); - lv_obj_set_style_img_recolor(brightnessIcon, lv_color_white(), LV_PART_MAIN); - lv_obj_set_style_img_recolor_opa(brightnessIcon, LV_OPA_COVER, LV_PART_MAIN); - lv_obj_align(brightnessIcon, LV_ALIGN_TOP_RIGHT, 0, -1); - lv_obj_add_event_cb(slider, bl_slider_event_cb, LV_EVENT_VALUE_CHANGED, NULL); - - menuLabel = lv_label_create(menuBox); - lv_label_set_text(menuLabel, "Lift to Wake"); - lv_obj_align(menuLabel, LV_ALIGN_TOP_LEFT, 0, 32); - lv_obj_t* wakeToggle = lv_switch_create(menuBox); - lv_obj_set_size(wakeToggle, 40, 22); - lv_obj_align(wakeToggle, LV_ALIGN_TOP_RIGHT, 0, 29); - lv_obj_set_style_bg_color(wakeToggle, lv_color_hex(0x505050), LV_PART_MAIN); - lv_obj_add_event_cb(wakeToggle, WakeEnableSetting_event_cb, LV_EVENT_VALUE_CHANGED, NULL); - if (get_wakeupByIMUEnabled()) { - lv_obj_add_state(wakeToggle, LV_STATE_CHECKED); - } else { - // lv_obj_clear_state(wakeToggle, LV_STATE_CHECKED); - } - - menuLabel = lv_label_create(menuBox); - lv_label_set_text(menuLabel, "Timeout"); - lv_obj_align(menuLabel, LV_ALIGN_TOP_LEFT, 0, 64); - lv_obj_t* drop = lv_dropdown_create(menuBox); - lv_dropdown_set_options(drop, "10s\n" - "20s\n" - "40s\n" - "1m\n" - "3m\n" - "10m\n" - "1h"); // 1h for debug purposes, if you don't want the device to go to slepp - // if you add more options here, do the same in timout_event_cb() - switch (get_sleepTimeout()) { - case 10000: {lv_dropdown_set_selected(drop, 0); break;} - case 20000: {lv_dropdown_set_selected(drop, 1); break;} - case 40000: {lv_dropdown_set_selected(drop, 2); break;} - case 60000: {lv_dropdown_set_selected(drop, 3); break;} - case 180000: {lv_dropdown_set_selected(drop, 4); break;} - case 600000: {lv_dropdown_set_selected(drop, 5); break;} - case 3600000: {lv_dropdown_set_selected(drop, 6); break;} - } - lv_dropdown_set_selected_highlight(drop, true); - lv_obj_align(drop, LV_ALIGN_TOP_RIGHT, 0, 61); - lv_obj_set_size(drop, 70, 22); - //lv_obj_set_style_text_font(drop, &lv_font_montserrat_12, LV_PART_MAIN); - //lv_obj_set_style_text_font(lv_dropdown_get_list(drop), &lv_font_montserrat_12, LV_PART_MAIN); - lv_obj_set_style_pad_top(drop, 1, LV_PART_MAIN); - lv_obj_set_style_bg_color(drop, color_primary, LV_PART_MAIN); - lv_obj_set_style_bg_color(lv_dropdown_get_list(drop), color_primary, LV_PART_MAIN); - lv_obj_set_style_border_width(lv_dropdown_get_list(drop), 1, LV_PART_MAIN); - lv_obj_set_style_border_color(lv_dropdown_get_list(drop), lv_color_hex(0x505050), LV_PART_MAIN); - lv_obj_add_event_cb(drop, timout_event_cb, LV_EVENT_VALUE_CHANGED, NULL); - - // // Add another label, then a settings box for WiFi - // menuLabel = lv_label_create(tab); - // lv_label_set_text(menuLabel, "Wi-Fi"); - // menuBox = lv_obj_create(tab); - // lv_obj_set_size(menuBox, lv_pct(100), 80); - // lv_obj_set_style_bg_color(menuBox, color_primary, LV_PART_MAIN); - // lv_obj_set_style_border_width(menuBox, 0, LV_PART_MAIN); - // menuLabel = lv_label_create(menuBox); - // lv_label_set_text(menuLabel, "Network"); - // menuLabel = lv_label_create(menuBox); - // lv_label_set_text(menuLabel, LV_SYMBOL_RIGHT); - // lv_obj_align(menuLabel, LV_ALIGN_TOP_RIGHT, 0, 0); - // menuLabel = lv_label_create(menuBox); - // lv_label_set_text(menuLabel, "Password"); - // lv_obj_align(menuLabel, LV_ALIGN_TOP_LEFT, 0, 32); - // menuLabel = lv_label_create(menuBox); - // lv_label_set_text(menuLabel, LV_SYMBOL_RIGHT); - // lv_obj_align(menuLabel, LV_ALIGN_TOP_RIGHT, 0, 32); - - // Another setting for the battery ---------------------------------------------------------- - menuLabel = lv_label_create(tab); - lv_label_set_text(menuLabel, "Battery"); - menuBox = lv_obj_create(tab); - lv_obj_set_size(menuBox, lv_pct(100), 77); // 125 - lv_obj_set_style_bg_color(menuBox, color_primary, LV_PART_MAIN); - lv_obj_set_style_border_width(menuBox, 0, LV_PART_MAIN); - - objBattSettingsVoltage = lv_label_create(menuBox); - lv_label_set_text(objBattSettingsVoltage, "Voltage:"); - lv_obj_align(objBattSettingsVoltage, LV_ALIGN_TOP_LEFT, 0, 0); - objBattSettingsPercentage = lv_label_create(menuBox); - lv_label_set_text(objBattSettingsPercentage, "Percentage:"); - lv_obj_align(objBattSettingsPercentage, LV_ALIGN_TOP_LEFT, 0, 32); - // objBattSettingsIscharging = lv_label_create(menuBox); - // lv_label_set_text(objBattSettingsIscharging, "Is charging:"); - // lv_obj_align(objBattSettingsIscharging, LV_ALIGN_TOP_LEFT, 0, 64); - - - // Memory statistics ------------------------------------------------------------------------ - menuLabel = lv_label_create(tab); - lv_label_set_text(menuLabel, "Memory usage"); - menuBox = lv_obj_create(tab); - lv_obj_set_size(menuBox, lv_pct(100), 48); - lv_obj_set_style_bg_color(menuBox, color_primary, LV_PART_MAIN); - lv_obj_set_style_border_width(menuBox, 0, LV_PART_MAIN); - - menuLabel = lv_label_create(menuBox); - lv_label_set_text(menuLabel, "Show mem usage"); - lv_obj_align(menuLabel, LV_ALIGN_TOP_LEFT, 0, 3); - lv_obj_t* memoryUsageToggle = lv_switch_create(menuBox); - lv_obj_set_size(memoryUsageToggle, 40, 22); - lv_obj_align(memoryUsageToggle, LV_ALIGN_TOP_RIGHT, 0, 0); - lv_obj_set_style_bg_color(memoryUsageToggle, lv_color_hex(0x505050), LV_PART_MAIN); - lv_obj_add_event_cb(memoryUsageToggle, showMemoryUsage_event_cb, LV_EVENT_VALUE_CHANGED, NULL); - if (getShowMemoryUsage()) { - lv_obj_add_state(memoryUsageToggle, LV_STATE_CHECKED); - } else { - // lv_obj_clear_state(memoryUsageToggle, LV_STATE_CHECKED); - } -} - -void notify_tab_before_delete_settings(void) { - // remember to set all pointers to lvgl objects to NULL if they might be accessed from outside. - // They must check if object is NULL and must not use it if so - objBattSettingsVoltage = NULL; - objBattSettingsPercentage = NULL; -} - -void register_gui_settings(void){ - register_gui(std::string(tabName_settings), & create_tab_content_settings, & notify_tab_before_delete_settings); -} diff --git a/Platformio/src/guis/gui_settings.h b/Platformio/src/guis/gui_settings.h deleted file mode 100644 index 5856f335..00000000 --- a/Platformio/src/guis/gui_settings.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include - -const char * const tabName_settings = "Settings"; -void register_gui_settings(void); - -// accessed by "guiStatusUpdate.cpp" -extern lv_obj_t* objBattSettingsVoltage; -extern lv_obj_t* objBattSettingsPercentage; -//extern lv_obj_t* objBattSettingsIscharging; - diff --git a/Platformio/src/guis/gui_settings_assets.c b/Platformio/src/guis/gui_settings_assets.c deleted file mode 100644 index a48b5286..00000000 --- a/Platformio/src/guis/gui_settings_assets.c +++ /dev/null @@ -1,74 +0,0 @@ -#include - -#ifndef LV_ATTRIBUTE_MEM_ALIGN -#define LV_ATTRIBUTE_MEM_ALIGN -#endif - -#ifndef LV_ATTRIBUTE_IMG_HIGH_BRIGHTNESS -#define LV_ATTRIBUTE_IMG_HIGH_BRIGHTNESS -#endif - -const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_HIGH_BRIGHTNESS uint8_t high_brightness_map[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc1, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd4, 0xd4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x5c, 0x8e, 0x04, 0x00, 0x00, 0x00, 0xc1, 0xc1, 0x00, 0x00, 0x00, 0x04, 0x8e, 0x5c, 0x00, 0x00, - 0x00, 0x00, 0x8c, 0xff, 0xa8, 0x01, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x00, 0x01, 0xa8, 0xff, 0x8c, 0x00, 0x00, - 0x00, 0x00, 0x04, 0xa9, 0xf5, 0x0d, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x0d, 0xf5, 0xa9, 0x04, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x42, 0xd4, 0xff, 0xff, 0xd4, 0x41, 0x00, 0x0a, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xd5, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xbd, 0xcc, 0xbd, 0x0d, 0x11, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x12, 0x0d, 0xbd, 0xcc, 0xbd, - 0xbd, 0xcc, 0xbd, 0x0d, 0x11, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x10, 0x0d, 0xbd, 0xcc, 0xbd, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xd4, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd2, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x40, 0xd3, 0xff, 0xfe, 0xd2, 0x3f, 0x00, 0x0a, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x04, 0xa9, 0xf5, 0x0d, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x0d, 0xf5, 0xa9, 0x04, 0x00, 0x00, - 0x00, 0x00, 0x8c, 0xff, 0xa8, 0x01, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x00, 0x01, 0xa8, 0xff, 0x8c, 0x00, 0x00, - 0x00, 0x00, 0x5c, 0x8e, 0x04, 0x00, 0x00, 0x00, 0xc1, 0xc1, 0x00, 0x00, 0x00, 0x04, 0x8e, 0x5c, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd4, 0xd4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc1, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -const lv_img_dsc_t high_brightness = { - .header.cf = LV_IMG_CF_ALPHA_8BIT, - .header.always_zero = 0, - .header.reserved = 0, - .header.w = 18, - .header.h = 18, - .data_size = 324, - .data = high_brightness_map, -}; - - -#ifndef LV_ATTRIBUTE_IMG_LOW_BRIGHTNESS -#define LV_ATTRIBUTE_IMG_LOW_BRIGHTNESS -#endif - -const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_LOW_BRIGHTNESS uint8_t low_brightness_map[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x43, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbd, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x27, 0x72, 0x01, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x00, 0x01, 0x72, 0x28, 0x00, 0x00, - 0x00, 0x00, 0x71, 0xf5, 0x0f, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x0d, 0xf5, 0x73, 0x00, 0x00, - 0x00, 0x00, 0x01, 0x0b, 0x00, 0x42, 0xd4, 0xff, 0xff, 0xd4, 0x41, 0x00, 0x0a, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x42, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x40, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xd5, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x00, 0x00, 0x00, 0x00, - 0x43, 0xbd, 0x0d, 0x11, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x12, 0x0d, 0xbc, 0x44, - 0x43, 0xbd, 0x0d, 0x11, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x11, 0x0d, 0xbc, 0x44, - 0x00, 0x00, 0x00, 0x00, 0xd4, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd2, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x41, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0x0b, 0x00, 0x40, 0xd3, 0xfe, 0xff, 0xd2, 0x3f, 0x00, 0x0a, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x71, 0xf5, 0x0f, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x0d, 0xf5, 0x73, 0x00, 0x00, - 0x00, 0x00, 0x27, 0x72, 0x01, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x00, 0x01, 0x72, 0x28, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbd, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x43, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -const lv_img_dsc_t low_brightness = { - .header.cf = LV_IMG_CF_ALPHA_8BIT, - .header.always_zero = 0, - .header.reserved = 0, - .header.w = 16, - .header.h = 16, - .data_size = 256, - .data = low_brightness_map, -}; diff --git a/Platformio/src/main.cpp b/Platformio/src/main.cpp index d1681d9d..03bce4ff 100644 --- a/Platformio/src/main.cpp +++ b/Platformio/src/main.cpp @@ -1,200 +1,666 @@ // OMOTE firmware for ESP32 -// 2023-2024 Maximilian Kern / Klaus Musch - -#include "applicationInternal/omote_log.h" -// init hardware and hardware loop -#include "applicationInternal/hardware/hardwarePresenter.h" -// register devices and their commands -// special -#include "devices/misc/device_specialCommands.h" -#include "applicationInternal/commandHandler.h" -// keyboards -#include "devices/keyboard/device_keyboard_mqtt/device_keyboard_mqtt.h" -#include "devices/keyboard/device_keyboard_ble/device_keyboard_ble.h" -// TV -#include "devices/TV/device_samsungTV/device_samsungTV.h" -//#include "devices/TV/device_lgTV/device_lgTV.h" -// AV receiver -#include "devices/AVreceiver/device_yamahaAmp/device_yamahaAmp.h" -//#include "devices/AVreceiver/device_denonAvr/device_denonAvr.h" -//#include "devices/AVreceiver/device_lgsoundbar/device_lgsoundbar.h" -// media player -#include "devices/mediaPlayer/device_appleTV/device_appleTV.h" -//#include "devices/mediaPlayer/device_lgbluray/device_lgbluray.h" -//#include "devices/mediaPlayer/device_samsungbluray/device_samsungbluray.h" -//#include "devices/mediaPlayer/device_shield/device_shield.h" -// misc -#include "devices/misc/device_smarthome/device_smarthome.h" -// register gui and keys -#include "applicationInternal/gui/guiBase.h" -#include "applicationInternal/gui/guiRegistry.h" -#include "guis/gui_sceneSelection.h" -#include "guis/gui_irReceiver.h" -#include "guis/gui_settings.h" -#include "guis/gui_numpad.h" -#include "devices/AVreceiver/device_yamahaAmp/gui_yamahaAmp.h" -#include "devices/mediaPlayer/device_appleTV/gui_appleTV.h" -#include "devices/misc/device_smarthome/gui_smarthome.h" -#include "applicationInternal/keys.h" -#include "applicationInternal/gui/guiStatusUpdate.h" -// register scenes -#include "scenes/scene__default.h" -#include "scenes/scene_allOff.h" -#include "scenes/scene_TV.h" -#include "scenes/scene_fireTV.h" -#include "scenes/scene_chromecast.h" -#include "scenes/scene_appleTV.h" -#include "applicationInternal/scenes/sceneHandler.h" - -#if defined(ARDUINO) -// in case of Arduino we have a setup() and a loop() -void setup() { - -#elif defined(WIN32) || defined(__linux__) -// in case of Windows/Linux, we have only a main() function, no setup() and loop(), so we have to simulate them -// forward declaration of loop() -void loop(unsigned long *pIMUTaskTimer, unsigned long *pUpdateStatusTimer); -// main function as usual in C -int main(int argc, char *argv[]) { +// 2023 Maximilian Kern + +#include // Hardware-specific library +#include // modified for inverted logic +#include +#include "SparkFunLIS3DH.h" +#include "Wire.h" +#include +#include +#include +#include +#include +#include "WiFi.h" +#include +#include "driver/ledc.h" +#include + +#define ENABLE_WIFI // Comment out to diable connected features + +// Pin assignment ----------------------------------------------------------------------------------------------------------------------- + +#define LCD_DC 9 // defined in TFT_eSPI User_Setup.h +#define LCD_CS 5 +#define LCD_MOSI 23 +#define LCD_SCK 18 +#define LCD_BL 4 +#define LCD_EN 10 + +#define USER_LED 2 + +#define SW_1 32 // 1...5: Output +#define SW_2 26 +#define SW_3 27 +#define SW_4 14 +#define SW_5 12 +#define SW_A 37 // A...E: Input +#define SW_B 38 +#define SW_C 39 +#define SW_D 34 +#define SW_E 35 + +#define IR_RX 15 // IR receiver input +#define ADC_BAT 36 // Battery voltage sense input (1/2 divider) +#define IR_VCC 25 // IR receiver power +#define IR_LED 33 // IR LED output + +#define SCL 22 +#define SDA 19 +#define ACC_INT 20 + +#define CRG_STAT 21 // battery charger feedback + +// Variables and Object declarations ------------------------------------------------------------------------------------------------------ + +// Battery declares +int battery_voltage = 0; +int battery_percentage = 100; +bool battery_ischarging = false; +SFE_MAX1704X fuelGauge(MAX1704X_MAX17048); + +// IMU declarations +int motion = 0; +#define SLEEP_TIMEOUT 20000 // time until device enters sleep mode in milliseconds +#define MOTION_THRESHOLD 50 // motion above threshold keeps device awake +int standbyTimer = SLEEP_TIMEOUT; +bool wakeupByIMUEnabled = true; +LIS3DH IMU(I2C_MODE, 0x19); // Default constructor is I2C, addr 0x19. + +// LCD declarations +TFT_eSPI tft = TFT_eSPI(); +#define screenWidth 240 +#define screenHeight 320 +Adafruit_FT6206 touch = Adafruit_FT6206(); +TS_Point touchPoint; +TS_Point oldPoint; +int backlight_brightness = 255; + +// LVGL declarations +static lv_disp_draw_buf_t draw_buf; +static lv_color_t bufA[ screenWidth * screenHeight / 10 ]; +static lv_color_t bufB[ screenWidth * screenHeight / 10 ]; +lv_obj_t* objBattPercentage; +lv_obj_t* objBattIcon; +lv_obj_t* panel; +lv_color_t color_primary = lv_color_hex(0x303030); // gray + +// Keypad declarations +const byte ROWS = 5; //four rows +const byte COLS = 5; //four columns +//define the symbols on the buttons of the keypads +char hexaKeys[ROWS][COLS] = { + {'s','^','-','m','e'}, // source, channel+, Volume-, mute, record + {'i','r','+','k','d'}, // info, right, Volume+, OK, down + {'4','v','1','3','2'}, // blue, channel-, red, yellow, green + {'>','o','b','u','l'}, // forward, off, back, up, left + {'?','p','c','<','='} // ?, play, config, rewind, stop +}; +byte rowPins[ROWS] = {SW_A, SW_B, SW_C, SW_D, SW_E}; //connect to the row pinouts of the keypad +byte colPins[COLS] = {SW_1, SW_2, SW_3, SW_4, SW_5}; //connect to the column pinouts of the keypad +Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); +#define BUTTON_PIN_BITMASK 0b1110110000000000000000000010000000000000 //IO34+IO35+IO37+IO38+IO39(+IO13) +byte keyMapTechnisat[ROWS][COLS] = { + {0x69,0x20,0x11,0x0D,0x56}, + {0x4F,0x37,0x10,0x57,0x51}, + {0x6E,0x21,0x6B,0x6D,0x6C}, + {0x34,0x0C,0x22,0x50,0x55}, + {'?' ,0x35,0x2F,0x32,0x36} +}; +byte virtualKeyMapTechnisat[10] = {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x0}; +byte currentDevice = 1; // Current Device to control (allows switching mappings between devices) + +// IR declarations +IRsend IrSender(IR_LED, true); +IRrecv IrReceiver(IR_RX); + +// Other declarations +byte wakeup_reason; +enum Wakeup_reasons{WAKEUP_BY_RESET, WAKEUP_BY_IMU, WAKEUP_BY_KEYPAD}; +Preferences preferences; + +#define WIFI_SSID "your_ssid" +#define WIFI_PASSWORD "your_password" +lv_obj_t* WifiLabel; +lv_obj_t* ChecksTable; +WiFiClient espClient; + +// array for checking which keys have already been recognized +char keysWorking[ROWS][COLS] = { + {'0','0','0','0','0'}, + {'0','0','0','0','0'}, + {'0','0','0','0','0'}, + {'0','0','0','0','0'}, + {'x','0','0','0','0'} +}; + +// Helper Functions ----------------------------------------------------------------------------------------------------------------------- + +// Set the page indicator scroll position relative to the tabview scroll position +static void store_scroll_value_event_cb(lv_event_t* e){ + float bias = (150.0 + 8.0) / 240.0; + int offset = 240 / 2 - 150 / 2 - 8 - 50 - 3; + lv_obj_t* screen = lv_event_get_target(e); + lv_obj_scroll_to_x(panel, lv_obj_get_scroll_x(screen) * bias - offset, LV_ANIM_OFF); +} + +// Wakeup by IMU Switch Event handler +static void WakeEnableSetting_event_cb(lv_event_t * e){ + wakeupByIMUEnabled = lv_obj_has_state(lv_event_get_target(e), LV_STATE_CHECKED); +} + +// Display flushing +void my_disp_flush( lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p ){ + uint32_t w = ( area->x2 - area->x1 + 1 ); + uint32_t h = ( area->y2 - area->y1 + 1 ); + + tft.startWrite(); + tft.setAddrWindow( area->x1, area->y1, w, h ); + tft.pushPixelsDMA( ( uint16_t * )&color_p->full, w * h); + tft.endWrite(); + + lv_disp_flush_ready( disp ); +} + +// Read the touchpad +void my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data){ + // int16_t touchX, touchY; + touchPoint = touch.getPoint(); + int16_t touchX = touchPoint.x; + int16_t touchY = touchPoint.y; + bool touched = false; + if ((touchX > 0) || (touchY > 0)) { + touched = true; + standbyTimer = SLEEP_TIMEOUT; + } + + if( !touched ){ + data->state = LV_INDEV_STATE_REL; + } + else{ + data->state = LV_INDEV_STATE_PR; + + // Set the coordinates + data->point.x = screenWidth - touchX; + data->point.y = screenHeight - touchY; + + //Serial.print( "touchpoint: x" ); + //Serial.print( touchX ); + //Serial.print( " y" ); + //Serial.println( touchY ); + //tft.drawFastHLine(0, screenHeight - touchY, screenWidth, TFT_RED); + //tft.drawFastVLine(screenWidth - touchX, 0, screenHeight, TFT_RED); + } +} + +void activityDetection(){ + static int accXold; + static int accYold; + static int accZold; + int accX = IMU.readFloatAccelX()*1000; + int accY = IMU.readFloatAccelY()*1000; + int accZ = IMU.readFloatAccelZ()*1000; + + // determine motion value as da/dt + motion = (abs(accXold - accX) + abs(accYold - accY) + abs(accZold - accZ)); + // Calculate time to standby + standbyTimer -= 100; + if(standbyTimer < 0) standbyTimer = 0; + // If the motion exceeds the threshold, the standbyTimer is reset + if(motion > MOTION_THRESHOLD) standbyTimer = SLEEP_TIMEOUT; + + // Store the current acceleration and time + accXold = accX; + accYold = accY; + accZold = accZ; +} + +void configIMUInterrupts() +{ + uint8_t dataToWrite = 0; + + //LIS3DH_INT1_CFG + //dataToWrite |= 0x80;//AOI, 0 = OR 1 = AND + //dataToWrite |= 0x40;//6D, 0 = interrupt source, 1 = 6 direction source + //Set these to enable individual axes of generation source (or direction) + // -- high and low are used generically + dataToWrite |= 0x20;//Z high + //dataToWrite |= 0x10;//Z low + dataToWrite |= 0x08;//Y high + //dataToWrite |= 0x04;//Y low + dataToWrite |= 0x02;//X high + //dataToWrite |= 0x01;//X low + if(wakeupByIMUEnabled) IMU.writeRegister(LIS3DH_INT1_CFG, 0b00101010); + else IMU.writeRegister(LIS3DH_INT1_CFG, 0b00000000); + + //LIS3DH_INT1_THS + dataToWrite = 0; + //Provide 7 bit value, 0x7F always equals max range by accelRange setting + dataToWrite |= 0x45; + IMU.writeRegister(LIS3DH_INT1_THS, dataToWrite); + + //LIS3DH_INT1_DURATION + dataToWrite = 0; + //minimum duration of the interrupt + //LSB equals 1/(sample rate) + dataToWrite |= 0x00; // 1 * 1/50 s = 20ms + IMU.writeRegister(LIS3DH_INT1_DURATION, dataToWrite); + + //LIS3DH_CTRL_REG5 + //Int1 latch interrupt and 4D on int1 (preserve fifo en) + IMU.readRegister(&dataToWrite, LIS3DH_CTRL_REG5); + dataToWrite &= 0xF3; //Clear bits of interest + dataToWrite |= 0x08; //Latch interrupt (Cleared by reading int1_src) + //dataToWrite |= 0x04; //Pipe 4D detection from 6D recognition to int1? + IMU.writeRegister(LIS3DH_CTRL_REG5, dataToWrite); + + //LIS3DH_CTRL_REG3 + //Choose source for pin 1 + dataToWrite = 0; + //dataToWrite |= 0x80; //Click detect on pin 1 + dataToWrite |= 0x40; //AOI1 event (Generator 1 interrupt on pin 1) + dataToWrite |= 0x20; //AOI2 event () + //dataToWrite |= 0x10; //Data ready + //dataToWrite |= 0x04; //FIFO watermark + //dataToWrite |= 0x02; //FIFO overrun + IMU.writeRegister(LIS3DH_CTRL_REG3, dataToWrite); + +} + +// Enter Sleep Mode +void enterSleep(){ + // Save settings to internal flash memory + preferences.putBool("wkpByIMU", wakeupByIMUEnabled); + preferences.putUChar("blBrightness", backlight_brightness); + preferences.putUChar("currentDevice", currentDevice); + if(!preferences.getBool("alreadySetUp")) preferences.putBool("alreadySetUp", true); + preferences.end(); + + // Configure IMU + uint8_t intDataRead; + IMU.readRegister(&intDataRead, LIS3DH_INT1_SRC);//clear interrupt + configIMUInterrupts(); + IMU.readRegister(&intDataRead, LIS3DH_INT1_SRC);//really clear interrupt + + #ifdef ENABLE_WIFI + // Power down modem + WiFi.disconnect(); + WiFi.mode(WIFI_OFF); + #endif + + // Prepare IO states + digitalWrite(LCD_DC, LOW); // LCD control signals off + digitalWrite(LCD_CS, LOW); + digitalWrite(LCD_MOSI, LOW); + digitalWrite(LCD_SCK, LOW); + digitalWrite(LCD_EN, HIGH); // LCD logic off + digitalWrite(LCD_BL, HIGH); // LCD backlight off + pinMode(CRG_STAT, INPUT); // Disable Pull-Up + digitalWrite(IR_VCC, LOW); // IR Receiver off + + // Configure button matrix for ext1 interrupt + pinMode(SW_1, OUTPUT); + pinMode(SW_2, OUTPUT); + pinMode(SW_3, OUTPUT); + pinMode(SW_4, OUTPUT); + pinMode(SW_5, OUTPUT); + digitalWrite(SW_1, HIGH); + digitalWrite(SW_2, HIGH); + digitalWrite(SW_3, HIGH); + digitalWrite(SW_4, HIGH); + digitalWrite(SW_5, HIGH); + gpio_hold_en((gpio_num_t)SW_1); + gpio_hold_en((gpio_num_t)SW_2); + gpio_hold_en((gpio_num_t)SW_3); + gpio_hold_en((gpio_num_t)SW_4); + gpio_hold_en((gpio_num_t)SW_5); + // Force display pins to high impedance + // Without this the display might not wake up from sleep + pinMode(LCD_BL, INPUT); + pinMode(LCD_EN, INPUT); + gpio_hold_en((gpio_num_t)LCD_BL); + gpio_hold_en((gpio_num_t)LCD_EN); + gpio_deep_sleep_hold_en(); + + esp_sleep_enable_ext1_wakeup(BUTTON_PIN_BITMASK, ESP_EXT1_WAKEUP_ANY_HIGH); + + delay(100); + // Sleep + esp_deep_sleep_start(); +} + +#ifdef ENABLE_WIFI +// WiFi status event +void WiFiEvent(WiFiEvent_t event){ + //Serial.printf("[WiFi-event] event: %d\n", event); + if(event == ARDUINO_EVENT_WIFI_STA_GOT_IP){ + + } + // Set status bar icon based on WiFi status + if(event == ARDUINO_EVENT_WIFI_STA_GOT_IP || event == ARDUINO_EVENT_WIFI_STA_GOT_IP6){ + //lv_label_set_text(WifiLabel, LV_SYMBOL_WIFI); + } + else{ + //lv_label_set_text(WifiLabel, ""); + } +} #endif +// Setup ---------------------------------------------------------------------------------------------------------------------------------- + +void setup() { + + setCpuFrequencyMhz(240); // Make sure ESP32 is running at full speed + + // Find out wakeup cause + if(esp_sleep_get_wakeup_cause() == ESP_SLEEP_WAKEUP_EXT1){ + if(log(esp_sleep_get_ext1_wakeup_status())/log(2) == 13) wakeup_reason = WAKEUP_BY_IMU; + else wakeup_reason = WAKEUP_BY_KEYPAD; + } + else { + wakeup_reason = WAKEUP_BY_RESET; + } + + // --- IO Initialization --- + + // Button Pin Definition + pinMode(SW_1, OUTPUT); + pinMode(SW_2, OUTPUT); + pinMode(SW_3, OUTPUT); + pinMode(SW_4, OUTPUT); + pinMode(SW_5, OUTPUT); + pinMode(SW_A, INPUT); + pinMode(SW_B, INPUT); + pinMode(SW_C, INPUT); + pinMode(SW_D, INPUT); + pinMode(SW_E, INPUT); + + // Power Pin Definition + pinMode(CRG_STAT, INPUT_PULLUP); + pinMode(ADC_BAT, INPUT); + + // IR Pin Definition + pinMode(IR_RX, INPUT); + pinMode(IR_LED, OUTPUT); + pinMode(IR_VCC, OUTPUT); + digitalWrite(IR_LED, HIGH); // HIGH off - LOW on + digitalWrite(IR_VCC, LOW); // HIGH on - LOW off + + // LCD Pin Definition + pinMode(LCD_EN, OUTPUT); + digitalWrite(LCD_EN, HIGH); + pinMode(LCD_BL, OUTPUT); + digitalWrite(LCD_BL, HIGH); + + // Other Pin Definition + pinMode(ACC_INT, INPUT); + pinMode(USER_LED, OUTPUT); + digitalWrite(USER_LED, LOW); + + // Release GPIO hold in case we are coming out of standby + gpio_hold_dis((gpio_num_t)SW_1); + gpio_hold_dis((gpio_num_t)SW_2); + gpio_hold_dis((gpio_num_t)SW_3); + gpio_hold_dis((gpio_num_t)SW_4); + gpio_hold_dis((gpio_num_t)SW_5); + gpio_hold_dis((gpio_num_t)LCD_EN); + gpio_hold_dis((gpio_num_t)LCD_BL); + gpio_deep_sleep_hold_dis(); + + // Configure the backlight PWM + // Manual setup because ledcSetup() briefly turns on the backlight + ledc_channel_config_t ledc_channel_left; + ledc_channel_left.gpio_num = (gpio_num_t)LCD_BL; + ledc_channel_left.speed_mode = LEDC_HIGH_SPEED_MODE; + ledc_channel_left.channel = LEDC_CHANNEL_5; + ledc_channel_left.intr_type = LEDC_INTR_DISABLE; + ledc_channel_left.timer_sel = LEDC_TIMER_1; + ledc_channel_left.flags.output_invert = 1; // Can't do this with ledcSetup() + ledc_channel_left.duty = 0; + + ledc_timer_config_t ledc_timer; + ledc_timer.speed_mode = LEDC_HIGH_SPEED_MODE; + ledc_timer.duty_resolution = LEDC_TIMER_8_BIT; + ledc_timer.timer_num = LEDC_TIMER_1; + ledc_timer.freq_hz = 640; + + ledc_channel_config(&ledc_channel_left); + ledc_timer_config(&ledc_timer); + // --- Startup --- + Serial.begin(115200); - // do some general hardware setup, like powering the TFT, I2C, ... - init_hardware_general(); - // get wakeup reason - init_sleep(); - // Restore settings from internal flash memory - init_preferences(); - // blinking led - init_userled(); - // Power Pin definition - init_battery(); - - // button Pin definition for hardware keys - init_keys(); - // setup IR sender - init_infraredSender(); - #if (ENABLE_KEYBOARD_BLE == 1) - init_keyboardBLE(); - #endif - // register commands for the devices - register_specialCommands(); - // TV - register_device_samsungTV(); -// register_device_lgTV(); - // AV receiver - register_device_yamahaAmp(); - //register_device_denonAvr(); - //register_device_lgsoundbar(); - // media player - register_device_appleTV(); - //register_device_lgbluray(); - //register_device_samsungbluray(); - //register_device_shield(); - // misc - register_device_smarthome(); - - #if (ENABLE_KEYBOARD_MQTT == 1) - register_device_keyboard_mqtt(); - #endif - #if (ENABLE_KEYBOARD_BLE == 1) - register_device_keyboard_ble(); - #endif - register_keyboardCommands(); - - // Register the GUIs. They will be displayed in the order they have been registered. - register_gui_sceneSelection(); - register_gui_irReceiver(); - register_gui_settings(); - register_gui_appleTV(); - register_gui_numpad(); - register_gui_smarthome(); - register_gui_yamahaAmp(); - // Only show these GUIs in the main gui list. If you don't set this explicitely, by default all registered guis are shown. - #if (USE_SCENE_SPECIFIC_GUI_LIST != 0) - main_gui_list = {tabName_yamahaAmp, tabName_sceneSelection, tabName_smarthome, tabName_settings, tabName_irReceiver}; - #endif + // Setup TFT + + // Slowly charge the VSW voltage to prevent a brownout + // Workaround for hardware rev 1! + for(int i = 0; i < 100; i++){ + digitalWrite(LCD_EN, HIGH); // LCD Logic off + delayMicroseconds(1); + digitalWrite(LCD_EN, LOW); // LCD Logic on + } + + delay(100); // Wait for the LCD driver to power on + tft.init(); + tft.initDMA(); + tft.setRotation(0); + tft.fillScreen(TFT_BLACK); + tft.setSwapBytes(true); + + // Setup touchscreen + Wire.begin(SDA, SCL, 400000); // Configure i2c pins and set frequency to 400kHz + bool TouchInitSuccessful = touch.begin(128); // Initialize touchscreen and set sensitivity threshold + + // Setup LVGL + lv_init(); + lv_disp_draw_buf_init( &draw_buf, bufA, bufB, screenWidth * screenHeight / 10 ); + + // Initialize the display driver + static lv_disp_drv_t disp_drv; + lv_disp_drv_init( &disp_drv ); + disp_drv.hor_res = screenWidth; + disp_drv.ver_res = screenHeight; + disp_drv.flush_cb = my_disp_flush; + disp_drv.draw_buf = &draw_buf; + lv_disp_drv_register( &disp_drv ); + + // Initialize the touchscreen driver + static lv_indev_drv_t indev_drv; + lv_indev_drv_init( &indev_drv ); + indev_drv.type = LV_INDEV_TYPE_POINTER; + indev_drv.read_cb = my_touchpad_read; + lv_indev_drv_register( &indev_drv ); + + // --- LVGL UI Configuration --- + + // Set the background color + lv_obj_set_style_bg_color(lv_scr_act(), lv_color_black(), LV_PART_MAIN); + + + + // Add content to the settings tab + // With a flex layout, setting groups/boxes will position themselves automatically + + + ChecksTable = lv_table_create(lv_scr_act()); + lv_table_set_col_width(ChecksTable, 0, 140); + lv_table_set_col_width(ChecksTable, 1, 60); + lv_table_set_col_cnt(ChecksTable, 2); + lv_obj_remove_style(ChecksTable, NULL, LV_PART_ITEMS | LV_STATE_PRESSED); + + lv_table_set_cell_value_fmt(ChecksTable, 0, 0, "IR LED"); + lv_table_set_cell_value_fmt(ChecksTable, 1, 0, "IR Receiver"); + lv_table_set_cell_value_fmt(ChecksTable, 2, 0, "WiFi"); + lv_table_set_cell_value_fmt(ChecksTable, 3, 0, "Buttons"); + lv_table_set_cell_value_fmt(ChecksTable, 4, 0, "Touchscreen"); + lv_table_set_cell_value_fmt(ChecksTable, 5, 0, "Fuel Gauge"); + lv_table_set_cell_value_fmt(ChecksTable, 6, 0, "IMU"); + + for(int i = 0; i < 7; i++){ //lv_table_get_row_cnt(table) + lv_table_set_cell_value_fmt(ChecksTable, i, 1, "?"); + } + + + + + + + + + + - // register the scenes and their key_commands_* - register_scene_defaultKeys(); - register_scene_TV(); - register_scene_fireTV(); - register_scene_chromecast(); - register_scene_appleTV(); - register_scene_allOff(); - // Only show these scenes on the sceneSelection gui. If you don't set this explicitely, by default all registered scenes are shown. - set_scenes_on_sceneSelectionGUI({scene_name_TV, scene_name_fireTV, scene_name_chromecast, scene_name_appleTV}); - - // init GUI - will initialize tft, touch and lvgl - init_gui(); - setLabelActiveScene(); - gui_loop(); // Run the LVGL UI once before the loop takes over - - // setup the Inertial Measurement Unit (IMU) for motion detection. Has to be after init_gui(), otherwise I2C will not work - init_IMU(); - - // init WiFi - needs to be after init_gui() because WifiLabel must be available - #if (ENABLE_WIFI_AND_MQTT == 1) - init_mqtt(); - #endif - omote_log_i("Setup finished in %lu ms.\r\n", millis()); + // --- End of LVGL configuration --- - #if defined(WIN32) || defined(__linux__) - // In Windows/Linux there is no loop function that is automatically being called. So we have to do this on our own infinitely here in main() - unsigned long IMUTaskTimer = 0; - unsigned long updateStatusTimer = 0; - while (1) - loop(&IMUTaskTimer, &updateStatusTimer); + + #ifdef ENABLE_WIFI + // Setup WiFi + WiFi.setHostname("OMOTE"); //define hostname + WiFi.onEvent(WiFiEvent); + WiFi.begin(WIFI_SSID, WIFI_PASSWORD); + WiFi.setSleep(true); #endif + // Setup IMU + IMU.settings.accelSampleRate = 50; //Hz. Can be: 0,1,10,25,50,100,200,400,1600,5000 Hz + IMU.settings.accelRange = 2; //Max G force readable. Can be: 2, 4, 8, 16 + IMU.settings.adcEnabled = 0; + IMU.settings.tempEnabled = 0; + IMU.settings.xAccelEnabled = 1; + IMU.settings.yAccelEnabled = 1; + IMU.settings.zAccelEnabled = 1; + int IMUInitSuccessful = IMU.begin(); + uint8_t intDataRead; + IMU.readRegister(&intDataRead, LIS3DH_INT1_SRC);//clear interrupt + + // Setup IR + IrSender.begin(); + digitalWrite(IR_VCC, HIGH); // Turn on IR receiver + IrReceiver.enableIRIn(); // Start the receiver + + // Setup Fuel Gauge IC + int FuelGaugeInitSuccessful = fuelGauge.begin(); + + + lv_timer_handler(); // Run the LVGL UI once before the loop takes over + + + Serial.print("Setup finished in "); + Serial.print(millis()); + Serial.println("ms."); + + + // Automated Checks + + + + uint64_t _chipmacid = 0LL; + esp_efuse_mac_get_default((uint8_t*) (&_chipmacid)); + Serial.print("ESP32 MAC: "); + Serial.println(_chipmacid); + + + if(IMUInitSuccessful == 0) lv_table_set_cell_value_fmt(ChecksTable, 6, 1, LV_SYMBOL_OK); + else lv_table_set_cell_value_fmt(ChecksTable, 6, 1, LV_SYMBOL_WARNING); + + if(TouchInitSuccessful) lv_table_set_cell_value_fmt(ChecksTable, 4, 1, LV_SYMBOL_OK); + else lv_table_set_cell_value_fmt(ChecksTable, 4, 1, LV_SYMBOL_WARNING); + + if(FuelGaugeInitSuccessful) lv_table_set_cell_value_fmt(ChecksTable, 5, 1, LV_SYMBOL_OK); + else lv_table_set_cell_value_fmt(ChecksTable, 5, 1, LV_SYMBOL_WARNING); + + lv_table_set_cell_value_fmt(ChecksTable, 2, 1, LV_SYMBOL_WARNING); + for(int i=0; i<50; i++){ + if (WiFi.status() == WL_CONNECTED) { + Serial.println(" Connected!"); + lv_table_set_cell_value_fmt(ChecksTable, 2, 1, LV_SYMBOL_OK); + break; + } + delay(100); + Serial.print("."); + } + + + + } // Loop ------------------------------------------------------------------------------------------------------------------------------------ -#if defined(ARDUINO) -unsigned long IMUTaskTimer = 0; -unsigned long updateStatusTimer = 0; -unsigned long *pIMUTaskTimer = &IMUTaskTimer; -unsigned long *pUpdateStatusTimer = &updateStatusTimer; -void loop() { -#elif defined(WIN32) || defined(__linux__) -void loop(unsigned long *pIMUTaskTimer, unsigned long *pUpdateStatusTimer) { -#endif - // --- do as often as possible -------------------------------------------------------- - // update backlight brightness. Fade in on startup, dim before going to sleep - update_backligthBrighness(); - // keypad handling: get key states from hardware and process them - keypad_loop(); - // process IR receiver, if activated - if (get_irReceiverEnabled()) { - infraredReceiver_loop(); - } - // update LVGL UI - gui_loop(); - // call mqtt loop to receive mqtt messages, if you are subscribed to some topics - #if (ENABLE_WIFI_AND_MQTT == 1) - mqtt_loop(); - #endif +void loop() { + + // Update Backlight brightness + static int fadeInTimer = millis(); // fadeInTimer = time after setup + if(millis() < fadeInTimer + backlight_brightness){ // Fade in the backlight brightness + ledcWrite(5, millis()-fadeInTimer); + } + else { // Dim Backlight before entering standby + if(standbyTimer < 2000) ledcWrite(5, 85); // Backlight dim + else ledcWrite(5, backlight_brightness); // Backlight on + } + + // Update LVGL UI + lv_timer_handler(); - // --- every 100 ms ------------------------------------------------------------------- - // Refresh IMU data (motion detection) every 100 ms - // If no action (key, TFT or motion), then go to sleep - if(millis() - *pIMUTaskTimer >= 100){ - *pIMUTaskTimer = millis(); + // Blink debug LED at 1 Hz + digitalWrite(USER_LED, millis() % 1000 > 500); - check_activity(); + // Refresh IMU data at 10Hz + static unsigned long IMUTaskTimer = millis(); + if(millis() - IMUTaskTimer >= 100){ + activityDetection(); + if(standbyTimer == 0){ + Serial.println("Entering Sleep Mode. Goodbye."); + enterSleep(); + } + IMUTaskTimer = millis(); + } + // Update battery stats at 1Hz + static unsigned long batteryTaskTimer = millis() + 1000; // add 1s to start immediately + if(millis() - batteryTaskTimer >= 1000){ + battery_voltage = (int)(fuelGauge.getVoltage()*1000); + battery_percentage = (int)fuelGauge.getSOC(); + battery_ischarging = !digitalRead(CRG_STAT); } - // --- every 1000 ms ------------------------------------------------------------------ - if(millis() - *pUpdateStatusTimer >= 1000) { - *pUpdateStatusTimer = millis(); + // Keypad Handling + customKeypad.getKey(); // Populate key list + for(int i=0; i -#include "scenes/scene_TV.h" -#include "applicationInternal/keys.h" -#include "applicationInternal/scenes/sceneRegistry.h" -#include "applicationInternal/hardware/hardwarePresenter.h" -// devices -#include "devices/TV/device_samsungTV/device_samsungTV.h" -#include "devices/AVreceiver/device_yamahaAmp/device_yamahaAmp.h" -#include "applicationInternal/commandHandler.h" -// guis -#include "guis/gui_numpad.h" - -uint16_t SCENE_TV ; //"Scene_tv" -uint16_t SCENE_TV_FORCE ; //"Scene_tv_force" - -std::map key_repeatModes_TV; -std::map key_commands_short_TV; -std::map key_commands_long_TV; - -void scene_setKeys_TV() { - key_repeatModes_TV = { - - {KEY_STOP, SHORT_REPEATED }, {KEY_REWI, SHORT }, {KEY_PLAY, SHORT }, {KEY_FORW, SHORT_REPEATED }, - {KEY_CONF, SHORT }, {KEY_INFO, SHORT }, - {KEY_UP, SHORT_REPEATED }, - {KEY_LEFT, SHORT_REPEATED }, {KEY_OK, SHORT }, {KEY_RIGHT, SHORT_REPEATED }, - {KEY_DOWN, SHORT_REPEATED }, - {KEY_SRC, SHORT }, - {KEY_CHUP, SHORT }, - {KEY_CHDOW, SHORT }, - - }; - - key_commands_short_TV = { - - {KEY_STOP, SAMSUNG_PAUSE }, {KEY_REWI, SAMSUNG_REWIND }, {KEY_PLAY, SAMSUNG_PLAY }, {KEY_FORW, SAMSUNG_FASTFORWARD}, - {KEY_CONF, SAMSUNG_GUIDE }, {KEY_INFO, SAMSUNG_MENU }, - {KEY_UP, SAMSUNG_UP }, - {KEY_LEFT, SAMSUNG_LEFT }, {KEY_OK, SAMSUNG_SELECT }, {KEY_RIGHT, SAMSUNG_RIGHT }, - {KEY_DOWN, SAMSUNG_DOWN }, - {KEY_SRC, SAMSUNG_EXIT }, - {KEY_CHUP, SAMSUNG_CHANNEL_UP}, - {KEY_CHDOW, SAMSUNG_CHANNEL_DOWN}, - - }; - - key_commands_long_TV = { - - - }; - -} - -void scene_start_sequence_TV(void) { - executeCommand(SAMSUNG_POWER_ON); - delay(500); - executeCommand(YAMAHA_POWER_ON); - delay(1500); - executeCommand(YAMAHA_INPUT_DVD); - delay(3000); - executeCommand(SAMSUNG_INPUT_TV); - -} - -void scene_end_sequence_TV(void) { - -} - -std::string scene_name_TV = "TV"; -t_gui_list scene_TV_gui_list = {tabName_numpad}; - -void register_scene_TV(void) { - register_command(&SCENE_TV, makeCommandData(SCENE, {scene_name_TV})); - register_command(&SCENE_TV_FORCE, makeCommandData(SCENE, {scene_name_TV, "FORCE"})); - - register_scene( - scene_name_TV, - & scene_setKeys_TV, - & scene_start_sequence_TV, - & scene_end_sequence_TV, - & key_repeatModes_TV, - & key_commands_short_TV, - & key_commands_long_TV, - & scene_TV_gui_list, - SCENE_TV); -} diff --git a/Platformio/src/scenes/scene_TV.h b/Platformio/src/scenes/scene_TV.h deleted file mode 100644 index 6a626060..00000000 --- a/Platformio/src/scenes/scene_TV.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include -#include - -extern uint16_t SCENE_TV; -// FORCE sends the start sequence again even if scene is already active -extern uint16_t SCENE_TV_FORCE; - -extern std::string scene_name_TV; -void register_scene_TV_commands(void); -void register_scene_TV(void); diff --git a/Platformio/src/scenes/scene__default.cpp b/Platformio/src/scenes/scene__default.cpp deleted file mode 100644 index c4b69dc1..00000000 --- a/Platformio/src/scenes/scene__default.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include -#include "applicationInternal/keys.h" -#include "applicationInternal/scenes/sceneRegistry.h" -#include "applicationInternal/commandHandler.h" -// devices -#include "devices/AVreceiver/device_yamahaAmp/device_yamahaAmp.h" -#include "devices/misc/device_smarthome/gui_smarthome.h" -// scenes -#include "scene__default.h" -#include "scenes/scene_allOff.h" -#include "scenes/scene_TV.h" -#include "scenes/scene_fireTV.h" -#include "scenes/scene_chromecast.h" -#include "scenes/scene_appleTV.h" - -uint16_t SCENE_SELECTION; -std::string scene_name_selection = "sceneSelection"; -uint16_t SCENE_BACK_TO_PREVIOUS_GUI_LIST; -std::string scene_back_to_previous_gui_list = "backToPreviousList"; -uint16_t GUI_PREV; -std::string scene_gui_prev = "GUI_prev"; -uint16_t GUI_NEXT; -std::string scene_gui_next = "GUI_next"; - -std::map key_repeatModes_default; -std::map key_commands_short_default; -std::map key_commands_long_default; - -// This is the main list of guis we want to be shown when swiping. Need not to be all the guis that have been registered, can be only a subset. -// You can swipe through these guis. Will be in the order you place them here in the vector. -// By default, it is a list of the guis that have been registered in main.cpp -// If a scene defines a scene specific gui list, this will be used instead as long as the scene is active and we don't explicitely navigate back to main_gui_list -t_gui_list main_gui_list; - -void register_scene_defaultKeys(void) { - key_repeatModes_default = { - {KEY_OFF, SHORT }, - {KEY_STOP, SHORT }, {KEY_REWI, SHORTorLONG }, {KEY_PLAY, SHORT }, {KEY_FORW, SHORTorLONG }, - {KEY_CONF, SHORT }, {KEY_INFO, SHORT }, - {KEY_UP, SHORT }, - {KEY_LEFT, SHORT }, {KEY_OK, SHORT }, {KEY_RIGHT, SHORT }, - {KEY_DOWN, SHORT }, - {KEY_BACK, SHORT }, {KEY_SRC, SHORT }, - {KEY_VOLUP, SHORT_REPEATED }, {KEY_MUTE, SHORT }, {KEY_CHUP, SHORT }, - {KEY_VOLDO, SHORT_REPEATED }, {KEY_REC, SHORT }, {KEY_CHDOW, SHORT }, - {KEY_RED, SHORT }, {KEY_GREEN, SHORT }, {KEY_YELLO, SHORT }, {KEY_BLUE, SHORT }, - }; - - key_commands_short_default = { - {KEY_OFF, SCENE_ALLOFF_FORCE}, - {KEY_STOP, GUI_SMARTHOME_ACTIVATE},/*{KEY_REWI, COMMAND_UNKNOWN }, {KEY_PLAY, COMMAND_UNKNOWN }, {KEY_FORW, COMMAND_UNKNOWN },*/ - /*{KEY_CONF, COMMAND_UNKNOWN }, {KEY_INFO, COMMAND_UNKNOWN },*/ - /* {KEY_UP, COMMAND_UNKNOWN },*/ - {KEY_LEFT, GUI_PREV }, /* {KEY_OK, COMMAND_UNKNOWN },*/ {KEY_RIGHT, GUI_NEXT }, - /* {KEY_DOWN, COMMAND_UNKNOWN },*/ - {KEY_BACK, SCENE_SELECTION }, /*{KEY_SRC, COMMAND_UNKNOWN },*/ - {KEY_VOLUP, YAMAHA_VOL_PLUS }, {KEY_MUTE, YAMAHA_MUTE_TOGGLE}, /*{KEY_CHUP, COMMAND_UNKNOWN },*/ - {KEY_VOLDO, YAMAHA_VOL_MINUS }, {KEY_REC, SCENE_BACK_TO_PREVIOUS_GUI_LIST }, /*{KEY_CHDOW, COMMAND_UNKNOWN },*/ - {KEY_RED, SCENE_TV_FORCE }, {KEY_GREEN, SCENE_FIRETV_FORCE}, {KEY_YELLO, SCENE_CHROMECAST_FORCE},{KEY_BLUE, SCENE_APPLETV_FORCE}, - }; - - key_commands_long_default = { - - - }; - - register_command(&SCENE_SELECTION , makeCommandData(SCENE, {scene_name_selection})); - register_command(&SCENE_BACK_TO_PREVIOUS_GUI_LIST, makeCommandData(SCENE, {scene_back_to_previous_gui_list})); - register_command(&GUI_PREV , makeCommandData(SCENE, {scene_gui_prev})); - register_command(&GUI_NEXT , makeCommandData(SCENE, {scene_gui_next})); - -} diff --git a/Platformio/src/scenes/scene__default.h b/Platformio/src/scenes/scene__default.h deleted file mode 100644 index 00c1194c..00000000 --- a/Platformio/src/scenes/scene__default.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#include -#include -#include -#include "applicationInternal/keys.h" -#include "applicationInternal/scenes/sceneRegistry.h" - -extern uint16_t SCENE_SELECTION; // command -extern std::string scene_name_selection; // payload: name of this fake default scene -extern uint16_t SCENE_BACK_TO_PREVIOUS_GUI_LIST; // command -extern std::string scene_back_to_previous_gui_list; // payload: name of this fake scene -extern uint16_t GUI_PREV; // command -extern std::string scene_gui_prev; // payload: name of this fake scene -extern uint16_t GUI_NEXT; // command -extern std::string scene_gui_next; // payload: name of this fake scene - -extern std::map key_repeatModes_default; -extern std::map key_commands_short_default; -extern std::map key_commands_long_default; - -extern t_gui_list main_gui_list; - -void register_scene_defaultKeys(void); diff --git a/Platformio/src/scenes/scene_allOff.cpp b/Platformio/src/scenes/scene_allOff.cpp deleted file mode 100644 index 1091c625..00000000 --- a/Platformio/src/scenes/scene_allOff.cpp +++ /dev/null @@ -1,94 +0,0 @@ -#include -#include "scenes/scene_allOff.h" -#include "applicationInternal/keys.h" -#include "applicationInternal/scenes/sceneRegistry.h" -#include "applicationInternal/hardware/hardwarePresenter.h" -// devices -#include "devices/TV/device_samsungTV/device_samsungTV.h" -#include "devices/AVreceiver/device_yamahaAmp/device_yamahaAmp.h" -#include "applicationInternal/commandHandler.h" - -uint16_t SCENE_ALLOFF ; //"Scene_allOff" -uint16_t SCENE_ALLOFF_FORCE; //"Scene_allOff_force" - -std::map key_repeatModes_allOff; -std::map key_commands_short_allOff; -std::map key_commands_long_allOff; - -void scene_setKeys_allOff() { - key_repeatModes_allOff = { - - - - - - - - - - - }; - - key_commands_short_allOff = { - - - - - - - - - - - }; - - key_commands_long_allOff = { - - - }; - -} - -void scene_start_sequence_allOff(void) { - executeCommand(SAMSUNG_POWER_OFF); - delay(500); - executeCommand(YAMAHA_POWER_OFF); - delay(500); - // repeat IR to be sure - executeCommand(SAMSUNG_POWER_OFF); - delay(500); - executeCommand(YAMAHA_POWER_OFF); - delay(500); - // repeat IR to be sure - executeCommand(SAMSUNG_POWER_OFF); - delay(500); - executeCommand(YAMAHA_POWER_OFF); - delay(500); - // you cannot power off FireTV, but at least you can stop the currently running app - executeCommand(KEYBOARD_HOME); - delay(500); - executeCommand(KEYBOARD_HOME); - -} - -void scene_end_sequence_allOff(void) { - -} - -std::string scene_name_allOff = "Off"; - -void register_scene_allOff(void) { - register_command(&SCENE_ALLOFF , makeCommandData(SCENE, {scene_name_allOff})); - register_command(&SCENE_ALLOFF_FORCE, makeCommandData(SCENE, {scene_name_allOff, "FORCE"})); - - register_scene( - scene_name_allOff, - & scene_setKeys_allOff, - & scene_start_sequence_allOff, - & scene_end_sequence_allOff, - & key_repeatModes_allOff, - & key_commands_short_allOff, - & key_commands_long_allOff, - NULL, - SCENE_ALLOFF); -} diff --git a/Platformio/src/scenes/scene_allOff.h b/Platformio/src/scenes/scene_allOff.h deleted file mode 100644 index 0b89ea01..00000000 --- a/Platformio/src/scenes/scene_allOff.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include -#include - -extern uint16_t SCENE_ALLOFF; -// FORCE sends the start sequence again even if scene is already active -extern uint16_t SCENE_ALLOFF_FORCE; - -extern std::string scene_name_allOff; -void register_scene_allOff_commands(void); -void register_scene_allOff(void); diff --git a/Platformio/src/scenes/scene_appleTV.cpp b/Platformio/src/scenes/scene_appleTV.cpp deleted file mode 100644 index 686ea5e3..00000000 --- a/Platformio/src/scenes/scene_appleTV.cpp +++ /dev/null @@ -1,86 +0,0 @@ -#include -#include "scenes/scene_appleTV.h" -#include "applicationInternal/keys.h" -#include "applicationInternal/scenes/sceneRegistry.h" -#include "applicationInternal/hardware/hardwarePresenter.h" -// devices -#include "devices/TV/device_samsungTV/device_samsungTV.h" -#include "devices/AVreceiver/device_yamahaAmp/device_yamahaAmp.h" -#include "applicationInternal/commandHandler.h" -// guis -#include "devices/mediaPlayer/device_appleTV/gui_appleTV.h" - -uint16_t SCENE_APPLETV ; //"Scene_appleTV" -uint16_t SCENE_APPLETV_FORCE; //"Scene_appleTV_force" - -std::map key_repeatModes_appleTV; -std::map key_commands_short_appleTV; -std::map key_commands_long_appleTV; - -void scene_setKeys_appleTV() { - key_repeatModes_appleTV = { - - - - - - - - - - - }; - - key_commands_short_appleTV = { - - - - - - - - - - - }; - - key_commands_long_appleTV = { - - - }; - -} - -void scene_start_sequence_appleTV(void) { - executeCommand(SAMSUNG_POWER_ON); - delay(500); - executeCommand(YAMAHA_POWER_ON); - delay(1500); - executeCommand(YAMAHA_INPUT_DVD); - delay(3000); - executeCommand(SAMSUNG_INPUT_HDMI_3); - -} - -void scene_end_sequence_appleTV(void) { - -} - -std::string scene_name_appleTV = "Apple TV"; -t_gui_list scene_appleTV_gui_list = {tabName_appleTV}; - -void register_scene_appleTV(void) { - register_command(&SCENE_APPLETV, makeCommandData(SCENE, {scene_name_appleTV})); - register_command(&SCENE_APPLETV_FORCE, makeCommandData(SCENE, {scene_name_appleTV, "FORCE"})); - - register_scene( - scene_name_appleTV, - & scene_setKeys_appleTV, - & scene_start_sequence_appleTV, - & scene_end_sequence_appleTV, - & key_repeatModes_appleTV, - & key_commands_short_appleTV, - & key_commands_long_appleTV, - & scene_appleTV_gui_list, - SCENE_APPLETV); -} diff --git a/Platformio/src/scenes/scene_appleTV.h b/Platformio/src/scenes/scene_appleTV.h deleted file mode 100644 index 3ac3a5e8..00000000 --- a/Platformio/src/scenes/scene_appleTV.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include -#include - -extern uint16_t SCENE_APPLETV; -// FORCE sends the start sequence again even if scene is already active -extern uint16_t SCENE_APPLETV_FORCE; - -extern std::string scene_name_appleTV; -void register_scene_appleTV_commands(void); -void register_scene_appleTV(void); diff --git a/Platformio/src/scenes/scene_chromecast.cpp b/Platformio/src/scenes/scene_chromecast.cpp deleted file mode 100644 index 1f080386..00000000 --- a/Platformio/src/scenes/scene_chromecast.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#include -#include "scenes/scene_chromecast.h" -#include "applicationInternal/keys.h" -#include "applicationInternal/scenes/sceneRegistry.h" -#include "applicationInternal/hardware/hardwarePresenter.h" -// devices -#include "devices/TV/device_samsungTV/device_samsungTV.h" -#include "devices/AVreceiver/device_yamahaAmp/device_yamahaAmp.h" -#include "applicationInternal/commandHandler.h" - -uint16_t SCENE_CHROMECAST ; //"Scene_chromecast" -uint16_t SCENE_CHROMECAST_FORCE; //"Scene_chromecast_force" - -std::map key_repeatModes_chromecast; -std::map key_commands_short_chromecast; -std::map key_commands_long_chromecast; - -void scene_setKeys_chromecast() { - key_repeatModes_chromecast = { - - - - - - - - - - - }; - - key_commands_short_chromecast = { - - - - - - - - - - - }; - - key_commands_long_chromecast = { - - - }; - -} - -void scene_start_sequence_chromecast(void) { - executeCommand(SAMSUNG_POWER_ON); - delay(500); - executeCommand(YAMAHA_POWER_ON); - delay(1500); - executeCommand(YAMAHA_INPUT_DVD); - delay(3000); - executeCommand(SAMSUNG_INPUT_HDMI_1); - -} - -void scene_end_sequence_chromecast(void) { - -} - -std::string scene_name_chromecast = "Chromecast"; - -void register_scene_chromecast(void) { - register_command(&SCENE_CHROMECAST, makeCommandData(SCENE, {scene_name_chromecast})); - register_command(&SCENE_CHROMECAST_FORCE, makeCommandData(SCENE, {scene_name_chromecast, "FORCE"})); - - register_scene( - scene_name_chromecast, - & scene_setKeys_chromecast, - & scene_start_sequence_chromecast, - & scene_end_sequence_chromecast, - & key_repeatModes_chromecast, - & key_commands_short_chromecast, - & key_commands_long_chromecast, - NULL, - SCENE_CHROMECAST); -} diff --git a/Platformio/src/scenes/scene_chromecast.h b/Platformio/src/scenes/scene_chromecast.h deleted file mode 100644 index 5ce5ef7f..00000000 --- a/Platformio/src/scenes/scene_chromecast.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include -#include - -extern uint16_t SCENE_CHROMECAST; -// FORCE sends the start sequence again even if scene is already active -extern uint16_t SCENE_CHROMECAST_FORCE; - -extern std::string scene_name_chromecast; -void register_scene_chromecast_commands(void); -void register_scene_chromecast(void); diff --git a/Platformio/src/scenes/scene_fireTV.cpp b/Platformio/src/scenes/scene_fireTV.cpp deleted file mode 100644 index 3979688f..00000000 --- a/Platformio/src/scenes/scene_fireTV.cpp +++ /dev/null @@ -1,95 +0,0 @@ -#include -#include "scenes/scene_fireTV.h" -#include "applicationInternal/keys.h" -#include "applicationInternal/scenes/sceneRegistry.h" -#include "applicationInternal/hardware/hardwarePresenter.h" -// devices -#include "devices/TV/device_samsungTV/device_samsungTV.h" -#include "devices/AVreceiver/device_yamahaAmp/device_yamahaAmp.h" -#include "applicationInternal/commandHandler.h" -// guis -#include "guis/gui_numpad.h" - -uint16_t SCENE_FIRETV ; //"Scene_firetv" -uint16_t SCENE_FIRETV_FORCE; //"Scene_firetv_force" - -std::map key_repeatModes_fireTV; -std::map key_commands_short_fireTV; -std::map key_commands_long_fireTV; - -void scene_setKeys_fireTV() { - key_repeatModes_fireTV = { - - {KEY_REWI, SHORTorLONG }, {KEY_PLAY, SHORT }, {KEY_FORW, SHORTorLONG }, - {KEY_CONF, SHORT }, {KEY_INFO, SHORT }, - {KEY_UP, SHORT }, - {KEY_LEFT, SHORT }, {KEY_OK, SHORT }, {KEY_RIGHT, SHORT }, - {KEY_DOWN, SHORT }, - {KEY_SRC, SHORT }, - - - - }; - - key_commands_short_fireTV = { - - {KEY_REWI, KEYBOARD_REWIND }, {KEY_PLAY, KEYBOARD_PLAYPAUSE}, {KEY_FORW, KEYBOARD_FASTFORWARD}, - {KEY_CONF, KEYBOARD_HOME }, {KEY_INFO, KEYBOARD_MENU }, - {KEY_UP, KEYBOARD_UP }, - {KEY_LEFT, KEYBOARD_LEFT }, {KEY_OK, KEYBOARD_SELECT }, {KEY_RIGHT, KEYBOARD_RIGHT }, - {KEY_DOWN, KEYBOARD_DOWN }, - {KEY_SRC, KEYBOARD_BACK }, - - - - }; - - key_commands_long_fireTV = { - {KEY_REWI, KEYBOARD_REWIND_LONG}, - {KEY_FORW, KEYBOARD_FASTFORWARD_LONG}, - }; - -} - -void scene_start_sequence_fireTV(void) { - executeCommand(SAMSUNG_POWER_ON); - delay(500); - executeCommand(YAMAHA_POWER_ON); - delay(1500); - executeCommand(YAMAHA_INPUT_DTV); - delay(3000); - executeCommand(SAMSUNG_INPUT_HDMI_2); - delay(100); - - executeCommand(KEYBOARD_HOME); - delay(500); - executeCommand(KEYBOARD_HOME); - -} - -void scene_end_sequence_fireTV(void) { - // you cannot power off FireTV, but at least you can stop the currently running app - executeCommand(KEYBOARD_HOME); - delay(500); - executeCommand(KEYBOARD_HOME); - -} - -std::string scene_name_fireTV = "Fire TV"; -t_gui_list scene_fireTV_gui_list = {tabName_numpad}; - -void register_scene_fireTV(void) { - register_command(&SCENE_FIRETV, makeCommandData(SCENE, {scene_name_fireTV})); - register_command(&SCENE_FIRETV_FORCE, makeCommandData(SCENE, {scene_name_fireTV, "FORCE"})); - - register_scene( - scene_name_fireTV, - & scene_setKeys_fireTV, - & scene_start_sequence_fireTV, - & scene_end_sequence_fireTV, - & key_repeatModes_fireTV, - & key_commands_short_fireTV, - & key_commands_long_fireTV, - & scene_fireTV_gui_list, - SCENE_FIRETV); -} diff --git a/Platformio/src/scenes/scene_fireTV.h b/Platformio/src/scenes/scene_fireTV.h deleted file mode 100644 index 4bb0dce7..00000000 --- a/Platformio/src/scenes/scene_fireTV.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include -#include - -extern uint16_t SCENE_FIRETV; -// FORCE sends the start sequence again even if scene is already active -extern uint16_t SCENE_FIRETV_FORCE; - -extern std::string scene_name_fireTV; -void register_scene_fireTV_commands(void); -void register_scene_fireTV(void); diff --git a/Platformio/src/secrets.h b/Platformio/src/secrets.h deleted file mode 100644 index 6aeac287..00000000 --- a/Platformio/src/secrets.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - Before changing anything in this file, consider to copy file "secrets_override_example.h" to file "secrets_override.h" and to do your changes there. - Doing so, you will - - keep your credentials secret - - most likely never have conflicts with new versions of this file -*/ -#define WIFI_SSID "YourWifiSSID" // override it in file "secrets_override.h" -#define WIFI_PASSWORD "YourWifiPassword" // override it in file "secrets_override.h" - -#define MQTT_SERVER "IPAddressOfYourBroker" // override it in file "secrets_override.h" -#define MQTT_SERVER_PORT 1883 // override it in file "secrets_override.h" -#define MQTT_USER "" // override it in file "secrets_override.h" -#define MQTT_PASS "" // override it in file "secrets_override.h" -#define MQTT_CLIENTNAME "OMOTE" // override it in file "secrets_override.h" - -// --- include override settings from seperate file --------------------------------------------------------------------------------------------------------------- -#if __has_include("secrets_override.h") - #include "secrets_override.h" -#endif diff --git a/Platformio/src/secrets_override_example.h b/Platformio/src/secrets_override_example.h deleted file mode 100644 index 857b643c..00000000 --- a/Platformio/src/secrets_override_example.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - If you add additional overrides here, you have to - 1. first add #undef - 2. add new #define -*/ -#undef WIFI_SSID -#undef WIFI_PASSWORD -#undef MQTT_SERVER - -#define WIFI_SSID "YourWifiSSID" // override here -#define WIFI_PASSWORD "YourWifiPassword" // override here -#define MQTT_SERVER "IPAddressOfYourBroker" // override here