Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pro - Progress bar values are about an order of magnitude off #244

Open
elliotmatson opened this issue Nov 7, 2024 · 12 comments
Open

Pro - Progress bar values are about an order of magnitude off #244

elliotmatson opened this issue Nov 7, 2024 · 12 comments
Labels

Comments

@elliotmatson
Copy link

Describe the bug
Progress bar is showing something close to the update value / 10

To Reproduce
Steps to reproduce the behavior:

Card influxBufferSizeCard(&dashboard, PROGRESS_CARD, "Influx Buffer", " kB", 0, 1024);
...
influxBufferSizeCard.update(20, " kB / 1024 kB");
dashboard.refreshCard(&influxBufferSizeCard);

Results in:
image

Have tested with ints and floats, and finally with a constant. It doesn't seem to be exactly inputVal/10, but it's typically pretty close.
Logging the value of inputVal immediately before calling update() verifies that the expected value is correct.

Expected behavior
Should show 20

Versions
ESP-DASH Pro @ 4.6.0
bblanchon/ArduinoJson @ ^7.1.0
mathieucarbou/AsyncTCP @ 3.2.12
mathieucarbou/ESPAsyncWebServer @ 3.2

@mathieucarbou
Copy link
Contributor

Are you sure to use int everywhere and not floats ?

Sliders support both int and floats:

Card _output1DimmerSlider = Card(&dashboard, SLIDER_CARD, YASOLR_LBL_050, "%", 0.0f, 100.0f, 0.01f);

if you construct the card with integer, it will have internally: _value_type = Card::INTEGER;

with floats, it will have internally: _value_type = Card::FLOAT;

This distinction is important for ESP-DASH to know how to output the numbers, and which callback to call between:

    void attachCallback(std::function<void(int)> cb);
    void attachCallbackF(std::function<void(float)> cb);

Rule: always use the same types: int, or float, but not a mix of them otherwise it will change the card type at runtime.

Note: this might not be related to your issue though, but just something to check.

@elliotmatson
Copy link
Author

I definitely used all ints in my original code, but when testing a float in update() I didn't change the min and max to floats as well

Copy link
Contributor

github-actions bot commented Dec 8, 2024

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Dec 8, 2024
@elliotmatson
Copy link
Author

Still seeing this issue

@github-actions github-actions bot removed the Stale label Dec 9, 2024
Copy link
Contributor

github-actions bot commented Jan 9, 2025

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Jan 9, 2025
@elliotmatson
Copy link
Author

Bump

@github-actions github-actions bot removed the Stale label Jan 10, 2025
@mathieucarbou
Copy link
Contributor

I definitely used all ints in my original code, but when testing a float in update() I didn't change the min and max to floats as well

yes, it is either everything floats (update ,callback AND definition), or everything in ints.

I do not have this behaviour in chrome and safari... really weird...

@elliotmatson
Copy link
Author

That's interesting, if it isn't reproducible for anyone else it must be with my build environment or browser, I'll see if I can run some more tests

@elliotmatson
Copy link
Author

I did some more digging, and confirmed that the values being sent over the websocket connection are indeed correct, so that narrows the issue down to the frontend somewhere. It's also not consistently incorrect by an order of magnitude, so that can be ignored

Image

@ayushsharma82
Copy link
Owner

Ah, now I got to understand your issue. @elliotmatson Please send a message over [email protected] to create a ticket, I'll reply back to you with a fix there. I believe we can fix it today itself.

@elliotmatson
Copy link
Author

Just sent, thanks so much!

@ayushsharma82
Copy link
Owner

ayushsharma82 commented Jan 23, 2025

@mathieucarbou We were so focused on blaming the int and floats haha but the issue was that UI calculates the % of raw value in the specified range. So what @elliotmatson thought was off-value was just the percentage in range of 0-100.

As mentioned on mail, the best fix is to keep the percentage but update the symbol string as well to show raw value. For example:

String symbol_str = "% (" + String(value) + "KB / 1024KB)";
progress_card.update(value, symbol_str.c_str());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants