Commit 11668b90eaed706ee40db6641aae2b4f50e13117
1 parent
81f31317
MAJ
Showing
7 changed files
with
84 additions
and
55 deletions
Show diff stats
site/add.php
@@ -23,9 +23,9 @@ session_start(); | @@ -23,9 +23,9 @@ session_start(); | ||
23 | <?php | 23 | <?php |
24 | if(add($_POST['nom'], $_POST['type'], $_POST['raspberry'], $_POST['unite'], $_POST['version'])) | 24 | if(add($_POST['nom'], $_POST['type'], $_POST['raspberry'], $_POST['unite'], $_POST['version'])) |
25 | { | 25 | { |
26 | - $arduino_simple = "[Arduino_init]\r\n"; | ||
27 | - $arduino_spi = "[Arduino_init]\r\n"; | ||
28 | - $nucleo = "[Nucleo_init]\r\n"; | 26 | + $arduino_simple = "[arduino_Setup]\r\n"; |
27 | + $arduino_spi = "[arduino_Setup]\r\n"; | ||
28 | + $nucleo = "[nucleo_Setup]\r\n"; | ||
29 | 29 | ||
30 | $setup = getSetup($_POST['raspberry']); | 30 | $setup = getSetup($_POST['raspberry']); |
31 | 31 |
site/reception.php
@@ -7,9 +7,9 @@ require("erreurs.php"); | @@ -7,9 +7,9 @@ require("erreurs.php"); | ||
7 | if(isset($_POST['sensor'])) | 7 | if(isset($_POST['sensor'])) |
8 | { | 8 | { |
9 | $ini = ""; | 9 | $ini = ""; |
10 | - $arduino_simple = "[Arduino]\r\n"; | ||
11 | - $arduino_spi = "[Arduino]\r\n"; | ||
12 | - $nucleo = "[Nucleo]\r\n"; | 10 | + $arduino_simple = "[arduino]\r\n"; |
11 | + $arduino_spi = "[arduino]\r\n"; | ||
12 | + $nucleo = "[nucleo]\r\n"; | ||
13 | 13 | ||
14 | $a_simple = false; | 14 | $a_simple = false; |
15 | $a_spi = false; | 15 | $a_spi = false; |
site/remove.php
@@ -27,9 +27,9 @@ session_start(); | @@ -27,9 +27,9 @@ session_start(); | ||
27 | $version = getVersion($nom); | 27 | $version = getVersion($nom); |
28 | if(remove($nom)) | 28 | if(remove($nom)) |
29 | { | 29 | { |
30 | - $arduino_simple = "[Arduino]\r\n"; | ||
31 | - $arduino_spi = "[Arduino]\r\n"; | ||
32 | - $nucleo = "[Nucleo]\r\n"; | 30 | + $arduino_simple = "[arduino]\r\n"; |
31 | + $arduino_spi = "[arduino]\r\n"; | ||
32 | + $nucleo = "[nucleo]\r\n"; | ||
33 | 33 | ||
34 | if($version == 0) | 34 | if($version == 0) |
35 | { | 35 | { |
site/removeRpi.php
@@ -24,9 +24,9 @@ session_start(); | @@ -24,9 +24,9 @@ session_start(); | ||
24 | $capteurs = getSensorByRaspberry($_POST['ip']); | 24 | $capteurs = getSensorByRaspberry($_POST['ip']); |
25 | 25 | ||
26 | $ini = ""; | 26 | $ini = ""; |
27 | - $arduino_simple = "[Arduino]\r\n"; | ||
28 | - $arduino_spi = "[Arduino]\r\n"; | ||
29 | - $nucleo = "[Nucleo]\r\n"; | 27 | + $arduino_simple = "[arduino]\r\n"; |
28 | + $arduino_spi = "[arduino]\r\n"; | ||
29 | + $nucleo = "[nucleo]\r\n"; | ||
30 | 30 | ||
31 | $a_simple = false; | 31 | $a_simple = false; |
32 | $a_spi = false; | 32 | $a_spi = false; |
site/stop.php
@@ -2,9 +2,9 @@ | @@ -2,9 +2,9 @@ | ||
2 | require_once("accesBase.php"); | 2 | require_once("accesBase.php"); |
3 | require("erreurs.php"); | 3 | require("erreurs.php"); |
4 | 4 | ||
5 | -$arduino_simple = "[Arduino]\r\n"; | ||
6 | -$arduino_spi = "[Arduino]\r\n"; | ||
7 | -$nucleo = "[Nucleo]\r\n"; | 5 | +$arduino_simple = "[arduino]\r\n"; |
6 | +$arduino_spi = "[arduino]\r\n"; | ||
7 | +$nucleo = "[nucleo]\r\n"; | ||
8 | 8 | ||
9 | $version = getVersion($_POST['nom']); | 9 | $version = getVersion($_POST['nom']); |
10 | 10 |
site/upload/inventaire.ini
site/upload/main.c
1 | -#include <avr/io.h> // for the input/output register | ||
2 | -#include <avr/interrupt.h> | ||
3 | -#include <util/delay.h> | 1 | +#include <avr/io.h> |
2 | +#include <avr/interrupt.h> | ||
3 | +#include <util/delay.h> | ||
4 | #include <string.h> | 4 | #include <string.h> |
5 | -#include <stdio.h> | ||
6 | #include <stdlib.h> | 5 | #include <stdlib.h> |
6 | +#include <stdio.h> | ||
7 | + | ||
8 | +//#ifndef RETOUR_H_ | ||
9 | +//#define RETOUR_H_ | ||
7 | 10 | ||
8 | #include "retour.h" | 11 | #include "retour.h" |
9 | 12 | ||
13 | +//#endif | ||
10 | #define PRESCALER 1024 | 14 | #define PRESCALER 1024 |
11 | #define TIME_SLOT 20 | 15 | #define TIME_SLOT 20 |
12 | #define BAUDRATE 103 | 16 | #define BAUDRATE 103 |
13 | 17 | ||
14 | -#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) | ||
15 | -#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) | ||
16 | - | ||
17 | -char Donnee[24]; | ||
18 | -float temp; | ||
19 | - | ||
20 | -// équivalent de analogueRead() | ||
21 | -int analogReadNew(uint8_t pin) { | ||
22 | - //Selection de la fréquence du prescaler | ||
23 | - ADCSRA |= (1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0); | ||
24 | - //Définition de la référence de tension | ||
25 | - ADMUX |= (1<<REFS0)|(1<<ADLAR); | ||
26 | - //Sélection de l'entrée analogique selon le pin | ||
27 | - ADMUX = (ADMUX&0xf0)|pin; | ||
28 | - //Activation de l'ADC | ||
29 | - ADCSRA |= (1<<ADEN); | ||
30 | - //Lancement de la conversion | ||
31 | - ADCSRA |= (1<<ADSC); | ||
32 | - //On attend la fin de la conversion | ||
33 | - while(bit_is_set(ADCSRA, ADSC)); | ||
34 | - //Résultat | ||
35 | - return ADCH; | 18 | +static volatile int pulse = 0; |
19 | +static volatile int i = 0; | ||
20 | + | ||
21 | + | ||
22 | +////////////////////////////////////////////// | ||
23 | + | ||
24 | +ISR(INT0_vect){ | ||
25 | + //i=1 indique l'écho HIGH | ||
26 | + if(i == 1) | ||
27 | + { | ||
28 | + //On arrête le timer | ||
29 | + TCCR1B = 0; | ||
30 | + //On stocke la valeur précédente du timer (l'aller-retour) | ||
31 | + pulse = TCNT1; | ||
32 | + //On reset la valeur de TCNT1 et de i à Zero | ||
33 | + TCNT1 = 0; | ||
34 | + i = 0; | ||
35 | + } | ||
36 | + | ||
37 | + //i=0 indique l'écho à LOW | ||
38 | + if(i==0) | ||
39 | + { | ||
40 | + //On set le bit CS10 à HIGH, debut du timer qui compte | ||
41 | + TCCR1B |= (1<<CS10); | ||
42 | + i = 1; | ||
43 | + } | ||
36 | } | 44 | } |
37 | 45 | ||
38 | -int main() | ||
39 | -{ | ||
40 | - int reading; | ||
41 | - init_serial(); | ||
42 | - while(1){ | ||
43 | - reading=analogReadNew(0); | ||
44 | - temp = reading * 1.9607843; | ||
45 | - dtostrf(temp, 4, 1, Donnee); | ||
46 | - //send_serial('T'); | 46 | + |
47 | +int main(void){ | ||
48 | + init_serial(); | ||
49 | + int16_t count_a = 0; | ||
50 | + char show_a[16]; | ||
51 | + //Trigger = PIND0 et ECHO = PIND2 | ||
52 | + DDRD = 0b11111011; | ||
53 | + _delay_ms(50); | ||
54 | + //Selection INT0 | ||
55 | + EIMSK |= (1<<INT0); | ||
56 | + //Interruption sur changement logique | ||
57 | + EICRA = 0x01; | ||
58 | + sei(); | ||
59 | + | ||
60 | + while(1) | ||
61 | + { | ||
62 | + //TRIGGER HIGH | ||
63 | + PORTD |= 1<<PIND0; | ||
64 | + //Durée de l'impulsion TRIGGER | ||
65 | + _delay_us(15); | ||
66 | + //TRIGGER LOW | ||
67 | + PORTD &= ~(1<<PIND0); | ||
68 | + //On calcule la distance en cm : pulse/(58/2/10) (en cm) | ||
69 | + count_a = pulse/1160.0; | ||
70 | + | ||
71 | + itoa(count_a,show_a,10); | ||
72 | + //dtostrf(count_a, 5,2, show_a); | ||
73 | + sprintf(show_a, "%d", count_a); | ||
74 | + //send_serial('D'); | ||
47 | //send_serial('='); | 75 | //send_serial('='); |
48 | //RETOUR | 76 | //RETOUR |
49 | - retour(Donnee); | ||
50 | - _delay_ms(2000); | ||
51 | - } | ||
52 | - return 0; | 77 | + retour(show_a); |
78 | + _delay_ms(1000); | ||
79 | + | ||
80 | + } | ||
81 | + return 0; | ||
53 | } | 82 | } |