Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
plante-qui-pleure
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Puissegur Alexis
plante-qui-pleure
Commits
4b777d02
Commit
4b777d02
authored
6 years ago
by
Puissegur Alexis
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of
https://gitlab.insa-rennes.fr/alex/plante-qui-pleure
parents
fc08b2a4
3717fc19
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/thingz.ino.txt
+20
-2
20 additions, 2 deletions
core/thingz.ino.txt
thingz.ino.txt
+0
-126
0 additions, 126 deletions
thingz.ino.txt
with
20 additions
and
128 deletions
core/thingz.ino.txt
+
20
−
2
View file @
4b777d02
...
...
@@ -6,9 +6,11 @@
#include "Bluetooth.h"
#include "Son.h"
#include "Potentiometer.h"
#include "MotionSensor.h"
#define SPAN 3000
#define HEADER_LIGHT_ON "LIGHT"
#define HEADER_SOUND_ON "SOUND"
#define HEADER_PLANT_OK "STOP"
#define REMAINING_TIME 300000 // 5MIN
#define DATASPAN 10000 // 5MIN
#define ALARMSPAN 10000 // 10SEC
...
...
@@ -40,6 +42,7 @@ Luminosite luminosite;
Potentiometer pot;
Son buzzer;
Bluetooth bluetooth;
MotionSensor motion;
int humi;
int lumi;
...
...
@@ -49,6 +52,7 @@ int dataTimeStamp;
unsigned long timeStamp;
boolean ledHasBeenTurnedOn;
boolean alarmHasBeenTurnedOn;
boolean plantInNeed;
unsigned long timePushed;
unsigned long alarmTimeStamp;
unsigned long lightTimeStamp;
...
...
@@ -63,7 +67,11 @@ void updateSensors(){
void display(){
monEcran1.setContrast(70, false);
updateSensors();
monEcran1.printMsg("CRYING PLANT !",0);
if(plantInNeed){
monEcran1.printMsg("CRYING PLANT !",0);
} else {
monEcran1.printMsg("PLANT IS OK !",0);
}
monEcran1.printMsg(((String)"TEMP : ") + temp,2);
monEcran1.printMsg(((String)"HUMI : ") + humi,3);
monEcran1.printMsg(((String)"LUMI : ") + lumi,4);
...
...
@@ -96,9 +104,13 @@ void receiveFromBluetooth() {
monEcran1.printMsg(buffer,0);
if (buffer.startsWith(HEADER_LIGHT_ON)){
dealWithLight();
plantInNeed = true;
}
else if (buffer.startsWith(HEADER_SOUND_ON)){
dealWithSound();
plantInNeed = true;
} else if(buffer.startsWith(HEADER_PLANT_OK)) {
plantInNeed = false;
}
}
...
...
@@ -132,6 +144,7 @@ void setup()
timeStamp = 0;
ledHasBeenTurnedOn = false;
alarmHasBeenTurnedOn = false;
plantInNeed = false;
timePushed = 0;
alarmTimeStamp = 0;
dataTimeStamp = 0;
...
...
@@ -180,7 +193,12 @@ if(millis() - timePushed < REMAINING_TIME){
ledHasBeenTurnedOn = false;
maLed1.eteint();
}
}
}
if(plantInNeed && motion.detectsStartOfMotion()){
dealWithSound();
dealWithLight();
}
}
This diff is collapsed.
Click to expand it.
thingz.ino.txt
deleted
100644 → 0
+
0
−
126
View file @
fc08b2a4
#include "Bouton.h"
#include "Led.h"
#include "Meteo.h"
#include "Screen.h"
#include "Luminosite.h"
#include "Bluetooth.h"
#include "Son.h"
#define SPAN 3000
#define HEADER_LIGHT_ON "LIGHT"
#define HEADER_SOUND_ON "SOUND"
#define REMAINING_TIME 10000
#define FAb4 740
#define LAb4 932
/*
Thingz prend ses mesures et envoie les donnes l'appli java (toutes les 5mins par ex)
l'appli java est une IHM configurable qui :
affiche les donnes en temps rel sur des graphiques
sait s'il faut arroser la plante ou non
envoie un mail au prof si besoin pour arroser
envoie via bluetooth si arrosage possible ou urgent et si en semaine ou weekend
son plus ou moins long
Messages bluetooth :
LIGHT;
SOUND;WEEKEND
SOUND;SEMAINE
*/
Bouton monBouton1;
Led maLed1;
Meteo meteo;
Screen monEcran1;
Bluetooth bluetooth;
Luminosite luminosite;
Son buzzer;
int humi;
int lumi;
int temp;
unsigned long timeStamp;
boolean ledHasToBeTurnedOn;
unsigned long timePushed;
unsigned long alarmTimeStamp;
void setup()
{
temp = 0;
lumi = 0;
humi = 0;
timeStamp = 0;
ledHasToBeTurnedOn = false;
timePushed = 0;
alarmTimeStamp = 0;
}
void updateSensors(){
temp = meteo.temperature();
lumi = luminosite.etat();
humi = meteo.getHumidity();
}
void display(){
monEcran1.setContrast(70, false);
updateSensors();
monEcran1.printMsg("CRYING PLANT !",0);
monEcran1.printMsg(((String)"TEMP : ") + temp,2);
monEcran1.printMsg(((String)"HUMI : ") + humi,3);
monEcran1.printMsg(((String)"LUMI : ") + lumi,4);
}
void sendBluetoothDataToServer(){
}
void dealWithSound(String data){
if(0){ // on weekend then water
} else { // on weekday then trigger the alarm for 5min
alarmTimeStamp = millis();
}
}
void receiveFromBluetooth() {
String buffer;
if (bluetooth.dataAvailable()){
buffer = bluetooth.receive();
}
if (buffer.startsWith(HEADER_LIGHT_ON)){
// DO NOTHING YET
}
else if (buffer.startsWith(HEADER_SOUND_ON)){
dealWithSound(buffer); // change
}
}
void fireAlarm(){
buzzer.tone(FAb4,600);
buzzer.tone(LAb4,200);
}
void loop()
{
if(millis() - timePushed < REMAINING_TIME){
if(millis() - timeStamp > SPAN){
timeStamp = millis();
display();
}
} else {
monEcran1.clear();
monEcran1.setContrast(0, false);
}
if (monBouton1.estTenuAppuye()) {
timePushed = millis();
maLed1.inverse();
}
if(millis() - alarmTimeStamp < REMAINING_TIME && millis() > REMAINING_TIME){
fireAlarm();
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment