Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional configuration for brightness sensor #217

Merged
merged 1 commit into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@
* Linking the webinterface to your smartphones homescreen provides an app-like usage of the interface
* Hardware buttons are not mandatory anymore.
* Integration to your instance of [home-assistant](https://www.home-assistant.io/) using [this repository](https://github.com/bk1285/rpi_wordclock_for_homeassistant/)
* Support for a brightness sensor (TSL2561)

### ⏳ In progress
* Integration of a brightness sensor

### :books: Further reading
* Exemplary builds are available at [pinterest](https://www.pinterest.de/berndkrolla/wordclock-gallery/)
* [Roadmap](https://github.com/bk1285/rpi_wordclock/projects)
Expand Down Expand Up @@ -77,11 +75,12 @@ Install adafruit-circuitpython-tsl2561 lib
sudo pip3 install adafruit-circuitpython-tsl2561
```

Set use_brightness_sensor config value to true
Set use_brightness_sensor config value to true and its address
```
# Set the brightness of the display (between 1 and 255)
brightness = 200
use_brightness_sensor = True
sensor_address = 0x39
```

#### Cronjob
Expand Down
3 changes: 3 additions & 0 deletions wordclock_config/wordclock_config.reference.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ default_font = wcfont

# Set the brightness of the display (between 1 and 255)
brightness = 255
# Supported sensor: TSL2561
use_brightness_sensor = False
# Sensor I2C address in decimal: 41 (0x29), 57 (0x39), 73 (0x49)
sensor_address = 57

[wordclock_interface]
# Defines type of interface (gpio_low: pin is set to low on event, gpio_high: pin is set to high on event, no_gpio: no pins are read at all (= disabled hardware buttons))
Expand Down
3 changes: 2 additions & 1 deletion wordclock_plugins/time_default/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def __init__(self, config):
self.brightness_change = 8

self.use_brightness_sensor = config.getboolean('wordclock_display', 'use_brightness_sensor')
self.brightness_sensor_address = config.getint('wordclock_display', 'sensor_address')

print(('Using brigtness sensor : ' + str(self.use_brightness_sensor)))
if self.use_brightness_sensor:
Expand All @@ -127,7 +128,7 @@ def __init__(self, config):
import busio
import adafruit_tsl2561
i2c = busio.I2C(board.SCL, board.SDA)
self.sensor = adafruit_tsl2561.TSL2561(i2c)
self.sensor = adafruit_tsl2561.TSL2561(i2c,self.brightness_sensor_address)
# save current brightness for switching back from sleep mode
self.wake_brightness = self.brightness_mode_pos

Expand Down