Forum
  • Search
  • Member List
  • Calendar
Hello There, Guest! Login Register — Login with Facebook

[IDEA] [Tut] How to turn off Backlight of a Waveshare 7" HDMI LCD using GPIO and screensaver
Thank you for your donation

Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Threaded Mode | Linear Mode
Idea: [Tut] How to turn off Backlight of a Waveshare 7" HDMI LCD using GPIO and screensaver
3rd Feb, 2017, 08:54 AM
Post: #1
Lucatze Offline
Registered
Posts: 3
Joined: Dec 2012
Reputation: 2
Lightbulb [Tut] How to turn off Backlight of a Waveshare 7" HDMI LCD using GPIO and screensaver
Hello partypeople,

i wanna show you how to easily turn off your Waveshares Backlight by using Kodis screensaver function and bring it back on with the power of a touch/key Wink
You can also use this to just "dim" the backlight.

Waveshares are cheap, so they are missing some crucial functions like "standby" mode. Luckily, they have a Backligt On / Off switch that is going to be very useful for us.

We need:
  • Raspi running recent Xbian
  • LCD that allows us to easily control its backlight circuit
  • A relais or similar circuit we can trigger using GPIOs
  • Basic knowledge of using a text editor / ssh
  • Basic knowledge of soldering and electronics

Installation:

1. Running Xbian on Raspi, with working LCD and maybe touch input

2. We need Software! pip will help us to install RPi.GPIO library

Terminal
kodi stop
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install python-dev gcc python-pip
sudo pip install RPi.GPIO

3. We have to add this group to grant python access to the GPIO pins, as Kodi addons have no root privileges. Than, add user Xbian to the group gpio.

Terminal
sudo addgroup gpio
sudo adduser xbian gpio

4. In order to turn on the display during boot, we need to create a script.

Terminal
nano /home/xbian/TurnDisplayOn.py

and paste following lines:

Code:
import RPi.GPIO as GPIO

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(07, GPIO.OUT)

GPIO.output(07, GPIO.LOW)

5. We have to update the GPIOs device ownership during boot, because the system will reset it on startup. We need to call our TurnOnDisplay.py script as well.

Terminal
sudo nano /etc/rc.local

Paste these three lines BEFORE exit 0

Code:
chown root.gpio /dev/gpiomem
chmod g+rw /dev/gpiomem
python /home/xbian/TurnDisplayOn.py

6. Now we need to install the screensaver addon that will help us to do the trick. In Kodi go to:
System > Add-Ons> Kodi Add-on repository > Look and feel > Screensaver > I used "Unary Clock Screensaver"

7. Back in terminal, we need to place our GPIO code within the add-on. If you are using another screensaver, the correct places will vary.

Terminal
nano ~/.kodi/addons/screensaver.unaryclock/resources/lib/gui.py

Add this line right after the other imports

Code:
import RPi.GPIO as GPIO

Scroll down and search for self.log("Screensaver starting") . Add these three lines after it and make sure to maintain the indentation:

Code:
GPIO.setmode(GPIO.BOARD)
GPIO.setup(07, GPIO.OUT)
GPIO.output(07, GPIO.HIGH)

Scroll down and look for self.log('Exit requested') and place this line under it:

Code:
GPIO.output(07, GPIO.LOW)

Save and exit the file.

8. The file we just edited is the actual screensaver script Kodi calls.. In order to be able to control the GPIOs without being root, we have to add it to the GPIOs group.

Terminal
sudo chown xbian:gpio ~/.kodi/addons/screensaver.unaryclock/resources/lib/gui.py

9. Back in Kodi go to:
System > Apperance > Screensaver > Screensaver Mode > Choose "Unary Clock Screensaver" > Set the desired time

10. Shutdown your Rasperry Pi

11. Connect the control circuit to the raspberry. In my case, i'm using a Saintsmart 2 Relais Module.
In our code, Pin 7 (GPIO 4) will control the relais. I connected mine like this:

Relais > Raspi
VCC > 5V PWR
GND > GND
IN1 > Pin 7 (GPIO 4)



12. Let's solder two wires to the Waveshares Backlight Switch...



13. and connect it to the relais.


Click here for a bigger picture

14. Fire up your raspi and wait for the screensaver to kick in... Wink
Notice: When you boot up, it can take up to 20 seconds before the backlight turns on.

Hope it works out for you Smile
Feel free to comment and improve the tutorial.





[Some thoughts]

Poti for Display dimming
You can add a poti or resistor to dimm your display. Be aware: The poti WILL turn warm/hot. This is not a very efficient way. Consider using a poti with a transistor or whatever you feel comfy with. The "hot" poti works for me. The potis value should be 200 or 500 Ohm. The 50k poti in the picture was the last one i had and works.... quite fragile Big Grin So value above represents max brightness to mostly off. A 100 Ohm one might work as wll.

Find all posts by this user
Quote this message in a reply
« Next Oldest | Next Newest »
Post Reply 


Messages In This Thread
[Tut] How to turn off Backlight of a Waveshare 7" HDMI LCD using GPIO and screensaver - Lucatze - 3rd Feb, 2017 08:54 AM
RE: [Tut] How to turn off Backlight of a Waveshare 7" HDMI LCD using GPIO and screensaver - rikardo1979 - 3rd Feb, 2017, 05:23 PM
RE: [Tut] How to turn off Backlight of a Waveshare 7" HDMI LCD using GPIO and screensaver - f1vefour - 8th Feb, 2017, 08:25 AM
RE: [Tut] How to turn off Backlight of a Waveshare 7" HDMI LCD using GPIO and screensaver - Lucatze - 8th Feb, 2017, 09:02 AM
RE: [Tut] How to turn off Backlight of a Waveshare 7" HDMI LCD using GPIO and screensaver - tridy - 10th Mar, 2017, 09:24 PM
RE: [Tut] How to turn off Backlight of a Waveshare 7" HDMI LCD using GPIO and screensaver - Yaodgelo - 7th Oct, 2017, 05:52 AM
RE: [Tut] How to turn off Backlight of a Waveshare 7" HDMI LCD using GPIO and screensaver - tmat256 - 18th Oct, 2017, 10:45 AM
RE: [Tut] How to turn off Backlight of a Waveshare 7" HDMI LCD using GPIO and screensaver - Desy166 - 20th Nov, 2017, 10:25 PM
RE: [Tut] How to turn off Backlight of a Waveshare 7" HDMI LCD using GPIO and screensaver - lpt2007 - 5th Jul, 2018, 08:15 AM
Review - johnsonberry - 21st Sep, 2018, 08:47 PM
[Tut] How to turn off Backlight of a Waveshare 7" HDMI LCD using GPIO and screensaver - newto - 10th Oct, 2018, 11:02 PM
RE: [Tut] How to turn off Backlight of a Waveshare 7" HDMI LCD using GPIO and screensaver - Skywatch - 11th Oct, 2018, 05:41 PM
RE: [Tut] How to turn off Backlight of a Waveshare 7" HDMI LCD using GPIO and screensaver - Nachteule - 11th Oct, 2018, 10:05 PM
RE: [Tut] How to turn off Backlight of a Waveshare 7" HDMI LCD using GPIO and screensaver - hoeb - 5th Jan, 2019, 07:26 AM
RE: [Tut] How to turn off Backlight of a Waveshare 7" HDMI LCD using GPIO and screensaver - Fistandantilus - 31st Mar, 2019, 11:22 PM
RE: [Tut] How to turn off Backlight of a Waveshare 7" HDMI LCD using GPIO and screensaver - Fistandantilus - 3rd Apr, 2019, 05:22 AM
RE: [Tut] new lcd MPI7006 - fox_ - 29th Oct, 2021, 07:13 PM
RE: [Tut] How to turn off Backlight of a Waveshare 7" HDMI LCD using GPIO and screensaver - charlotte - 27th Nov, 2024, 08:26 PM

  • View a Printable Version
  • Send this Thread to a Friend
  • Subscribe to this thread
Forum Jump:

Current time: 1st Jun, 2025, 07:12 PM Powered By MyBB, © 2002-2025 MyBB Group.