Start a new topic

ITEAD code syntax

Hello,

Just started testing Nextion displays.
Not much code examples to be found.
Finally found this:

https://www.itead.cc/blog/advanced-application-3-slide-to-unlock-and-battery-charging-progress-project/


The display is standalone for now, no serial connection. Just simple testing.

What I'm trying to do is changing a global variable when a button is pressed.

Here's the code when button is pressed


if(page2.va0.val >= 100)
{
  page2.va0.val = page2.va0.val -100
  page2.t1.val = page2.va0.val
}


These are the errors I get.

Error: Invalid Variables:page2.va0.val ( Double click to jump to code)
Error: Invalid Variables:page2.va0.val ( Double click to jump to code)
Error: Invalid Variables:page2.t1.val ( Double click to jump to code)
Error: Compile failed! 3 Errors, 0 Warnings,


What am I missing?


not much code examples? mhmhmhmh everywhere in the Galley, where a HMI file is attached you have code ...

 

Yes, but the code is only visible if you open a .hmi file.
So far I've only seen small pieces of code when i.e. clicking a button.
Have I missed something?
Anyway the subject was not the amount of code examples.
What is the specific problem with the code I tried to produce and get errors from?

 

Maybe that's not the subject, but the point ... :-)


HMI files are your source code, and you surely must open them to read the code !!!! HMI files are no Ascii files which you can just open in your Notepad ...


honestly, the issue is that you start with copy and paste something ready made without understanding the underlaying ...


why don't you start simple with a fresh new own empty project ... one page, put one button on your canvas, and start playing with all ~35 available commands, one after the other, ... which are well documented on a very few pages ...



These commands can be found in the Nextion Instruction Set located here
http://wiki.iteadstudio.com/Nextion_Instruction_Set

Other samples and Tutorials can be located in the Itead Blog located here
https://www.itead.cc/blog/

Further Information can be found in the posts in the Announcement section of the Forum
Nexion FAQs
http://support.iteadstudio.com/support/discussions/topics/11000002523
Nextion Users manual
http://support.iteadstudio.com/support/discussions/topics/1000065323


Sorry, but reading this all and playing with your hardware is up to you ... :-)



if(page2.va0.val >= 100)

{

  page2.va0.val = page2.va0.val -100

  page2.t1.val = page2.va0.val

}


These are the errors I get.

Error: Invalid Variables:page2.va0.val ( Double click to jump to code)

Error: Invalid Variables:page2.va0.val ( Double click to jump to code)

Error: Invalid Variables:page2.t1.val ( Double click to jump to code)

Error: Compile failed! 3 Errors, 0 Warnings,


Invalid Variables = page2.va0.val is perhaps less obvious for first timers

this either means that

   - there is indeed no page2.va0.val

        (such as page2.t1.val indeed there is no such variable, page2.t1.txt yes)

    - or a syntax error causing page2.va0.val to be invalid

there can only be these two possibilities.


for page2.va0.val  the error is in the extra spaces you added. let me highlight.

The start of the parenthesis ends the variable

   Error: Invalid Variables:page2.va0.val ( Double click to jump to code)

   Error: Invalid Variables:page2.va0.val ( Double click to jump to code)

   Error: Invalid Variables:page2.t1.val ( Double click to jump to code)

Indeed there is no space terminated attributes.


So when the erroneous spacing is removed you get just 1 error

Error: Invalid Variables:page2.t1.val( Double click to jump to code)

And this is because a text component does not have a .val attribute.


But such a snippet of code without the corresponding HMI posted

makes it impossible for the other users to dig in to see if this is

indeed the case as they can not check for the variables existence.


page2.t1 is perhaps the wrong component chosen for what you want.

  the Number component is more suited for numerical manipulation.


As per the Nextion FAQs, it is not Itead's duty to debug user code.

This is why it is necessary to post coding questions in the Free Chat section

  - here within a public forum other users are able to help answer.

  - within a public forum all users are able to discuss

  - and discussion may even offer suggestions, and academical debate.

But all answers are voluntary,

  and only if user choses to spend their time to dig in to your issues.


Indeed, users maybe less likely to want to download someone else's HMI

 - too focused on just their own endeavours to be bothered with other HMIs

But when your objective is to see code, and code resides in HMI

   then it is to your benefit to download HMI and actually open.

On the flip side, your reluctance to do so raises questions for others

  - if you are uninterested in downloading,

    they will reciprocate, and not want to download yours

    - and yet, this may be the only way to locate your error.

      so that you get an answer from them as to why your code fails.

But mostly, users will not play librarian for another user.

  - if you show too less effort to help yourself, they will not invest their time

  - their reading of the required documents

      - will increase their understandings and not your understandings


The forum contains over 2000 pieces of code

 - I know I have myself made full code tutorials, others have as well.

For the users that have invested their time to create and provide their code

  to the benefit of the community, such a statement that there is no

  examples to be found ... try less to insult them ...   such will

  not inspire them to dig in for you when you overlook their contributions.


For examples,

   there are techniques to accomplish a task, in pseudo and in actual code

   there are several libraries specific to a programming language

   there are examples to a specific MCU.

   some users have even made problem specific tools

   the forum is not the only location for examples

   - I think YouTube has over 25,000 Nextion related postings.

And I am mostly certain every possible Nextion issue has been covered

   at least twice in forum, sometimes over 100 - such as how to text


Lately, the postings are more:  I want to do this, help me do "my project"

But this too is perhaps in the wrong fashion

   as the answers become project specific one overlooks as it isn't their project

Yet your answer is actually covered, and only needs to be adapted to yours.


One must only be willing to look and try some for themselves.

When you will eventually like to dig into the newer less than documented ESP32

   you surely will not find so many examples commercial ready

This too will require you to dig into much documentation (much doesn't yet exist)

   the nuances of ESP32 dual core are more advanced than ESP8266

   multi-threaded is much less forgiving than single core sequential processing.

And even fewer will be found who are willing to dig in to make their efforts free to you

   so that you can commercially make profits off of the hard work they had to do.


Such an ESP32 will have many more resources than the 2.4" Basic Nextion model.

But such deep prerequisite understandings needed for the ESP32 will also

make assumptions that one already can figure out lesser MCUs

 - such as the STM32 Cortex M0 on the Basic model Nextion.

    - such will be obviously less capable and resource restricted in comparison.

In such confined space of a Cortex M0, there would not be such internal space

to include Nextion side error checking to look for multiple variations when parsing.

Parsing would therefore have to be basic forms of parsing ... logically.


Therefore space is a command delimiter, and parsing comes on each operator

 - there is no such space to bloat firmware to make decisions for whitespace.

 - Nextion is 32-bit integer based, non complex evaluation, no variant types.

 - very basic level of logic, not too many instructions


Nextion is not a programming language, should be thought of as command set

 - yet a good programmer knows all is in the ordering of these commands

   it can indeed be manipulated into amazing results - user skill dependent.

But in HMI, is MCU or display in control of the project

   Nextion should be responsible for input to inform MCU

   the MCU should be first to decide if action should be taken

   the MCU then should update the display of decision, result and status.

You certainly create an interesting design decision when you spread

   controller logic across two devices to parallel controlling logic

   both in control of the logic and its future maintenance.


As for document errors in the Nextion Instruction Set ...

 - we do not have the ability to edit it, task belongs to another, or it would be done.

As such the Bug Report thread * Grammatical Errors, and Document Corrections 

   is where any errors are to be reported to so the ones that can edit will find.


This might be all I am willing to provide for free to a commercial endeavour.

Patrick,
Like to thank you for your lenghty and explainative answer.
Sorry to have expressed that there are not so many code examples.
There are lot's of them.
Problem is I just want to test the display standalone for now.
Not because the plan is to stick with that. There will be a host processor in the application.

The interest for Nextion displays are primarily to take workload off from the host processor.
Many applications are more costly codewise for user interface like buttons and screens than the real application.
I really love the idea to just control all this with simple serial commands.
Actually I'm eagerly awaiting PCB's to arrive. It will be first attempt at an STM32 Cortex M0.
Been coding for an STM32 Cortex M3 device for 5 years and feel pretty excited to meet it's junior brother.
This IDE has been simple to work with even though I tried something harder than letting a host send simple commads as my first project.
Thanks again for making the effort to explain things in a nice way.

Richard



 

Login or Signup to post a comment