Start a new topic

The Yet-to-be-Documented B[ ] Component Array

So indev2 sent an HMI to show / compare efficiencies.  Somewhere he has learned of or discovered the component array b.  So here is my expanded example using the b[id] component array in v038 of the Nextion Editor. 

This example has 10 Slider components each with a number component to track the value of the sliders, and outputs the 4 byte sequence over serial.

The Power/Kill checkbox
- when checked clears all to zero and notifies 0x42 0x00 0x00 0x00
- when clear allows the sliders to be used.
-5 decreases all by values 5, and notifies 0x42 0x00 0x01 0x00
+5 increases all values by 5, and notifies 0x42 0x00 0x02 0x00

The individual Sliders display the slider value while moving
- once released will notify 0x42 0xAA 0xBB 0x00
    - where AA is the slider 0 (Top) to 10 (Bottom)
    - where BB is the value of the slider from 0 to 100

sys0=x, (where 1 enables, 0 disables) sending slider notifications over serial.

The code in the hotspot events exploits the b component array to
  • change current slider background color
  • track current and last slider selected
  • use of .id attribute to calculate notifications
  • increasing each slider by +/- 5 or set to zero
  • set the numeric component value to the slider value
  • using the component array inside a for loop

So I wonder what else is yet to be documented.
(34.1 KB)

1 person likes this idea


So here is something else you can do with the b[ ] component array.  Create a Nextion Analog Clock. 

Since the Nextion doesn't have floating point or Trigonometry functions, storing info in variables is a necessity.  But when it comes to accessing the information when needed, who wants to have to write a crazy long if() { }else if() { }else if ....  

Skip that!  Accessing that variable data via b[seconds+offset].val makes it a whole lot easier.

The TFT file can be loaded onto an enhanced 3.5" or run in the Nextion Simulator.

And now you know that it is possible.  Enjoy.

(512 KB)

So here are two more things using the b[ ] array

Here's an analog clock for the 3.2" Basic Nextion. 

Adapted from the enhanced model, but without RTC (using a timer)


The second is a 10 line typewriter for lower ASCII (0x20-0x7E) support.


The TFT file can be loaded onto a basic 3.2" or run in the Nextion Simulator.

(If your system is busy, the simulator will loose some seconds over time).

(467 KB)
Can you provide the hmi file? I would like to see how this is done.


The throttles.HMI was posted above showcasing

- the b[.id].attribute component array.

Version 0.43 of the Nextion Editor includes keyboards activated by the use of the .key attribute in the Text and Number Components.  Unlocking these keyboard pages also showcase the use of the b[.id].attribute component array.

1 person likes this
Aaaahh. Thank you. That's quite nice. I'll have a bit of additional reading to do. I went right past that.

Did I miss a nice tip like that for the analog clock? I'd like to look at that code too.



Sorry, I must apologize, but the code for the three handed analog clock is not being revealed.  It is not necessary for my personal code to be given away freely to describe and showcase the b[.id] array.  The TFT is downloadable and can be run in the Nextion Editor debug to show that it indeed works.  While I disseminate much of my knowledge free here on the board, I must be able to retain some things for myself.

But as for tips, it is not using layer gauges, that would be impossible, as would using 60^3 pictures also impossible.  It is a lot of precision work that will take a fair amount of time to create.

Thanks. I totally understand and appreciate your tips and assistance. Cheers!


Login or Signup to post a comment