- Add app path get() functions to `TactilityC` - Improved `Dispatcher` and `DispatcherThread` - Improved `PubSub` (type safety) - Created test for `DispatcherThread` and `PubSub` - Save properties files on app exit (various apps) by posting it to the main dispatcher (fixes UI hanging briefly on app exit) - Fixed bug with `SystemSettings` being read from the wrong file path. - `loadPropertiesFile()` now uses `file::readLines()` instead of doing that manually - Increased timer task stack size (required due to issues when reading a properties file for the very first time) - General cleanup - Created `EstimatedPower` driver that uses an ADC pin to measure voltage and estimate the battery charge that is left. - Cleanup of T-Deck board (updated to new style)
63 lines
1.4 KiB
C++
63 lines
1.4 KiB
C++
/**
|
|
* @brief key-value storage for general purpose.
|
|
* Maps strings on a fixed set of data types.
|
|
*/
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include <unordered_map>
|
|
|
|
namespace tt {
|
|
|
|
/**
|
|
* A dictionary that maps keys (strings) onto several atomary types.
|
|
*/
|
|
class Bundle final {
|
|
|
|
typedef uint32_t Hash;
|
|
|
|
enum class Type {
|
|
Bool,
|
|
Int32,
|
|
String,
|
|
};
|
|
|
|
typedef struct {
|
|
Type type;
|
|
union {
|
|
bool value_bool;
|
|
int32_t value_int32;
|
|
};
|
|
std::string value_string;
|
|
} Value;
|
|
|
|
std::unordered_map<std::string, Value> entries;
|
|
|
|
public:
|
|
|
|
Bundle() = default;
|
|
|
|
Bundle(const Bundle& bundle) {
|
|
this->entries = bundle.entries;
|
|
}
|
|
|
|
bool getBool(const std::string& key) const;
|
|
int32_t getInt32(const std::string& key) const;
|
|
std::string getString(const std::string& key) const;
|
|
|
|
bool hasBool(const std::string& key) const;
|
|
bool hasInt32(const std::string& key) const;
|
|
bool hasString(const std::string& key) const;
|
|
|
|
bool optBool(const std::string& key, bool& out) const;
|
|
bool optInt32(const std::string& key, int32_t& out) const;
|
|
bool optString(const std::string& key, std::string& out) const;
|
|
|
|
void putBool(const std::string& key, bool value);
|
|
void putInt32(const std::string& key, int32_t value);
|
|
void putString(const std::string& key, const std::string& value);
|
|
};
|
|
|
|
} // namespace
|