#Absolue Value of the Modulo function?

1 messages · Page 1 of 1 (latest)

neat garden
#

Hi, It is very hard to explain it by writing but i will try to explain my problem with my poor english 🙂

I am a newbie in mobiflight, arduino and any kind of coding. I am trying to learn by reading forums and watching some videos.

In my project, i am using an rotary encoder as a selector knob for eight different variable. (com1, com2, nav1, nav2 etc).

I am reading the encoder input from Mobiflight Variable as "selector" and transform it to an output value by using modulus function of eight.

There is no problem for selecting the desired variable by using the encoder. When i rotate the encoder either left or right, -and many tours- selection works well.

I am using the same Mobiflight Variable "selector" also for displaying the selection caret in my 20*4 LCD display. When the selector value is positive, there is no problem, caret works well. But if i turn the encoder to the left so many tours and the selector value turns to negative, my caret disappears.

I think that, if i can transform the "selector " value to absolute value, caret selection will be working for negative values also. ( I tried "$+8" but it did not worked)

Or is there another way?

Here some screenshots and videos in order to help me explaining my problem.

Thanks...

visual orbit
#

the abs() function should give you the absolute value

#

so maybe abs($)%8?

neat garden
visual orbit
#

Post a screenshot of your config

neat garden
#

Are these enough?

visual orbit
#

No, I need to see screenshots of the configuration where you applied the transform

neat garden
#

this one?

#

there are also precondition rules...

tired coral
#

I would suggest making the value "in range" directly from the Input config.
In the encoder input config On left do this
($+7)%8
For on Right
($+1)%8

#

These two functions will wrap around

#

Then there is no need for converting the value in the output config

#

And the value is always in range of 0 to 7

neat garden
visual orbit
#

hero @tired coral again 😄

tired coral
#

the formula for DEC event is actually very clever, and not my invention. There is no need for if statements.

daring moat
#

great idea

daring moat
#

reminds me also that it would be nice to be able to set a variable in reverse in the lcd

#

@flat laurel have you thought about that ever?

narrow olive
neat garden
#

Is it possible to use a custom character/shape as caret instead of default ones like <,>?

flat laurel
#

not at the moment

daring moat
#

yeah, the reversed color mode is usually what those displays can do, so make a black box and light characters

visual orbit
neat garden
flat laurel
#

and blink!

daring moat
#

it could be like *bold*

#

but modifiers would be better but how to do that for lcd?

#

ie reverse + blink