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