robocup メイン

Dependencies:   AQM0802A L6470_lib PID mbed

wordString.cpp

Committer:
ryuna
Date:
2014-12-23
Revision:
2:054444aa1990
Parent:
0:ae08e2e1d82d

File content as of revision 2:054444aa1990:


#include <sstream>
#include "mbed.h"

string StringFIN;

using namespace std;


//extern Serial pc; // tx, rx 

string IntToString(int number)
{
  stringstream ss;
  ss << number;
  return ss.str();
}

void array(int power1,int power2,int power3,int power4)
{
    int input[4] = {power1,power2,power3,power4};
    int value = 0;
    string StringA[4] = {"0","0","0","0"};
    
    
    string StringX = "0";
    string StringY = "0";
    string StringZ = "0";
    string String0 = "0";
    
    StringFIN = "0";
    
    for(uint8_t i = 0 ; i < 4; i++){
        
        value = input[i];
        
        StringX =  IntToString(i+1);
        
        if( (value < 0) && (value >= -100) ){
            StringY = "R";
            value = abs(value);
            StringZ = IntToString(value);
        }else if( (value >= 0) && (value <= 100) ){
            StringY = "F";
            StringZ = IntToString(value);
        }else{
            value = abs(value);
            StringY = "F";
            StringZ = "000";
        }
        
        if(value < 10){
            String0 = "00";
            StringZ = String0 + StringZ;
        }else if(value < 100)
        {
            String0 = "0";
            StringZ = String0 + StringZ;
        }else{
            
        }
        
        StringA[i] = (StringX + StringY + StringZ);
        
        if(i == 0)StringFIN  = StringA[i];
        else StringFIN  += StringA[i];
        
    }
    
    StringFIN += "\r\n";   
}