Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 27 additions & 13 deletions Enviromate_48/Enviromate_48.ino
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ opnieuw gesaved worden met de deafult waarden.
*/
#define check 28

#define backlightTimeSec 30 // time before the screen will be darkened
#define brightnessMin 30 // minimal brightness
#define brightnessMax 100 // maximal brightness

Time lastTouchTime;
word LDRdrempel = 600;
word displayLight = 50;
word lastdisplayLight;
Expand Down Expand Up @@ -240,6 +245,7 @@ void setup() {
// Initialize the rtc object
rtc.begin();
setRTCtime();
lastTouchTime = rtc.getTime();
String zt = (zomer == 1) ? "Zomertijd" : "Wintertijd";
Serial.println(zt);
ZonOpZonOnder();
Expand Down Expand Up @@ -385,20 +391,23 @@ boolean serialInput() {

// nextion seriele input
boolean nexserialInput() {
while (Serial1.available()) {
char inChar = (char)Serial1.read();
if (isAscii(inChar)) {
if (inChar != '\r') {
inputString += inChar;
if(Serial1.available()){
while (Serial1.available()) {
char inChar = (char)Serial1.read();
if (isAscii(inChar)) {
if (inChar != '\r') {
inputString += inChar;
}
}
if (inChar == '\r') {
inputString.replace("\n", "");
inputString += "~";
inputComplete = true;
}
}
if (inChar == '\r') {
inputString.replace("\n", "");
inputString += "~";
inputComplete = true;
}
return true;
}
//return false;
return false;
}


Expand Down Expand Up @@ -433,7 +442,7 @@ void loop() {
UV_OnOff(); // in-, uitschakelen UV lamp
Warmte_OnOff(); // in-, uitschakelen warmte lamp
alarmBeep(); // Alarm beeper
backlight(); // regel nextion backlight
backlight(rtc.getTime()); // regel nextion backlight

if (Debug) {
DebugOutput(); // seriële info naar monitor
Expand All @@ -452,8 +461,13 @@ void loop() {
}
/* einde 1 seconde loop */

backlight(rtc.getTime()); // regel nextion backlight

// dit deel draait op max snelheid
nexserialInput();
if (nexserialInput()){
// update touch time for backlight
lastTouchTime = rtc.getTime();
}
if (inputComplete == false) {
serialInput();
}
Expand Down
19 changes: 17 additions & 2 deletions Enviromate_48/IO.ino
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,22 @@ float mapfloat(float x, float in_min, float in_max, float out_min, float out_max
//UVI einde --------------------------------------------------------------------------------------


void backlight(){
void backlight(Time timeNow){
uint8_t minDiff = timeNow.min - lastTouchTime.min;
uint8_t secDiff = timeNow.sec - lastTouchTime.sec;
if((minDiff*60+secDiff) >= backlightTimeSec){
if(displayLight>brightnessMin){
displayLight--;
}
} else{
if(displayLight<brightnessMax){
displayLight++;
}
}
Serial1.print("dim=");
Serial1.print(displayLight);
endString();
/*
word LDRValue = analogRead(A7);
word valLDR;
if (LDRValue < LDRdrempel) { valLDR = map(LDRValue, 0, LDRdrempel, 30, 70);}
Expand All @@ -320,5 +335,5 @@ void backlight(){
Serial.print(displayLight);
Serial.print(", ");
*/
}
// }
}
Binary file modified Nextion_UI_43.HMI
Binary file not shown.