Previously I spent some time setting up my wonderful new LilyGo T-Display Keyboard functions, mainly to control my music server, similar to its pre-decessors. It has a lot more potential and I have been starting to add features.
Screen Saver
As Lily works on battery when not connected to USB there is a limited amount of time before it needs to be recharged. It is sensible to turn off the screen when not in use. The factory_Test sketch which was provided with Lily shows how to turn the display off and put ESP32 into deep sleep mode
The first two commands DISPOFF and SLPIN blank Lilies LCD display and turn off power to the LCD. I struggled to find documentation for these commands. In fact they are well-documented in the ST7899V datasheet which corresponds to the LCD. I can turn the screen back on with DISPON and SLPOUT commands.
So now I need to setup a proper screen saver. It should wait until Lily has been inactive for a short while, say a minute and power down the screen. When a key is pressed the screen should be powered on, allowing the user to continue.
I need a timer function to do this. There are generic Arduino timer libraries but it is better to use the ESP32 timer function. We set up a timer with an alarm so that the screen blanks after 10 seconds (during testing, 1 minute for real use). If the user presses a key either before or after the screen blanks the timer is reset and the screen is restored so they can continue.
This works very well, keyboard input is still possible when the screen is off so there is no delay in waiting for Lily to wakeup. I have added some menus for favorite albums, radio stations and chart playlists so it is useful to have the screen on for this. For some of the other functions I dont usually need the screen.
No comments:
Post a Comment