logo elektroda
logo elektroda
X
logo elektroda

OpenBeken Charts Driver - configurable and flexible measurement history on your device

p.kaczmarek2 4875 65
ADVERTISEMENT
📢 Listen (AI):
  • #61 21261598
    max4elektroda
    Level 20  
    jkwim wrote:
    One issue that I found when the chart is working is that the bottom part of the screen cannot be kept without scrolling back to chart window.

    Yes, I see what you mean.
    We will need to change the "redrawing". Actually the chart is destroyed and a new instance is created.
    I think I already have a solution, will open an PR soon and post it here.
    In my test I could change this to "update" the chart, which doesn't seem to refocus to the chart.

    Added after 1 [hours] 29 [minutes]:

    Please try the builds from PR #1389.
    For this does redrawing w/o setting the focus on the chart ...

    Web page with line chart and navigation buttons.
  • ADVERTISEMENT
  • #62 21261957
    jkwim
    Level 12  
    Will give it a try
    Thanks

    Added after 11 [hours] 32 [minutes]:

    Upgraded to OpenBK7231T_App_1389_merge_b1e0d8dd960f.

    It works fine now.

    Thanks for your quick update.
  • ADVERTISEMENT
  • #63 21262367
    max4elektroda
    Level 20  
    Thanks for your feedback!

    @p.kaczmarek2: Just found a nasty little "bug" with charts: When setting things, we don't care for the indexes, so the device might crash on wrong input.

    Windows emulator e.g. will crash if you define a single value graph
    chart_create 96 1 1 and later do
    chart_addNow 10 20. Same will happen, if you later call
    chart_setVar 1 "XX" "YY"

    We should check for "<=numVars" or "<=numAxes" before setting them.

    I would propose to do this in the "calling commands" (CMD_Chart_SetAxis/CMD_Chart_SetVar/CMD_Chart_AddNow/CMD_Chart_Add) and mayby, just to be sure, also in the code actually doing the settings (Chart_SetAxis/Chart_SetVar/Chart_SetSample).

    Open is the question, what to do in this case when adding samples?
    Only taking as much samples as defined or reject the whole command?
  • ADVERTISEMENT
  • #64 21262676
    p.kaczmarek2
    Moderator Smart Home
    Nice find, I'd just return out of command with INVALID_ARG return code (or how was this enumeration called in Obk)...
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #65 21263018
    max4elektroda
    Level 20  
    I extend PR #1389 to take care of this, too.

    I took this one because I would also merge the change to use update() for the charts.

    It was not so evident to me when I focussed on the charts, that every refresh used to set the focus on the chart, which is annoying if you scrolled down to the buttons and the browser switches back all the time.

    Some tests would be great, now the update should not move the view of the page and all input should be checked against the charts properties.
    So if you could try if it's intercepting all kinds of "false" input that would be great.

    Add names for non-existent axes or vars, setting more samples than defined ...

    I hope it's stable regarding this now.
  • #66 21440659
    Zogdan
    Level 9  
    Checked on ESP32C3 and works fine.

    Just a suggestion : Could it be an idea to include a DIFF option?
    I would like to see the difference with the last added value in the chart (eg for energy consumption)

    Thinking loud : It could work a bit like this.

    mydiffvar = chart_getVar 0 -1
    would mean : mydiffvar is always the previous value of chart var 0
    this would allow to add that to the chart, publish it to mqtt or whatever.

    mydiffvar = chart_getVar 0 -2 would be 2 hops back in time

    So suppose the chart series is this :

    t | 500
    t-1 | 450
    t-2 | 300

    then


    | Var0 | chart_getVar 0 -1 | chart_getVar 0 -2
    t | 500 | 50 | 200
    t-1 | 450 | 150 | null
    t-2 | 300 | null | null
📢 Listen (AI):

Topic summary

The OpenBeken firmware introduces a configurable and scriptable charts driver enabling visualization of multiple variables with multiple axes directly on supported devices without requiring Home Assistant. The driver supports platforms based on BK7231T, BK7231N, BK7231M, T34, BL2028N, XR809, W800, LN882H, BL602, and others. Users configure charts via commands such as chart_create, chart_setVar, chart_setAxis, and addRepeatingEvent to plot variables like temperature, humidity, voltage, and power. Initial issues included crashes due to missing null checks in chart_setVar and chart_setAxis before chart_create, heap corruption from uninitialized memory, and platform-specific bugs such as vsnprintf handling null pointers. These were addressed through patches adding null checks, memory zeroing, and input validation to prevent crashes on invalid indexes. The charts driver was integrated with a ring buffer for data storage, with ongoing improvements to reduce flickering by updating charts instead of recreating them, and repositioning the chart below the "state" div to avoid page scroll jumps. Users reported stable long-term operation on various devices, including W600 and BL602, with some platform-specific driver enablement required in obk_config.h and Makefiles. The Windows simulator supports testing charts, facilitating development. Suggestions for future enhancements include adding a DIFF function to compute differences between consecutive samples. The driver supports variable expansion (e.g., $voltage*0.1) if ENABLE_EXPAND_CONSTANT is enabled. Sample configurations and troubleshooting tips were shared, including manual command sequences to generate pseudo-random data for testing. The charts driver is now considered production-ready with ongoing refinements and cross-platform support.
Summary generated by the language model.
ADVERTISEMENT