2025-05-2501
Wegen des GRAD Zeichen viel pobiert.
This commit is contained in:
@ -41,7 +41,7 @@ build_flags = ${env.build_flags}
|
|||||||
-Dmqtt_port=61883
|
-Dmqtt_port=61883
|
||||||
-DINNEN=\"hjk/devices/TEMPWOHNZIM/telemetry/temperature\"
|
-DINNEN=\"hjk/devices/TEMPWOHNZIM/telemetry/temperature\"
|
||||||
;-DFLUR=\"hjk/devices/TEMPFLUR/telemetry/temperature\"
|
;-DFLUR=\"hjk/devices/TEMPFLUR/telemetry/temperature\"
|
||||||
-DCO2=\"hjk/devices/257923/telemetry/co2\"
|
;-DCO2=\"hjk/devices/257923/telemetry/co2\"
|
||||||
-DAKKU=\"hjk/devices/WETTERSTATION/telemetry/battery\"
|
-DAKKU=\"hjk/devices/WETTERSTATION/telemetry/battery\"
|
||||||
-DWETTER=\"hjk/devices/WETTERSTATION/telemetry/temperature_Htu_21\"
|
-DWETTER=\"hjk/devices/WETTERSTATION/telemetry/temperature_Htu_21\"
|
||||||
-DLUFTDRUCK=\"hjk/devices/WETTERSTATION/telemetry/pressure\"
|
-DLUFTDRUCK=\"hjk/devices/WETTERSTATION/telemetry/pressure\"
|
||||||
|
89
src/main.cpp
89
src/main.cpp
@ -67,9 +67,9 @@ PubSubClient client(espClient);
|
|||||||
#define matrix_width 64
|
#define matrix_width 64
|
||||||
#define matrix_height 32
|
#define matrix_height 32
|
||||||
|
|
||||||
// This defines the 'on' time of the display is us. The larger this number,
|
// This defines the 'on' time of the display is us. The larger this number, ---> Dies definiert die Einschaltzeit des Displays. Je größer diese Zahl,
|
||||||
// the brighter the display. If too large the ESP will crash
|
// the brighter the display. If too large the ESP will crash ---> desto heller das Display. Wenn zu groß, stürzt das ESP ab
|
||||||
uint8_t display_draw_time=10; //30-70 is usually fine
|
uint8_t display_draw_time=45; //30-70 is usually fine ---> 30-70 ist normalerweise in Ordnung
|
||||||
|
|
||||||
//PxMATRIX display(32,16,P_LAT, P_OE,P_A,P_B,P_C);
|
//PxMATRIX display(32,16,P_LAT, P_OE,P_A,P_B,P_C);
|
||||||
PxMATRIX display(64,32,P_LAT, P_OE,P_A,P_B,P_C,P_D);
|
PxMATRIX display(64,32,P_LAT, P_OE,P_A,P_B,P_C,P_D);
|
||||||
@ -198,7 +198,7 @@ void print_wifi_status() {
|
|||||||
Serial.print(rssi);
|
Serial.print(rssi);
|
||||||
Serial.println(" dBm");
|
Serial.println(" dBm");
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
scroll_text(64-16,40,"IP Adress: " + WiFi.localIP().toString()+ " signal strength (RSSI): " + String(rssi, DEC) + " dBm", 96,96,0, false);
|
scroll_text(matrix_height-16,40,"IP Adress: " + WiFi.localIP().toString()+ " signal strength (RSSI): " + String(rssi, DEC) + " dBm", 96,96,0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void display_update_enable(bool is_enable)
|
void display_update_enable(bool is_enable)
|
||||||
@ -477,13 +477,13 @@ void Test()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
startTime = millis();
|
startTime = millis();
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
//WiFi.mode( WIFI_OFF );
|
//WiFi.mode( WIFI_OFF );
|
||||||
delay( 10 );
|
Serial.println("Start");
|
||||||
Serial.println("Start");
|
// initialise_wifi();
|
||||||
// initialise_wifi();
|
setup_wifi();
|
||||||
setup_wifi();
|
|
||||||
|
|
||||||
// Define your display layout here, e.g. 1/8 step, and optional SPI pins begin(row_pattern, CLK, MOSI, MISO, SS)
|
// Define your display layout here, e.g. 1/8 step, and optional SPI pins begin(row_pattern, CLK, MOSI, MISO, SS)
|
||||||
display.begin(SCAN); // Rows-scan pattern 1/32
|
display.begin(SCAN); // Rows-scan pattern 1/32
|
||||||
@ -520,27 +520,25 @@ void setup() {
|
|||||||
|
|
||||||
// Set the brightness of the panels (default is 255)
|
// Set the brightness of the panels (default is 255)
|
||||||
display.setBrightness(Helligkeit);
|
display.setBrightness(Helligkeit);
|
||||||
display_update_enable(true);
|
|
||||||
|
|
||||||
display.clearDisplay();
|
|
||||||
|
/* display.clearDisplay();
|
||||||
display.setTextColor(myRED);
|
display.setTextColor(myRED);
|
||||||
display.setCursor(0,0);
|
display.setCursor(0,0);
|
||||||
display.print("Pixel");
|
display.print("Pixel");
|
||||||
display.setTextColor(myGREEN);
|
display.setTextColor(myGREEN);
|
||||||
display.setCursor(30,0);
|
display.setCursor(30,0);
|
||||||
display.print("Time");
|
display.print("Time"); */
|
||||||
//----------------------
|
//----------------------
|
||||||
display.setTextColor(myBLUE);
|
/* display.setTextColor(myBLUE);
|
||||||
display.setCursor(2,matrix_height-8);
|
display.setCursor(2,matrix_height-8);
|
||||||
display.print("Pixel");
|
display.print("Pixel");
|
||||||
display.setTextColor(myYELLOW);
|
display.setTextColor(myYELLOW);
|
||||||
display.setCursor(30,matrix_height-8);
|
display.setCursor(30,matrix_height-8);
|
||||||
display.print("1234");
|
display.print("1234"); */
|
||||||
|
display_update_enable(true);
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
delay(1000);
|
|
||||||
print_wifi_status();
|
|
||||||
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
|
||||||
setenv("TZ", TZ_INFO, 1);
|
setenv("TZ", TZ_INFO, 1);
|
||||||
@ -551,8 +549,10 @@ void setup() {
|
|||||||
delay(5000);
|
delay(5000);
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
}
|
}
|
||||||
|
display.clearDisplay();
|
||||||
lastNTPtime = time(&now);
|
lastNTPtime = time(&now);
|
||||||
lastEntryTime = millis();
|
lastEntryTime = millis();
|
||||||
|
print_wifi_status();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -643,14 +643,21 @@ void scroll_text2(uint8_t ypos, unsigned long scroll_delay, String text, uint8_t
|
|||||||
|
|
||||||
void scroll_Grad(uint8_t ypos, unsigned long scroll_delay, String text, uint8_t colorR, uint8_t colorG, uint8_t colorB, boolean blink)
|
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;
|
uint16_t text_length = text.length();
|
||||||
display.setTextWrap(false); // we don't wrap text so it scrolls nicely
|
text_length = text_length + 2;
|
||||||
|
uint16_t HV = matrix_width + (((text_length) * 5));
|
||||||
|
if (text_length == 19){
|
||||||
|
HV = HV -55;
|
||||||
|
}
|
||||||
|
else HV = HV - 50;
|
||||||
|
Serial.printf("Stringlänge : %d %d\r\n",text_length, HV);
|
||||||
|
display.setTextWrap(false); // we don't wrap text so it scrolls nicely --> Wir brechen den Text nicht um, damit er gut scrollt
|
||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
display.setRotation(0);
|
display.setRotation(0);
|
||||||
display.setTextColor(display.color565(colorR,colorG,colorB));
|
display.setTextColor(display.color565(colorR,colorG,colorB));
|
||||||
|
|
||||||
// Asuming 5 pixel average character width
|
// Asuming 5 pixel average character width
|
||||||
for (int xpos=matrix_width; xpos>-(matrix_width+text_length*5); xpos--)
|
for (int xpos=matrix_width; xpos>-(matrix_width+(text_length*5)); xpos--)
|
||||||
{
|
{
|
||||||
if (millis() - lastTime >= 1000)
|
if (millis() - lastTime >= 1000)
|
||||||
{
|
{
|
||||||
@ -665,15 +672,15 @@ void scroll_Grad(uint8_t ypos, unsigned long scroll_delay, String text, uint8_t
|
|||||||
display.fillRect(TimeX + 30, TimeY - 8, 2, 15, myBLACK);
|
display.fillRect(TimeX + 30, TimeY - 8, 2, 15, myBLACK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Serial.printf("XPOS = %d\r\n", xpos);
|
||||||
display.setTextColor(display.color565(colorR,colorG,colorB));
|
display.setTextColor(display.color565(colorR,colorG,colorB));
|
||||||
display.fillRect(xpos, ypos-1, 64-xpos, 9, (myBLACK));
|
display.fillRect(xpos, ypos-1, 64-xpos, 9, (myBLACK));
|
||||||
display.setCursor(xpos,ypos);
|
display.setCursor(xpos,ypos);
|
||||||
display.print(text);
|
display.print(text);
|
||||||
display.setCursor(xpos+132, ypos-5);
|
display.setCursor(xpos+HV, ypos-5);
|
||||||
display.setFont(&Picopixel);
|
display.setFont(&Picopixel);
|
||||||
display.print("o");
|
display.print("o");
|
||||||
display.setCursor(xpos+136, ypos+6);
|
display.setCursor(xpos+HV+4, ypos+6);
|
||||||
display.setFont();
|
display.setFont();
|
||||||
// ...........
|
// ...........
|
||||||
display.println("C");
|
display.println("C");
|
||||||
@ -688,7 +695,11 @@ static void setup_wifi() {
|
|||||||
|
|
||||||
long ErrCount = 0;
|
long ErrCount = 0;
|
||||||
|
|
||||||
delay(10);
|
WiFi.mode( WIFI_OFF );
|
||||||
|
delay( 10 );
|
||||||
|
/* WiFi.persistent( false );
|
||||||
|
WiFi.setHostname(hostname.c_str()); //define hostname */
|
||||||
|
//WiFi.mode( WIFI_STA );
|
||||||
// We start by connecting to a WiFi network
|
// We start by connecting to a WiFi network
|
||||||
if (!ip.fromString(MYIP)) { // try to parse into the IPAddress
|
if (!ip.fromString(MYIP)) { // try to parse into the IPAddress
|
||||||
Serial.println("UnParsable IP");
|
Serial.println("UnParsable IP");
|
||||||
@ -705,6 +716,11 @@ static void setup_wifi() {
|
|||||||
if (!subnet.fromString(SUBNET)) { // try to parse into the IPAddress
|
if (!subnet.fromString(SUBNET)) { // try to parse into the IPAddress
|
||||||
Serial.println("UnParsable GATEWAY");
|
Serial.println("UnParsable GATEWAY");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* IPAddress ip( 192, 168, 127, 53);
|
||||||
|
IPAddress gateway( 192, 168, 127, 1 );
|
||||||
|
IPAddress subnet( 255, 255, 255, 0 );
|
||||||
|
IPAddress dns(192, 168, 127, 1); */
|
||||||
if (!WiFi.config(ip, gateway, subnet, dns, secondarDNS))
|
if (!WiFi.config(ip, gateway, subnet, dns, secondarDNS))
|
||||||
{
|
{
|
||||||
Serial.println("STA Failed to configure");
|
Serial.println("STA Failed to configure");
|
||||||
@ -718,9 +734,9 @@ static void setup_wifi() {
|
|||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
ErrCount ++;
|
ErrCount ++;
|
||||||
if (ErrCount >= MaxErrCount){
|
if (ErrCount >= MaxErrCount){
|
||||||
endTime = millis();
|
/* endTime = millis();
|
||||||
unsigned long Pause = stoerung -((endTime - startTime) * 1000); // Pause
|
unsigned long Pause = stoerung -((endTime - startTime) * 1000); // Pause */
|
||||||
ESP.deepSleep(Pause); // Pause
|
ESP.restart();
|
||||||
delay(100);
|
delay(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -747,7 +763,9 @@ void loop() {
|
|||||||
ZeigeDatum(timeinfo, 1, 0);
|
ZeigeDatum(timeinfo, 1, 0);
|
||||||
ZeigeZeit(timeinfo, TimeX, TimeY);
|
ZeigeZeit(timeinfo, TimeX, TimeY);
|
||||||
//ZeigeZeit(timeinfo, 1,40);
|
//ZeigeZeit(timeinfo, 1,40);
|
||||||
|
#ifdef Co2
|
||||||
ZeigeCO(1,CoY);
|
ZeigeCO(1,CoY);
|
||||||
|
#endif
|
||||||
/* if ((timeinfo.tm_min % 10) == 0){
|
/* if ((timeinfo.tm_min % 10) == 0){
|
||||||
/* if (Covid19 != 0){
|
/* if (Covid19 != 0){
|
||||||
scroll_text(matrix_height-8,20,"Landkreis Heilbronn", 30,30,30, true);
|
scroll_text(matrix_height-8,20,"Landkreis Heilbronn", 30,30,30, true);
|
||||||
@ -779,8 +797,7 @@ void loop() {
|
|||||||
scroll_text2(matrix_height-24,20,"ich w\201nsche Euch allen ein", 128,128,0, true);
|
scroll_text2(matrix_height-24,20,"ich w\201nsche Euch allen ein", 128,128,0, true);
|
||||||
scroll_text2(matrix_height-24,20,"Frohes neues Jahr 2022.", 128,255,0, true); */
|
scroll_text2(matrix_height-24,20,"Frohes neues Jahr 2022.", 128,255,0, true); */
|
||||||
|
|
||||||
ZeigeWetter(double(TempWohn), WetterY,WetterX);
|
//ZeigeWetter(double(TempWohn), WetterY,WetterX);
|
||||||
//Serial.println("START");
|
|
||||||
if (Aussentemp > -99.9){
|
if (Aussentemp > -99.9){
|
||||||
char szWetter[10];
|
char szWetter[10];
|
||||||
#ifdef FLUR
|
#ifdef FLUR
|
||||||
@ -795,7 +812,6 @@ void loop() {
|
|||||||
/* eingeführt werden, sonst kommt es zu
|
/* eingeführt werden, sonst kommt es zu
|
||||||
einen Socket Fehler !!!! */
|
einen Socket Fehler !!!! */
|
||||||
scroll_text(matrix_height-8,30,"Luftdruck: " + String(Pressure) + " hPa", 0,0,255, true);
|
scroll_text(matrix_height-8,30,"Luftdruck: " + String(Pressure) + " hPa", 0,0,255, true);
|
||||||
dtostrf(Aussentemp, 4, 1, szWetter);
|
|
||||||
//Serial.print(Aussentemp); Serial.print(" "); Serial.println(szWetter);
|
//Serial.print(Aussentemp); Serial.print(" "); Serial.println(szWetter);
|
||||||
/* Achtung sehr wichtig,
|
/* Achtung sehr wichtig,
|
||||||
wenn das gesamt Laufschrift mehr
|
wenn das gesamt Laufschrift mehr
|
||||||
@ -803,7 +819,8 @@ void loop() {
|
|||||||
client.loop();
|
client.loop();
|
||||||
/* eingeführt werden, sonst kommt es zu
|
/* eingeführt werden, sonst kommt es zu
|
||||||
einen Socket Fehler !!!! */
|
einen Socket Fehler !!!! */
|
||||||
scroll_Grad(matrix_height-8,30,"Aussentemperatur: " + String(szWetter), 0,0,64, true);
|
dtostrf(Aussentemp, 4, 1, szWetter);
|
||||||
|
scroll_Grad(matrix_height-8,30,"Aussentemperatur: " + String(szWetter), 0,0,255, true);
|
||||||
/* Achtung sehr wichtig,
|
/* Achtung sehr wichtig,
|
||||||
wenn das gesamt Laufschrift mehr
|
wenn das gesamt Laufschrift mehr
|
||||||
als 30 Sekunden Dauert muss ein .... */
|
als 30 Sekunden Dauert muss ein .... */
|
||||||
@ -811,7 +828,11 @@ void loop() {
|
|||||||
/* eingeführt werden, sonst kommt es zu
|
/* eingeführt werden, sonst kommt es zu
|
||||||
einen Socket Fehler !!!! */
|
einen Socket Fehler !!!! */
|
||||||
dtostrf(Luftfeuchtigkeit, 4, 1, szWetter);
|
dtostrf(Luftfeuchtigkeit, 4, 1, szWetter);
|
||||||
scroll_text(matrix_height-8,30,"Luftfeuchtigkeit: " + String(szWetter) + " %", 0,0,64, true);
|
scroll_text(matrix_height-8,30,"Luftfeuchtigkeit: " + String(szWetter) + " %", 0,0,255, true);
|
||||||
|
client.loop();
|
||||||
|
dtostrf(TempWohn, 5, 1, szWetter);
|
||||||
|
scroll_Grad(matrix_height-8,30,"Wohnzimmer: " + String(szWetter), 0, 255, 0, true);
|
||||||
|
client.loop();
|
||||||
}
|
}
|
||||||
if ((Akku <= GRENZWERT) && (Akku > 0)){
|
if ((Akku <= GRENZWERT) && (Akku > 0)){
|
||||||
scroll_text(matrix_height-8,40,"Akku: " + String(Akku) + " Volt", 255, 0, 0, true);
|
scroll_text(matrix_height-8,40,"Akku: " + String(Akku) + " Volt", 255, 0, 0, true);
|
||||||
|
Reference in New Issue
Block a user