Dodawnie zmiany interwalu
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
#include "SD.h"
|
#include "SD.h"
|
||||||
#include "SPI.h"
|
#include "SPI.h"
|
||||||
|
|
||||||
#define Version "0.47"
|
#define Version "0.48"
|
||||||
#define WIRE Wire
|
#define WIRE Wire
|
||||||
#define DHTTYPE DHT22
|
#define DHTTYPE DHT22
|
||||||
#define DHTPIN 4 //GPIO04 D4
|
#define DHTPIN 4 //GPIO04 D4
|
||||||
@@ -84,10 +84,13 @@ int years;
|
|||||||
//##########################################################################################################################
|
//##########################################################################################################################
|
||||||
int intervalTempIdx = 3;
|
int intervalTempIdx = 3;
|
||||||
int intervalTempWrite = 0;
|
int intervalTempWrite = 0;
|
||||||
|
int intervalTempWriteMins = 0;
|
||||||
|
int intervalTempWriteHours = 0;
|
||||||
|
|
||||||
|
|
||||||
int minsToSet = -1;
|
int minsToSet = -1;
|
||||||
int hoursToSet = -1;
|
int hoursToSet = -1;
|
||||||
|
int intervalToSet = -1;
|
||||||
int adcVoltValue;
|
int adcVoltValue;
|
||||||
|
|
||||||
float measuredVoltage = 0;
|
float measuredVoltage = 0;
|
||||||
@@ -230,13 +233,13 @@ void setup() {
|
|||||||
display.setCursor(60, 0);
|
display.setCursor(60, 0);
|
||||||
display.println(Version);
|
display.println(Version);
|
||||||
display.setCursor(0, 8);
|
display.setCursor(0, 8);
|
||||||
if (intervalTempIdx = 1) {
|
if (intervalTempIdx == 1) {
|
||||||
intervalTempWrite = 1;
|
intervalTempWrite = 1;
|
||||||
} else if (intervalTempIdx = 2) {
|
} else if (intervalTempIdx == 2) {
|
||||||
intervalTempWrite = 5;
|
intervalTempWrite = 5;
|
||||||
} else if (intervalTempIdx = 3) {
|
} else if (intervalTempIdx == 3) {
|
||||||
intervalTempWrite = 15;
|
intervalTempWrite = 15;
|
||||||
} else if (intervalTempIdx = 4) {
|
} else if (intervalTempIdx == 4) {
|
||||||
intervalTempWrite = 60;
|
intervalTempWrite = 60;
|
||||||
} else {
|
} else {
|
||||||
intervalTempWrite = 360;
|
intervalTempWrite = 360;
|
||||||
@@ -362,7 +365,7 @@ void setup() {
|
|||||||
humL = lastHumL;
|
humL = lastHumL;
|
||||||
}
|
}
|
||||||
//setup END
|
//setup END
|
||||||
//######################
|
//######################################################################################################################################################################
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
@@ -391,14 +394,13 @@ void loop() {
|
|||||||
humL = (dhtL.readHumidity() + 1.7); //kalibracja
|
humL = (dhtL.readHumidity() + 1.7); //kalibracja
|
||||||
if (isnan(humL)) { humL = lastHumL; }
|
if (isnan(humL)) { humL = lastHumL; }
|
||||||
|
|
||||||
//##########################################################################################################################
|
if (intervalTempIdx == 1) {
|
||||||
if (intervalTempIdx = 1) {
|
|
||||||
intervalTempWrite = 1;
|
intervalTempWrite = 1;
|
||||||
} else if (intervalTempIdx = 2) {
|
} else if (intervalTempIdx == 2) {
|
||||||
intervalTempWrite = 5;
|
intervalTempWrite = 5;
|
||||||
} else if (intervalTempIdx = 3) {
|
} else if (intervalTempIdx == 3) {
|
||||||
intervalTempWrite = 15;
|
intervalTempWrite = 15;
|
||||||
} else if (intervalTempIdx = 4) {
|
} else if (intervalTempIdx == 4) {
|
||||||
intervalTempWrite = 60;
|
intervalTempWrite = 60;
|
||||||
} else {
|
} else {
|
||||||
intervalTempWrite = 360;
|
intervalTempWrite = 360;
|
||||||
@@ -469,56 +471,101 @@ void loop() {
|
|||||||
if (menuL1 == 10) {
|
if (menuL1 == 10) {
|
||||||
display.setCursor(0, 8);
|
display.setCursor(0, 8);
|
||||||
display.print("Enter edycja czasu");
|
display.print("Enter edycja czasu");
|
||||||
display.setCursor(0, 16);
|
display.setCursor(0, 18);
|
||||||
display.print("Intwerwal: ");
|
display.print("Inwerwal: ");
|
||||||
|
|
||||||
|
|
||||||
//##########################################################################################################################
|
//##########################################################################################################################
|
||||||
display.print(intervalTempIdx);
|
|
||||||
|
|
||||||
|
if (intervalTempIdx == 1) {
|
||||||
|
intervalTempWrite = 1;
|
||||||
|
} else if (intervalTempIdx == 2) {
|
||||||
|
intervalTempWrite = 5;
|
||||||
|
} else if (intervalTempIdx == 3) {
|
||||||
|
intervalTempWrite = 15;
|
||||||
|
} else if (intervalTempIdx == 4) {
|
||||||
|
intervalTempWrite = 60;
|
||||||
|
} else {
|
||||||
|
intervalTempWrite = 360;
|
||||||
|
}
|
||||||
if (intervalTempWrite >= 60) {
|
if (intervalTempWrite >= 60) {
|
||||||
display.setCursor(60, 16);
|
display.setCursor(60, 18);
|
||||||
display.print((intervalTempIdx / 60));
|
display.print((intervalTempWrite / 60));
|
||||||
display.setCursor(80, 16);
|
display.setCursor(80, 18);
|
||||||
display.print("godz");
|
display.print("godz");
|
||||||
} else {
|
} else {
|
||||||
display.setCursor(60, 16);
|
display.setCursor(60, 18);
|
||||||
display.print((intervalTempIdx));
|
display.print((intervalTempWrite));
|
||||||
display.setCursor(80, 16);
|
display.setCursor(80, 18);
|
||||||
display.print("godz");
|
display.print("min");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (menuL1 == 9) {
|
if (menuL1 == 9) {
|
||||||
display.setCursor(0, 8);
|
display.setCursor(0, 8);
|
||||||
delay(100);
|
delay(100);
|
||||||
display.print("Interwal:");
|
display.print("Ustaw Interwal");
|
||||||
delay(100);
|
delay(100);
|
||||||
|
|
||||||
if (digitalRead(BTN_ENTER) == HIGH and menuL2 == 10) {
|
if (digitalRead(BTN_ENTER) == HIGH and menuL2 == 10) {
|
||||||
menuL2 = 9;
|
menuL2 = 9;
|
||||||
}
|
}
|
||||||
//##########################################################################################################################
|
|
||||||
if (menuL2 == 9) {
|
if (menuL2 == 9) {
|
||||||
display.setCursor(0, 16);
|
display.setCursor(0, 16);
|
||||||
display.print("Ustaw godziny");
|
display.print("Interwal:");
|
||||||
display.setCursor(45, 16);
|
display.setCursor(64, 16);
|
||||||
display.print(hoursToSet);
|
if (intervalToSet == -1) {
|
||||||
delay(100);
|
intervalToSet = intervalTempIdx;
|
||||||
|
}
|
||||||
|
if (intervalToSet == 1) {
|
||||||
|
intervalTempWrite = 1;
|
||||||
|
} else if (intervalToSet == 2) {
|
||||||
|
intervalTempWrite = 5;
|
||||||
|
} else if (intervalToSet == 3) {
|
||||||
|
intervalTempWrite = 15;
|
||||||
|
} else if (intervalToSet == 4) {
|
||||||
|
intervalTempWrite = 60;
|
||||||
|
} else {
|
||||||
|
intervalTempWrite = 360;
|
||||||
|
}
|
||||||
|
if (intervalTempWrite >= 60) {
|
||||||
|
display.setCursor(60, 16);
|
||||||
|
display.print((intervalTempWrite / 60));
|
||||||
|
display.setCursor(80, 16);
|
||||||
|
display.print("godz");
|
||||||
|
} else {
|
||||||
|
display.setCursor(60, 16);
|
||||||
|
display.print((intervalTempWrite));
|
||||||
|
display.setCursor(80, 16);
|
||||||
|
display.print("min");
|
||||||
|
}
|
||||||
|
delay(250);
|
||||||
|
|
||||||
if (digitalRead(BTN_ENTER) == HIGH) {
|
if (digitalRead(BTN_ENTER) == HIGH) {
|
||||||
intervalTempWrite++;
|
menuL2 = 10;
|
||||||
if (intervalTempWrite >= 6) {
|
intervalTempIdx = intervalToSet;
|
||||||
intervalTempWrite = 1;
|
intervalToSet = -1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (menuL2 == 8) {
|
|
||||||
|
}
|
||||||
|
if (menuL1 == 8) {
|
||||||
|
display.setCursor(0, 8);
|
||||||
|
display.print("Ustaw godziny");
|
||||||
|
|
||||||
|
if (digitalRead(BTN_ENTER) == HIGH and menuL2 == 10) {
|
||||||
|
menuL2 = 9;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (menuL2 == 9) {
|
||||||
display.setCursor(0, 16);
|
display.setCursor(0, 16);
|
||||||
display.print("Godzina:");
|
display.print("Godzina:");
|
||||||
display.setCursor(45, 16);
|
display.setCursor(50, 16);
|
||||||
if (hoursToSet == -1) {
|
if (hoursToSet == -1) {
|
||||||
hoursToSet = now.hour();
|
hoursToSet = now.hour();
|
||||||
}
|
}
|
||||||
display.print(hoursToSet);
|
display.print(hoursToSet);
|
||||||
delay(100);
|
delay(250);
|
||||||
|
|
||||||
if (digitalRead(BTN_ENTER) == HIGH) {
|
if (digitalRead(BTN_ENTER) == HIGH) {
|
||||||
// tu ustawianie czasu
|
// tu ustawianie czasu
|
||||||
@@ -528,6 +575,8 @@ void loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (menuL1 == 7) {
|
if (menuL1 == 7) {
|
||||||
display.setCursor(0, 8);
|
display.setCursor(0, 8);
|
||||||
display.print("Ustaw minuty");
|
display.print("Ustaw minuty");
|
||||||
@@ -562,7 +611,7 @@ void loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (menuL1 == 36) {
|
if (menuL1 == 6) {
|
||||||
display.setCursor(0, 8);
|
display.setCursor(0, 8);
|
||||||
display.print("Ustaw sekundy na 0");
|
display.print("Ustaw sekundy na 0");
|
||||||
|
|
||||||
@@ -583,7 +632,7 @@ void loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (menuL1 == 6) {
|
if (menuL1 == 5) {
|
||||||
display.setCursor(0, 8);
|
display.setCursor(0, 8);
|
||||||
display.print("Wyjdz");
|
display.print("Wyjdz");
|
||||||
if (digitalRead(BTN_ENTER) == HIGH) {
|
if (digitalRead(BTN_ENTER) == HIGH) {
|
||||||
@@ -726,13 +775,16 @@ void loop() {
|
|||||||
if (menuL2 == 9 and hoursToSet < 23) {
|
if (menuL2 == 9 and hoursToSet < 23) {
|
||||||
hoursToSet = hoursToSet + 1;
|
hoursToSet = hoursToSet + 1;
|
||||||
}
|
}
|
||||||
|
if (menuL2 == 9 and intervalToSet < 5) {
|
||||||
|
intervalToSet = intervalToSet + 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (digitalRead(BTN_DOWN) == HIGH and menuL0 >= 7) {
|
if (digitalRead(BTN_DOWN) == HIGH and menuL0 >= 7) {
|
||||||
if (menuL0 > 7 && menuL1 == 10) {
|
if (menuL0 > 7 && menuL1 == 10) {
|
||||||
menuL0 = menuL0 - 1;
|
menuL0 = menuL0 - 1;
|
||||||
}
|
}
|
||||||
if (menuL1 > 6 and menuL1 <= 9 && menuL2 == 10) {
|
if (menuL1 > 5 and menuL1 <= 9 && menuL2 == 10) {
|
||||||
menuL1 = menuL1 - 1;
|
menuL1 = menuL1 - 1;
|
||||||
}
|
}
|
||||||
if (menuL2 > 6 and menuL2 < 9 and menuL0 != 10 and menuL1 != 10) {
|
if (menuL2 > 6 and menuL2 < 9 and menuL0 != 10 and menuL1 != 10) {
|
||||||
@@ -744,6 +796,9 @@ void loop() {
|
|||||||
if (menuL2 == 9 and hoursToSet > 1) {
|
if (menuL2 == 9 and hoursToSet > 1) {
|
||||||
hoursToSet = hoursToSet - 1;
|
hoursToSet = hoursToSet - 1;
|
||||||
}
|
}
|
||||||
|
if (menuL2 == 9 and intervalToSet > 1) {
|
||||||
|
intervalToSet = intervalToSet - 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -771,7 +826,7 @@ void loop() {
|
|||||||
delay(500);
|
delay(500);
|
||||||
}
|
}
|
||||||
//zapis na SD poziom baterii
|
//zapis na SD poziom baterii
|
||||||
if (mins % 1 == 0 && secs == 0) {
|
if (mins % 1 == 0 && secs == 7) {
|
||||||
File file = SD.open("/GeneralLog.txt", FILE_APPEND);
|
File file = SD.open("/GeneralLog.txt", FILE_APPEND);
|
||||||
if (file) {
|
if (file) {
|
||||||
display.fillRect(0, 0, 128, 64, SSD1306_WHITE);
|
display.fillRect(0, 0, 128, 64, SSD1306_WHITE);
|
||||||
@@ -782,10 +837,20 @@ void loop() {
|
|||||||
file.println(formatNumber(currentBatteryVoltage, 2));
|
file.println(formatNumber(currentBatteryVoltage, 2));
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Serial.println("intervalTempWrite");
|
||||||
|
Serial.println(intervalTempWrite);
|
||||||
|
Serial.println("dzielenie");
|
||||||
|
Serial.println(mins % intervalTempWrite);
|
||||||
|
|
||||||
//zapis na SD temp i hum
|
//zapis na SD temp i hum
|
||||||
if (mins % intervalTempWrite == 0 && secs == 0) {
|
if (intervalTempWrite >=360){
|
||||||
|
intervalTempWriteHours = (intervalTempWrite/60);
|
||||||
|
} else {
|
||||||
|
intervalTempWriteHours = -1;
|
||||||
|
}
|
||||||
|
if ((intervalTempWriteHours == -1 && mins % intervalTempWrite == 0) or (intervalTempWriteHours == hourss && mins == 0) && secs == 0){
|
||||||
|
// mins % intervalTempWrite == 0 && secs == 0) {
|
||||||
File file = SD.open("/TempHumLog.txt", FILE_APPEND);
|
File file = SD.open("/TempHumLog.txt", FILE_APPEND);
|
||||||
if (file) {
|
if (file) {
|
||||||
display.fillRect(0, 0, 124, 64, SSD1306_WHITE);
|
display.fillRect(0, 0, 124, 64, SSD1306_WHITE);
|
||||||
|
|||||||
Reference in New Issue
Block a user