New pi kernel
This commit is contained in:
parent
a2b430f5e1
commit
87e092e028
2
Makefile
2
Makefile
@ -1,7 +1,7 @@
|
|||||||
all:
|
all:
|
||||||
gcc -Wall -O2 -o TSL2561.o -c TSL2561.c
|
gcc -Wall -O2 -o TSL2561.o -c TSL2561.c
|
||||||
gcc -Wall -O2 -o motion.o -c motion.c
|
gcc -Wall -O2 -o motion.o -c motion.c
|
||||||
gcc -Wall -O2 -o motion -l wiringPi -l curl TSL2561.o motion.o
|
gcc -Wall -O2 -o motion TSL2561.o motion.o -l curl -l wiringPi
|
||||||
make clean
|
make clean
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
19
motion.c
19
motion.c
@ -8,7 +8,7 @@
|
|||||||
#include "TSL2561.h"
|
#include "TSL2561.h"
|
||||||
|
|
||||||
#define MOTION_PIN 0
|
#define MOTION_PIN 0
|
||||||
#define SECONDS_TO_OFF 5*60
|
#define SECONDS_TO_OFF 5
|
||||||
|
|
||||||
int pin_read = 0;
|
int pin_read = 0;
|
||||||
int state = 1;
|
int state = 1;
|
||||||
@ -47,7 +47,7 @@ void light_control_script(int turn_on) {
|
|||||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_output);
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_output);
|
||||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 0L);
|
curl_easy_setopt(curl, CURLOPT_VERBOSE, 0L);
|
||||||
struct curl_slist *chunk = NULL;
|
struct curl_slist *chunk = NULL;
|
||||||
chunk = curl_slist_append(chunk, "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIwYzBjYzMzOWZmOGQ0NjBiYmJiYzI3NjA2M2U1MjhjNCIsImlhdCI6MTYwMzcxMDAzMywiZXhwIjoxOTE5MDcwMDMzfQ.HSnBiBNG6x6b1AAgh6AEAUALj4uSWfv-y-YS7QrNve0");
|
chunk = curl_slist_append(chunk, "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIyNDdkMTIxOGY5YmM0MTQ0ODcxYjE2YzRlNzYxNmE2NSIsImlhdCI6MTY0MTI1MTU1OSwiZXhwIjoxOTU2NjExNTU5fQ.OXI80PmYRgGS1HdI7a2cp3jJi-t3c-AQd7Et3CgYqZQ");
|
||||||
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk);
|
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk);
|
||||||
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 1L);
|
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 1L);
|
||||||
|
|
||||||
@ -94,8 +94,7 @@ int main(){
|
|||||||
counter += 1;
|
counter += 1;
|
||||||
if(counter >= SECONDS_TO_OFF*2){
|
if(counter >= SECONDS_TO_OFF*2){
|
||||||
printf("Turning off\n");
|
printf("Turning off\n");
|
||||||
//system("tvservice -o");
|
system("xrandr --output HDMI-1 --off");
|
||||||
system("vcgencmd display_power 0");
|
|
||||||
light_control_script(0);
|
light_control_script(0);
|
||||||
state = 0;
|
state = 0;
|
||||||
}
|
}
|
||||||
@ -105,20 +104,12 @@ int main(){
|
|||||||
|
|
||||||
if(!state && pin_read){
|
if(!state && pin_read){
|
||||||
printf("Turning on\n");
|
printf("Turning on\n");
|
||||||
system("vcgencmd display_power 1");
|
system("xrandr --output HDMI-1 --auto");
|
||||||
|
|
||||||
if(read_light_level(&light_sensor) < 10) {
|
if(read_light_level(&light_sensor) < 10) {
|
||||||
light_control_script(1);
|
light_control_script(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//system("tvservice -p");
|
|
||||||
//system("fbset -depth 8");
|
|
||||||
//usleep(50*1000);
|
|
||||||
//system("fbset -depth 16");
|
|
||||||
//usleep(50*1000);
|
|
||||||
//system("fbset -depth 24");
|
|
||||||
//usleep(50*1000);
|
|
||||||
//system("fbset -depth 32");
|
|
||||||
state = 1;
|
state = 1;
|
||||||
}
|
}
|
||||||
counter = 0;
|
counter = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user