Kalyax 2 years ago
parent
commit
9f6f890453
  1. 5
      api/set_light.php
  2. 4
      api/temp.php
  3. 5
      scripts/get_temp.sh
  4. 3
      scripts/led.sh
  5. 1
      scripts/toto
  6. 0
      start_dev.sh
  7. 5
      test.php
  8. 1
      toto

5
api/set_light.php

@ -1,5 +1,6 @@
<?php <?php
$light = $_POST["light"]; $light = $_POST["light"];
$output = shell_exec('bash ../scripts/led.sh '.$light); $output = null;
echo $output exec('bash ../scripts/led.sh '.$light, $output);
var_dump($output);
?> ?>

4
api/temp.php

@ -1,4 +1,4 @@
<?php <?php
$output = shell_exec('bash ../scripts/temp.sh'); $output = shell_exec('bash ../scripts/get_temp.sh');
echo $output echo $output
?> ?>

5
scripts/get_temp.sh

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
response=`i2cget -y 1 0x18 0x05 w` response=`/usr/sbin/i2cget -y 1 0x18 0x05 w`
upper_byte=$(($response & 0x00FF)) upper_byte=$(($response & 0x00FF))
lower_byte=$(($response & 0xFF00)) lower_byte=$(($response & 0xFF00))
let "sign=0" let "sign=0"
@ -13,5 +13,4 @@ else
upper_byte=$((upper_byte & 0x0F)) upper_byte=$((upper_byte & 0x0F))
let "temperature = ($upper_byte*100 * 16 + $lower_byte*100 / 4096)" let "temperature = ($upper_byte*100 * 16 + $lower_byte*100 / 4096)"
fi fi
# printf %.2f "$(($temperature))e-2" printf %.2f "$(($temperature))e-2"
echo $temperature > toto;

3
scripts/led.sh

@ -1,7 +1,8 @@
#!/bin/bash #!/bin/bash
echo $1
gpio mode $1 out gpio mode $1 out
let "out=`gpio read $1`" let "out=`gpio read $1`"
echo $out
if [ $out = 1 ] if [ $out = 1 ]
then then
gpio write $1 0 gpio write $1 0

1
scripts/toto

@ -0,0 +1 @@
0

0
start_dev.sh

5
test.php

@ -0,0 +1,5 @@
<?php
$out = null;
exec("scripts/get_temp.sh", $out);
var_dump($out);
?>

1
toto

@ -0,0 +1 @@
0
Loading…
Cancel
Save