Thomas Buck 7 роки тому
джерело
коміт
d493c5b73e
Аккаунт користувача з таким Email не знайдено
5 змінених файлів з 133 додано та 0 видалено
  1. 2
    0
      .gitignore
  2. 25
    0
      COPYING
  3. 4
    0
      DisplayBacklight/AppDelegate.m
  4. 22
    0
      README.md
  5. 80
    0
      epilepsy.sh

+ 2
- 0
.gitignore Переглянути файл

@@ -1,2 +1,4 @@
1 1
 .DS_Store
2 2
 DisplayBacklight.xcodeproj/project.xcworkspace/xcuserdata
3
+Icon

4
+

+ 25
- 0
COPYING Переглянути файл

@@ -0,0 +1,25 @@
1
+Copyright (c) 2017, Thomas Buck
2
+All rights reserved.
3
+
4
+Redistribution and use in source and binary forms, with or without
5
+modification, are permitted provided that the following conditions
6
+are met:
7
+
8
+ - Redistributions of source code must retain the above copyright notice,
9
+   this list of conditions and the following disclaimer.
10
+
11
+ - Redistributions in binary form must reproduce the above copyright
12
+   notice, this list of conditions and the following disclaimer in the
13
+   documentation and/or other materials provided with the distribution.
14
+
15
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
19
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ 4
- 0
DisplayBacklight/AppDelegate.m Переглянути файл

@@ -100,6 +100,10 @@ struct LEDStrand strands[] = {
100 100
 // If this is defined it will print the FPS every DEBUG_PRINT_FPS seconds
101 101
 //#define DEBUG_PRINT_FPS 10
102 102
 
103
+// When grabbing screenshots the resulting picture will not have any color filtering
104
+// effects applied, as is the case when using software like f.lux that makes the colors
105
+// warmer at night. So I've added the algorithm to 'warm up' the colors myself. Set
106
+// the target temperature in Kelvin here, it should be the same as in f.lux.
103 107
 // ToDo Change color-temperature depending on time of day to match f.lux adjustments
104 108
 #define TARGET_COLOR_TEMPERATURE 2800.0
105 109
 

+ 22
- 0
README.md Переглянути файл

@@ -0,0 +1,22 @@
1
+# DisplayBacklight
2
+
3
+DisplayBacklight is an Ambilight-clone made with an Arduino controlled by a macOS machine.
4
+
5
+## Hardware
6
+
7
+The software currently only supports driving RGB-LEDs with the colors from the edge of a screen, so you have to place an RGB LED strip on the outer edges of your computer monitors. Multiple screens are supported using a single LED strip for all of them.
8
+
9
+You need an LED strip with individually addressable LEDs like the popular [WS2812 RGB LED strips](https://www.sparkfun.com/products/12025). The data line is connected to pin 2 of the Arduino. The [Adafruit Neo-Pixel library](https://github.com/adafruit/Adafruit_NeoPixel) is used to control the LEDs.
10
+
11
+## Protocol
12
+
13
+The color data is transmitted using the serial port and the USB-UART converter built into most Arduinos. Communication happens at 115200bps, the LED count is hardcoded in both firmware and host software. First, a magic string, also hardcoded, is sent, followed by 3 bytes containing Red, Green and Blue, for each LED. When the last byte has been received the whole strip is refreshed at once.
14
+
15
+## Software
16
+
17
+The macOS host software is opening the connection to the serial port, grabbing a screenshot, processing the edges to calculate each LED color and finally sending it to the device.
18
+
19
+## License
20
+
21
+DisplayBacklight itself is made by Thomas Buck <xythobuz@xythobuz.de> and released under a BSD 2-Clause License. See the accompanying COPYING file.
22
+

+ 80
- 0
epilepsy.sh Переглянути файл

@@ -0,0 +1,80 @@
1
+#!/bin/bash
2
+
3
+# The serialHelper115200 file is my own SerialHelper Utility compiled
4
+# with 115200 baud. Get it from here:
5
+# https://github.com/xythobuz/SerialHelper
6
+
7
+DATA_FILE=led_data_file
8
+
9
+if [ $# -ne 6 ]; then
10
+    echo "Usage: two times three hex bytes for color"
11
+    echo "$0 r1 g1 b1 r2 g2 b2"
12
+    exit
13
+fi
14
+
15
+PORTFILE=`ls /dev/tty.wchusbserial* | head -n 1`
16
+echo "Using $PORTFILE as serial port..."
17
+
18
+echo "WARNING: This is toggling the LEDs very fast between your two colors!"
19
+echo "The name epilepsy is no joke. Be careful."
20
+read -p "Press ENTER to continue..."
21
+
22
+echo "Opening serial port..."
23
+serialHelper115200 -rw $PORTFILE >/dev/null 2>/dev/null &
24
+TERM_PID=$!
25
+echo "PID is $TERM_PID"
26
+
27
+echo "Waiting for Arduino to be ready..."
28
+sleep 3
29
+
30
+echo
31
+
32
+for i in `seq 1 20`; do
33
+
34
+    echo "Preparing data to send..."
35
+    echo -n "xythobuzRGBled" > $DATA_FILE
36
+    for i in {1..156}; do
37
+        echo -n -e "\x$1\x$2\x$3" >> $DATA_FILE
38
+    done
39
+
40
+    echo "Sending data..."
41
+    cat $DATA_FILE > $PORTFILE
42
+
43
+    echo "Waiting for data to appear..."
44
+    sleep 0.05
45
+
46
+    echo
47
+
48
+    echo "Preparing data to send..."
49
+    echo -n "xythobuzRGBled" > $DATA_FILE
50
+    for i in {1..156}; do
51
+        echo -n -e "\x$4\x$5\x$6" >> $DATA_FILE
52
+    done
53
+
54
+    echo "Sending data..."
55
+    cat $DATA_FILE > $PORTFILE
56
+
57
+    echo "Waiting for data to appear..."
58
+    sleep 0.05
59
+
60
+    echo
61
+done
62
+
63
+echo "Preparing data to send..."
64
+echo -n "xythobuzRGBled" > $DATA_FILE
65
+for i in {1..156}; do
66
+    echo -n -e "\x00\x00\x00" >> $DATA_FILE
67
+done
68
+
69
+echo "Sending data..."
70
+cat $DATA_FILE > $PORTFILE
71
+
72
+echo "Waiting for data to appear..."
73
+sleep 0.1
74
+
75
+echo "Closing serial port..."
76
+kill $TERM_PID
77
+
78
+echo "Deleting created data file..."
79
+rm -rf $DATA_FILE
80
+

Завантаження…
Відмінити
Зберегти