Update lcd on button click.
This commit is contained in:
94
aqi.ino
94
aqi.ino
@@ -72,11 +72,11 @@ void setup()
|
|||||||
|
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
|
|
||||||
|
sen44.begin(Wire);
|
||||||
|
|
||||||
uint16_t error;
|
uint16_t error;
|
||||||
char errorMessage[256];
|
char errorMessage[256];
|
||||||
|
|
||||||
sen44.begin(Wire);
|
|
||||||
|
|
||||||
error = sen44.deviceReset();
|
error = sen44.deviceReset();
|
||||||
if (error) {
|
if (error) {
|
||||||
Serial.print("Error trying to execute getSerialNumber(): ");
|
Serial.print("Error trying to execute getSerialNumber(): ");
|
||||||
@@ -95,17 +95,66 @@ void setup()
|
|||||||
|
|
||||||
// Clean Fan
|
// Clean Fan
|
||||||
sen44.startFanCleaning();
|
sen44.startFanCleaning();
|
||||||
|
|
||||||
|
// calibrate
|
||||||
|
lcd.setCursor(0, 0);
|
||||||
|
lcd.print(" calibrating...");
|
||||||
|
|
||||||
|
// allow 2 minute calibration
|
||||||
|
delay(120000);
|
||||||
|
}
|
||||||
|
|
||||||
|
void update_lcd()
|
||||||
|
{
|
||||||
|
lcd.clear();
|
||||||
|
|
||||||
|
if (isStandardValues) {
|
||||||
|
lcd.setCursor(0, 0);
|
||||||
|
lcd.print("t:");
|
||||||
|
lcd.print(round(ambientTemperature));
|
||||||
|
|
||||||
|
lcd.setCursor(8, 0);
|
||||||
|
lcd.print("h:");
|
||||||
|
lcd.print(round(ambientHumidity));
|
||||||
|
|
||||||
|
lcd.setCursor(0, 1);
|
||||||
|
lcd.print("f:");
|
||||||
|
lcd.print(round(feelsLikeTemperature));
|
||||||
|
|
||||||
|
lcd.setCursor(8, 1);
|
||||||
|
lcd.print("v:");
|
||||||
|
lcd.print(vocIndex, 0);
|
||||||
|
} else {
|
||||||
|
lcd.setCursor(0, 0);
|
||||||
|
lcd.print(" 1:");
|
||||||
|
lcd.print(massConcentrationPm1p0);
|
||||||
|
|
||||||
|
lcd.setCursor(8, 0);
|
||||||
|
lcd.print(" 2:");
|
||||||
|
lcd.print(massConcentrationPm2p5);
|
||||||
|
|
||||||
|
lcd.setCursor(0, 1);
|
||||||
|
lcd.print(" 4:");
|
||||||
|
lcd.print(massConcentrationPm4p0);
|
||||||
|
|
||||||
|
lcd.setCursor(8, 1);
|
||||||
|
lcd.print("10:");
|
||||||
|
lcd.print(massConcentrationPm10p0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
currentTime = millis();
|
currentTime = millis();
|
||||||
|
|
||||||
if (currentTime - buttonTime >= 500) {
|
// modes button
|
||||||
|
if (currentTime - buttonTime >= 100) {
|
||||||
buttonTime = currentTime;
|
buttonTime = currentTime;
|
||||||
|
|
||||||
if (digitalRead(buttonPin) == LOW)
|
if (digitalRead(buttonPin) == LOW) {
|
||||||
isStandardValues = !isStandardValues;
|
isStandardValues = !isStandardValues;
|
||||||
|
update_lcd();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// sen44
|
// sen44
|
||||||
@@ -135,41 +184,6 @@ void loop()
|
|||||||
// Display
|
// Display
|
||||||
if (currentTime - lcdTime >= 2000) {
|
if (currentTime - lcdTime >= 2000) {
|
||||||
lcdTime = currentTime;
|
lcdTime = currentTime;
|
||||||
|
update_lcd();
|
||||||
lcd.clear();
|
|
||||||
|
|
||||||
if (isStandardValues) {
|
|
||||||
lcd.setCursor(0, 0);
|
|
||||||
lcd.print("t:");
|
|
||||||
lcd.print(round(ambientTemperature));
|
|
||||||
|
|
||||||
lcd.setCursor(8, 0);
|
|
||||||
lcd.print("h:");
|
|
||||||
lcd.print(round(ambientHumidity));
|
|
||||||
|
|
||||||
lcd.setCursor(0, 1);
|
|
||||||
lcd.print("f:");
|
|
||||||
lcd.print(round(feelsLikeTemperature));
|
|
||||||
|
|
||||||
lcd.setCursor(8, 1);
|
|
||||||
lcd.print("v:");
|
|
||||||
lcd.print(vocIndex, 0);
|
|
||||||
} else {
|
|
||||||
lcd.setCursor(0, 0);
|
|
||||||
lcd.print(" 1:");
|
|
||||||
lcd.print(massConcentrationPm1p0);
|
|
||||||
|
|
||||||
lcd.setCursor(8, 0);
|
|
||||||
lcd.print(" 2:");
|
|
||||||
lcd.print(massConcentrationPm2p5);
|
|
||||||
|
|
||||||
lcd.setCursor(0, 1);
|
|
||||||
lcd.print(" 4:");
|
|
||||||
lcd.print(massConcentrationPm4p0);
|
|
||||||
|
|
||||||
lcd.setCursor(8, 1);
|
|
||||||
lcd.print("10:");
|
|
||||||
lcd.print(massConcentrationPm10p0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user