REDAC HybridController
Firmware for LUCIDAC/REDAC Teensy
Loading...
Searching...
No Matches
user.h
Go to the documentation of this file.
1// Copyright (c) 2023 anabrid GmbH
2// Contact: https://www.anabrid.com/licensing/
3// SPDX-License-Identifier: MIT OR GPL-2.0-or-later
4
5#pragma once
6
7#include <ArduinoJson.h>
8#include <list>
9
11#include "utils/singleton.h"
12
13namespace nvmconfig {
14
27 int max_doc_bytes = 600;
28 DynamicJsonDocument *doc;
29
30 std::string name() const { return "user"; }
31 void reset_defaults() { delete doc; }
32 void clear() { delete doc; }
33 void fromJson(JsonObjectConst src, Context c = Context::Flash) override {
34 if(!doc) doc = new DynamicJsonDocument(max_doc_bytes);
35 else doc->clear();
36 *doc = src;
37 }
38 void toJson(JsonObject target, Context c = Context::Flash) const override {
39 if(doc) target = doc->as<JsonObject>();
40 }
41 };
42
43 //JSON_CONVERT_SUGAR(VendorOTP);
44} // ns nvmconfig
Define singletons which are not static-space allocated (and thus consume valuable ICTM space).
Definition singleton.h:46
uint32_t src
Definition flasher.cpp:63
@ Flash
Flash-Facing (writing/reading)
Permanent untyped arbitrary information which a device user wants to store.
Definition user.h:26
void clear()
Clear local memory in order to save RAM if an object is not needed during runtime but only at startup...
Definition user.h:32
DynamicJsonDocument * doc
Definition user.h:28
std::string name() const
Definition user.h:30
void fromJson(JsonObjectConst src, Context c=Context::Flash) override
Definition user.h:33
void toJson(JsonObject target, Context c=Context::Flash) const override
Definition user.h:38