some improvements

This commit is contained in:
2023-05-16 18:37:20 -07:00
parent 97b42ba949
commit 7687db6dbd

23
aqi.ino
View File

@@ -4,7 +4,6 @@
#include <LiquidCrystal.h> #include <LiquidCrystal.h>
SensirionI2CSen44 sen44; SensirionI2CSen44 sen44;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int buttonPin = 6; const int buttonPin = 6;
@@ -28,7 +27,8 @@ float ambientTemperature = 0;
float feelsLikeTemperature = 0; float feelsLikeTemperature = 0;
// calculate heat index // calculate heat index
float heatIndex(float t, float rh) { float heatIndex(float t, float rh)
{
float hi = 0.0; float hi = 0.0;
if (t <= 40.0) if (t <= 40.0)
hi = t; hi = t;
@@ -53,11 +53,13 @@ float heatIndex(float t, float rh) {
} }
// convert celcius to fahrenheit // convert celcius to fahrenheit
float celsiusToFahrenheit(float degrees) { float celsiusToFahrenheit(float degrees)
{
return degrees * 1.8 + 32; return degrees * 1.8 + 32;
} }
void setup() { void setup()
{
Serial.begin(115200); Serial.begin(115200);
while (!Serial) while (!Serial)
delay(100); delay(100);
@@ -95,19 +97,16 @@ void setup() {
sen44.startFanCleaning(); sen44.startFanCleaning();
} }
void loop() { void loop()
{
currentTime = millis(); currentTime = millis();
delay(50); if (currentTime - buttonTime >= 500) {
// Display Button
if (currentTime - buttonTime >= 100) {
buttonTime = currentTime; buttonTime = currentTime;
if (digitalRead(buttonPin) == LOW) { if (digitalRead(buttonPin) == LOW)
isStandardValues = !isStandardValues; isStandardValues = !isStandardValues;
} }
}
// sen44 // sen44
if (currentTime - sen44Time >= 1000) { if (currentTime - sen44Time >= 1000) {
@@ -134,7 +133,7 @@ void loop() {
} }
// Display // Display
if (currentTime - lcdTime >= 500) { if (currentTime - lcdTime >= 2000) {
lcdTime = currentTime; lcdTime = currentTime;
lcd.clear(); lcd.clear();