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,47 +95,17 @@ 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 loop()
|
void update_lcd()
|
||||||
{
|
{
|
||||||
currentTime = millis();
|
|
||||||
|
|
||||||
if (currentTime - buttonTime >= 500) {
|
|
||||||
buttonTime = currentTime;
|
|
||||||
|
|
||||||
if (digitalRead(buttonPin) == LOW)
|
|
||||||
isStandardValues = !isStandardValues;
|
|
||||||
}
|
|
||||||
|
|
||||||
// sen44
|
|
||||||
if (currentTime - sen44Time >= 1000) {
|
|
||||||
sen44Time = currentTime;
|
|
||||||
|
|
||||||
uint16_t error;
|
|
||||||
char errorMessage[256];
|
|
||||||
|
|
||||||
// Read Measurement
|
|
||||||
error = sen44.readMeasuredMassConcentrationAndAmbientValues(
|
|
||||||
massConcentrationPm1p0, massConcentrationPm2p5, massConcentrationPm4p0,
|
|
||||||
massConcentrationPm10p0, vocIndex, ambientHumidity, ambientTemperature);
|
|
||||||
|
|
||||||
if (error) {
|
|
||||||
Serial.print("Error trying to execute "
|
|
||||||
"readMeasuredMassConcentrationAndAmbientValues(): ");
|
|
||||||
errorToString(error, errorMessage, 256);
|
|
||||||
Serial.println(errorMessage);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ambientTemperature = celsiusToFahrenheit(ambientTemperature);
|
|
||||||
feelsLikeTemperature = heatIndex(ambientTemperature, ambientHumidity);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Display
|
|
||||||
if (currentTime - lcdTime >= 2000) {
|
|
||||||
lcdTime = currentTime;
|
|
||||||
|
|
||||||
lcd.clear();
|
lcd.clear();
|
||||||
|
|
||||||
if (isStandardValues) {
|
if (isStandardValues) {
|
||||||
@@ -171,5 +141,49 @@ void loop()
|
|||||||
lcd.print("10:");
|
lcd.print("10:");
|
||||||
lcd.print(massConcentrationPm10p0);
|
lcd.print(massConcentrationPm10p0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop()
|
||||||
|
{
|
||||||
|
currentTime = millis();
|
||||||
|
|
||||||
|
// modes button
|
||||||
|
if (currentTime - buttonTime >= 100) {
|
||||||
|
buttonTime = currentTime;
|
||||||
|
|
||||||
|
if (digitalRead(buttonPin) == LOW) {
|
||||||
|
isStandardValues = !isStandardValues;
|
||||||
|
update_lcd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// sen44
|
||||||
|
if (currentTime - sen44Time >= 1000) {
|
||||||
|
sen44Time = currentTime;
|
||||||
|
|
||||||
|
uint16_t error;
|
||||||
|
char errorMessage[256];
|
||||||
|
|
||||||
|
// Read Measurement
|
||||||
|
error = sen44.readMeasuredMassConcentrationAndAmbientValues(
|
||||||
|
massConcentrationPm1p0, massConcentrationPm2p5, massConcentrationPm4p0,
|
||||||
|
massConcentrationPm10p0, vocIndex, ambientHumidity, ambientTemperature);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
Serial.print("Error trying to execute "
|
||||||
|
"readMeasuredMassConcentrationAndAmbientValues(): ");
|
||||||
|
errorToString(error, errorMessage, 256);
|
||||||
|
Serial.println(errorMessage);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ambientTemperature = celsiusToFahrenheit(ambientTemperature);
|
||||||
|
feelsLikeTemperature = heatIndex(ambientTemperature, ambientHumidity);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Display
|
||||||
|
if (currentTime - lcdTime >= 2000) {
|
||||||
|
lcdTime = currentTime;
|
||||||
|
update_lcd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user