Tying arc value to an external pin count input

Never mind, I got it. Probably not the best or easiest way to do it, but it actually works pretty good. I found a couple of examples that, between them, did what I wanted, so I was able to combine them and get something that works. And after hours of modifying and tweaking lots of code, it’s making a bit more sense.

Sorry for a such a noob question, but this is pretty confusing (for something seemingly so simple).
I’m trying to build an interface to several systems on an RV. I want to display the value of water used.
I have a 4" CYD, everything works. I can count pulses, the arc on the display works (displays and changes via touchscreen).
But I want to tie it’s value to the pulse counter.
The only real relevant bits of code are, I have an input pin, drives an interrupt handler, which increments a pulse count.
I know I need to tie an observer for the arc to that pulse count, but just not sure how to get there. (or, at least I think that’s what I need)

The examples are confusing, because everything is “self contained”, nothing is tied to an external input, only the screen. And (at least to me), the examples on binding and observers, looks like several ways to do “something” in the same program snippet.

And none of the searches I tried provided anything of much relevance, not sure how to even phrase the search input.

(an idea, (and more work for the mods) would be putting common working answers to common noobie questions like this in their own topic to make it easier to search though)

Hi!

I would say observers and subjects is one good way to do it.

Just take care to not call lvgl functions from outside it’s loop or thread. And specially do not call it from inside an ISR.

I would update a global variable from the ISR in a safe way probably using portENTER_CRITICAL_ISR and portEXIT_CRITICAL_ISR

Then in LVGL side I would create a timer callback function that reads from that global variable from time to time (also in a safe way) and updates a subject.

And the an observer callback function that reads the subject and updates the arc, or bind the arc value directly to the subject.

Thanks for that information.
What ever I’m doing, A) I’m sure is wrong, and B) is breaking it.
The ISR only sets a flag. So I can operate on it if and when I choose to. Then it would call a routine that updates the value. I figured that binding the value would work the best, I’m not sure how to actually “create” that binding.
That part seems to be working the way I’m doing it. That part makes sense. But when I do the button change (color or text) the same basic way, it doesn’t work, that doesn’t make sense.
As I posted in the other thread, it’s the LVGL demo from Random Nerds heart rate monitor. The scale works just like I wanted, so…

This is what I’m doing.
Build the screen and loop.
On ISR, set a flag.
In loop, check the flag,
if set, increment/decrement a water flow counter
in loop, call routine that updates arc value and needle if changed.

The heart rate (water flow) value updates fine. But when I add a couple of buttons, and try to use them, I get null pointer issues. The part driving me crazy is, as far as I can tell, I’m doing the same thing, the same way they did it.
I’m sure I’m doing something I’m not supposed to be, or doing it at the wrong point in the program. So I’m going to tear it down to bare bones and try a few examples from the LVGL doc and see if I can’t figure it out. I know I’m missing something basic, just not sure what (or where as the case may be).
I worked out the issue of apparently trying to update the screen while LVGL was apparently doing the same.
But it looks like changing/operating on, the button in the call back is the wrong way to do it.
Like I also said, I’m learning more from it being broken, than I am from it working, so,