final cup

Dependencies:   HMC6352 PID mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers wordString.cpp Source File

wordString.cpp

00001 
00002 #include <sstream>
00003 #include "mbed.h"
00004 
00005 string StringFIN;
00006 
00007 using namespace std;
00008 
00009 
00010 //extern Serial pc; // tx, rx 
00011 
00012 string IntToString(int number)
00013 {
00014   stringstream ss;
00015   ss << number;
00016   return ss.str();
00017 }
00018 
00019 void array(int power1,int power2,int power3,int power4)
00020 {
00021     int input[4] = {power1,power2,power3,power4};
00022     int value = 0;
00023     string StringA[4] = {"0","0","0","0"};
00024     
00025     
00026     string StringX = "0";
00027     string StringY = "0";
00028     string StringZ = "0";
00029     string String0 = "0";
00030     
00031     StringFIN = "0";
00032     
00033     for(uint8_t i = 0 ; i < 4; i++){
00034         
00035         value = input[i];
00036         
00037         StringX =  IntToString(i+1);
00038         
00039         if( (value < 0) && (value >= -100) ){
00040             StringY = "R";
00041             value = abs(value);
00042             StringZ = IntToString(value);
00043         }else if( (value >= 0) && (value <= 100) ){
00044             StringY = "F";
00045             StringZ = IntToString(value);
00046         }else{
00047             value = abs(value);
00048             StringY = "F";
00049             StringZ = "000";
00050         }
00051         
00052         if(value < 10){
00053             String0 = "00";
00054             StringZ = String0 + StringZ;
00055         }else if(value < 100)
00056         {
00057             String0 = "0";
00058             StringZ = String0 + StringZ;
00059         }else{
00060             
00061         }
00062         
00063         StringA[i] = (StringX + StringY + StringZ);
00064         
00065         if(i == 0)StringFIN  = StringA[i];
00066         else StringFIN  += StringA[i];
00067         
00068     }
00069     
00070     StringFIN += "\r\n";   
00071 }