Added AM2302 sensor reading to one of the screens
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
#ifndef AM2302_SENSOR_H
|
||||
#define AM2302_SENSOR_H
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
struct Am2302Reading
|
||||
{
|
||||
float temperatureC;
|
||||
float humidityPercent;
|
||||
bool valid;
|
||||
};
|
||||
|
||||
class Am2302Sensor
|
||||
{
|
||||
public:
|
||||
explicit Am2302Sensor(uint8_t pin);
|
||||
|
||||
void begin();
|
||||
bool update(unsigned long now);
|
||||
Am2302Reading reading() const;
|
||||
|
||||
private:
|
||||
uint8_t pin_;
|
||||
unsigned long nextRead_;
|
||||
Am2302Reading reading_;
|
||||
};
|
||||
|
||||
#endif
|
||||
+2
-1
@@ -15,6 +15,7 @@ public:
|
||||
Carousel(Screen *screens, size_t screenCount);
|
||||
void draw(U8G2 &u8g2);
|
||||
bool consumeDirty();
|
||||
void requestRedraw();
|
||||
void nextScreen();
|
||||
void update(unsigned long now);
|
||||
|
||||
@@ -26,4 +27,4 @@ private:
|
||||
bool dirty_;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
+4
-1
@@ -3,8 +3,11 @@
|
||||
|
||||
#include <U8g2lib.h>
|
||||
|
||||
#include "am2302_sensor.h"
|
||||
|
||||
void drawScreen1(U8G2 &u8g2);
|
||||
void drawScreen2(U8G2 &u8g2);
|
||||
void setEnvironmentReading(Am2302Reading reading);
|
||||
void drawEnvironmentScreen(U8G2 &u8g2);
|
||||
void drawWeatherIconScreen(U8G2 &u8g2);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user