New pi kernel

This commit is contained in:
Daniel Kluge 2022-10-31 14:01:29 +01:00
parent a2b430f5e1
commit 87e092e028
3 changed files with 10 additions and 15 deletions

View File

@ -1,7 +1,7 @@
all:
gcc -Wall -O2 -o TSL2561.o -c TSL2561.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
clean:

View File

@ -8,7 +8,7 @@
#include "TSL2561.h"
#define MOTION_PIN 0
#define SECONDS_TO_OFF 5*60
#define SECONDS_TO_OFF 5
int pin_read = 0;
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_VERBOSE, 0L);
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_TIMEOUT, 1L);
@ -94,8 +94,7 @@ int main(){
counter += 1;
if(counter >= SECONDS_TO_OFF*2){
printf("Turning off\n");
//system("tvservice -o");
system("vcgencmd display_power 0");
system("xrandr --output HDMI-1 --off");
light_control_script(0);
state = 0;
}
@ -105,20 +104,12 @@ int main(){
if(!state && pin_read){
printf("Turning on\n");
system("vcgencmd display_power 1");
system("xrandr --output HDMI-1 --auto");
if(read_light_level(&light_sensor) < 10) {
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;
}
counter = 0;

4
start.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
export DISPLAY=:0.0
/home/pi/motion/motion