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 · 2 comments
Open

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

elliotmatson opened this issue Nov 7, 2024 · 2 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

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

2 participants