2025-11-1301
This commit is contained in:
140
src/main.cpp
140
src/main.cpp
@@ -20,7 +20,7 @@
|
||||
#include <Adafruit_HTU21DF.h>
|
||||
|
||||
#include <mess_BME280.h>
|
||||
|
||||
#include <mess_HTU21D.h>
|
||||
|
||||
// Pins for LED MATRIX
|
||||
#ifdef ESP32
|
||||
@@ -75,8 +75,6 @@ unsigned long endTime;
|
||||
#define mqtt_port 61883
|
||||
WiFiClient espClient;
|
||||
PubSubClient client(espClient);
|
||||
Adafruit_HTU21DF htu = Adafruit_HTU21DF();
|
||||
|
||||
|
||||
|
||||
#define matrix_width 64
|
||||
@@ -163,7 +161,7 @@ float FeuchteInnen = 0.00;
|
||||
float TemparaturInnen = 0.00;
|
||||
bool NOHTU = false;
|
||||
bool readHtuFlag = true;
|
||||
float akku = 2.87;
|
||||
float akku = 5.00;
|
||||
int Helligkeit = 255;
|
||||
|
||||
|
||||
@@ -203,7 +201,6 @@ void ZeigeTemperatur(float Temperatur, uint16_t Color);
|
||||
|
||||
void ZeigeInnenFeuchtigkeit(float Luftfeuchtigkeit);
|
||||
void ZeigeLuftdruck(float Pressure);
|
||||
void readHtu();
|
||||
void AkkuAlarm();
|
||||
|
||||
#ifdef ESP8266
|
||||
@@ -652,18 +649,6 @@ void BlinkSec(bool blink){
|
||||
}
|
||||
}
|
||||
|
||||
void readHtu(){
|
||||
if (!NOHTU){
|
||||
FeuchteInnen = htu.readHumidity();
|
||||
TemparaturInnen = htu.readTemperature();
|
||||
TemparaturInnen = TemparaturInnen + HTU_Korrectur;
|
||||
Serial.printf("Htu21D: Temperarur Innen %3.2f °C und\n Luftfeuchtigkeit %3.2f %%\n\n", TemparaturInnen, FeuchteInnen );
|
||||
}else{
|
||||
FeuchteInnen = 20.00;
|
||||
TemparaturInnen = 30.00;
|
||||
}
|
||||
}
|
||||
|
||||
void Test()
|
||||
{
|
||||
display.setCursor(1, 40);
|
||||
@@ -682,7 +667,7 @@ void setup() {
|
||||
delay(500);
|
||||
|
||||
}
|
||||
readHtu();
|
||||
read_HTU21D();
|
||||
Init_BME280();
|
||||
delay(5000);
|
||||
WiFi.mode( WIFI_OFF );
|
||||
@@ -694,62 +679,16 @@ void setup() {
|
||||
|
||||
// Define your display layout here, e.g. 1/8 step, and optional SPI pins begin(row_pattern, CLK, MOSI, MISO, SS)
|
||||
display.begin(16); // Rows-scan pattern 1/32
|
||||
//display.begin(8, 14, 13, 12, 4);
|
||||
|
||||
// Define multiplex implemention here {BINARY, STRAIGHT} (default is BINARY)
|
||||
//display.setMuxPattern(BINARY);
|
||||
|
||||
// Set the multiplex pattern {LINE, ZIGZAG,ZZAGG, ZAGGIZ, WZAGZIG, VZAG, ZAGZIG} (default is LINE)
|
||||
// display.setScanPattern(LINE);
|
||||
|
||||
|
||||
// Rotate display
|
||||
//display.setRotate(true);
|
||||
|
||||
// Flip display
|
||||
//display.setFlip(true);
|
||||
|
||||
// Control the minimum color values that result in an active pixel
|
||||
//display.setColorOffset(5, 5,5);
|
||||
|
||||
// Set the multiplex implemention {BINARY, STRAIGHT} (default is BINARY)
|
||||
//display.setMuxPattern(BINARY);
|
||||
|
||||
// Set the color order {RRGGBB, RRBBGG, GGRRBB, GGBBRR, BBRRGG, BBGGRR} (default is RRGGBB)
|
||||
display.setColorOrder(RRBBGG);
|
||||
|
||||
// Set the time in microseconds that we pause after selecting each mux channel
|
||||
// (May help if some rows are missing / the mux chip is too slow)
|
||||
//display.setMuxDelay(0,1,0,0,0);
|
||||
|
||||
// Set the number of panels that make up the display area width (default is 1)
|
||||
//display.setPanelsWidth(2);
|
||||
|
||||
// Set the brightness of the panels (default is 255)
|
||||
//display.setBrightness(50);
|
||||
display.setBrightness(255);
|
||||
display.clearDisplay();
|
||||
// Set driver chip type
|
||||
//display.setDriverChip(FM6124);
|
||||
|
||||
display.setTextColor(myRED);
|
||||
display.setCursor(0,0);
|
||||
display.print("Pixel");
|
||||
display.setTextColor(myGREEN);
|
||||
display.setCursor(30,0);
|
||||
display.print("Time");
|
||||
//----------------------
|
||||
/* display.setTextColor(myBLUE);
|
||||
display.setCursor(2,50);
|
||||
display.print("Pixel");
|
||||
display.setTextColor(myYELLOW);
|
||||
display.setCursor(30,50);
|
||||
display.print("Time"); */
|
||||
display_update_enable(true);
|
||||
//delay(5000);
|
||||
//--------------------------------------------------
|
||||
//--------------------------------------------------
|
||||
|
||||
|
||||
print_wifi_status();
|
||||
configTime(0, 0, NTP_SERVER);
|
||||
@@ -786,12 +725,6 @@ void scroll_text(uint8_t ypos, unsigned long scroll_delay, String text, uint8_t
|
||||
// Asuming 5 pixel average character width
|
||||
for (int xpos=matrix_width; xpos>-(matrix_width+text_length*5); xpos--)
|
||||
{
|
||||
// getNTPtime(10);
|
||||
// Serial.printf ("%D %D \n",SekOld,timeinfo.tm_sec);
|
||||
// if (SekOld != timeinfo.tm_sec){
|
||||
// SekOld = timeinfo.tm_sec;
|
||||
// blinkSek = !blinkSek;
|
||||
// }
|
||||
if (millis() - lastTime >= (1000 - scroll_delay))
|
||||
{
|
||||
lastTime = millis();
|
||||
@@ -820,40 +753,6 @@ void scroll_text(uint8_t ypos, unsigned long scroll_delay, String text, uint8_t
|
||||
}
|
||||
}
|
||||
|
||||
/* void scroll_text2(uint8_t ypos, unsigned long scroll_delay, String text, uint8_t colorR, uint8_t colorG, uint8_t colorB, boolean blink)
|
||||
{
|
||||
uint16_t text_length = text.length();
|
||||
display.setTextWrap(false); // we don't wrap text so it scrolls nicely
|
||||
display.setTextSize(2);
|
||||
display.setRotation(0);
|
||||
display.setTextColor(display.color565(colorR,colorG,colorB));
|
||||
|
||||
// Asuming 5 pixel average character width
|
||||
for (int xpos=matrix_width; xpos>-(matrix_width+text_length*10); xpos--)
|
||||
{
|
||||
if (millis() - lastTime >= 1000)
|
||||
{
|
||||
lastTime = millis();
|
||||
blinkSek = !blinkSek;
|
||||
}
|
||||
if (blinkSek && blink) {
|
||||
display.fillRect(4 + 27, ypos - 3, 5, 5, myWHITE);
|
||||
display.fillRect(4 + 27, ypos + 1, 5, 5, myWHITE);
|
||||
}else{
|
||||
display.fillRect(4 + 27, ypos -8, 2, 2, myYELLOW);
|
||||
display.fillRect(4 + 27, ypos +1, 2, 2, myYELLOW);
|
||||
}
|
||||
display.setTextColor(display.color565(colorR,colorG,colorB));
|
||||
//display.clearDisplay();
|
||||
display.fillRect(xpos, ypos, 64-xpos, 16, (myBLACK));
|
||||
display.setCursor(xpos,ypos);
|
||||
display.println(text);
|
||||
delay(scroll_delay);
|
||||
yield();
|
||||
}
|
||||
display.setTextSize(1);
|
||||
} */
|
||||
|
||||
void scroll_Grad(uint8_t ypos, unsigned long scroll_delay, String text, uint8_t colorR, uint8_t colorG, uint8_t colorB, boolean blink)
|
||||
{
|
||||
uint16_t text_length = text.length() +2;
|
||||
@@ -904,9 +803,6 @@ static void setup_wifi() {
|
||||
|
||||
//WiFi.forceSleepWake();
|
||||
delay( 1 );
|
||||
/* WiFi.persistent( false );
|
||||
WiFi.setHostname(hostname.c_str()); //define hostname
|
||||
WiFi.mode( WIFI_STA ); */
|
||||
WiFi.config( ip, gateway, subnet, dns1, dns2);
|
||||
|
||||
WiFi.begin(ssid, pass);
|
||||
@@ -926,19 +822,6 @@ static void setup_wifi() {
|
||||
Serial.print("IP address: \t");
|
||||
Serial.println(WiFi.localIP());
|
||||
|
||||
/* Serial.begin(115200);
|
||||
Serial.print("Connecting to: ");
|
||||
Serial.println(ssid);
|
||||
WiFi.begin(ssid, pass);
|
||||
|
||||
while(WiFi.status() != WL_CONNECTED){
|
||||
delay(500);
|
||||
Serial.print(".");
|
||||
}
|
||||
Serial.println("");
|
||||
Serial.println("WiFi connected");
|
||||
Serial.print("IP-Address of ESP8266 module: ");
|
||||
Serial.println(WiFi.localIP()); */
|
||||
}
|
||||
|
||||
|
||||
@@ -949,8 +832,6 @@ void loop() {
|
||||
reconnect();
|
||||
}
|
||||
|
||||
//client.loop();
|
||||
|
||||
getNTPtime(10);
|
||||
|
||||
|
||||
@@ -969,9 +850,10 @@ void loop() {
|
||||
{
|
||||
if (readHtuFlag == true)
|
||||
{
|
||||
readHtu();
|
||||
read_HTU21D();
|
||||
Read_BME280();
|
||||
readHtuFlag = false;
|
||||
Serial.printf(" HTU: %3.2f\t\t %3.2f\n\n", htu21Data.Temp, BME280Data.Temp);
|
||||
}
|
||||
}else{
|
||||
readHtuFlag = true;
|
||||
@@ -981,15 +863,13 @@ void loop() {
|
||||
{
|
||||
case 0 ... 14:
|
||||
{
|
||||
//ZeigeInnenTemp(TemparaturInnen);
|
||||
ZeigeTemperatur(TemparaturInnen, myGREEN);
|
||||
ZeigeInnenFeuchtigkeit(Feuchte);
|
||||
ZeigeTemperatur(htu21Data.Temp, myGREEN);
|
||||
ZeigeInnenFeuchtigkeit(htu21Data.Feuchte);
|
||||
ZeigeInnenCO(Co2);
|
||||
break;
|
||||
}
|
||||
case 15 ... 29:
|
||||
{
|
||||
//ZeigeAussenTemp(Aussentemp);
|
||||
ZeigeTemperatur(Aussentemp, myHimmelblau);
|
||||
ZeigeAussenFeuchtigkeit(Luftfeuchtigkeit);
|
||||
ZeigeLuftdruck(Pressure);
|
||||
@@ -997,14 +877,13 @@ void loop() {
|
||||
}
|
||||
case 30 ... 44:
|
||||
{
|
||||
ZeigeTemperatur(TemparaturInnen, myGREEN);
|
||||
ZeigeInnenFeuchtigkeit(Feuchte);
|
||||
ZeigeTemperatur(htu21Data.Temp, myGREEN);
|
||||
ZeigeInnenFeuchtigkeit(htu21Data.Feuchte);
|
||||
ZeigeInnenCO(Co2);
|
||||
break;
|
||||
}
|
||||
case 45 ... 59:
|
||||
{
|
||||
//ZeigeAussenTemp(Aussentemp);
|
||||
ZeigeTemperatur(Aussentemp, myHimmelblau);
|
||||
ZeigeAussenFeuchtigkeit(Luftfeuchtigkeit);
|
||||
ZeigeLuftdruck(Pressure);
|
||||
@@ -1023,7 +902,6 @@ bool getNTPtime(int sec) {
|
||||
do {
|
||||
time(&now);
|
||||
localtime_r(&now, &timeinfo);
|
||||
//Serial.print(".");
|
||||
delay(10);
|
||||
} while (((millis() - start) <= (1000 * sec)) && (timeinfo.tm_year < (2016 - 1900)));
|
||||
if (timeinfo.tm_year <= (2016 - 1900)) return false; // the NTP call was not successful }
|
||||
|
||||
Reference in New Issue
Block a user