TempTrack-ESP/include/storage.h

49 lines
1.2 KiB
C
Raw Normal View History

2023-05-29 18:29:15 +02:00
#pragma once
#include <stddef.h>
#include <stdint.h>
#include "temperature.h"
constexpr uint8_t temperatureSensorCount = 2;
// Max size: 7664
constexpr size_t rtcStorageSize = 7580;
2023-05-29 18:29:15 +02:00
constexpr size_t maxEepromSize = 13350;
2023-06-03 08:14:30 +02:00
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(bool isFirstRun);
2023-05-29 18:29:15 +02:00
/**
* @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();
2023-06-01 16:18:48 +02:00
uint16_t getNumberOfMeasurements();
2023-06-08 14:58:12 +02:00
uint32_t getTotalNumberOfMeasurements();
uint32_t getStartTimeOfCurrentRecording();
2023-06-01 16:18:48 +02:00
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);
uint16_t getDataChecksum();
2023-06-18 15:15:55 +02:00
void discardAllRecordedBytes();