v7

Dependents:   robot_final

Robot.cpp

Committer:
fab16
Date:
2017-03-02
Revision:
4:c8ae1b606d51
Parent:
3:3f75a7741b8f
Child:
5:152295068384

File content as of revision 4:c8ae1b606d51:

#include "Robot.h"
#include "m3pi.h"
   
    m3pi m3piR; 
    SRF05 srf(p21,p22);

   Robot::Robot(){
        obstacle = false;
        Affichage affichage;
        LED led;
        Deplacement deplacement;
        Pattern pattern;
        
    }
    
   Robot::~Robot(){
            // TODO fermer connexion bluetooth
    }
    
    Affichage Robot::getAffichage(){
       return affichage; 
    }
    
    LED Robot::getLed(){
       return led; 
    }
    
    Deplacement Robot::getDeplacement(){
        return deplacement;
    }
    
    Pattern Robot::getPattern(){
        return pattern;
    }
    
    void Robot::action(int idAction){
     
        switch(idAction){
        
            // deplacement simple
            case 0 : 
            {
                this->deplacement.avancer();
                break;
            }
               
            case 1 :
            {
                this->deplacement.droite();
                break;
            }
               
            case 2 :
            {
                this->deplacement.reculer();
                break;
            }
              
            case 3 : 
            {
                this->deplacement.gauche();
                break;
            }
                
            case 4 : 
            {
                this->deplacement.tourner_gauche();
                break;
            }
            
            case 5 :
            {
                this->deplacement.tourner_droite();
                break;
            }
            
            // pattern
            
            case 6 :
            {
                this->pattern.carre();
                break;
            }
            
             case 7 :
            {
                this->pattern.triangle();
                break;
            }
            
            // led
            case 8 :
            {
                this->led.K1000(1);
                break;
            }
            
            case 9 :
            {
                this->led.K2000(1);
                break;
            }
            
            case 10 :
            {
                this->led.K3000(1);
                break;
            }
            
            case 11 :
            {
                this->led.K4000(1);
                break;
            }
            
            case 12 :
            {
                this->led.LED_desynchrone(1);
                break;
            }
            
              case 13 :
            {
                this->led.LED_Blinking(DigitalOut (LED1),1);
                break;
            }
            
             case 14 :
            {
                this->led.LED_Blinking(DigitalOut (LED2),1);
                break;
            }
            
             case 15 :
            {
                this->led.LED_Blinking(DigitalOut (LED3),1);
                break;
            }
            
             case 16 :
            {
                this->led.LED_Blinking(DigitalOut (LED4),1);
                break;
            }
            
            
            // affichage
            
             case 17 :
            {
                this->affichage.bonjour();
                break;
            }
        }   
        
    }
    
    void Robot::utiliserUltrason(){
        affichage.effacerTout();
        float result = srf.read();
        //m3piR.printf("%.1f",result);
        affichage.affichageUltrason(result); 
    }