Nextion lcd font wizard9/20/2023 ![]() ![]() If an event happens, the callback function of the setup function is executed. In this line of code we define that in every cycle we monitor the events of the touch event list. The loop function contains only one line of code. If we did not defined touch press events but touch release events, the functions would be: b0.attachPop(b0PopCallback, &b0) The callback function asks: When do I have to executed the predefined functions? Therefore we attach the push event to both objects and define that if the event occurs, the predefined functions should be called. The last part of the setup function is to register the push or pop event callback functions. Also the Nextion library is initialized in the setup function. Because we use the UART communication between the Nextion display and the microcontroller, the baud rate is set to 9600 which is recommended by Nextion. The only difference is that we do not increase the variable, but we reset the variable to 0.Īfter the two functions are defined, we create the setup function in the Arduino IDE. The function for the second button b1 is nearly the same. After we increased the variable, the value of the number component is set to the increased variable with the setValue function. The function to read the number is getValue. ![]() Inside this variable we store the current value of the numberbox object which is the displayed number in the number component. Inside the function, the logic of the script is pretty easy. The touch press event is the push callback and the touch release event would be a pop callback. The function is called for the b0 object and in the Nextion Editor we defined that the component should have a touch press event and not a touch release event. That is why I call the function b0PushCallback. I like to give my functions a predefined structured name. ![]() The first function we create is the function for b0 that increase the number of the display. Now for each element of the nex_listen_list, we have to create a function, that is called when the event for this object is triggered. In this example we include the two buttons and also NULL is included every time to this list. The next part in the script is to create a touch event list called nex_listen_list to define what objects trigger an event. It is useful to create more than one font for your project. In the generator you can choose from different fonts and select the height.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |