Skip to main content

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 FileNotFoundError if the hidraw device for the touchscreen could not be found
  • the setBrightness() method may raise an IOError if 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

waveshare-ws170120-brightness-1.0.0.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

waveshare_ws170120_brightness-1.0.0-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file waveshare-ws170120-brightness-1.0.0.tar.gz.

File metadata

File hashes

Hashes for waveshare-ws170120-brightness-1.0.0.tar.gz
Algorithm Hash digest
SHA256 45587fe57d7661a564699c9894d27bbf70a674512b951a18df44b680ee0c13e7
MD5 677284744e232d96cc5e957821688fa1
BLAKE2b-256 14d9bfc51b4316a9952ba47ef3d9cb53965da630d211d8241e82119b58c4acda

See more details on using hashes here.

File details

Details for the file waveshare_ws170120_brightness-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for waveshare_ws170120_brightness-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 62ec70400ebe6fd731082970af2235d28915aaa65bcf6448bca1207c715786fb
MD5 3aad362808ce61a870fe3aeda81519f7
BLAKE2b-256 f0116a1b9d9b10523082d10ab3e956237d98a873cd4a1162a138819b801f950f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page