Program to control TFT Backlight 'sleep mode' with juj/fbcp-ili9341 driver
#1
Lightbulb 
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.
Reply
#2
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?
Card Fighters' Clash 2 English Translation ( http://cfc2english.blogspot.com/ )
Neo Geo Pocket Flash Cart and Linker Project ( http://www.flashmasta.com/ )
Avatar art thanks to Trev-Mun ( http://trevmun.deviantart.com/ )
Reply
#3
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.
Reply
#4
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
Reply
#5
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.
Card Fighters' Clash 2 English Translation ( http://cfc2english.blogspot.com/ )
Neo Geo Pocket Flash Cart and Linker Project ( http://www.flashmasta.com/ )
Avatar art thanks to Trev-Mun ( http://trevmun.deviantart.com/ )
Reply
#6
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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)