Start a new topic

Recommended minimum knowledge base for dealing with Nextion?

What do you think about creating such list?

When I started a year ago with Nextion and Arduino I knew quite a few. I had very basic knowledge in programming, even less in electronics. And I didn't know what should I study to get more familiar to it. Google helped, but path was winding. I tried to look through those examples in Nextion library, but it confused me even more. Those * and & signes drove me crazy. And code was like Chinese to me (assuming I am not Chinese). But I had idea in my head what I wanted to create and it led me through that path of ignorance till now. I am still on that path but now I can imagine what are those pins for, what is serial and its basics, and that when byte is read it is no more avaliable, and even a bit about pointers and references so it looks not so hieroglyphic anymore. 

So my point is that I suggest to create kind of walkthrough on minimum information for people who know what they want to create, but dont know where to begin. 

I can predict that you'll say about datasheets and C programming folios, but that  tons of information may be excess for hobbyist-beginner and can scary him away.

But if he would see that there is not too difficult to start and after a short time already create simple things he would realize what knowlege he requires for continuing and thats where books and datasheets come.

So that is my point how I think newbies can be attracted.


I heard you.  But how to make it more simple ?

What you describe is learning Arduino C++


I have already made a Nextion TTL Serial thread.

and like most good things is in the Gallery

  Tools Tips Tricks and How-TOs thread.

In this thread I animate a TTL byte 

  - from TX buffer until RX buffer.

This can be replicated in code to make a Software Serial


But here comes the part that is more hard

 - you want specifically Arduino MCU boards - mostly AVRs, some Cortex M0/M3

 - you want specifically want Arduino's version of C++


And there is better than 10,000s of MCUs not Arduino

And there is better than 100 programming languages not Arduino C++

And it is in this crazy mix of language 54 with MCU 6732 or language 92 with MCU 4528

 - that the "workload" to describe fairly for each becomes ... well, beyond crazy.


The other day a user asked about the STM32F407 series

 - there is more than one (eight) depending on # of pins, package, flash size, sram

   this will dictate what modules are in the MCU and what pins they are on.

   and what this MCU is capable of

Another asks about an STM32F103 series 

 - here there is 49 MCUs in the series


Now the STM32F103 is a Cortex M3 ARM design

   but for this Cortex M3 ARM design is many Manufacturers

   Between the equivalent GD32 by GigaDevices and ST's STM32

   - the USART module we speak of needed for Nextion, is different.

   GDs module comprises the 4 pins (2 of which Nextion needs)

   and ST's also uses 4 pins - but what of the 2 unused pins?

  A USART module can be 5V Tolerant, or NOT (and if not I smell disaster)

  What clock speed the MCU is running at will effect error rates


So just from the hardware stand point -- you can surely see why Refer to Datasheet

 - the Reference Manual for the STM32F407 is around 1740 pages.

But lets not kid ourselves, printing the Arduino Reference Manuals for the MCU that 

  is on the Arduino board many times also exceeds 1 ream of paper.


Arduino kind of glosses past this part, I think this is incorrect to do

 - instead you end up searching google for answers and understandings when

   the needed link on the Board page would have explained much

 - To me a search inside the reference PDF is much faster than Google search.


Now we start into what Programming Language

 - there are many to choose from depending on your chosen MCU platform.

 - I like Pascal, Gerry likes Basic, a few on here like Python.


But the language chosen has many differences between compiler vendors.

 - some have implemented almost everything, some have not even implemented all the basics.

But basic to what, a limited MCU doesn't have room for every command to be called

 - Pin high/low for amount of time under condition of ... is basic, maybe all that is needed.

But the compiler should minimally have what you need to build all others needed pieces.


Each compiler comes with it's basics

  - a list of all functions it is able to do

For Arduino it is listed out on their Reference Page


But programming requires logic, step by step of what order to put what

- the MCU will only execute exactly as it was told to do

- when the result is not what you desired

   it was not told correctly to do what you wanted.


Teaching programming is perhaps beyond the duties of a manufacturer

as is everything else beyond the electrical basics

 - which is found in the Nextion DataSheet for each Nextion model

 - Nextions instruction set is covered in Nextion Instruction Set


There is a big reason why DataSheets are so important

 - they already list out all the "need to know" information


Now Arduino's push hardware without thought, just connect and go?

- can be real dangerous depending on what was built.

  - a high voltage relay switch can kill in the wrong scenario

- Now something goes wrong with the project

  and the users have glossed over all the important information

  and they don't know any of the basics, how to troubleshoot, how to fix.


I am just not sure I can wrap my head around

   a cut copy paste culture of do without understanding


By why Nextion over most of the other HMI screens, besides price point

 - ease of human readable instruction sets

 - speed to make a graphic interface

 - touch events by simply checking off Send Component ID and done, the rest is MCU side

    (OpenSource Fishtank project demonstrated this - entire project is Send Component ID)

A Basic HMI can be created within hours, not weeks or months

User saves both Time and Money ... this is why users should be attracted

  - they need to understand: their chosen MCU, and their chosen Programming Language


And I try to show that Nextion side Logic is even more capable.

  - For the last few months I have at least one tutorial per month all sources included.


Lastly I am going to demonstrate a quick HMI for an HP42s calculator project

 - 1 picture, 1 font, 4 Text Components, 37 Hotspots

 - All hotspots with Press/Release Send Component IDs checked.

 - Graphic - 7 mins, 1 custom font 1.5hours, HMI work - 30 mins max 

 - Arduino framework for the project - a few seconds because I made a tool.

 - so around two hours and the rest is now up to the MCU side - done.

   but with a different font, under an hour.

 - How long the MCU side code takes ... who knows


Now sure, I'll spend a few weeks getting most logic put into Nextion side Logic

 - but that is an advanced use, and beyond the basics needed to use Nextion.

ino
(13.3 KB)
HMI

Indeed Nextion is one of a kind product. I tried to search web for the analogues, but could find anything more convenient than Nextion display+editor combination. 

But for those who are not professionals many options can be not visible. Like above you have spoken of variety if MCUs and languages. Maybe it would be a good idea to describe those combinations? Why one is better then another and for what purposes can be used. Kind of table maybe.  Everyone knows Arduino because they have good promotion company and its name is in everyones ear.  Other MCUs like STM32 and others, I heard of it, but do not know why should I use it instead of something else. I believe answer is deeper in characteristics, but how people get familiar to that information if it is not their profession? For instance I want to make kitchen robot that would peel potatos for me. How do I choose rigth MCU for it? Should I do a market research fisrt or go ask someone?.. 


I think I distracted and that is not quite a Nextion task to review MCUs, but maybe it is not too bad idea as displays meant to be used in pair with them.  

Stepping stone number one:  What is out there.

 - we can start to scratch the surface of with DigiKey or similar.


DigiKey is just one of many electronic parts suppliers.

 - will they list all?  No. Usually just what they have or willing to get.

 - this excludes any who haven't made a deal to give up profits to DigiKey to be listed.

 - this will exclude many who may have had supply issue in the past (less reliable)

 - many other reasons why not in DigiKey .. too new, too few, small batch, etc.

 - some other considerations - not all is exportable or restricted for exports.

 - DigiKey is regionally biased, I am sure China has much more available

Embedded - Microcontollers (56080 items)


But these then are broken down - What do you need?

 - Core bit width 4, 8, 16, 32, Multi core?

 - Speeds ?

 - Number of IO lines

 - programming memory size

 - type of memory

 - EEPROM or not?  if so Size?

 - Ram size needed?

 - for what required voltage

 - operating temperatures

 - packaging in pin count, size, shape, pitch


And what and how do you want to use and connect and need?

 - A/D?  D/A? resolution?

 - PWMs ?  with Motor Control, without?

 - UART/USARTs ?

 - Sound?

 - I2C ?

 - SPI ?

 - CAN ?

 - I2S ?

 - SMB ?

 - IR ?

 - Bluetooth ?

 - Wifi ?

 - Ethernet?

 - LCD ?

 - Need DMAs ?

 - Want/Need WDT ?

 - Encryption AES? 

 - SDIO, MMC, SD, TF, USB, USB OTG, SmartCard?

 - ATA, SCSI, ATAPI, etc, etc, etc.


Simply put if the MCU has either a Hardware TTL UART module or better

 - or two digital GPIO pins and programmer is willing to bit-bang serial as needed

Then Nextion being a TTL Serial device, the MCU can talk to Nextion and Nextion to the MCU.


Trying to promote one MCU over the other is not a fair practice.

 - would it be good practice to say Silver Surfer is a better Super Hero?

It largely depends on what the task of the MCU is to be.


If you have the need for 6 IOs in your project, it doesn't make sense to pick a 230 IO MCU

Likewise if you have little code logic

   read photoresister - if day do else if night do 

Then it doesn't make sense to choose an MCU that has 1MB of program space.


Some things come down to budget

 - on making first prototype, overkill resources doesn't matter too much, you spent $87 for MCU

But when you finally like what you made and now want to consider a small production run

 - do you still use $87 MCU when a $0.93 MCU can also perform the same task?  No.

(Someone else will like your design and see such, realize, and make cheaper with smaller)


Good to point out, that when learning, small steps to understand, then advance.

- making a Kulinary Kitchen Kid to peel taters is cool, but hardly first project for beginners

Too many times first project idea is way beyond beginner capabilities

 - this is why first project, the "Hello World" is usually blink a digital pin with an LED.


Arduino doesn't care that you can not do it, as long as you bought the tater tiller kit from them.


But how to select an MCU has everything to do with picking one that will do task needed.

- picking the right tools for the job saves many headaches

  - such as serial - why learn to program bit-banging when MCU has Hardware Serial

    choosing the one with Hardware Serial port saves a lot of headaches.


I didn't cover anything on Programming Languages ... (other than there exists over 100)


I need to iterate that a programming language choice is a personal preference.

Things to look for in a programming language depends on personal writing style but, if there are

- user defined variables of a few given data types

- branch control to subroutines, procedures, functions

- loop control, for, while, repeat until

- pointers (not all programming languages support pointers)

- access to hardware modules, such as Serial (if not written already, programmer needs to write)

- inline assembly

Then there are the building blocks to program and build more complex functions and routines.

A programming language is only as good as its compiler (machine code generator) and optimizations.


Somewhere along the lines of trying out a few languages with a few compilers vendors

a persons preference emerges, and the personal choice is made.


Example from your own * and & pointer reference and dereference

 - The Pascal language does not have this, instead it has its own . (period) and ^ (caret)

C style languages use << and  >> for shifting, Pascal uses SHL and SHR

C styles use &&,  || and !  where Pascal uses AND, OR and NOT


But which is the better MCU language is specific to which the individual can code most effectively with.


@Ivan, the minimal knowledge is simple: Create a serial connection, send a command to change some text. That is enough to make a clock.

For an Arduino Uno, with just one hardware serial port (which is used to upload a sketch), the serial connection is already not easy. So it depends on lot on the MCU as Patrick Martin already wrote. It is therefor not possible to make that list.

My suggestion is: Start with what you know, and move forward from there. Using the Arduino library, adding touch, adding animated pictures... to get the most out of the dislay, you need to be an advanced programmer, but you don't have to be if you start simple.

Speaking of Arduino library. I would not recommend use it to anyone. It is quite demanding on resources and not very good in architecture. It is better to understand how Nextion communicates with Arduino using commands from commands list and in its base create couple of own functions. Lots of tasks can be realized by only 6 commands. I would like to share my own small simple library I've created from official lib for my project which can make life  easier to manys.  

zip
@Ivan, that code still uses the String object, which is not recommended for basic Arduino boards. The code for 'touch' seems to be missing. If that code works for you, that's fine. I have created something similar without the String object and with the sprintf function. I think that the Arduino library should split the serial data streams to and from the display and handle them separately. Well, that's the problem: everyone has an opinion about it. Maybe the "perfect" Arduino library is not possible.

 

I am not sure how it is not good on Architecture, especially for those learning.


   NexComponent is inherited from NexTouch is inherited from NexObject


Such a common structure makes good learning curve for those who don't know.

But everyone is able to remove the functions they do not in the end need

 - as Ivan has done

But not everyone has the same ability to add the missing functions from Ivan's.

Ivan's library doesn't catch incoming notices from Nextion

 - but on a plus forces user's to know what is available (Attributes/Instruction Set)


A compiler will only add what is needed to final binary, so it matters less how

many unused functions there are in code.


@Koepel


Perfect is ... (perhaps subjective to given project)

To me all Nextion Return Data has value, not just touch

To me access to all vars, sys or component also important


I am not going to argue down to bits, 

- but what is gained by losing Strings is lost by sprintf

I can say it was possible to implement numerically without Strings


Handling to and from is function of RX buffer and TX buffer

 - the reason why Iteadlib reads before write

 - but unless multitasking, has less value as need is sequential


But is perfect in having all functions?

 - is perfect smallest?  fastest?


By architecture I meant situation when I change my page in editor(add, remove components, change their order) I have to edit those changes in definition of objects in code as well. With structure as in my library you can change page as you want. Save only names of objects and it will work without editing code. 

Patrick, I would like to ask another thing about library. When I was looking through its sources, I couldnt understand one thing and still do not understand.. shame on me. 

 

NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name)
{
    this->__pid = pid;
    this->__cid = cid;
    this->__name = name;
}

 what does "this ->"  mean? 

So really the fastest means is to first solidify HMI design

 - then create code for .ino based on HMI design

Then in this manner, changes are completed.


Order components with arrows up/dn (Bring Top .id=n, Bring Bottom .id=1)

  When components that will not change are lowest .id values

  they are unaffected by changes made by upper .id values

The changes you refer to only occur to smaller group of components if at all



NexObject has a structure with three members - see NexObject.h

  __pid  // page number

  __cid  // component .id attr

  __name // .objname in HMI


The code snippet you posted is a constructor

  - basically how to "create and build object" 

    this refers to this object, it is a C thang  Self in Pascal

    this-> is a pointer to member

    so that object's __pid member is this->__pid

    and in the entire assignment this->__pid = pid;

      where pid is the number that was passed

   NexComponent myComponent = NexComponent(0,1,"page0.t0");

     0 __pid,   1 __ cid,   page0.t0  __name 

 with C depending on reference or dereference

    this.__pid format can also be used  

Thank you, Patrick :)

Login or Signup to post a comment