/* * This file is part of HayBox * Copyright (C) 2024 Jonathan Haylett * * HayBox is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software. If not, see . */ #ifndef _CORE_PERSISTENCE_HPP #define _CORE_PERSISTENCE_HPP #include #include class Persistence { public: typedef struct _ConfigHeader { size_t config_size = 0; uint32_t config_crc = 0; } ConfigHeader; Persistence(); ~Persistence(); bool SaveConfig(Config &config); bool LoadConfig(Config &config); bool CheckSavedConfig(); size_t LoadConfigRaw(Print &out, bool validate = true); static constexpr size_t config_offset = sizeof(ConfigHeader); private: static constexpr char config_filename[] = "config.bin"; bool CheckSavedConfig(File &config_file); }; extern Persistence persistence; #endif