From 7c8c1d204d326198bc9d1cae1371428e4a23f56e Mon Sep 17 00:00:00 2001 From: Victor Le Roch Date: Tue, 12 May 2020 11:22:59 +0200 Subject: [PATCH] Decouverte simu quest 3 --- .DS_Store | Bin 0 -> 8196 bytes board.cpp | 5 ++++- compile_mac.sh | 3 +++ mydevices.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- mydevices.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ sketch_ino.cpp | 16 +++++++++++++--- 6 files changed, 116 insertions(+), 5 deletions(-) create mode 100644 .DS_Store create mode 100755 compile_mac.sh diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..4327633fe5c56e9f108eeab86e3e8a5786b53b48 GIT binary patch literal 8196 zcmeHMU2GIp6u#e5V5SUoT9GaV-6a)Lp+XA?1%Yh0rBW%OvW2#QmffA99hse}JF{D$ zmJ~JqCmIb#6BX3>qKUx>F+4ybQA2o8iA{)zK7olZylDDjf}Xi|w)BS*pA3Y#$=vVW zbIv_;&zbMe-8;(|Lp-O|G8SfxNpyLr&Ym8 z83-~EWFW{ukbxirw@U_S&-RKm$-XbNK^dRYOglv~>FV`ouQWY;wtlQ$yQRLj zXVkX=v3Nr)&Nim{oL=AWxm2%dIBreNMTDjlO`SGfl8U9`nZ-{edhEW0n{;zdJel3) z^;(l|Ps(q%*|s^-PNsGkdS911yTP{Hq+#h zyVUaj{)cL+qpMaAR7d-3m)ESSj;^k)85oeI@`bhQoA+c69PEE);Ltl1Hx>A=B32^$ zBlWw~;<1g*XY1=Dawp#)Vh$ZI#C)j`vs^qwnHk>Hyy-EerNcC-_cc~=~h22cu z)~ueV5ZlwXnafyCms*-mn(3UGboF}E^o&VX;-s^-X|~#q;TpEp+2QK@-GZYrs*atG zopl?yvo2N5Ir=u8d>MJYkvx*CGVg9%dp$SK4n6A-R>o>Xu<~cK%I7awxOmyhH5(d+ zO4QP_duA)jPD-lf8hZ^ryS>lQ+@8*)lh!TGu)5pxhGV2mz0FEy^irIX<)N}twIm#_ zm?ueUWk)V$Je@P#16-QoD{60UlX1|-`Y z$^xIxl4>Q~wvV2=>d2B9sw`h2$*Q*9Or~_x7p<-%(dPEN2+tR;TQA9_sP3RIS{aJR z;bKLpkIS-p?n&?7ElJ1S+N)bPX4ND~ot~y%({xR$EKs5{RwbG|ZdvtqyZhK8R>xwj zjqPPNJIr2VN7)H>nw??i*-z{@c7YvXhSDb=!Su(un#VB$YVba;YGZJm+>mz!h3ihAK*iLiZ5{jC-D`&!w>io7w`)% z<0`J(S?hbuBcld zA9?2E9`hI`j;0@HoS+n^TY*aac@Kr>R?M5P+#lIaMAY}+SPf!z6xM_~-J_ettrsYj zib|Y3C-d&2NR^_3mV)RmiBv_@kR(i(MQRmw3b9`3Rw}C^>Qo}QG&HYbZaA`5Stk+s z)gta_gA$9V(}?Rrt28Q2bkkF^$|fc2Evb5eU1EQ*VT3T9$XSL8qGuJBq7EC-giUBh z3$|bfI*6RRup2rNw8tlC9(_d6!*~wQ;{~GW8+emQdIWFdD30MHe2h=T>y%yZAj&f0{-p} #include "core_simulation.h" +int luminosite_environnement = 200; + // exemple de capteur analogique de temperature, ne pas oublier d'heriter de Device class AnalogSensorTemperature: public Device { @@ -25,6 +27,25 @@ public: virtual void run(); }; + +class AnalogSensorLuminosity: public Device{ +private: + int temps; + int val; + //static int luminosite_environnement; +public: + //static int luminosite_environnement; + AnalogSensorLuminosity(int t); + virtual void run(); +}; + + + + + + + + // exemple d'actionneur digital : une led, ne pas oublier d'heriter de Device class DigitalActuatorLED: public Device { private: @@ -40,6 +61,25 @@ public: virtual void run(); }; + + +class IntelligentDigitalActuatorLED: public Device{ + private: + // etat de la LED + int state; + // temps entre 2 affichage de l etat de la led + int temps; + + public: + // initialisation du temps de rafraichiisement + IntelligentDigitalActuatorLED(int t); + // thread representant l'actionneur et permettant de fonctionner independamment de la board + virtual void run(); + }; + + + + // exemple d'actionneur sur le bus I2C permettant d'echanger des tableaux de caracteres : un ecran, ne pas oublier d'heriter de Device class I2CActuatorScreen : public Device{ protected: @@ -53,4 +93,12 @@ public: virtual void run(); }; + + + +//class ExternalDigitalSensorButton: public Device + + + + #endif diff --git a/sketch_ino.cpp b/sketch_ino.cpp index f8147cb..fef0877 100644 --- a/sketch_ino.cpp +++ b/sketch_ino.cpp @@ -8,24 +8,34 @@ void Board::setup(){ // on fixe les pin en entree et en sorite en fonction des capteurs/actionneurs mis sur la carte pinMode(1,INPUT); pinMode(0,OUTPUT); + pinMode(2,INPUT); } // la boucle de controle arduino void Board::loop(){ char buf[100]; int val; + int val1; static int cpt=0; static int bascule=0; int i=0; for(i=0;i<10;i++){ // lecture sur la pin 1 : capteur de temperature - val=analogRead(1); - sprintf(buf,"temperature %d",val); + val1=analogRead(1); + sprintf(buf,"temperature %d",val1); Serial.println(buf); + + // lecture sur la pin 2 : capteur de temperature + val=analogRead(2); + sprintf(buf,"luminosite %d",val); + Serial.println(buf); + if(cpt%5==0){ // tous les 5 fois on affiche sur l ecran la temperature - sprintf(buf,"%d",val); + sprintf(buf,"%d",val1); bus.write(1,buf,100); + + } cpt++; sleep(1);