diff --git a/CLC-qthing/SiliconTorch/CapMan.cpp b/CLC-qthing/SiliconTorch/CapMan.cpp new file mode 100644 index 0000000000000000000000000000000000000000..138fa285c1926825e4814279320d4e7460d08c63 --- /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 0000000000000000000000000000000000000000..2bcf8840f7b310a4a4ff3a5927bb0c1f6e359340 --- /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 4a8de3897c1967eb0ae81db19af977668e0f392b..9891c54e262af1c94a178bc434c39e8c9bab6d6e 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 0000000000000000000000000000000000000000..f5cd73e02095cfe79edc0f1c6c48260ffa0e912c --- /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 8a98cb2cd3dba6de9f60fd870c92a3dc393642a3..a3fc5e0637b5857d71ecc894740d9ebb336ea4b6 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 0000000000000000000000000000000000000000..99e8859c91cb1273e66db6eb4720eddc2f550b62 --- /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 0000000000000000000000000000000000000000..738870d6b1ad2a00c7844ef34004b91e58a200c1 --- /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 0000000000000000000000000000000000000000..b3230b3989d1fb9154222539b228ec5371710ab7 --- /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 0000000000000000000000000000000000000000..6f0a9e2a8361b6c00bb215205d59db411436c27a --- /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 0000000000000000000000000000000000000000..1b61ff1f22b7c5a6e32ab4dc3d5722c4def7eda2 --- /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 0000000000000000000000000000000000000000..866578a7f8639d12f1957dbeea63358f4fff23b2 --- /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 a16e17dac9ee47498c93e90380a3ce2561da10eb..8ffd2d851b9e26649534d22c9ec172e6351cc447 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 0000000000000000000000000000000000000000..f1785a6dfa00c0955dbaf64823572e7129e77f80 --- /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 0000000000000000000000000000000000000000..9ada8dcbd1099552de1aaa1fd5ad28a0559fca5d --- /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 a634ac7c74abeb11f57879bc30f054c15f26feb2..fc3c6397567c14ffbb261d3b89494345c485dfe5 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 b8e049ab2575c06e50e8ed5b5b2a30a24c491333..3acace6f7961a2dfbdb210e89c2a15b1f614b84e 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 b9bf347820d4226a84c0a10de72f72607b341006..c8ce0fb631620be58343d945e3bc64e0c47af617 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 c71e6578f1c8967a0b5efa5ae5d269661e165d66..0bd8b40b9222467b16a9530014b873b222618917 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;