2023-05-29 18:29:15 +02:00
|
|
|
#pragma once
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#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;
|
2023-06-01 22:54:13 +02:00
|
|
|
constexpr size_t rtcStorageSize = 7600;
|
2023-05-29 18:29:15 +02:00
|
|
|
|
|
|
|
constexpr size_t maxEepromSize = 13350;
|
|
|
|
constexpr size_t eepromSize = 13350;
|
|
|
|
|
2023-06-03 08:14:30 +02:00
|
|
|
constexpr size_t totalStorageSize = rtcStorageSize + eepromSize;
|
|
|
|
|
2023-05-29 18:29:15 +02:00
|
|
|
// 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;
|
|
|
|
|
|
|
|
void storageConfigure();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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);
|
|
|
|
|
|
|
|
void saveTemperatureAtCurrentIndex(Temperature temp);
|
|
|
|
|
|
|
|
uint16_t getTotalNumberOfStoredBytes();
|
|
|
|
|
2023-06-01 16:18:48 +02:00
|
|
|
uint16_t getNumberOfMeasurements();
|
|
|
|
|
|
|
|
uint8_t getLastTemperature(uint8_t sensorIndex);
|
|
|
|
|
2023-06-03 08:14:30 +02:00
|
|
|
uint16_t getTimeSinceValidTemperature(uint8_t sensorIndex);
|
|
|
|
|
2023-05-29 18:29:15 +02:00
|
|
|
uint16_t getRecordedBytesAtOffset(uint8_t* buffer, uint16_t offset, uint16_t count);
|
|
|
|
|
|
|
|
void discardAllRecordedBytes();
|