Skip to content
Snippets Groups Projects
Commit 77fd1278 authored by Mario Engelmann's avatar Mario Engelmann
Browse files

mostly comments

parent 0c588721
No related branches found
No related tags found
No related merge requests found
......@@ -145,7 +145,7 @@ void displayLight(bool turnOn) {
lcd.backlight();
prevMillis = millis();
curState = true;
// turn off after lightMillis ms
// turn off after lightMillis (30 000 ms)
} else if (curState && millis() - prevMillis > lightMillis) {
lcd.noBacklight();
curState = false;
......
#ifndef SOUNDFILES_H
#define SOUNDFILES_H
// index for the sound files for mp3 module TDB380
// the files are .mp3 instead of .wav
/*
* index for the sound files for mp3 module TDB380
* the files are .mp3 instead of .wav
*/
#define SOUND_NULL 33 // A033.wav
#define SOUND_EIN 1 // A001.wav
#define SOUND_EINS 44 // A044.wav
......
......@@ -4,25 +4,39 @@
#include <DHT.h>
/* No new valid temperature for < 60 seconds? I sleep.
* No new valid temperature for > 60 seconds? REAL PROBLEM! */
* No new valid temperature for > 60 seconds? REAL PROBLEM!
*/
const uint32_t ERRORTIME = 10000;
// Update the temperature only every second
const uint32_t TEMPUPDATETIME = 1000;
// UP temperature for solar system 1
/*
* UP temperature for solar system 1
* 1. update only after a second (TEMPUPDATETIME) otherwise return UNCHANGED
* 2. get temperature from temperatur sensor check for errors
* 3. return ERROR if error occured first time
* 4. if error occurred longer than 10 s (ERRORTIME) return LONG_TIME_ERROR
* 5. update temperatur, time variables and return SUCCESS
* function below work the same, except that they use another
* temperature sensor library
*/
static OneWire oneWireT1up(T1UP);
static DallasTemperature dallasTemps(&oneWireT1up);
UPDATESTATE t1up(float* temp) {
static uint32_t prevMillis = 0;
static uint32_t errorStartMillis = 0;
uint32_t curMillis = millis();
// only update once a second
if (curMillis - prevMillis < TEMPUPDATETIME) {
return UNCHANGED;
}
// get temperature from sensor
dallasTemps.requestTemperatures();
float tempC = dallasTemps.getTempCByIndex(0);
// check if error occured
if (tempC == DEVICE_DISCONNECTED_C) {
if (errorStartMillis) {
// check if error occurred longer than some seconds (10s)
if (curMillis - errorStartMillis > ERRORTIME) {
return LONG_TIME_ERROR;
}
......@@ -32,6 +46,7 @@ UPDATESTATE t1up(float* temp) {
return ERROR;
}
// update temperature and time variables
*temp = tempC;
errorStartMillis = 0;
prevMillis = curMillis;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment