From 3afdacaf31b1e97f1f77b8eb7d2a969757eadeb7 Mon Sep 17 00:00:00 2001 From: Jochen Vothknecht <jochen3120@gmail.com> Date: Sun, 8 May 2022 04:36:21 +0200 Subject: [PATCH] Backing up many changes --- CLC-qthing/SiliconTorch/CapMan.cpp | 35 +++++++++ CLC-qthing/SiliconTorch/CapMan.hpp | 78 +++++++++++++++++++ CLC-qthing/SiliconTorch/CyanBus.hpp | 4 + ...nF.cpp => FxCyanF-classImplementation.cpp} | 0 .../SiliconTorch/FxCyanF-configureFromNVS.cpp | 50 ++++++++++++ CLC-qthing/SiliconTorch/FxCyanF.hpp | 4 + CLC-qthing/SiliconTorch/FxPublish.cpp | 45 +++++++++++ CLC-qthing/SiliconTorch/FxPublish.hpp | 45 +++++++++++ CLC-qthing/SiliconTorch/NVSExplorer.cpp | 61 +++++++++++++++ CLC-qthing/SiliconTorch/NVSExplorer.hpp | 59 ++++++++++++++ CLC-qthing/SiliconTorch/SiliconTorch.cpp | 42 ++++++++++ CLC-qthing/SiliconTorch/SiliconTorch.hpp | 38 +++++++++ CLC-qthing/SimpleUART.hpp | 1 - CLC-qthing/SpiderLib/Time.cpp | 20 +++++ CLC-qthing/SpiderLib/Time.hpp | 23 ++++++ CLC-qthing/SpiderLib/Util.cpp | 27 +++++-- CLC-qthing/SpiderLib/Util.hpp | 14 ++-- CLC-qthing/device_config.h | 2 +- CLC-qthing/device_main.cpp | 21 ++++- 19 files changed, 551 insertions(+), 18 deletions(-) create mode 100644 CLC-qthing/SiliconTorch/CapMan.cpp create mode 100644 CLC-qthing/SiliconTorch/CapMan.hpp rename CLC-qthing/SiliconTorch/{FxCyanF.cpp => FxCyanF-classImplementation.cpp} (100%) create mode 100644 CLC-qthing/SiliconTorch/FxCyanF-configureFromNVS.cpp create mode 100644 CLC-qthing/SiliconTorch/FxPublish.cpp create mode 100644 CLC-qthing/SiliconTorch/FxPublish.hpp create mode 100644 CLC-qthing/SiliconTorch/NVSExplorer.cpp create mode 100644 CLC-qthing/SiliconTorch/NVSExplorer.hpp create mode 100644 CLC-qthing/SiliconTorch/SiliconTorch.cpp create mode 100644 CLC-qthing/SiliconTorch/SiliconTorch.hpp create mode 100644 CLC-qthing/SpiderLib/Time.cpp create mode 100644 CLC-qthing/SpiderLib/Time.hpp diff --git a/CLC-qthing/SiliconTorch/CapMan.cpp b/CLC-qthing/SiliconTorch/CapMan.cpp new file mode 100644 index 0000000..138fa28 --- /dev/null +++ b/CLC-qthing/SiliconTorch/CapMan.cpp @@ -0,0 +1,35 @@ +#include "CapMan.hpp" + +// C++ system level +// #include <cstring> // memset, strncmp +// #include <cstdlib> // TODO: is this for memcpy? +#include <cinttypes> +// #include <functional> + +// ESP32 specific +// #include "esp_err.h" +#include "esp_log.h" +// #include "driver/gpio.h" +// #include "driver/uart.h" + +// project specific +// #include "" + +// qthing stuff +// #include <qthing> + +/* +namespace SiliconTorch { + + // CapabilityManager + namespace CapMan { + + + void CapMan::publish() { + ESP_LOGW(TAG, "Not implemented!"); + } + + + } +} +*/ \ No newline at end of file diff --git a/CLC-qthing/SiliconTorch/CapMan.hpp b/CLC-qthing/SiliconTorch/CapMan.hpp new file mode 100644 index 0000000..2bcf884 --- /dev/null +++ b/CLC-qthing/SiliconTorch/CapMan.hpp @@ -0,0 +1,78 @@ +#pragma once + +// C++ system level +// #include <string> +// #include <cstring> // memset, strncmp +// #include <cstdlib> // TODO: is this for memcpy? +#include <cinttypes> +// #include <functional> + +// ESP32 specific +// #include "esp_err.h" +#include "esp_log.h" +// #include "driver/gpio.h" +// #include "driver/uart.h" + +// project specific +// #include "" + +// qthing stuff +// #include <qthing> + +/* +namespace SiliconTorch { + + // CapabilityManager + namespace CapMan { + + + enum ColorType { + RGB, + RGBW, + RGBWYU, + Greyscale, + CyanLight, // Like GreyScale but with differently colored Pixels + Monochrome, + }; + + + class CapMan { + + public: + + + + void registerLEDStrip(std::string& name, uint16_t startIdx, uint16_t length, ColorType); + + + + // void registerExtension(std::string& name); + // void registerExtension(std::string& name, std::initializer_list<std::pair<>> properties); + + + + + void publish(); + + + // ⬇⬇ Singleton stuff ⬇⬇ + + static CapMan& instance() { + static CapMan _instance; + return _instance; + } + + CapMan(CapMan const&) = delete; + void operator=(CapMan const&) = delete; + + // ⬆⬆ Singleton stuff ⬆⬆ + + private: + + + + }; + + } +} +*/ \ No newline at end of file diff --git a/CLC-qthing/SiliconTorch/CyanBus.hpp b/CLC-qthing/SiliconTorch/CyanBus.hpp index 4a8de38..9891c54 100644 --- a/CLC-qthing/SiliconTorch/CyanBus.hpp +++ b/CLC-qthing/SiliconTorch/CyanBus.hpp @@ -14,6 +14,10 @@ #include "SpiderLib/Callback.hpp" #include "SpiderLib/CallbackMap.hpp" +// qthing stuff +// #include "" + + namespace SiliconTorch { diff --git a/CLC-qthing/SiliconTorch/FxCyanF.cpp b/CLC-qthing/SiliconTorch/FxCyanF-classImplementation.cpp similarity index 100% rename from CLC-qthing/SiliconTorch/FxCyanF.cpp rename to CLC-qthing/SiliconTorch/FxCyanF-classImplementation.cpp diff --git a/CLC-qthing/SiliconTorch/FxCyanF-configureFromNVS.cpp b/CLC-qthing/SiliconTorch/FxCyanF-configureFromNVS.cpp new file mode 100644 index 0000000..f5cd73e --- /dev/null +++ b/CLC-qthing/SiliconTorch/FxCyanF-configureFromNVS.cpp @@ -0,0 +1,50 @@ +#include "FxCyanF.hpp" + +// C++ system level +#include <string> +// #include <cstdio> +// #include <cstdlib> +// #include <algorithm> +// #include <functional> + +// ESP32 specific +#include "nvs.h" +#include "nvs_flash.h" +#include "esp_log.h" + +// misc +// #include <nlohmann/json.hpp> + +// qthing stuff +// #include <qthing> +// #include <qthing/mqtt_common.hpp> + +// project specific +// #include "FxVSync.hpp" +// #include "CyanBus.hpp" +// #include "Metrics.hpp" + + + +namespace SiliconTorch { + + // namespace FxCyanF { + + + const std::string nameSpace = "FxCyanF"; + + + bool configureFromNVS(FxCyanF& target) { + + nvs_flash_init(); + + nvs_handle_t nvs; + nvs_open(nameSpace.c_str(), NVS_READONLY, &nvs); + + + return false; + } + + + // } +} diff --git a/CLC-qthing/SiliconTorch/FxCyanF.hpp b/CLC-qthing/SiliconTorch/FxCyanF.hpp index 8a98cb2..a3fc5e0 100644 --- a/CLC-qthing/SiliconTorch/FxCyanF.hpp +++ b/CLC-qthing/SiliconTorch/FxCyanF.hpp @@ -85,5 +85,9 @@ namespace SiliconTorch { Metrics::Incrementer frameCntInc; Metrics::Incrementer errorCntInc; }; + + + bool configureFromNVS(FxCyanF& target); + //} } diff --git a/CLC-qthing/SiliconTorch/FxPublish.cpp b/CLC-qthing/SiliconTorch/FxPublish.cpp new file mode 100644 index 0000000..99e8859 --- /dev/null +++ b/CLC-qthing/SiliconTorch/FxPublish.cpp @@ -0,0 +1,45 @@ +#include "FxPublish.hpp" + +// C++ system level +#include <string> +// #include <cstring> // memset, strncmp +// #include <cstdlib> // TODO: is this for memcpy? +// #include <cinttypes> +// #include <functional> + +// ESP32 specific +#include "esp_log.h" + +// project specific +#include "CyanBus.hpp" + +// qthing stuff +#include <qthing> + + +/* +static const char* TAG = "FxPublish"; + + +namespace SiliconTorch { + + namespace FxPublish { + + const std::string HEADER("fxPublish"); + + + FxPublish::FxPublish() {} + + + void FxPublish::registerAtCyanBus(CyanBus::CyanBus& cyanBus) { + if (!registeredAtCB) { + registeredAtCB = true; + + } else { + ESP_LOGW(TAG, "Already registered!"); + } + } + + } +} +*/ \ No newline at end of file diff --git a/CLC-qthing/SiliconTorch/FxPublish.hpp b/CLC-qthing/SiliconTorch/FxPublish.hpp new file mode 100644 index 0000000..738870d --- /dev/null +++ b/CLC-qthing/SiliconTorch/FxPublish.hpp @@ -0,0 +1,45 @@ +#pragma once + +// C++ system level +#include <string> +// #include <cstring> // memset, strncmp +// #include <cstdlib> // TODO: is this for memcpy? +// #include <cinttypes> +// #include <functional> + +// ESP32 specific +// #include "esp_log.h" + +// project specific +#include "CyanBus.hpp" + +// qthing stuff +// #include <qthing> + + +/* +namespace SiliconTorch { + + namespace FxPublish { + + extern const std::string HEADER; + + + class fxPublish { + + public: + + FxPublish(); + + void registerAtCyanBus(CyanBus::CyanBus& cyanBus); + + + private: + + bool registeredAtCB = false; + + }; + + } +} +*/ \ No newline at end of file diff --git a/CLC-qthing/SiliconTorch/NVSExplorer.cpp b/CLC-qthing/SiliconTorch/NVSExplorer.cpp new file mode 100644 index 0000000..b3230b3 --- /dev/null +++ b/CLC-qthing/SiliconTorch/NVSExplorer.cpp @@ -0,0 +1,61 @@ +#include "CapMan.hpp" + +// C++ system level +#include <set> +// #include <cstring> // memset, strncmp +// #include <cstdlib> // TODO: is this for memcpy? +#include <cinttypes> +// #include <functional> + +// ESP32 specific +#include "esp_log.h" +#include "nvs_flash.h" +// #include "esp_err.h" +// #include "driver/uart.h" + +// project specific +// #include "" + +// qthing stuff +// #include <qthing> + + + +namespace SiliconTorch { + + namespace NVSExplorer { + + + // NVSExplorer::NVSExplorer() { + void BullShit() { + + nvs_flash_init(); + + ESP_LOGW("NVS", "Scanning 👀"); + + nvs_iterator_t it = nvs_entry_find("nvs", NULL, NVS_TYPE_ANY); + + while (it != NULL) { + nvs_entry_info_t info; + nvs_entry_info(it, &info); + it = nvs_entry_next(it); + + ESP_LOGW("NVS", "namespace[ %s ] key[ %s ] type[ %d ]", info.namespace_name, info.key, info.type); + } + + + } + + + /* std::set<std::string> listKeys(std::string& _namespace) { + + } + + std::set<std::string> listNamespaces() { + std::string _namespace = NULL; + return listKeys(_namespace); + } */ + + + } +} diff --git a/CLC-qthing/SiliconTorch/NVSExplorer.hpp b/CLC-qthing/SiliconTorch/NVSExplorer.hpp new file mode 100644 index 0000000..6f0a9e2 --- /dev/null +++ b/CLC-qthing/SiliconTorch/NVSExplorer.hpp @@ -0,0 +1,59 @@ +#pragma once + +// C++ system level +// #include <cstring> // memset, strncmp +// #include <cstdlib> // TODO: is this for memcpy? +#include <cinttypes> +// #include <functional> + +// ESP32 specific +// #include "esp_err.h" +#include "esp_log.h" +// #include "driver/gpio.h" +// #include "driver/uart.h" + +// project specific +// #include "" + +// qthing stuff +// #include <qthing> + + +namespace SiliconTorch { + + namespace NVSExplorer { + + + //class NVSExplorer { + + //public: + + //NVSExplorer(); + + static void BullShit(); + + + // std::set<std::string> listNamespaces(); + // std::set<std::string> listKeys(std::string& _namespace); + + + // ⬇⬇ Singleton stuff ⬇⬇ + +/* static NVSExplorer& instance() { + static NVSExplorer _instance; + return _instance; + } + + NVSExplorer(NVSExplorer const&) = delete; + void operator=(NVSExplorer const&) = delete; + + // ⬆⬆ Singleton stuff ⬆⬆ +*/ + //private: + + + + //}; + + } +} diff --git a/CLC-qthing/SiliconTorch/SiliconTorch.cpp b/CLC-qthing/SiliconTorch/SiliconTorch.cpp new file mode 100644 index 0000000..1b61ff1 --- /dev/null +++ b/CLC-qthing/SiliconTorch/SiliconTorch.cpp @@ -0,0 +1,42 @@ +#include "SiliconTorch.hpp" + +// C++ system level +#include <cstring> // memset, strncmp +#include <cstdlib> // TODO: is this for memcpy? +#include <cinttypes> +#include <functional> + +// ESP32 specific +#include "esp_err.h" +#include "esp_log.h" +#include "driver/gpio.h" +#include "driver/uart.h" +#include "freertos/FreeRTOS.h" +#include "freertos/queue.h" + +// project specific +#include "CyanBusCRC.hpp" +#include "LambdaTask.hpp" +#include "SpiderLib/Callback.hpp" +#include "SpiderLib/CallbackMap.hpp" + +// qthing stuff +// #include "" + + +static const char* const TAG = "SiliconTorch"; + + +namespace SiliconTorch { + + namespace SiliconTorch { + + + SiliconTorch::SiliconTorch() { + + } + + + + } +} diff --git a/CLC-qthing/SiliconTorch/SiliconTorch.hpp b/CLC-qthing/SiliconTorch/SiliconTorch.hpp new file mode 100644 index 0000000..866578a --- /dev/null +++ b/CLC-qthing/SiliconTorch/SiliconTorch.hpp @@ -0,0 +1,38 @@ +#pragma once + +// C++ system level +#include <string> +#include <cinttypes> +#include <functional> + +// ESP32 specific +#include "freertos/FreeRTOS.h" +#include "freertos/queue.h" + +// project specific +#include "LambdaTask.hpp" +#include "SpiderLib/Callback.hpp" +#include "SpiderLib/CallbackMap.hpp" + +// qthing stuff +// #include "" + + +namespace SiliconTorch { + + namespace SiliconTorch { + + + + class SiliconTorch { + + public: + + SiliconTorch(); + + private: + + + }; + } +} diff --git a/CLC-qthing/SimpleUART.hpp b/CLC-qthing/SimpleUART.hpp index a16e17d..8ffd2d8 100644 --- a/CLC-qthing/SimpleUART.hpp +++ b/CLC-qthing/SimpleUART.hpp @@ -4,4 +4,3 @@ - diff --git a/CLC-qthing/SpiderLib/Time.cpp b/CLC-qthing/SpiderLib/Time.cpp new file mode 100644 index 0000000..f1785a6 --- /dev/null +++ b/CLC-qthing/SpiderLib/Time.cpp @@ -0,0 +1,20 @@ +#include "Time.hpp" + +// ESP32 specific +#include "esp_timer.h" + +// C++ system level +#include <cinttypes> + +// project specific +// #include "MyHeader.hpp" + + + +namespace SpiderLib { + + uint32_t Time::s() { return (uint32_t)(esp_timer_get_time() / 1000000ULL); } + uint64_t Time::ms() { return (uint64_t)(esp_timer_get_time() / 1000ULL); } + uint64_t Time::us() { return (uint64_t) esp_timer_get_time(); } + +} diff --git a/CLC-qthing/SpiderLib/Time.hpp b/CLC-qthing/SpiderLib/Time.hpp new file mode 100644 index 0000000..9ada8dc --- /dev/null +++ b/CLC-qthing/SpiderLib/Time.hpp @@ -0,0 +1,23 @@ +#pragma once + +// ESP32 specific +// #include "MyHeader.h" + +// C++ system level +#include <cinttypes> + +// project specific +// #include "MyHeader.hpp" + + +namespace SpiderLib { + + + class Time { + public: + static uint32_t s(); + static uint64_t ms(); + static uint64_t us(); + }; + +} diff --git a/CLC-qthing/SpiderLib/Util.cpp b/CLC-qthing/SpiderLib/Util.cpp index a634ac7..fc3c639 100644 --- a/CLC-qthing/SpiderLib/Util.cpp +++ b/CLC-qthing/SpiderLib/Util.cpp @@ -1,10 +1,13 @@ #include "Util.hpp" // ESP32 specific -#include "esp_timer.h" +// #include "esp_log.h" // C++ system level -#include <cinttypes> +#include <string> +#include <vector> +#include <sstream> +// #include <cinttypes> // project specific // #include "MyHeader.hpp" @@ -13,9 +16,23 @@ namespace SpiderLib { + namespace Util { - uint32_t Time::s() { return (uint32_t)(esp_timer_get_time() / 1000000ULL); } - uint64_t Time::ms() { return (uint64_t)(esp_timer_get_time() / 1000ULL); } - uint64_t Time::us() { return (uint64_t) esp_timer_get_time(); } + // Taken from: https://stackoverflow.com/a/27511119 + // slightly modified by fxk8y + std::vector<std::string> split(const std::string& s, char delim) { + std::string item; + std::stringstream ss(s); + std::vector<std::string> out; + + while (std::getline(ss, item, delim)) { + out.push_back(item); + // out.push_back(std::move(item)); // if C++11 (based on comment from @mchiasson) + } + + return out; + } + + } } diff --git a/CLC-qthing/SpiderLib/Util.hpp b/CLC-qthing/SpiderLib/Util.hpp index b8e049a..3acace6 100644 --- a/CLC-qthing/SpiderLib/Util.hpp +++ b/CLC-qthing/SpiderLib/Util.hpp @@ -1,9 +1,11 @@ #pragma once // ESP32 specific -// #include "MyHeader.h" +// #include "esp_log.h" // C++ system level +#include <vector> +#include <string> #include <cinttypes> // project specific @@ -12,11 +14,9 @@ namespace SpiderLib { + namespace Util { - class Time { - public: - static uint32_t s(); - static uint64_t ms(); - static uint64_t us(); - }; + std::vector<std::string> split(const std::string& s, char delim); + + } } diff --git a/CLC-qthing/device_config.h b/CLC-qthing/device_config.h index b9bf347..c8ce0fb 100644 --- a/CLC-qthing/device_config.h +++ b/CLC-qthing/device_config.h @@ -1,5 +1,5 @@ // hostname and device namespace -#define DEVICE_NAME "CyanLight" +#define DEVICE_NAME "CLC-Drucker" #define NTP_SERVER "pool.ntp.org" diff --git a/CLC-qthing/device_main.cpp b/CLC-qthing/device_main.cpp index c71e657..0bd8b40 100644 --- a/CLC-qthing/device_main.cpp +++ b/CLC-qthing/device_main.cpp @@ -23,6 +23,8 @@ #include "SiliconTorch/FxCyanRGB8.hpp" +//#include "SiliconTorch/FxPublish.hpp" + // ### END LIBS ### @@ -31,14 +33,23 @@ SiliconTorch::CyanBus::CyanBus* cyanBus = NULL; +//SiliconTorch::FxPublish::FxPublish* fxPub = NULL; SiliconTorch::FxCyanRGB8::FxCyanRGB8* cyanRGB = NULL; CyanLight::CyanLightControl* ctrl; +#include "SiliconTorch/NVSExplorer.hpp" + void device_main() { + + + //SiliconTorch::NVSExplorer::BullShit(); + +//return; + qthing::Config cfg; // Needed for packet parsing, animation rendering and stuff @@ -48,18 +59,20 @@ void device_main() { - cyanBus = new SiliconTorch::CyanBus::CyanBus(13, 14, 12, 15, 2000000); // Pinout of CyanStripe + //cyanBus = new SiliconTorch::CyanBus::CyanBus(13, 14, 12, 15, 2000000); // Pinout of CyanStripe - auto led0 = cfg.add<qthing::leds::WS2812B_V3>(GPIO_NUM_27, 8); + /* auto led0 = cfg.add<qthing::leds::WS2812B_V3>(GPIO_NUM_27, 8); cyanRGB = new SiliconTorch::FxCyanRGB8::FxCyanRGB8(8); cyanRGB->registerUDPHandler(); cyanRGB->registerAtCyanBus(*cyanBus); auto bullshitPtr = std::shared_ptr<qthing::Animation<qthing::RGB>>(cyanRGB, [](void*){}); - cfg.add<qthing::Animator<qthing::RGBW8>>(led0)->setAnimation(bullshitPtr); + cfg.add<qthing::Animator<qthing::RGBW8>>(led0)->setAnimation(bullshitPtr); */ + //fxPub = new SiliconTorch::FxPublish::FxPublish(); + //fxPub->registerAtCyanBus(*cyanBus); @@ -69,7 +82,7 @@ void device_main() { qthing::enable_wifi(); cfg.apply(); - return; + //return; -- GitLab