2 Ревизии

Автор SHA1 Съобщение Дата
  Thomas B 95a0fb91c0 extended readme преди 3 месеца
  Thomas B 6bd3442aa1 write display values every 5s to influx and ignore ddc errors. преди 3 месеца
променени са 2 файла, в които са добавени 46 реда и са изтрити 10 реда
  1. 36
    0
      README.md
  2. 10
    10
      client/brightness.py

+ 36
- 0
README.md Целия файл

@@ -1,6 +1,42 @@
1 1
 # AutoBrightness
2 2
 
3
+Simple solution to measure ambient room lighting conditions with an AtTiny85 based USB lux sensor and set external display backlight intensity accordingly via DDC/CI.
3 4
 
5
+See [this blog post for details](https://www.xythobuz.de/auto_brightness.html).
6
+
7
+## Sensor
8
+
9
+Uses a [Digispark Rev. 3 clone](https://www.az-delivery.de/en/products/digispark-board) with a [GY-302 BH1750 breakout board](https://www.az-delivery.de/en/products/gy-302-bh1750-lichtsensor-lichtstaerke-modul-fuer-arduino-und-raspberry-pi) connected to the I2C bus.
10
+
11
+[![Front of PCB](https://www.xythobuz.de/img/autobrightness_pcb_1_small.jpg)](https://www.xythobuz.de/img/autobrightness_pcb_1.jpg)
12
+[![Back of PCB](https://www.xythobuz.de/img/autobrightness_pcb_2_small.jpg)](https://www.xythobuz.de/img/autobrightness_pcb_2.jpg)
13
+
14
+### Quick Start
15
+
16
+Check out the repo and required submodules.
17
+
18
+    git clone https://git.xythobuz.de/thomas/AutoBrightness.git
19
+    cd AutoBrightness
20
+    git submodule update --init
21
+
22
+Build the firmware and upload it.
23
+
24
+    make -C sensor upload
25
+
26
+Prepare udev rules for our new device.
27
+
28
+    sudo cp sensor/49-autobrightness.rules /etc/udev/rules.d/49-autobrightness.rules
29
+    sudo udevadm control --reload-rules
30
+    sudo udevadm trigger
31
+
32
+## Client
33
+
34
+### Quick Start
35
+
36
+Install dependency and run the client.
37
+
38
+    yay -S python-pyusb
39
+    ./client/brightness.py
4 40
 
5 41
 ## License
6 42
 

+ 10
- 10
client/brightness.py Целия файл

@@ -5,7 +5,7 @@ import ddc
5 5
 import time
6 6
 import influx
7 7
 
8
-filter_fact = 0.9
8
+filter_fact = 0.99
9 9
 
10 10
 c_in = 0.6, -30.0, # in_a, in_b
11 11
 calibration = {
@@ -78,6 +78,10 @@ if __name__ == "__main__":
78 78
 
79 79
             try:
80 80
                 influx.write("brightness,location=pc-back", "lux", brightness)
81
+
82
+                for d in disps:
83
+                    name = '_'.join(d["name"].split())
84
+                    influx.write("brightness,location=" + name, "backlight", d["prev"])
81 85
             except:
82 86
                 pass
83 87
 
@@ -88,13 +92,9 @@ if __name__ == "__main__":
88 92
             for d in disps:
89 93
                 val = lux_to_disp(d["name"], brightness)
90 94
                 if val != d["prev"]:
91
-                    d["prev"] = val
92
-                    print("{}: Setting \"{}\" to {}".format(time.ctime(), d["name"], val))
93
-                    ddc.ddc_set(d["_id"], val)
94
-
95 95
                     try:
96
-                        name = '_'.join(d["name"].split())
97
-                        influx.write("brightness,location=" + name, "backlight", val)
98
-                    except:
99
-                        pass
100
-
96
+                        print("{}: Setting \"{}\" to {}".format(time.ctime(), d["name"], val))
97
+                        ddc.ddc_set(d["_id"], val)
98
+                        d["prev"] = val
99
+                    except Exception as e:
100
+                        print(e)

Loading…
Отказ
Запис