Register / Login  |  Desktop view  |  Jump to bottom of page

tcMenu Arduinio library » Update LCD display only when "Menu" is inactive

Author: jacobez
21/03/2021 15:33:16
Hi Dave,
Thanks for the library & assistance you provide to all.

I am new to this library and have spent quite a bit of time on trying to understand it, but am missing something.
I have an Arduino Mega, 20x4 LCD on i2C and 3 buttons with pull-up logic and some menu items running. I've also implemented the eeprom storage and it all works well.

The menu now displays and I've been able to take over the display and show display some system parameters from sensors on the LCD on the display as explained in the "takeOverDisplay" example. My challenge is that when I schedule the "Display Sensors function" that should update the display only when the menu is inactivated, the display is distorted with a mix of the sensor display and the menu.

How do I test if the menu is active and ensure that the "Display Sensors function" does not run while the menu is open?

Thanks in advance for your assistance.
Regards,
Jaco

Author: davetcc
22/03/2021 08:46:40
 
My challenge is that when I schedule the "Display Sensors function" that should update the display only when the menu is inactivated, the display is distorted with a mix of the sensor display and the menu.


It sounds like you're updating the display outside of the rendering callback. You must never draw to the display outside of that callback because you'd otherwise risk multiple commands being sent to the LCD at once.

How do I test if the menu is active and ensure that the "Display Sensors function" does not run while the menu is open?


The best way to do that is invert the logic, put all the drawing code for this only in the take over display callback, and the sensor function just stores this state into a variable somewhere (that would then be read by your drawing code).

Author: jacobez
22/03/2021 15:02:00
Thanks Dave, I understand and shall try accordingly.




Register / Login  |  Desktop view  |  Jump to top of page