TempTrack-ESP/include/temperature.h

43 lines
996 B
C
Raw Normal View History

2023-05-29 18:29:15 +02:00
#pragma once
#include <stdint.h>
2023-06-01 16:18:48 +02:00
// Note: Pin requires external 4.7kOhm pull-up
constexpr uint8_t TEMPERATURE_SENSOR_PIN = 23;
2023-05-29 18:29:15 +02:00
constexpr uint8_t TEMPERATURE_SENSOR_MAX_COUNT = 2;
2023-06-01 16:18:48 +02:00
// The number of bytes composing a temperature sensor address
constexpr int TEMPERATURE_SENSOR_ADDRESS_SIZE = 8;
2023-05-29 18:29:15 +02:00
constexpr uint8_t temperatureSensorNotAvailable = 0;
constexpr uint8_t temperatureSensorFailure = 1;
constexpr uint8_t temperatureMinimumValue = 2;
enum class TemperatureStatus {
sensorNotFound = temperatureSensorNotAvailable,
sensorError = temperatureSensorFailure,
temperatureIsValid = temperatureMinimumValue,
};
struct Temperature {
TemperatureStatus status;
/**
* @brief The temperature value, in millidegrees celsius
* This value is only valid if the status is `temperatureIsValid`
*/
long value;
};
void temperatureConfigure();
2023-06-01 16:18:48 +02:00
void temperaturePerformUpdate(Temperature* temperatures);
void copySensorAddress(uint8_t index, uint8_t* buffer);