-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlightcontrol.php
30 lines (24 loc) · 895 Bytes
/
lightcontrol.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
// Author: Andrew Afonso
// Description: A simple controller that sets the colors on a GPIO controlled LED strip on a RasPi
// https://github.com/andrewbluepiano/SignPi/
// Remove the pound from the hexidecimal value passed in
$colorHex = str_replace('#', '', $_POST['lightcolor']);
$brightness = intval($_POST['brightness']);
// If a full hexidecimal value
if(strlen($colorHex) == 6){
// Split the values into their sub RGB values
$rgb_array = str_split($colorHex, 2);
// Convert from hesidecimal values to RGB values, but also invert the values because... pigpio
$red = 255 - hexdec($rgb_array[0]);
$green = 255 - hexdec($rgb_array[1]);
$blue = 255 - hexdec($rgb_array[2]);
shell_exec("pigs p 14 " . $red);
shell_exec("pigs p 4 " . $blue);
shell_exec("pigs p 24 " . $green);
}
if($brightness < 226){
shell_exec("pigs p 7 " . $brightness);
}
header('Location: ../');
?>