I2C reorganisation delete devices.cpp on est des genies
This commit is contained in:
parent
a38774d31f
commit
8600c09ba2
10 changed files with 77 additions and 68 deletions
5
OtherDevices/I2CDevices/Keyboard.cpp
Normal file
5
OtherDevices/I2CDevices/Keyboard.cpp
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
//
|
||||||
|
// Created by camer on 22/05/2020.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "../../include/I2CDevices/Keyboard.h"
|
21
OtherDevices/I2CDevices/Screen.cpp
Normal file
21
OtherDevices/I2CDevices/Screen.cpp
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
//
|
||||||
|
// Created by camer on 22/05/2020.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "../../include/I2CDevices/Screen.h"
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// classe I2CActuatorScreen
|
||||||
|
Screen::Screen ():Device(){}
|
||||||
|
|
||||||
|
void Screen::run(){
|
||||||
|
while(1){
|
||||||
|
if ( (i2cbus!=NULL)&&!(i2cbus->isEmptyRegister(i2caddr))){
|
||||||
|
Device::i2cbus->requestFrom(i2caddr, buf, I2C_BUFFER_SIZE);
|
||||||
|
cout << "---screen :"<< buf << endl;
|
||||||
|
}
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,4 @@
|
||||||
#include "core_simulation.h"
|
#include "core_simulation.h"
|
||||||
#include "mydevices.h"
|
|
||||||
#include "include/AnalogDevices/AnalogSensors/AnalogSensorTemperature.h"
|
#include "include/AnalogDevices/AnalogSensors/AnalogSensorTemperature.h"
|
||||||
#include "include/DigitalDevices/DigitalActuators/IntelligentDigitalActuatorLED.h"
|
#include "include/DigitalDevices/DigitalActuators/IntelligentDigitalActuatorLED.h"
|
||||||
#include "include/AnalogDevices/AnalogSensors/AnalogSensorLuminosity.h"
|
#include "include/AnalogDevices/AnalogSensors/AnalogSensorLuminosity.h"
|
||||||
|
@ -7,6 +6,7 @@
|
||||||
#include "include/AnalogDevices/AnalogSensors/AnalogSensorManometre.h"
|
#include "include/AnalogDevices/AnalogSensors/AnalogSensorManometre.h"
|
||||||
#include "include/DigitalDevices/DigitalActuators/DigitalActuatorRadiator.h"
|
#include "include/DigitalDevices/DigitalActuators/DigitalActuatorRadiator.h"
|
||||||
#include "include/DigitalDevices/DigitalActuators/DigitalActuatorElectrovanne.h"
|
#include "include/DigitalDevices/DigitalActuators/DigitalActuatorElectrovanne.h"
|
||||||
|
#include "include/I2CDevices/Screen.h"
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
// creation d'une board
|
// creation d'une board
|
||||||
|
@ -15,7 +15,7 @@ int main(){
|
||||||
AnalogSensorTemperature temperature(TEMP,DELAY);
|
AnalogSensorTemperature temperature(TEMP,DELAY);
|
||||||
//DigitalActuatorLED led1(DELAY);
|
//DigitalActuatorLED led1(DELAY);
|
||||||
IntelligentDigitalActuatorLED led1(DELAY);
|
IntelligentDigitalActuatorLED led1(DELAY);
|
||||||
I2CActuatorScreen screen;
|
Screen screen;
|
||||||
AnalogSensorLuminosity luminosite(DELAY);
|
AnalogSensorLuminosity luminosite(DELAY);
|
||||||
ExternalDigitalSensorButton button(DELAY);
|
ExternalDigitalSensorButton button(DELAY);
|
||||||
AnalogSensorManometre manometre(PRESSURE,DELAY);
|
AnalogSensorManometre manometre(PRESSURE,DELAY);
|
||||||
|
|
|
@ -2,7 +2,10 @@
|
||||||
// Created by camer on 16/05/2020.
|
// Created by camer on 16/05/2020.
|
||||||
//
|
//
|
||||||
#include "../../core_simulation.h"
|
#include "../../core_simulation.h"
|
||||||
#include "../../mydevices.h"
|
#include <unistd.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <thread>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
#ifndef PROJET_VICTORAVECUNK_ANALOGDEVICE_H
|
#ifndef PROJET_VICTORAVECUNK_ANALOGDEVICE_H
|
||||||
#define PROJET_VICTORAVECUNK_ANALOGDEVICE_H
|
#define PROJET_VICTORAVECUNK_ANALOGDEVICE_H
|
||||||
|
|
|
@ -7,7 +7,10 @@
|
||||||
|
|
||||||
|
|
||||||
#include "../../core_simulation.h"
|
#include "../../core_simulation.h"
|
||||||
#include "../../mydevices.h"
|
#include <unistd.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <thread>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
class DigitalDevice : public Device {
|
class DigitalDevice : public Device {
|
||||||
protected:
|
protected:
|
||||||
|
|
14
include/I2CDevices/Keyboard.h
Normal file
14
include/I2CDevices/Keyboard.h
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
//
|
||||||
|
// Created by camer on 22/05/2020.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef PROJET_VICTORAVECUNK_KEYBOARD_H
|
||||||
|
#define PROJET_VICTORAVECUNK_KEYBOARD_H
|
||||||
|
|
||||||
|
|
||||||
|
class Keyboard {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif //PROJET_VICTORAVECUNK_KEYBOARD_H
|
25
include/I2CDevices/Screen.h
Normal file
25
include/I2CDevices/Screen.h
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
//
|
||||||
|
// Created by camer on 22/05/2020.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef PROJET_VICTORAVECUNK_SCREEN_H
|
||||||
|
#define PROJET_VICTORAVECUNK_SCREEN_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "../../core_simulation.h"
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
class Screen : public Device{
|
||||||
|
protected:
|
||||||
|
// memorise l'affichage de l'ecran
|
||||||
|
char buf[I2C_BUFFER_SIZE];
|
||||||
|
|
||||||
|
public:
|
||||||
|
// constructeur
|
||||||
|
Screen ();
|
||||||
|
// thread representant le capteur et permettant de fonctionner independamment de la board
|
||||||
|
virtual void run();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif //PROJET_VICTORAVECUNK_SCREEN_H
|
|
@ -1,35 +0,0 @@
|
||||||
|
|
||||||
#include "mydevices.h"
|
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// classe I2CActuatorScreen
|
|
||||||
I2CActuatorScreen::I2CActuatorScreen ():Device(){}
|
|
||||||
|
|
||||||
void I2CActuatorScreen::run(){
|
|
||||||
while(1){
|
|
||||||
if ( (i2cbus!=NULL)&&!(i2cbus->isEmptyRegister(i2caddr))){
|
|
||||||
Device::i2cbus->requestFrom(i2caddr, buf, I2C_BUFFER_SIZE);
|
|
||||||
cout << "---screen :"<< buf << endl;
|
|
||||||
}
|
|
||||||
sleep(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//TODO Capteur de temperature a revoir avec conditions
|
|
||||||
//TODO Electrovanne / moteur (a voir food)
|
|
||||||
//TODO Radiateur rechauffer terrarium
|
|
||||||
//TODO PHmetre pour qualite de l'eau
|
|
||||||
//TODO regarder les manometre
|
|
||||||
//TODO Electrovanne pour remplir la piscine
|
|
||||||
|
|
||||||
//TODO Ecran d'affichage avec infos de temps, derniere bouffe, infos sur tortues
|
|
||||||
//TODO Bouton pour sauter prochaine bouffe (I2C)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
24
mydevices.h
24
mydevices.h
|
@ -1,24 +0,0 @@
|
||||||
#ifndef MYDEVICES_H
|
|
||||||
#define MYDEVICES_H
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <thread>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <fstream>
|
|
||||||
#include "core_simulation.h"
|
|
||||||
|
|
||||||
// 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:
|
|
||||||
// memorise l'affichage de l'ecran
|
|
||||||
char buf[I2C_BUFFER_SIZE];
|
|
||||||
|
|
||||||
public:
|
|
||||||
// constructeur
|
|
||||||
I2CActuatorScreen ();
|
|
||||||
// thread representant le capteur et permettant de fonctionner independamment de la board
|
|
||||||
virtual void run();
|
|
||||||
};
|
|
||||||
//class ExternalDigitalSensorButton: public Device
|
|
||||||
#endif
|
|
|
@ -30,8 +30,6 @@ void Board::setup(){
|
||||||
// la boucle de controle arduino
|
// la boucle de controle arduino
|
||||||
void Board::loop(){
|
void Board::loop(){
|
||||||
char buf[100];
|
char buf[100];
|
||||||
int val;
|
|
||||||
int val1;
|
|
||||||
static int cpt=0;
|
static int cpt=0;
|
||||||
static int bascule=0;
|
static int bascule=0;
|
||||||
int i=0;
|
int i=0;
|
||||||
|
@ -73,10 +71,9 @@ void Board::loop(){
|
||||||
|
|
||||||
// if(cpt%5==0){
|
// if(cpt%5==0){
|
||||||
// tous les 5 fois on affiche sur l ecran la temperature
|
// tous les 5 fois on affiche sur l ecran la temperature
|
||||||
sprintf(buf,"%d",val1);
|
sprintf(buf,"%f",temperature.getValue());
|
||||||
bus.write(1,buf,100);
|
bus.write(1,buf,100);
|
||||||
|
//bus.requestFrom(1,buf,100);
|
||||||
|
|
||||||
// }
|
// }
|
||||||
cpt++;
|
cpt++;
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
Loading…
Reference in a new issue