ropg / ezTime

ezTime — pronounced "Easy Time" — is a very easy to use Arduino time and date library that provides NTP network time lookups, extensive timezone support, formatted time and date strings, user events, millisecond precision and more.
MIT License
327 stars 92 forks source link

Using ezTime with nodemcu-32s w/64x32 HUb75 LED Matrix #163

Open heffnerm2 opened 1 year ago

heffnerm2 commented 1 year ago

I've got it able to display time dma_display->print(myTZ.dateTime("m-j-y")); , however i cannot get it to update the string in real time. I tried
if (secondChanged()) { dma_display->print(myTZ.dateTime("m-j-y")); } and it overwrites the initial display ever second without erasing the original.

How can i get it to "replace' the original digits with the new ones?

Thanks

Pius171 commented 1 year ago

I will need to see more of your code, in order to help. Have you tried printing to the serial monitor, to see if the time changes?

heffnerm2 commented 1 year ago

Serial monitor doesn't change. Here's whole code:

include

include

include

include

include

include

include

include

include

include

include

include

include

include

include

include

include

include

include

include

include

//#include //#include "sntp.h" //#include "time.h"

//Configuration const int panelResX = 64; // Number of pixels wide of each INDIVIDUAL panel module. const int panelResY = 32; // Number of pixels tall of each INDIVIDUAL panel module. const int panel_chain = 1; // Total number of panels chained one to another

//bool secondChanged();

define myTZ_POSIX TZ= EST -5 EDT ,M3 .5 .0 /2 ,m10 .5 .0 /3

//bool enableHeater = false; //uint8_t loopCnt = 0;

//Adafruit_SHT31 sht31 = Adafruit_SHT31();

char ssid[] = "PZRG4"; char pass[] = "erica610";

//float Ct = sht31.readTemperature(); //float Ih = sht31.readHumidity(); //float It = (Ct*1.8)+32;

MatrixPanel_I2S_DMA *dma_display = nullptr;

Timezone myTZ;

uint16_t myBLACK = dma_display->color565(0, 0, 0); uint16_t myWHITE = dma_display->color565(255, 255, 255); uint16_t myRED = dma_display->color565(255, 0, 0); uint16_t myGREEN = dma_display->color565(0, 255, 0); uint16_t myBLUE = dma_display->color565(0, 0, 255);

const int defaultBrightness = (40*255)/100; // full (100%) brightness

int16_t xOne, yOne; uint16_t w, h;

void displaySetup() {

HUB75_I2S_CFG mxconfig( panelResX, // module width panelResY, // module height panel_chain // Chain length );

// If you are using a 64x64 matrix you need to pass a value for the E pin // The trinity connects GPIO 18 to E. // This can be commented out for any smaller displays (but should work fine with it) //mxconfig.gpio.e = 18;

// May or may not be needed depending on your matrix // Example of what needing it looks like: // https://github.com/mrfaptastic/ESP32-HUB75-MatrixPanel-I2S-DMA/issues/134#issuecomment-866367216 mxconfig.clkphase = false;

// Some matrix panels use different ICs for driving them and some of them have strange quirks. // If the display is not working right, try this. //mxconfig.driver = HUB75_I2S_CFG::FM6126A;

dma_display = new MatrixPanel_I2S_DMA(mxconfig); dma_display->begin(); }

void setup() {

Serial.begin(115200);

WiFi.begin("PZRG4", "erica610");

/*

/ dma_display->getTextBounds("11:15:11am", 0, 0, &xOne, &yOne, &w, &h); xPosition = dma_display->width() / 2 - w / 2 + 1; dma_display->setCursor(xPosition, 16); dma_display->setTextColor(myWHITE); dma_display->print(myTZ.dateTime ("g:i:sa")); / dma_display->getTextBounds("02-21-22", 0, 0, &xOne, &yOne, &w, &h); xPosition = dma_display->width() / 2 - w / 2 + 1; dma_display->setCursor(xPosition, 24); dma_display->setTextColor(myRED); dma_display->print(myTZ.dateTime ("m-j-y"));

//dma_display->fillScreen(myBLACK);

//delay(1000);

}

void loop() {

void events();{

if (secondChanged()) {

dma_display->getTextBounds("11:15:11am", 0, 0, &xOne, &yOne, &w, &h); int xPosition = dma_display->width() / 2 - w / 2 + 1; dma_display->setCursor(xPosition, 16); dma_display->setTextColor(myWHITE); dma_display->print(myTZ.dateTime ("g:i:sa")); //dma_display->print(myTZ.dateTime("m-j-y")); } }

heffnerm2 commented 1 year ago

Centered Text 1_3_23.txt

Serial monitor doesn't change.

Pius171 commented 1 year ago

@heffnerm2 , your void event function is inside the void loop, you can't create a function inside another function

Also, there are some errors in the void loop. Did this code compile?

heffnerm2 commented 1 year ago

I cleaned it up, yes it does compile and run. I get the displays i expected Temp and Humidity inside and outside and time/date, but it does not update time/date

[Centered Text 1_3_23.txt] (https://github.com/ropg/ezTime/files/10339308/Centered.Text.1_3_23.txt)