Hi there FreeRTOS team!
I’ve a working FreeRTOS application on ESP32. All my tasks are triggered only by notifications. They do their job and go back to sleep until an event triggers them. The most frequent event is a user rotatory encoder input. Every time the user moves left/right or up/down, the encoder sends a notification to the UI task to print the menu.
My problem here is that I’m using a global flag to keep count of the encoder value. When the UI task prints the menu, the task resets the encoder value to 0. Then, the user will start scrolling again from the 0th option and everyone is happy.
I would like to not use a global variable for this. I know I can use a mutex and use the encoder value as a shared resource, but I have several other similar scenarios where this is happening, so the complexity of several mutexes all around the code seems difficult to handle.
I’m doing this in ESP32, so atomic operations seem to be part of the answer here but I’m not sure.
I arrived at a FreeRTOS architecture decision that I don’t feel comfortable solving myself, and I’m not even sure how to put the right question into text, so I would appreciate the help navigating this decision
EDIT
I think part of this problem is that I know the UI task will finish printing the display way before the user can rotate the encoder again, so I know the encoder value won’t be updated in between. Its like “I’m done using this encoder value, its your turn”. I suppose this is a physical implementation rather than a FreeRTOS implementation?
Thanks a lot in advance