Giter VIP home page Giter VIP logo

rpi-auto-backlight's Introduction

rpi-auto-backlight

A Python service for automatically adjusting the brightness of the official Raspberry Pi 7" touch display based on the signal received from an external brightness sensor.

Requirements

Installation

  1. Clone the project repository
git clone https://github.com/dquercus/rpi-auto-backlight.git
  1. Install python dependencies for the project
sudo apt-get install python3-pip python3-rpi.gpio
sudo pip3 install rpi-backlight
  1. Create this udev rule to update permissions, otherwise you'll have to run the service as root:
echo 'SUBSYSTEM=="backlight",RUN+="/bin/chmod 666 /sys/class/backlight/%k/brightness /sys/class/backlight/%k/bl_power"' | sudo tee -a /etc/udev/rules.d/backlight-permissions.rules
  1. Create service user with access to the GPIO ports
adduser --system --no-create-home autobacklight
sudo usermod -a -G gpio autobacklight
  1. Deploy script and register service
cd rpi-auto-backlight
sudo cp rpi-auto-backlight-gpio.py /usr/local/bin/
sudo chmod +x /usr/local/bin/rpi-auto-backlight-gpio.py
sudo cp rpi-auto-backlight-gpio.service /etc/systemd/system/
sudo chmod 777 /etc/systemd/system/rpi-auto-backlight-gpio.service
  1. Adjust and then copy configuration file /etc/auto_backlight.cfg
cd rpi-auto-backlight
sudo cp auto_backlight.cfg /etc/auto_backlight.cfg 
  1. Enable service so its executed on boot
sudo systemctl daemon-reload
sudo systemctl enable rpi-auto-backlight-gpio.service

Configuration

The script supports the following configuration options via configuration file:

Variable Description Default value
RPI_PORT GPIO port for light digital signal 7
DARK_BRIGHTNESS Brightness level when no light detected 5
LIGHT_BRIGHTNESS Brightness level when light detected 90
LOOP_PAUSE Indicates how ofter the system checks for a new value in the GPIO port 2

Configuration file can by changed using system variable AUTO_BRIGHTNESS_CONFIG_FILE to point to a different path.

Acknowledgements

Thanks to torfsen/python-systemd-tutorial for the instructions for running a python script as daemon using systemd.

rpi-auto-backlight's People

Contributors

dquercus avatar knothed avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.