2024-12-0901 Interval wird jetzt gespeichert.
This commit is contained in:
parent
7708e5cb38
commit
7f61c47bf6
88
src/main.cpp
88
src/main.cpp
|
@ -52,6 +52,9 @@ SPIClass mySpi = SPIClass(VSPI);
|
||||||
#include<mess_htu21.h>
|
#include<mess_htu21.h>
|
||||||
#include <mcp9808.h>
|
#include <mcp9808.h>
|
||||||
#include <mess_BMP280.h>
|
#include <mess_BMP280.h>
|
||||||
|
#include <Preferences.h>
|
||||||
|
|
||||||
|
Preferences preferences;
|
||||||
|
|
||||||
// TEST
|
// TEST
|
||||||
#include "FS.h"
|
#include "FS.h"
|
||||||
|
@ -63,6 +66,7 @@ void showTime(tm localTime);
|
||||||
void zeigeZeit(tm localTime, int x, int y);
|
void zeigeZeit(tm localTime, int x, int y);
|
||||||
void drawMenue(int32_t xs, int32_t sy);
|
void drawMenue(int32_t xs, int32_t sy);
|
||||||
void Menue();
|
void Menue();
|
||||||
|
void zeige_IP(int x, int y);
|
||||||
|
|
||||||
void listDir(fs::FS &fs, const char * dirname, uint8_t levels) {
|
void listDir(fs::FS &fs, const char * dirname, uint8_t levels) {
|
||||||
Serial.printf("Listing directory: %s\n", dirname);
|
Serial.printf("Listing directory: %s\n", dirname);
|
||||||
|
@ -224,6 +228,7 @@ void testFileIO(fs::FS &fs, const char * path) {
|
||||||
// ENDE TEST
|
// ENDE TEST
|
||||||
int WiFiError = 36;
|
int WiFiError = 36;
|
||||||
int Versuche;
|
int Versuche;
|
||||||
|
int interval;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
|
||||||
|
@ -282,6 +287,7 @@ void setup() {
|
||||||
Serial.println("WiFi connected.");
|
Serial.println("WiFi connected.");
|
||||||
Serial.print("IP address: \t");
|
Serial.print("IP address: \t");
|
||||||
Serial.println(WiFi.localIP());
|
Serial.println(WiFi.localIP());
|
||||||
|
zeige_IP(0, 0);
|
||||||
// SD Karte ----------------------------------------
|
// SD Karte ----------------------------------------
|
||||||
if (!SD.begin(SS, mySpi, 80000000)) {
|
if (!SD.begin(SS, mySpi, 80000000)) {
|
||||||
Serial.println("Card Mount Failed");
|
Serial.println("Card Mount Failed");
|
||||||
|
@ -315,10 +321,7 @@ void setup() {
|
||||||
testFileIO(SD, "/hello.txt");
|
testFileIO(SD, "/hello.txt");
|
||||||
deleteFile(SD, "/hello.txt"); */
|
deleteFile(SD, "/hello.txt"); */
|
||||||
// ---------------------------------End SD Karte -------------------
|
// ---------------------------------End SD Karte -------------------
|
||||||
tft.setTextColor(TFT_YELLOW, TFT_BLACK);
|
zeige_IP(0, 0);
|
||||||
tft.setTextSize(2);
|
|
||||||
tft.println(WiFi.localIP());
|
|
||||||
tft.setTextSize(1);
|
|
||||||
// Initialize a NTPClient to get time
|
// Initialize a NTPClient to get time
|
||||||
configTime(0, 0, NTP_SERVER);
|
configTime(0, 0, NTP_SERVER);
|
||||||
// See https://github.com/nayarsystems/posix_tz_db/blob/master/zones.csv for Timezone codes for your region
|
// See https://github.com/nayarsystems/posix_tz_db/blob/master/zones.csv for Timezone codes for your region
|
||||||
|
@ -338,6 +341,8 @@ void setup() {
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
}
|
}
|
||||||
lastNTPtime = time(&now);
|
lastNTPtime = time(&now);
|
||||||
|
preferences.begin("Interval", false);
|
||||||
|
interval = preferences.getUInt("Interval", SAVE_INTERVAL);;
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------
|
//--------------------------------------------------------
|
||||||
|
@ -406,15 +411,10 @@ void loop() {
|
||||||
|
|
||||||
TouchPoint touch = touchscreen.getTouch();
|
TouchPoint touch = touchscreen.getTouch();
|
||||||
if (touch.zRaw != 0){
|
if (touch.zRaw != 0){
|
||||||
|
|
||||||
//printTouchToSerial(p);
|
|
||||||
/* ts_x = map(touch.x, 200, 3700, 1, SCREEN_WIDTH);
|
|
||||||
ts_y = map(touch.y, 240, 3800, 1, SCREEN_HEIGHT);
|
|
||||||
ts_z = touch.zRaw ; */
|
|
||||||
printTouchToSerial2(touch.x, touch.y, touch.xRaw);
|
printTouchToSerial2(touch.x, touch.y, touch.xRaw);
|
||||||
|
|
||||||
if((touch.x >= 275) && (touch.y >= 210)){
|
if((touch.x >= 275) && (touch.y >= 210)){
|
||||||
Serial.printf(" Gefunden bei: %i : %i : %i \t", touch.y, touch.x, touch.zRaw);
|
Serial.printf(" Gefunden bei: %i : %i : %i \n", touch.y, touch.x, touch.zRaw);
|
||||||
Menue();
|
Menue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,6 +422,7 @@ void loop() {
|
||||||
getNTPtime(10);
|
getNTPtime(10);
|
||||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||||
zeigeZeit(timeinfo, 215, 0);
|
zeigeZeit(timeinfo, 215, 0);
|
||||||
|
zeige_IP(0, 0);
|
||||||
Minuten = timeinfo.tm_min;
|
Minuten = timeinfo.tm_min;
|
||||||
if (Minuten != MintenOld){
|
if (Minuten != MintenOld){
|
||||||
MintenOld = Minuten;
|
MintenOld = Minuten;
|
||||||
|
@ -431,7 +432,10 @@ void loop() {
|
||||||
getTemperature_MCP9808();
|
getTemperature_MCP9808();
|
||||||
read_BMP_280();
|
read_BMP_280();
|
||||||
drawMenue(300,225);
|
drawMenue(300,225);
|
||||||
if (Minuten % SAVE_INTERVAL == 0){
|
/* if (interval == 60){
|
||||||
|
interval = 0;
|
||||||
|
} */
|
||||||
|
if ((Minuten % interval == 0) || (Minuten == 0)){
|
||||||
sprintf(ausgabe, "%s;%f;%f\n", szZeit, htuData.t, htuData.h);
|
sprintf(ausgabe, "%s;%f;%f\n", szZeit, htuData.t, htuData.h);
|
||||||
appendFile(SD, "/daten.csv", ausgabe);
|
appendFile(SD, "/daten.csv", ausgabe);
|
||||||
Serial.print("SAVE ----> "); Serial.println(ausgabe);
|
Serial.print("SAVE ----> "); Serial.println(ausgabe);
|
||||||
|
@ -474,6 +478,7 @@ void zeigeZeit(tm localTime, int x = 0, int y = 0){
|
||||||
localTime.tm_hour,
|
localTime.tm_hour,
|
||||||
localTime.tm_min,
|
localTime.tm_min,
|
||||||
localTime.tm_sec);
|
localTime.tm_sec);
|
||||||
|
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||||
tft.setCursor(x, y);
|
tft.setCursor(x, y);
|
||||||
tft.setTextSize(2);
|
tft.setTextSize(2);
|
||||||
tft.println(szZeit);
|
tft.println(szZeit);
|
||||||
|
@ -484,25 +489,40 @@ void drawMenue(int32_t xs, int32_t sy){
|
||||||
tft.drawLine(xs,sy+5,xs+15,sy+5, TFT_YELLOW);
|
tft.drawLine(xs,sy+5,xs+15,sy+5, TFT_YELLOW);
|
||||||
tft.drawLine(xs,sy+10,xs+15,sy+10, TFT_YELLOW);
|
tft.drawLine(xs,sy+10,xs+15,sy+10, TFT_YELLOW);
|
||||||
}
|
}
|
||||||
|
void Auswahl(int Wert){
|
||||||
|
tft.setTextColor(TFT_YELLOW, TFT_BLACK);
|
||||||
|
tft.setCursor(1,220);
|
||||||
|
tft.setTextSize(2);
|
||||||
|
if (Wert < 10){
|
||||||
|
tft.printf("Auswahl: %1i Minute. ", Wert);
|
||||||
|
} else {
|
||||||
|
tft.printf("Auswahl: %2i Minuten.", Wert);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Menue(){
|
void Menue(){
|
||||||
|
boolean zurueck = true;
|
||||||
tft.fillScreen(TFT_BLACK);
|
tft.fillScreen(TFT_BLACK);
|
||||||
while(1){
|
drawMenue(300,225);
|
||||||
|
delay(200);
|
||||||
|
do{
|
||||||
TouchPoint touch = touchscreen.getTouch();
|
TouchPoint touch = touchscreen.getTouch();
|
||||||
tft.setTextColor(TFT_YELLOW, TFT_BLACK);
|
tft.setTextColor(TFT_YELLOW, TFT_BLACK);
|
||||||
tft.drawCentreString("Einstellungen: ", 160, 20, 4);
|
tft.drawCentreString("Einstellungen: ", 160, 20, 2);
|
||||||
getNTPtime(10);
|
getNTPtime(10);
|
||||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||||
|
zeige_IP(0,0);
|
||||||
zeigeZeit(timeinfo, 215, 0);
|
zeigeZeit(timeinfo, 215, 0);
|
||||||
|
tft.setTextColor(TFT_YELLOW, TFT_BLACK);
|
||||||
tft.setCursor(1,50);
|
tft.setCursor(1,50);
|
||||||
tft.setTextSize(2);
|
tft.setTextSize(2);
|
||||||
tft.println("Interval der Daten-\nsicherung (in Minuten).");
|
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||||
|
tft.println("Interval der Messwert-\nspeicherung in Minuten.");
|
||||||
if (touch.zRaw != 0){
|
if (touch.zRaw != 0){
|
||||||
|
//printTouchToSerial2(touch.x, touch.y, touch.xRaw);
|
||||||
printTouchToSerial2(touch.x, touch.y, touch.xRaw);
|
|
||||||
|
|
||||||
if(((touch.x >= 15) && (touch.x <= 55)) && ((touch.y >= 95) && (touch.y <= 125))){
|
if(((touch.x >= 15) && (touch.x <= 55)) && ((touch.y >= 95) && (touch.y <= 125))){
|
||||||
Serial.printf(" Gefunden bei 1: %i : %i : %i \t", touch.y, touch.x, touch.zRaw);
|
Serial.printf(" Gefunden bei 1: %i : %i : %i \n", touch.y, touch.x, touch.zRaw);
|
||||||
tft.drawRoundRect(11,91,38,38,5,TFT_GOLD);
|
tft.drawRoundRect(11,91,38,38,5,TFT_GOLD);
|
||||||
tft.drawRoundRect(12,92,36,36,5,TFT_GOLD);
|
tft.drawRoundRect(12,92,36,36,5,TFT_GOLD);
|
||||||
tft.drawRoundRect(13,93,34,34,5,TFT_GOLD);
|
tft.drawRoundRect(13,93,34,34,5,TFT_GOLD);
|
||||||
|
@ -510,10 +530,11 @@ void Menue(){
|
||||||
tft.drawRoundRect(11,91,38,38,5,TFT_BLACK);
|
tft.drawRoundRect(11,91,38,38,5,TFT_BLACK);
|
||||||
tft.drawRoundRect(12,92,36,36,5,TFT_BLACK);
|
tft.drawRoundRect(12,92,36,36,5,TFT_BLACK);
|
||||||
tft.drawRoundRect(13,93,34,34,5,TFT_BLACK);
|
tft.drawRoundRect(13,93,34,34,5,TFT_BLACK);
|
||||||
|
interval = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(((touch.x >= 65) && (touch.x <= 95)) && ((touch.y >= 95) && (touch.y <= 125))){
|
if(((touch.x >= 65) && (touch.x <= 95)) && ((touch.y >= 95) && (touch.y <= 125))){
|
||||||
Serial.printf(" Gefunden bei 2: %i : %i : %i \t", touch.y, touch.x, touch.zRaw);
|
Serial.printf(" Gefunden bei 2: %i : %i : %i \n", touch.y, touch.x, touch.zRaw);
|
||||||
tft.drawRoundRect(61,91,38,38,5,TFT_GOLD);
|
tft.drawRoundRect(61,91,38,38,5,TFT_GOLD);
|
||||||
tft.drawRoundRect(62,92,36,36,5,TFT_GOLD);
|
tft.drawRoundRect(62,92,36,36,5,TFT_GOLD);
|
||||||
tft.drawRoundRect(63,93,34,34,5,TFT_GOLD);
|
tft.drawRoundRect(63,93,34,34,5,TFT_GOLD);
|
||||||
|
@ -521,9 +542,10 @@ void Menue(){
|
||||||
tft.drawRoundRect(61,91,38,38,5,TFT_BLACK);
|
tft.drawRoundRect(61,91,38,38,5,TFT_BLACK);
|
||||||
tft.drawRoundRect(62,92,36,36,5,TFT_BLACK);
|
tft.drawRoundRect(62,92,36,36,5,TFT_BLACK);
|
||||||
tft.drawRoundRect(63,93,34,34,5,TFT_BLACK);
|
tft.drawRoundRect(63,93,34,34,5,TFT_BLACK);
|
||||||
|
interval = 5;
|
||||||
}
|
}
|
||||||
if(((touch.x >= 110) && (touch.x <= 140)) && ((touch.y >= 95) && (touch.y <= 125))){
|
if(((touch.x >= 110) && (touch.x <= 140)) && ((touch.y >= 95) && (touch.y <= 125))){
|
||||||
Serial.printf(" Gefunden bei 3: %i : %i : %i \t", touch.y, touch.x, touch.zRaw);
|
Serial.printf(" Gefunden bei 3: %i : %i : %i \n", touch.y, touch.x, touch.zRaw);
|
||||||
tft.drawRoundRect(111,91,38,38,5,TFT_GOLD);
|
tft.drawRoundRect(111,91,38,38,5,TFT_GOLD);
|
||||||
tft.drawRoundRect(112,92,36,36,5,TFT_GOLD);
|
tft.drawRoundRect(112,92,36,36,5,TFT_GOLD);
|
||||||
tft.drawRoundRect(113,93,34,34,5,TFT_GOLD);
|
tft.drawRoundRect(113,93,34,34,5,TFT_GOLD);
|
||||||
|
@ -531,9 +553,10 @@ void Menue(){
|
||||||
tft.drawRoundRect(111,91,38,38,5,TFT_BLACK);
|
tft.drawRoundRect(111,91,38,38,5,TFT_BLACK);
|
||||||
tft.drawRoundRect(112,92,36,36,5,TFT_BLACK);
|
tft.drawRoundRect(112,92,36,36,5,TFT_BLACK);
|
||||||
tft.drawRoundRect(113,93,34,34,5,TFT_BLACK);
|
tft.drawRoundRect(113,93,34,34,5,TFT_BLACK);
|
||||||
|
interval = 10;
|
||||||
}
|
}
|
||||||
if(((touch.x >= 150) && (touch.x <= 195)) && ((touch.y >= 95) && (touch.y <= 125))){
|
if(((touch.x >= 150) && (touch.x <= 195)) && ((touch.y >= 95) && (touch.y <= 125))){
|
||||||
Serial.printf(" Gefunden bei 4: %i : %i : %i \t", touch.y, touch.x, touch.zRaw);
|
Serial.printf(" Gefunden bei 4: %i : %i : %i \n", touch.y, touch.x, touch.zRaw);
|
||||||
tft.drawRoundRect(161,91,38,38,5,TFT_GOLD);
|
tft.drawRoundRect(161,91,38,38,5,TFT_GOLD);
|
||||||
tft.drawRoundRect(162,92,36,36,5,TFT_GOLD);
|
tft.drawRoundRect(162,92,36,36,5,TFT_GOLD);
|
||||||
tft.drawRoundRect(163,93,34,34,5,TFT_GOLD);
|
tft.drawRoundRect(163,93,34,34,5,TFT_GOLD);
|
||||||
|
@ -541,9 +564,10 @@ void Menue(){
|
||||||
tft.drawRoundRect(161,91,38,38,5,TFT_BLACK);
|
tft.drawRoundRect(161,91,38,38,5,TFT_BLACK);
|
||||||
tft.drawRoundRect(162,92,36,36,5,TFT_BLACK);
|
tft.drawRoundRect(162,92,36,36,5,TFT_BLACK);
|
||||||
tft.drawRoundRect(163,93,34,34,5,TFT_BLACK);
|
tft.drawRoundRect(163,93,34,34,5,TFT_BLACK);
|
||||||
|
interval = 30;
|
||||||
}
|
}
|
||||||
if(((touch.x >= 200) && (touch.x <= 230)) && ((touch.y >= 95) && (touch.y <= 125))){
|
if(((touch.x >= 200) && (touch.x <= 230)) && ((touch.y >= 95) && (touch.y <= 125))){
|
||||||
Serial.printf(" Gefunden bei 5: %i : %i : %i \t", touch.y, touch.x, touch.zRaw);
|
Serial.printf(" Gefunden bei 5: %i : %i : %i \n", touch.y, touch.x, touch.zRaw);
|
||||||
tft.drawRoundRect(211,91,38,38,5,TFT_GOLD);
|
tft.drawRoundRect(211,91,38,38,5,TFT_GOLD);
|
||||||
tft.drawRoundRect(212,92,36,36,5,TFT_GOLD);
|
tft.drawRoundRect(212,92,36,36,5,TFT_GOLD);
|
||||||
tft.drawRoundRect(213,93,34,34,5,TFT_GOLD);
|
tft.drawRoundRect(213,93,34,34,5,TFT_GOLD);
|
||||||
|
@ -551,6 +575,11 @@ void Menue(){
|
||||||
tft.drawRoundRect(211,91,38,38,5,TFT_BLACK);
|
tft.drawRoundRect(211,91,38,38,5,TFT_BLACK);
|
||||||
tft.drawRoundRect(212,92,36,36,5,TFT_BLACK);
|
tft.drawRoundRect(212,92,36,36,5,TFT_BLACK);
|
||||||
tft.drawRoundRect(213,93,34,34,5,TFT_BLACK);
|
tft.drawRoundRect(213,93,34,34,5,TFT_BLACK);
|
||||||
|
interval = 60;
|
||||||
|
}
|
||||||
|
if((touch.x >= 275) && (touch.y >= 210)){
|
||||||
|
Serial.printf(" Gefunden bei: %i : %i : %i \n", touch.y, touch.x, touch.zRaw);
|
||||||
|
zurueck = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tft.drawRoundRect(10,90,40,40,5,TFT_GREEN);
|
tft.drawRoundRect(10,90,40,40,5,TFT_GREEN);
|
||||||
|
@ -565,7 +594,18 @@ void Menue(){
|
||||||
tft.drawNumber(30, 170, 105);
|
tft.drawNumber(30, 170, 105);
|
||||||
tft.drawNumber(60, 220, 105);
|
tft.drawNumber(60, 220, 105);
|
||||||
tft.setTextSize(1);
|
tft.setTextSize(1);
|
||||||
delay(200);
|
Auswahl(interval);
|
||||||
|
|
||||||
}
|
} while(zurueck == true);
|
||||||
}
|
tft.fillScreen(TFT_BLACK);
|
||||||
|
preferences.putUInt("Interval", interval);
|
||||||
|
delay(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
void zeige_IP(int x = 1, int y = 0){
|
||||||
|
tft.setCursor(x, y);
|
||||||
|
tft.setTextColor(TFT_YELLOW, TFT_BLACK);
|
||||||
|
tft.setTextSize(2);
|
||||||
|
tft.println(WiFi.localIP());
|
||||||
|
tft.setTextSize(1);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user