Start a new topic

Sliders showing range

The enclosed calculates and should displays a range on a slider from the Top value(90) to the Bot value(40).

The button initiates the calcs and displays the answer for the h0.val=65 on t0 and the h0.hig value=150 on t1 

Thesw answers are correct, but the slider is located wrong

If I directly enter h0.val=65 and h0.hig=150 in Debug then the slider position is correct 

Why the difference?

Also.. I get errors with h0.val=(Top.val+Bot.val)/2  thats why the double line using Calc. A sample of the construct would be nice please


slider values can be represented by more than one cursor position ... according to ...

    - the cursor dimensions, slider dimensions and value range
    - slider values are triggered by the center of your used cursor, not by its edge ...

A Slider with

    - 100 Pixel length
    - a value range of 1-10
has 10 areas of each 10 Pixels

When the Cursor is less than this 10 Pixels range per value, the Cursor can be set to different positions, which still represent the same value area inside the slider.

The Cursor is no Snapping Object, it is a continuouse sliding over the full length of your slider.

When you set the Cursor value directly, it Snaps, when you move with your finger, it won't ...

See the Gallery, SlickSliders and TrickySliders ...



As an integer driven MCU without such things as floating support and others

None complex evaluations and assignments

There is no order of operations

Parsing occurs on operator from left to right.

However, I think your math maybe wrong for your expectation.

 - you may want to re-examine.

Slider height is made up of

  - range  0 to 100  101 points

  - and cursor (height in this case)

So as slider is height of 303 less height of cursor of "after calc" of 150

leaves 153 pixels for range

  1 pixel for lowest range, spacing becomes 1.52 pixels per range number

65x1.52+1 pixels 99.8 so integer math 99 from bottom or 204 from top of slider

Slider starts at 75 ... bottom maybe should be at coord y 279

Cursor height is 150 so cursor starts at 130 

Now when I place a coloured background text component 150 high at y of 130

and press your button - I get the parallel of slider cursor 1 pixel lower.  so close

perhaps the 99.8 1st pixel at top instead of at bottom as I calculated.


So it is working as expected with the code provided.   Exactly doing as told.

Yes,, Integer maths is a pain

Try reading what I've written

Non Complex

Parsing Occurs Left to Right on Operator.

Isn't it already stated above -- No? 

integer math has nothing to do how a mathematical expression is parsed and treated. Integer math only calculate with Integers ... nothing more nothing less.

Nextion math parser treats any mathematical expression strict from left to right, one by one ...
no need to follow any complex rule, just calculate strict one by one from left to right, step by step ...

What can be more easy ... :-?


Login or Signup to post a comment