#pragma once #include #include #include "temperature.h" constexpr uint8_t temperatureSensorCount = 2; constexpr size_t storageSize = 80000; constexpr uint16_t storageIntervalInSeconds = 15; constexpr size_t maximumStorageDurationInHours = (storageSize / TEMPERATURE_SENSOR_MAX_COUNT) * storageIntervalInSeconds / 3600; // Max size: 7664 constexpr size_t maxRtcStorageSize = 7664; constexpr size_t rtcStorageSize = 7550; constexpr size_t maxEepromSize = 13350; constexpr size_t eepromSize = 13350; constexpr size_t totalStorageSize = rtcStorageSize + eepromSize; // The minimum temperature to store, in millidegrees celcius // True minimum will be higher by 1°, since two values are reserved constexpr long temperatureShiftForStorage = -40000; constexpr long maximumTemperature = temperatureShiftForStorage + 255 * 500; constexpr uint8_t temperatureMaximumValue = 255; enum class StorageFlags: uint8_t { HasInitializedEEPROM = 1, FailedToInitEEPROM = 2, FailedToWriteEEPROM = 4, RTCStorageOverflow = 5, }; void storageConfigure(bool isFirstRun); /** * @brief Save temperatures for both temperature sensors * * Temperatures are in millidegrees celsius * * @param temperatures The array of temperatures * @param count The number of elements in the array */ void saveTemperatures(Temperature* temperatures); uint16_t getTotalNumberOfStoredBytes(); uint16_t getNumberOfMeasurements(); uint32_t getTotalNumberOfMeasurements(); uint8_t getLastTemperature(uint8_t sensorIndex); uint16_t getTimeSinceValidTemperature(uint8_t sensorIndex); uint16_t getRecordedBytesAtOffset(uint8_t* buffer, uint16_t offset, uint16_t count); void discardAllRecordedBytes(); uint8_t getStorageErrorFlags();