#pragma once

#include <stdint.h>


// Note: Pin requires external 4.7kOhm pull-up
constexpr uint8_t TEMPERATURE_SENSOR_PIN = 23;

constexpr uint8_t TEMPERATURE_SENSOR_MAX_COUNT = 2;

// The number of bytes composing a temperature sensor address
constexpr int TEMPERATURE_SENSOR_ADDRESS_SIZE = 8;

constexpr uint8_t temperatureSensorNotAvailable = 0;
constexpr uint8_t temperatureSensorFailure = 1;
constexpr uint8_t temperatureMinimumValue = 2;

enum class TemperatureStatus: uint8_t {

    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();

void temperaturePerformUpdate(Temperature* temperatures);

uint8_t* getSensorAddress(uint8_t index);

void copySensorAddress(uint8_t index, uint8_t* buffer);