Stop the Crazy slider

The value of slider position is stored in firebase as "lim:". This "lim" value can also be changed by the microcontroller. When the microcontroller changes this value, I tried to place the slider's position at that value. When I do this with the microcontroller, the position of the slider goes to the set value. No problem so far. Now when I change the sliders position in the app, it goes crazy like this in video. I sent the value to firebase from the microcontroller as both an int and a string, and the result is the same.

More detail
OK, let me tell you more.
1- I changed the slider position. The microcontroller read the changed value of the Slider from the firebase. no problem...
2- I changed this value from the value it left with the rotary encoder from the microcontroller. According to this new value, the position of the Slider has also changed. no problem.
3. Now I changed the Slider again. and he went crazy

Try the SliderTools extension and use the SliderTools.TouchUp event:

grafik

2 Likes

Why would you do that though If the microcontroller sets the limit automatically?

1 Like

You created a feedback loop:

  1. thumb changes, asks Firebase to change its value
  2. Firebase change is detected, so it tries to update thumb.
  3. go to step 1
2 Likes

Good spot ABG. Also, what happens if the User sends a value manually at the same time as the microcontroller........

1 Like

Keeping Huseyin

  1. How often does the microcontroller send the Limit value to Firebase?
  2. What exactly does the value represent? If it's a sensor value, the values could vary wildly.

The value stored in the firebase can be changed both with the rotary encoder on the microcontroller and with the app.

The value stored in the firebase can be changed both with the rotary encoder on the microcontroller and with the app.

Rotary encoder send the value when interrupt enabled .
It is sending the value at first. Depending on the value, the position of the slider also changes. no problem so far. Now the slider goes crazy when I change the slider.
Rotary encoder. It s like potentiometer that you changed the frequency a radio or volume up etc.

In order to stop a feedback loop, you need some way to mute the feedback for a certain amount of time.

That would involve adding a global true/false variable MUTED, checked by both events and required to be false before propagating an update.

You would also need a one shot nonrepeating Clock Timer to turn off the muting after a second.

Another alternative would be to keep a global variable with prior value(s), to help avoid unnecessary attempts to propagate changes. If the new value matches the old value, don't try to propagate it.

2 Likes

OK, let me tell you more.
1-I changed the slider position. The microcontroller read the changed value of the Slider from the firebase. no problem...
2- I changed this value from the value it left with the rotary encoder from the microcontroller. According to this new value, the position of the Slider has also changed. no problem.
3. Now I changed the Slider again. and he went crazy

The ThumbChanged event is too unsyable to use for this app.

Just poll the thumb position with a repeating Clock.

Show us your new blocks if you changed anything. The old blocks are clearly at fault.

1 Like

I didn't change anything. I will share aia file if kids let me :slight_smile: I couldn't upload the file. I try to upload drive now

Use this extension and send the data in the Touch up event.

1 Like

Here is the project.
Thank you all for your attention .

https://gallery.appinventor.mit.edu/?galleryid=a3200923-fcc3-4edd-9d2a-422b55d0cd99

Thank you. I am going to try it. When kids are sleep. :))

As I already said here: Stop the Crazy slider - #2 by Anke

1 Like

Here is a sample for how to use a Canvas instead of a Slider, to get a TouchUp event, without need for any extensions.
https://groups.google.com/g/mitappinventortest/c/eA_T9NWTa6A/m/SZTS48_FAAAJ

1 Like

Export Project

1 Like

Off course. I see. Both of them are same. I will look all them.
Thankfully.