せとうちオープン用のメインプログラム

Dependencies:   mbed AQM1602 HMC6352 PID

minilib/wordString2.cpp

Committer:
lilac0112_1
Date:
2016-05-01
Revision:
0:b910276f9da2

File content as of revision 0:b910276f9da2:

#include "mbed.h"
#include "def.h"

#include "extern.h"

using namespace std;
//string StringFIN;

string Int2Char2String(int number)
{
    char str[5];
    sprintf(str, "%d", number);
    string ss;
    ss = str;
    return ss;
}

void array2(int power1,int power2,int power3,int power4)
{
    int input[4] = {power1,power2,power3,power4};
    int value;
    string StringA[4] = {"0","0","0","0"};
    
    
    string StringX = "0";
    string StringY = "0";
    string StringZ = "0";
    string String0 = "0";
    
    StringFIN = "0";
    
    for(int i = 0 ; i < 4; i++){
        
        value = input[i];
        
        StringX =  Int2Char2String(i+1);
        
        if( (value < 0) && (value >= -100) ){
            StringY = "R";
            value = abs(value);
            StringZ = Int2Char2String(value);
        }else if( (value >= 0) && (value <= 100) ){
            StringY = "F";
            StringZ = Int2Char2String(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";   
}