Skip to content
Snippets Groups Projects
Commit 5aea8b73 authored by fxk8y's avatar fxk8y :spider:
Browse files

Polishing things :sparkler:

parent 4a02949b
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,7 @@ idf_component_register(
"." "SiliconTorch" "SpiderLib"
INCLUDE_DIRS
"."
"." "SpiderLib"
REQUIRES
main
......
......@@ -8,8 +8,6 @@
// #include <functional>
// ESP32 specific
#include "nvs.h"
#include "nvs_flash.h"
#include "esp_log.h"
// misc
......@@ -20,6 +18,7 @@
// #include <qthing/mqtt_common.hpp>
// project specific
#include "NVSExplorer.hpp"
#include "SpiderLib/NumberTypes.hpp"
// #include "FxVSync.hpp"
// #include "CyanBus.hpp"
......@@ -41,18 +40,13 @@ namespace SiliconTorch {
}
nvs_flash_init();
nvs_handle_t nvs;
nvs_open(nvsNameSpace, NVS_READONLY, &nvs);
std::string ns = "fxCyan";
u32 frq = 0;
nvs_get_u32(nvs, "frequency", &frq);
u8 res = 0;
nvs_get_u8(nvs, "resolution", &res);
frq = NVSExplorer::NVSExplorer::instance().getUnsignedInt(ns, "frequency", frq);
res = NVSExplorer::NVSExplorer::instance().getUnsignedInt(ns, "resolution", res);
if (frq == 0 || res == 0) {
ESP_LOGW(TAG, "No config for CyanLight found"); // TODO: Log-Level Debug
......@@ -69,7 +63,7 @@ namespace SiliconTorch {
char channel[32];
snprintf(channel, 32, "ch%d_gpio", ch);
nvs_get_i8(nvs, channel, &gpio);
//nvs_get_i8(nvs, channel, &gpio);
if (gpio >= 0) {
......
This diff is collapsed.
......@@ -15,7 +15,7 @@
// #include "driver/uart.h"
// project specific
#include "SpiderLib/NumberTypes.hpp"
#include <Types.hpp>
// #include "SpiderLib/ManagedMutex.hpp"
// qthing stuff
......@@ -34,74 +34,74 @@ namespace SiliconTorch {
public:
std::set<std::string> listNamespaces();
std::set<std::string> listKeys(const std::string& nameSpace);
std::set<str> listNamespaces();
std::set<str> listKeys(const str& nameSpace);
void rmKey(const std::string& nameSpace, const std::string& key);
void rmKey(const str& nameSpace, const str& key);
bool setU8(const std::string& nameSpace, const std::string& key, u8 value);
bool setI8(const std::string& nameSpace, const std::string& key, i8 value);
bool setU8(const str& nameSpace, const str& key, u8 value);
bool setI8(const str& nameSpace, const str& key, i8 value);
bool setU16(const std::string& nameSpace, const std::string& key, u16 value);
bool setI16(const std::string& nameSpace, const std::string& key, i16 value);
bool setU16(const str& nameSpace, const str& key, u16 value);
bool setI16(const str& nameSpace, const str& key, i16 value);
bool setU32(const std::string& nameSpace, const std::string& key, u32 value);
bool setI32(const std::string& nameSpace, const std::string& key, i32 value);
bool setU32(const str& nameSpace, const str& key, u32 value);
bool setI32(const str& nameSpace, const str& key, i32 value);
bool setU64(const std::string& nameSpace, const std::string& key, u64 value);
bool setI64(const std::string& nameSpace, const std::string& key, i64 value);
bool setU64(const str& nameSpace, const str& key, u64 value);
bool setI64(const str& nameSpace, const str& key, i64 value);
u8 getU8(const std::string& nameSpace, const std::string& key, u8 defaultValue = 0);
i8 getI8(const std::string& nameSpace, const std::string& key, i8 defaultValue = 0);
u8 getU8(const str& nameSpace, const str& key, u8 defaultValue = 0);
i8 getI8(const str& nameSpace, const str& key, i8 defaultValue = 0);
u16 getU16(const std::string& nameSpace, const std::string& key, u16 defaultValue = 0);
i16 getI16(const std::string& nameSpace, const std::string& key, i16 defaultValue = 0);
u16 getU16(const str& nameSpace, const str& key, u16 defaultValue = 0);
i16 getI16(const str& nameSpace, const str& key, i16 defaultValue = 0);
u32 getU32(const std::string& nameSpace, const std::string& key, u32 defaultValue = 0);
i32 getI32(const std::string& nameSpace, const std::string& key, i32 defaultValue = 0);
u32 getU32(const str& nameSpace, const str& key, u32 defaultValue = 0);
i32 getI32(const str& nameSpace, const str& key, i32 defaultValue = 0);
u64 getU64(const std::string& nameSpace, const std::string& key, u64 defaultValue = 0);
i64 getI64(const std::string& nameSpace, const std::string& key, i64 defaultValue = 0);
u64 getU64(const str& nameSpace, const str& key, u64 defaultValue = 0);
i64 getI64(const str& nameSpace, const str& key, i64 defaultValue = 0);
float getFloat(const std::string& nameSpace, const std::string& key);
double getDouble(const std::string& nameSpace, const std::string& key);
float getFloat(const str& nameSpace, const str& key);
double getDouble(const str& nameSpace, const str& key);
bool setFloat(const std::string& nameSpace, const std::string& key, float value);
bool setDouble(const std::string& nameSpace, const std::string& key, double value);
bool setFloat(const str& nameSpace, const str& key, float value);
bool setDouble(const str& nameSpace, const str& key, double value);
// Gets the key regardless of its type in flash
i64 getSignedInt(const std::string& nameSpace, const std::string& key, i64 defaultValue = 0);
u64 getUnsignedInt(const std::string& nameSpace, const std::string& key, u64 defaultValue = 0);
i64 getSignedInt(const str& nameSpace, const str& key, i64 defaultValue = 0);
u64 getUnsignedInt(const str& nameSpace, const str& key, u64 defaultValue = 0);
// TODO: ⮦ Both unimplemented atm ⮧
bool setSignedInt(const std::string& nameSpace, const std::string& key, i64 value, nvs_type_t entryType = NVS_TYPE_ANY);
bool setUnsignedInt(const std::string& nameSpace, const std::string& key, u64 value, nvs_type_t entryType = NVS_TYPE_ANY);
bool setSignedInt(const str& nameSpace, const str& key, i64 value, nvs_type_t entryType = NVS_TYPE_ANY);
bool setUnsignedInt(const str& nameSpace, const str& key, u64 value, nvs_type_t entryType = NVS_TYPE_ANY);
size_t getStringLength(const std::string& nameSpace, const std::string& key, size_t defaultValue = 0);
std::string getString(const std::string& nameSpace, const std::string& key, const std::string& defaultValue = "");
// size_t getLongString(const std::string& nameSpace, const std::string& key, char* const buffer);
size_t getStringLength(const str& nameSpace, const str& key, size_t defaultValue = 0);
str getString(const str& nameSpace, const str& key, const str& defaultValue = "");
// size_t getLongString(const str& nameSpace, const str& key, char* const buffer);
bool setString(const std::string& nameSpace, const std::string& key, const std::string& value);
bool setString(const str& nameSpace, const str& key, const str& value);
std::string type2str(nvs_type_t typ);
nvs_type_t getType(const std::string& nameSpace, const std::string& key);
std::string getTypeStr(const std::string& nameSpace, const std::string& key);
str type2str(nvs_type_t typ);
nvs_type_t getType(const str& nameSpace, const str& key);
str getTypeStr(const str& nameSpace, const str& key);
std::string deviceTopic(const std::string& suffix);
str deviceTopic(const str& suffix);
std::string requestTopic(const std::string& cmd);
std::string requestTopic(const std::string& cmd, const std::string& nameSpace);
std::string requestTopic(const std::string& cmd, const std::string& nameSpace, const std::string& key);
str requestTopic(const str& cmd);
str requestTopic(const str& cmd, const str& nameSpace);
str requestTopic(const str& cmd, const str& nameSpace, const str& key);
std::string responseTopic(const std::string& cmd);
std::string responseTopic(const std::string& cmd, const std::string& nameSpace);
std::string responseTopic(const std::string& cmd, const std::string& nameSpace, const std::string& key);
str responseTopic(const str& cmd);
str responseTopic(const str& cmd, const str& nameSpace);
str responseTopic(const str& cmd, const str& nameSpace, const str& key);
// ⬇⬇ Singleton stuff ⬇⬇
......
#pragma once
#include <string>
using str = std::string;
// TODO: more useful types…?
#pragma once
#include <NumberTypes.hpp>
#include <ObjectTypes.hpp>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment