TempTrack-ESP/include/temperature.h

45 lines
1.0 KiB
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: uint8_t {
2023-05-29 18:29:15 +02:00
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);
2023-07-03 09:43:47 +02:00
uint8_t* getSensorAddress(uint8_t index);
2023-06-01 16:18:48 +02:00
void copySensorAddress(uint8_t index, uint8_t* buffer);