Grupo T / Mbed OS GRUPOT

classes.h

Committer:
lucasfontenla
Date:
2018-05-15
Revision:
24:92f612ca218b
Child:
26:f891ff6beb33

File content as of revision 24:92f612ca218b:

#define tx PC_10
#define rx PC_11

#define sendTime 0.1

Serial ihm(tx, rx); //tx e rx (D1 e D0)

class IHM { 
    int n;
    string buffer;
    char buffer_char[8];
    
    public:
        int debug;
    
        // PUBLIC FUNCTIONS ----------------------------------------------------------------------------------------------------------------------------------------
        void send_position(float X, float Y, float Z){
            //printf("Position sent\n\r");
            buffer = "";
            
            buffer.append("p");
            
            n = sprintf(buffer_char, "X%.3f", X);
            buffer.append(buffer_char);    
            n = sprintf(buffer_char, "Y%.3f", Y);
            buffer.append(buffer_char);  
            n = sprintf(buffer_char, "Z%.3f", Z);
            buffer.append(buffer_char); 
            
            send(buffer); 
        }

    private:
        
        // PRIVATE FUNCTIONS ----------------------------------------------------------------------------------------------------------------------------------------
        void send(string msg){
            msg.append("x");
            
            for(int i = 0; i < msg.length(); i++){
                ihm.putc(msg[i]);
                wait_us(1);   
            }
        }       
};