Moved TRMNL stuff to its own file

This commit is contained in:
2026-06-22 18:11:31 +03:00
parent fe8346925a
commit 23e2fbd995
7 changed files with 373 additions and 162 deletions

View File

@@ -6,6 +6,7 @@ using nlohmann::json;
using std::endl;
using std::ifstream;
using std::ofstream;
using std::istream;
using std::ostream;
using std::string;
@@ -18,7 +19,7 @@ bool read_file_json(json& j, const string& filename, ostream* log)
{
if (nullptr != log)
{
*log << "Could not open file" << endl;
*log << "Could not open file to read - " << filename << endl;
}
return false;
}
@@ -45,6 +46,24 @@ bool read_stream_json(json& j, istream& in, ostream* log)
return true;
}
bool write_file_json(const json& j, const string& filename, ostream* log)
{
ofstream file(filename);
if (!file.is_open())
{
if (nullptr != log)
{
*log << "Could not open file to write - " << filename << endl;
}
return false;
}
file << j.dump(4) << endl;
return true;
}
bool json_extract(const json& j, const string& key, string& out)
{
bool result = false;