First version with basic recording
This commit is contained in:
10
include/bluetooth.h
Normal file
10
include/bluetooth.h
Normal file
@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void bluetoothConfigure();
|
||||
|
||||
bool bluetoothIsConnected();
|
||||
|
||||
// In main.cpp
|
||||
uint32_t secondsUntilNextTemperatureMeasurement();
|
14
include/config.h
Normal file
14
include/config.h
Normal file
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <hal/gpio_types.h>
|
||||
|
||||
constexpr uint32_t serialBaudRate = 115200;
|
||||
|
||||
constexpr gpio_num_t wakeupButtonPin = GPIO_NUM_13;
|
||||
// The time (in seconds) for which the device should stay awake after the button is pressed
|
||||
// The device also stays awake as long as a bluetooth connection is active
|
||||
constexpr uint32_t wakeupDurationAfterButtonPress = 30;
|
||||
|
||||
|
||||
constexpr uint32_t temperatureMeasurementIntervalSeconds = 60;
|
45
include/storage.h
Normal file
45
include/storage.h
Normal file
@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "temperature.h"
|
||||
|
||||
constexpr uint8_t temperatureSensorCount = 2;
|
||||
|
||||
constexpr size_t storageSize = 80000;
|
||||
constexpr uint16_t storageIntervalInSeconds = 15;
|
||||
constexpr size_t maximumStorageDurationInHours = (storageSize / TEMPERATURE_SENSOR_MAX_COUNT) * storageIntervalInSeconds / 3600;
|
||||
|
||||
// Max size: 7664
|
||||
constexpr size_t maxRtcStorageSize = 7664;
|
||||
constexpr size_t rtcStorageSize = 7632;
|
||||
|
||||
constexpr size_t maxEepromSize = 13350;
|
||||
constexpr size_t eepromSize = 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();
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
void saveTemperatureAtCurrentIndex(Temperature temp);
|
||||
|
||||
uint16_t getTotalNumberOfStoredBytes();
|
||||
|
||||
uint16_t getRecordedBytesAtOffset(uint8_t* buffer, uint16_t offset, uint16_t count);
|
||||
|
||||
void discardAllRecordedBytes();
|
34
include/temperature.h
Normal file
34
include/temperature.h
Normal file
@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
constexpr uint8_t TEMPERATURE_SENSOR_MAX_COUNT = 2;
|
||||
|
||||
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();
|
||||
|
||||
void temperaturePerformUpdate(Temperature* temperatures);
|
Reference in New Issue
Block a user