Start a new topic

Can´t find the mistake in my easy programm

Hey there,


i have tryed an easy Programm with the Nextion TFT. Time and Date are shown on the Start Display. Changing to my PowerLED submenu works fine too.

But the button for turning it on and off doesn´t work. It will not change the text from the word "An" to "Aus", when i touch it. My Programm is very small, so is there anybody out there who could take a look? I checked everything and tried for hours to make it run, but nothing will help.


I attached the .ino an the .hmi file. So everything i did should be visible.


Thanks a lot for your help!


#include <TimeLib.h>

#include <Nextion.h>

char buffer[100];

NexText Time = NexText(0, 2 ,"Time");

NexText Date = NexText(0, 3 ,"Date");

NexButton LEDbutton = NexButton(2, 11, "LEDbutton");

NexTouch *nexListenList[] =

{

    &LEDbutton,

    &Time,

    &Date,

    NULL

};

//Funktionen Startbildschirm

void updateTime(){

  snprintf(buffer, 100, "%02d:%02d:%02d",hour(),minute(),second());

  Time.setText(buffer);

  snprintf(buffer, 100, "%02d.%02d.%d",day(),month(),year());

  Date.setText(buffer);}

void LEDbuttonPopCallback(void *ptr)

{

    NexButton *btn = (NexButton *)ptr;

    memset(buffer, 0, sizeof(buffer));

    btn->getText(buffer, sizeof(buffer));

    if (strcmp(buffer,"An"))

    {

        strcpy(buffer, "An");

    }

    else

    {

        strcpy(buffer, "Aus");

    }

    btn->setText(buffer);

   

}

void setup(){

  nexInit();

  LEDbutton.attachPop(LEDbuttonPopCallback, &LEDbutton);

  setSyncProvider(getTeensy3Time);

       }

void loop(void)

{

    nexLoop(nexListenList);

    updateTime();

}

time_t getTeensy3Time(){

  return Teensy3Clock.get();}




ino
(1.04 KB)
HMI
(812 KB)
Login or Signup to post a comment