HanSolo / medusa

A JavaFX library for Gauges
Apache License 2.0
687 stars 129 forks source link

setValue(xxx) - bipolar behavior #174

Closed chocomo99 closed 5 years ago

chocomo99 commented 5 years ago

Using the basic gauge with scale from zero to 100. setValue() behaves differently inside/outside while loop. See comments in code snippet.

public void getVal(){ double valu = 1.0; double curval; /*/ while (valu < 100) { curval = gauge.getValue(); // curval = gauge.getCurrentValue(); System.out.println("Value is " + Double.toString(curval)); valu += 1.0; gauge.setValue(valu50.0); // must scale by 50.0 to move needle to correct position } /**/ // valu = 55.0; // gauge.setValue(valu); // sets the needle to specified value }

regards, chocomo99

chocomo99 commented 5 years ago

After running some parametric tests a couple of observations... The hard wired scale factor in setValue() is what moves the needle. The needle consistently stops at twice the scale factor. The loop counter (valu) has no effect on needle movement for valu > 2. Interestingly the output of getCurrentValue() reads 1, 1, valu*(scale factor). So setValue() appears to work correctly after the second iteration of the loop even though it doesn't move the needle as expected. Wish I could be more help but my many years of experience are in Fortran, C, C++, ADA and a few other languages. Only been doing JAVA for about a month.
I'm trying to build a digital gauge cluster for a non-OBD vehicle. Currently I'm using Octave to read the Arduino board and display a bar chart. A bit clunky to say the least. Raspberry PI 3 + Arduino + Medusa appears to be the ticket. It looks like others have successfully used the Medusa gauge library so I still wonder if I'm doing something dumb.

chocomo99 commented 5 years ago

When the loop counter valu is incremented by a larger number the needle moves in proportion to that number. But only the first time through the loop has any effect on needle movement. Strangely getCurrentValue() sugggests that setValue() failed on the first time through the loop but indicates that setValue() is working on subsequent loops. Just the opposite of actual needle movement. I moved setValue() to a separate method hoping the needle would move upon exiting that method and returning to the while loop. That didn't help. Is the loop itself preventing display refresh? I put the thread to sleep for 1sec each time through the loop but that didn't help. Not sure what else to try.

HanSolo commented 5 years ago

I‘m currently on vacation but will take a look when I‘ll be back.

chocomo99 commented 5 years ago

I'm glad you're on vacation and apologize for interrupting. There was a build warning about a version mismatch with SceneBuilder. Attempting to solve that issue I upgraded to the latest version of Eclipse, Java SDK and JavaFX. Huge mistake - after much misery & failure I reinstalled Eclipse 4.11, SceneBuilder 8, JAVA SDK 8, JAVAFX 8 and Medusa version 8. Everything works perfect now. At least my suspicion about the version mismatch causing the problem was correct. Thanks for making this awesome library available to the public. Issue CLOSED.