Nextion Editor v0.53
New in v0.53
New Encoding support for: koi8-r,
- Windows 874, 1255, 1256, 1257 and 1258
- Assignments now support HEX values
- Debug Simulator enhancements
- New component QRCode
- Number has new .format attribute
- prints (to replace print)
- covx (to replace cov)
Realtime touch coordinates
- system variables tch0, tch1, tch2, tch3
Nextion Address Mode (Advanced)
- system variable addr
Protocol Reparse (Advanced)
- system variables u[index], usize, recmod
- instruction ucopy and code_c
- byte alignment now handled by firmware
Two weeks ago, we talked already about the enhanced functionality of the enhanced "K" series (and btw also the intelligent "P" series) Nextion HMIs. In that blog article, we discovered the integrated RTC and we used the Nextion Expansion board in combination with touch screen buttons to adjust it. Sometimes, especially in industrial or other rough environments, touching a small screen is not the best way of interacting, thus, external alternative IO solutions may be put in place. Today, let's replace the 6 buttons by a single control, an external rotary encoder with push-button, i.e. a EC12 from Alps.Thus, the small Nextion I/O adapter will be sufficient for our needs.
Remember the Sunday Blog articles from November and December 2020? We looked at controlling our Nextion HMIs from an Arduino or compatible MCU. We saw that everything was relatively simple and required only a few lines of code if everything was known in advance: The type of the serial port (hardware, software, virtual USB), the use of a second serial port for debugging (or not), the GUI components we wanted to address, and so on. Just to be clear: This is not about making the well established and approved official Nextion library obsolete! This is a new and different way as a result of the didactical approach in my Blog articles. Depending on your scientific curiosity and your specific use case, you'll prefer to take either the one or he other. In ever case, our "didactic" NextionX library is actually only half-baked: All communication from the MCU (Arduino) towards the Nextion HMI is already and fully implemented. But the current version (0.5.0) does not yet allow to read information (attributes, events) back from the Nextion to the MCU. This will be the subject of future blog posts.
First of all: Happy 2021 to all my readers! And thank you for all your constructive suggestions and remarks regarding this blog! There is a huge positive feedback for the previous episodes where we started developing an ultra-compact alternative universal Nextion library for Arduino which overcomes some restrictions of the official library. For example the ability to handle multiple Nextion HMIs on one single MCU and without needing a specific object for each component type, and, and and... I for myself do not yet know how far this will finally go. But there are also other readers who wrote me that they were more interested in learning about the advanced use of the Nextion programming language. Although nearly everybody seems happy that everything I told and taught over the last 30 episodes runs on a standard "T" HMI, including very advanced mathematics and drawing algorithms, people want to know what the enhanced models bring in addition, besides more memory. Thus, I decided to write one week about specific and advanced Nextion features and every other week, we'll move on with our newNextion library.
We created already a universal communication class in the last two episodes (Part 7 here and Part 8 here). It allows us with a little less than 60 lines of code in a separate .h file to handle one or even multiple Nextion HMIs connected to our MCU (Arduino or whatsoever), optionally using a second serial port for debugging each. And we can use this classes' cmdWrite() method to send commands to each of our connected Nextion HMIs without caring about the terminator which is automatically added. With this "Multiple Nextion HMIs on one Arduino", we went already beyond most existing libraries.Since, depending on our MCU and its number of serial ports, our class has alternatively to deal with HardwareSerial, SoftwareSerial, AltSoftSerial, USBSerial, we learned that the GNU C++11 compiler which is used by the Arduino IDE is a bit (in fact, very very) finicky about the type of passed object references (Serial, Serial1, Serial2, etc.) when it comes to construct depending objects like our NexComm class, we had the occasion to learn about template classes. We will need this knowledge later.
Hooray... this is the 30th edition of the NEXTION Sunday blog! But to our big surprise, it was the one published last week, talking about wrapping the Nextion communication functionality in a simple C++ class which had the double number of readers than other blog episodes during the first 7 days. Obviously, there are many people interested in having a simple .h file accompanying their main .ino (or .c or .cpp) file instead of linking a highly complex, heavy and specialized library. Enough motivation to move on!
Over the last weeks, we have seen how a few lines of Python or C++ (Arduino) code allowed us to fully control our Nextion HMI and how we could catch events happening there on the MCU (Arduino) side. Now, these were simple examples and if you remember well from episode 4, our code was compact and worked well, but this was for only one component on a single page. Also, episode 6 gave us the opportunity to "listen" to generic Touch Press and Touch Release events, but that's far from covering the full list of data which the Nextion HMI can send back to the MCU.Time to make things more flexible and to de-clutter our Arduino Sketches. You may naturally use the official Nextion Library, but if you are like me and you want to understand how things work and you want to remain in control of every.single.byte, you are cordially invited to read this and the coming episodes and follow the idea of modularizing our elementary functions and to wrap them up in a few classes. I don't know yet where this will end, but odds are good that we end up with a simple, flexible, and compact miniature edition of a Nextion library which we will fully understand since we have written it ourselves, and which at the same time overcomes some restrictions of the actual library.