Początek menu zmiany interwału rejestrowania

This commit is contained in:
Kamil Siejka
2025-06-19 09:37:31 +02:00
parent 536b203cb7
commit 90d98bf848

View File

@@ -1,3 +1,4 @@
//Płytka: "FireBeetle-ESP32"
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
@@ -9,7 +10,7 @@
#include "SD.h"
#include "SPI.h"
#define Version "0.46"
#define Version "0.47"
#define WIRE Wire
#define DHTTYPE DHT22
#define DHTPIN 4 //GPIO04 D4
@@ -80,7 +81,9 @@ int dayss;
int months;
int years;
int intervalTempWrite = 1;
//##########################################################################################################################
int intervalTempIdx = 3;
int intervalTempWrite = 0;
int minsToSet = -1;
int hoursToSet = -1;
@@ -215,7 +218,8 @@ void setup() {
if (!rtc.begin()) {
Serial.println("Nie znaleziono DS3231 RTC!");
while (1); // Zatrzymaj program, jeśli RTC nie jest dostępny
while (1)
; // Zatrzymaj program, jeśli RTC nie jest dostępny
}
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // Address 0x3C for 128x32
display.setTextSize(1);
@@ -226,10 +230,21 @@ void setup() {
display.setCursor(60, 0);
display.println(Version);
display.setCursor(0, 8);
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;
}
display.println("Interval:");
display.setCursor(60, 8);
display.setCursor(80, 8);
display.println(intervalTempWrite);
display.setCursor(70, 8);
display.setCursor(90, 8);
display.println("min");
display.setCursor(0, 16);
@@ -277,7 +292,6 @@ void setup() {
File file = SD.open("/TempHumLog.txt", FILE_APPEND);
file.println("Data; Godzina; Temp; Humi; Feel,TempH,HumH, TempM, HumM, TempL, HumL");
file.close();
}
sprintf(dateString, "%02d/%02d/%4d %02d:%02d:%02d", now.day(), now.month(), now.year(), now.hour(), now.minute(), now.second());
if (SD.exists("/GeneralLog.txt")) {
@@ -325,22 +339,28 @@ void setup() {
if (isnan(tempH)) {
lastTempH = 0.0;
tempH = lastTempH; }
tempH = lastTempH;
}
if (isnan(tempM)) {
lastTempM = 0.0;
tempM = lastTempM;}
tempM = lastTempM;
}
if (isnan(tempL)) {
lastTempL = 0.0;
tempL = lastTempL;}
tempL = lastTempL;
}
if (isnan(humH)) {
lastHumH = 0.0;
humH = lastHumH;}
humH = lastHumH;
}
if (isnan(humM)) {
lastHumM = 0.0;
humM = lastHumM;}
humM = lastHumM;
}
if (isnan(humL)) {
lastHumL = 0.0;
humL = lastHumL;}
humL = lastHumL;
}
//setup END
//######################
}
@@ -371,7 +391,18 @@ void loop() {
humL = (dhtL.readHumidity() + 1.7); //kalibracja
if (isnan(humL)) { humL = lastHumL; }
//##########################################################################################################################
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;
}
// Compute heat index in Celsius (isFahreheit = false)
heat_idx = dht.computeHeatIndex(temp, hum, false);
@@ -438,18 +469,48 @@ void loop() {
if (menuL1 == 10) {
display.setCursor(0, 8);
display.print("Enter edycja czasu");
display.setCursor(0, 16);
display.print("Intwerwal: ");
//##########################################################################################################################
display.print(intervalTempIdx);
if (intervalTempWrite >= 60) {
display.setCursor(60, 16);
display.print((intervalTempIdx / 60));
display.setCursor(80, 16);
display.print("godz");
} else {
display.setCursor(60, 16);
display.print((intervalTempIdx));
display.setCursor(80, 16);
display.print("godz");
}
}
if (menuL1 == 9) {
display.setCursor(0, 8);
delay(100);
display.print("Ustaw godziny");
delay(150);
display.print("Interwal:");
delay(100);
if (digitalRead(BTN_ENTER) == HIGH and menuL2 == 10) {
menuL2 = 9;
}
//##########################################################################################################################
if (menuL2 == 9) {
display.setCursor(0, 16);
display.print("Ustaw godziny");
display.setCursor(45, 16);
display.print(hoursToSet);
delay(100);
if (digitalRead(BTN_ENTER) == HIGH) {
intervalTempWrite++;
if (intervalTempWrite >= 6) {
intervalTempWrite = 1;
}
}
}
if (menuL2 == 8) {
display.setCursor(0, 16);
display.print("Godzina:");
display.setCursor(45, 16);
@@ -467,7 +528,7 @@ void loop() {
}
}
}
if (menuL1 == 8) {
if (menuL1 == 7) {
display.setCursor(0, 8);
display.print("Ustaw minuty");
@@ -501,7 +562,7 @@ void loop() {
}
}
}
if (menuL1 == 7 ) {
if (menuL1 == 36) {
display.setCursor(0, 8);
display.print("Ustaw sekundy na 0");
@@ -647,7 +708,6 @@ void loop() {
display.println(humL, 1);
display.setCursor(120, 24);
display.println("%");
}
if (digitalRead(BTN_UP) == HIGH and menuL0 < 10) {
@@ -660,12 +720,10 @@ void loop() {
if (menuL2 < 9 and menuL0 != 10 and menuL1 != 10) {
menuL2 = menuL2 + 1;
}
if (menuL2 == 9 and minsToSet <59)
{
if (menuL2 == 9 and minsToSet < 59) {
minsToSet = minsToSet + 1;
}
if (menuL2 == 9 and hoursToSet < 23)
{
if (menuL2 == 9 and hoursToSet < 23) {
hoursToSet = hoursToSet + 1;
}
}
@@ -680,12 +738,10 @@ void loop() {
if (menuL2 > 6 and menuL2 < 9 and menuL0 != 10 and menuL1 != 10) {
menuL2 = menuL2 - 1;
}
if (menuL2 == 9 and minsToSet > 1)
{
if (menuL2 == 9 and minsToSet > 1) {
minsToSet = minsToSet - 1;
}
if (menuL2 == 9 and hoursToSet > 1)
{
if (menuL2 == 9 and hoursToSet > 1) {
hoursToSet = hoursToSet - 1;
}
}
@@ -713,7 +769,6 @@ void loop() {
lastBatteryVoltage = currentBatteryVoltage;
currentBatteryVoltage = batteryVoltage;
delay(500);
}
//zapis na SD poziom baterii
if (mins % 1 == 0 && secs == 0) {