Freeplaytech Forum
Program to control TFT Backlight 'sleep mode' with juj/fbcp-ili9341 driver - Printable Version

+- Freeplaytech Forum (https://forum.freeplaytech.com)
+-- Forum: Freeplay Zero / Freeplay CM3 / Game Pie Advance (https://forum.freeplaytech.com/forumdisplay.php?fid=24)
+--- Forum: Freeplay Zero/CM3 (AKA GPA) Software (https://forum.freeplaytech.com/forumdisplay.php?fid=26)
+--- Thread: Program to control TFT Backlight 'sleep mode' with juj/fbcp-ili9341 driver (/showthread.php?tid=4716)



Program to control TFT Backlight 'sleep mode' with juj/fbcp-ili9341 driver - Porcinus - 12-16-2018

This programs is design to work aside of Freeplay setPCA9633 on Raspberry Pi 3 on Freeplay Zero/CM3 platform (with installed backlight control).
It also require to have juj fbcp-ili9341 driver running with backlight control and backlight pin set.


# Provided scripts :
- compile.sh : Compile cpp file (run this first).
- install.sh : Install service (need restart)
- remove.sh : Remove service

GitHub :  https://github.com/porcinus/FreeplayBacklightDaemon

Driver compilation cmd : cmake -DFREEPLAYTECH_WAVESHARE32B=ON -DSPI_BUS_CLOCK_DIVISOR=6 -DDISPLAY_BREAK_ASPECT_RATIO_WHEN_SCALING=ON -DBACKLIGHT_CONTROL=ON -DGPIO_TFT_BACKLIGHT=31 -DSTATISTICS=0 ..

Please note: This line use gpio pin 31, I don't think it's in use but not sure...
Don't miss to edit nns-freeplay-backlight-daemon.service set path and pin correctly.

Todo/ideas:
- [DONE] Monitor evdev, need more work to ignore analog input (workaround for noisy line)
- [ABORT] go in sleep mode if no input detected, wrong idea if some want to watch a movie...
- [DONE] Look around pthread to avoid use of system()

pthread version look stable, reduce cpu load by around 2-3 time but 'huge' increase in memory usage. There is 2 child threads (gpio, evdev), 8mb heap for each.


RE: Program to control TFT Backlight 'sleep mode' with juj/fbcp-ili9341 driver - Flavor - 12-18-2018

Once again, this is quite awesome. At some point, I would like to add this (at least as an option) in the Freeplay CM3/Zero SD image. Would you have any problem with that?


RE: Program to control TFT Backlight 'sleep mode' with juj/fbcp-ili9341 driver - Porcinus - 12-18-2018

Thanks Smile
No problem at all Wink

Please note that sleep and wake are together based on gpio, no inputs events whatsoever.
I don't have any way to check how the program behave on Zero, so if you can check on your side Smile

GPIO_TFT_BACKLIGHT can only be 0-31 for reason I don't understand, if you have another pin pin in this range that will never be in use, i will be glad to update the git as well Wink



Edit:
If you want, I will take a look on evdev monitoring, a simple 'cat' may do the tick, but I am going to be really busy in next days.
Updated service file for autorestart on crash.


RE: Program to control TFT Backlight 'sleep mode' with juj/fbcp-ili9341 driver - Porcinus - 12-19-2018

If you can want a bit, I missed a 'security', in current code, there is no check if file use to return to wake brightness does not exist. Will add this maybe the afternoon Smile


RE: Program to control TFT Backlight 'sleep mode' with juj/fbcp-ili9341 driver - Flavor - 12-20-2018

To be honest, Porcinus, I have been really busy with several other things lately. I have not had a chance to work on software much lately. If you wanted to look at the evdev stuff, that'd be awesome. If you had an easy way to install this into a working/running Freeplay CM3 image, that'd be even better. Then, I could make a new image with your mods and test it. If things seem fine, then maybe that should be in our next SD image. Any help I could get in making that go smooth would be really appreciated. I'd try to support that however we can.


RE: Program to control TFT Backlight 'sleep mode' with juj/fbcp-ili9341 driver - Porcinus - 12-20-2018

Right now, Backlight and Overlay programs fully work in my current setup.

You just have to clone git and run 'compile.sh' to build binary, Overlay require libgd-dev, libpng-dev, zlib1g-dev, libfreetype6-dev, ffmpeg and omxplayer.

-To install Overlay, please refer to 'service/install.txt', to use hotkey in addon board set pin to 41, for power switch set pin to 20 and add argument ' -reverselogic'.

-To install Backlight:
Compile juj fbcp-ili9341 driver with backlight control enable:
git clone https://github.com/juj/fbcp-ili9341.git
cd fbcp-ili9341
mkdir build
cd build
cmake -DARMV8A=ON -DFREEPLAYTECH_WAVESHARE32B=ON -DSPI_BUS_CLOCK_DIVISOR=6 -DDISPLAY_BREAK_ASPECT_RATIO_WHEN_SCALING=ON -DUSE_DMA_TRANSFERS=ON -DBACKLIGHT_CONTROL=ON -DGPIO_TFT_BACKLIGHT=31 -DSTATISTICS=0 ..
make -j
sudo ./fbcp-ili9341

Then edit path in 'nns-freeplay-backlight-daemon.service' and run 'install.sh'

Should work as is Smile