Refactor sensor data handling: update sensor read functions to return structured data and improve timer management in main loop
This commit is contained in:
@@ -3,6 +3,12 @@
|
||||
|
||||
#define I2C_BME280_ADDRESS 0x76
|
||||
|
||||
struct BME280Data_t
|
||||
{
|
||||
float pressure;
|
||||
float temperature;
|
||||
float humidity;
|
||||
};
|
||||
|
||||
void BME280_Init();
|
||||
bool BME280_DataReady();
|
||||
bool BME280_Read(float &pressure, float &temperature, float &humidity);
|
||||
BME280Data_t BME280_Read();
|
||||
@@ -3,5 +3,10 @@
|
||||
#define RX 4
|
||||
#define TX 5
|
||||
|
||||
void GPS_Init();
|
||||
void GPS_Read(float &lat, float &lon);
|
||||
struct GPSData_t
|
||||
{
|
||||
float lat;
|
||||
float lon;
|
||||
};
|
||||
|
||||
GPSData_t GPS_Read();
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
void MAX7219_Init();
|
||||
void MAX7219_DisplayText(const char *text, textPosition_t align, uint16_t speed, uint16_t pause);
|
||||
bool MAX7219_StartAnimation();
|
||||
bool MAX7219_Animate();
|
||||
void MAX7219_ResetAnimation();
|
||||
void MAX7219_ClearDisplay();
|
||||
void MAX7219_SetBrightness(uint8_t brightness);
|
||||
@@ -6,5 +6,10 @@
|
||||
#define RL 10000.0 // 10kΩ
|
||||
#define RO 10000.0 // Resistencia del aire limpio
|
||||
|
||||
struct MQ7Data_t
|
||||
{
|
||||
float co;
|
||||
};
|
||||
|
||||
void MQ7_Init();
|
||||
void MQ7_Read(float &sensorValue);
|
||||
MQ7Data_t MQ7_Read();
|
||||
@@ -13,8 +13,23 @@
|
||||
#include "MAX7219.hpp"
|
||||
#include "MQ7v2.hpp"
|
||||
|
||||
uint32_t getChipID();
|
||||
void prettyReadMQ7();
|
||||
void prettyReadBME280();
|
||||
void prettyReadGPS();
|
||||
void testMatrix();
|
||||
struct TaskTimer {
|
||||
uint32_t lastRun = 0;
|
||||
uint32_t interval = 1000;
|
||||
|
||||
TaskTimer() = default;
|
||||
|
||||
TaskTimer(uint32_t last, uint32_t interval)
|
||||
: lastRun(last), interval(interval) {}
|
||||
};
|
||||
|
||||
enum AirQualityStatus {
|
||||
GOOD,
|
||||
BAD
|
||||
};
|
||||
|
||||
void readMQ7();
|
||||
void readBME280();
|
||||
void readGPS();
|
||||
void writeMatrix(const char* message);
|
||||
uint32_t getChipID();
|
||||
Reference in New Issue
Block a user