Control the brightness of an Waveshare WS170120 touch-screen.
Project description
WaveShare WS170120 Brightness
Table of Contents
Intro
A simple python pip module and script in order to control the backlight of a WaveShare WS170120 touchscreen. The tools provided by Waveshare are binary only and are only able to set the brightness in steps of 10%, while the hardware supports steps of 1%.
The project has been generated from some simple USB capturing. The protocol is easy enough, see USB-Protocol
Installation
pip
pip install waveshare-ws170120-brightness
or
git clone https://github.com/rotdrop/waveshare-ws170120-brightness.git
pip install ./waveshare-ws170120-brightness
or directly from github
pip install waveshare-ws170120-brightness@git+https://github.com/rotdrop/waveshare-ws170120-brightness.git
pipx
This generates an isolated virtual environment and installes the bundled script waveshare-ws170120-brightness.
pipx install waveshare-ws170120-brightness
or
git clone https://github.com/rotdrop/waveshare-ws170120-brightness.git
pipx install ./waveshare-ws170120-brightness
or directly from github
pipx install waveshare-ws170120-brightness@git+https://github.com/rotdrop/waveshare-ws170120-brightness.git
Manually
Clone the repository, install the requirements (see requirements.txt). The python script is located in init.py.
Usage
Python Module
from waveshare_ws170120_brightness import WaveshareWS170120
...
backlightController = WaveshareWS170120(verbosity=1)
backlichtController.setBrightness(percentage=47)
The class constructor as well as the setBrightness() method will raise exceptions if something goes wrong.
- the constructor will raise a
FileNotFoundErrorif the hidraw device for the touchscreen could not be found - the
setBrightness()method may raise anIOErrorif writing to the hidraw device gave unexpected results
In addition, the called system services may raise their own errors. These are not caught in the program code.
Standalone Script
The corresponding executable just has the same name as the package, waveshare-ws170120-brightness. Please run
waveshare-ws170120-brightness -h
for usage information. Currently, this generates the output
usage: waveshare-ws170120-brightness [-h] -b PERCENTAGE [-v]
Set the brightness of an attached Waveshare WS170120 touch-screen
options:
-h, --help show this help message and exit
-b PERCENTAGE, --brightness PERCENTAGE
set the brightness value to the given percentage.
-v, --verbose
However, that may change ...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters