SignalK / SensESP

Universal Signal K sensor framework for the ESP32 platform
https://signalk.org/SensESP/
Apache License 2.0
150 stars 81 forks source link

CurveInterpolator does not store samples permanently #566

Closed ruedigerO closed 2 years ago

ruedigerO commented 2 years ago

When samples are added/changed via WebUI the values are not stored permanently (after restarting the ESP the default samples are back)

mairas commented 2 years ago

Could you provide a bit more context to this one? Some example software, for example?

It works for me, using this software: https://github.com/hatlabs/SH-ESP32-engine-hat-firmware

This is how I initialize the curve interpolators in that software:

  auto tank_level = (new CurveInterpolator(nullptr, config_path))
                        ->set_input_title("Sender Resistance (ohms)")
                        ->set_output_title("Fuel Level (ratio)");

  if (tank_level->get_samples().empty()) {
    // If there's no prior configuration, provide a default curve
    tank_level->clear_samples();
    tank_level->add_sample(CurveInterpolator::Sample(0, 0));
    tank_level->add_sample(CurveInterpolator::Sample(180., 1));
    tank_level->add_sample(CurveInterpolator::Sample(300., 1));
  }

I'm not completely happy about how the curves are defined; creating a data structure for that is a lot of work, and the way I did it above feels like manual labor...

ruedigerO commented 2 years ago

Thanks for the code snippet- I changed my code like this and got it working. Before - I tried to implement it like the example in the old (SensESP v1.x) version. That didn't work.

Maybe a little more documentation about this nice feature would be helpful.

mairas commented 2 years ago

Maybe a little more documentation about this nice feature would be helpful.

Yes, I'd love that! Could you write some?

ruedigerO commented 2 years ago

I don’t think that’s a good idea, cause I am a beginner in programming C++ and a lousily writer :-(

Am 18.02.2022 um 13:32 schrieb Matti Airas @.***>:

Maybe a little more documentation about this nice feature would be helpful.

Yes, I'd love that! Could you write some?

— Reply to this email directly, view it on GitHub https://github.com/SignalK/SensESP/issues/566#issuecomment-1044451466, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALJXZSGOPBPJE5VPTI5KHOTU3Y36DANCNFSM5OOMOZJA. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you modified the open/close state.