TempTrack-ESP/include/storage.h

49 lines
1.2 KiB
C++

#pragma once
#include <stddef.h>
#include <stdint.h>
#include "temperature.h"
constexpr uint8_t temperatureSensorCount = 2;
// Max size: 7664
constexpr size_t rtcStorageSize = 7580;
constexpr size_t maxEepromSize = 13350;
// 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(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();
uint32_t getStartTimeOfCurrentRecording();
uint8_t getLastTemperature(uint8_t sensorIndex);
uint16_t getTimeSinceValidTemperature(uint8_t sensorIndex);
uint16_t getRecordedBytesAtOffset(uint8_t* buffer, uint16_t offset, uint16_t count);
uint16_t getDataChecksum();
void discardAllRecordedBytes();