Start a new topic

Creating a Nextion Piano within Nextion Logic Questins

Please explain this statement from the piano example - pwmf=b[sys0+26].val*3

In the HMI, I could not find a component called "b" and the use of the square brackets is mystery.

It appears that the bracketed value is an index into an array but I can't find any information in the Nextion instructions.


Also is it possible to do a "click" command across pages?  I get a compiler error when I try using this example  from a page1 button - click page2.b0,0


Thank you


Fred


1) pwmf sets the PWM frequency, the frequency is equated as val multiplied by 3.

    I found tones were more pleasant using a multiplier at fractional duty

    identifying the component of b[sys0+26] renders a variable holding base freq for the equation.


2) The b[.id] component array was discovered  by user indev2 in version 0.38 of the Nextion Editor.  Every component has an .id attribute, and access the component attribute via b[.id].attribute. Since then it was used officially in the keyboard source as well as revealing the p[number] page index.


3) I never tried to click across pages as pages not current are not in memory.


1 person likes this

So since I never tried before - I decided to attempt a click across pages.

Compile error 0x02 Parse:Invalid Component ID


So click is limited to components on the current page

- but you already knew that when you saw your compile error


1 person likes this
Thanks Martin.  Now I understand the b[id] component usage.

Fred

 

The b[.id] component array is very powerful.  A very welcome discovery that allowed for component access via the array in a for and while loop.  This cut down massively long if() else if() else ...  The attributes accessed when using the b[.id].attribute MUST exist, so the user needs to be certain that the assignment will work, otherwise the firmware melts and you don't get the effect you are looking for.

Login or Signup to post a comment