ロボカップ2013のジャパンオープンメインプログラム

Dependencies:   PID TextLCD mbed

Committer:
ryuna
Date:
Sun Apr 27 02:37:13 2014 +0000
Revision:
0:fb4c529248d7
update_4/27

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ryuna 0:fb4c529248d7 1
ryuna 0:fb4c529248d7 2 #include <sstream>
ryuna 0:fb4c529248d7 3 #include "mbed.h"
ryuna 0:fb4c529248d7 4
ryuna 0:fb4c529248d7 5 string StringFIN;
ryuna 0:fb4c529248d7 6
ryuna 0:fb4c529248d7 7 using namespace std;
ryuna 0:fb4c529248d7 8
ryuna 0:fb4c529248d7 9
ryuna 0:fb4c529248d7 10 //extern Serial pc; // tx, rx
ryuna 0:fb4c529248d7 11
ryuna 0:fb4c529248d7 12 string IntToString(int number)
ryuna 0:fb4c529248d7 13 {
ryuna 0:fb4c529248d7 14 stringstream ss;
ryuna 0:fb4c529248d7 15 ss << number;
ryuna 0:fb4c529248d7 16 return ss.str();
ryuna 0:fb4c529248d7 17 }
ryuna 0:fb4c529248d7 18
ryuna 0:fb4c529248d7 19 void array(int power1,int power2,int power3,int power4)
ryuna 0:fb4c529248d7 20 {
ryuna 0:fb4c529248d7 21 int input[4] = {power1,power2,power3,power4};
ryuna 0:fb4c529248d7 22 int value = 0;
ryuna 0:fb4c529248d7 23 string StringA[4] = {"0","0","0","0"};
ryuna 0:fb4c529248d7 24
ryuna 0:fb4c529248d7 25
ryuna 0:fb4c529248d7 26 string StringX = "0";
ryuna 0:fb4c529248d7 27 string StringY = "0";
ryuna 0:fb4c529248d7 28 string StringZ = "0";
ryuna 0:fb4c529248d7 29 string String0 = "0";
ryuna 0:fb4c529248d7 30
ryuna 0:fb4c529248d7 31 StringFIN = "0";
ryuna 0:fb4c529248d7 32
ryuna 0:fb4c529248d7 33 for(uint8_t i = 0 ; i < 4; i++){
ryuna 0:fb4c529248d7 34
ryuna 0:fb4c529248d7 35 value = input[i];
ryuna 0:fb4c529248d7 36
ryuna 0:fb4c529248d7 37 StringX = IntToString(i+1);
ryuna 0:fb4c529248d7 38
ryuna 0:fb4c529248d7 39 if( (value < 0) && (value >= -100) ){
ryuna 0:fb4c529248d7 40 StringY = "R";
ryuna 0:fb4c529248d7 41 value = abs(value);
ryuna 0:fb4c529248d7 42 StringZ = IntToString(value);
ryuna 0:fb4c529248d7 43 }else if( (value >= 0) && (value <= 100) ){
ryuna 0:fb4c529248d7 44 StringY = "F";
ryuna 0:fb4c529248d7 45 StringZ = IntToString(value);
ryuna 0:fb4c529248d7 46 }else{
ryuna 0:fb4c529248d7 47 value = abs(value);
ryuna 0:fb4c529248d7 48 StringY = "F";
ryuna 0:fb4c529248d7 49 StringZ = "000";
ryuna 0:fb4c529248d7 50 }
ryuna 0:fb4c529248d7 51
ryuna 0:fb4c529248d7 52 if(value < 10){
ryuna 0:fb4c529248d7 53 String0 = "00";
ryuna 0:fb4c529248d7 54 StringZ = String0 + StringZ;
ryuna 0:fb4c529248d7 55 }else if(value < 100)
ryuna 0:fb4c529248d7 56 {
ryuna 0:fb4c529248d7 57 String0 = "0";
ryuna 0:fb4c529248d7 58 StringZ = String0 + StringZ;
ryuna 0:fb4c529248d7 59 }else{
ryuna 0:fb4c529248d7 60
ryuna 0:fb4c529248d7 61 }
ryuna 0:fb4c529248d7 62
ryuna 0:fb4c529248d7 63 StringA[i] = (StringX + StringY + StringZ);
ryuna 0:fb4c529248d7 64
ryuna 0:fb4c529248d7 65 if(i == 0)StringFIN = StringA[i];
ryuna 0:fb4c529248d7 66 else StringFIN += StringA[i];
ryuna 0:fb4c529248d7 67
ryuna 0:fb4c529248d7 68 }
ryuna 0:fb4c529248d7 69
ryuna 0:fb4c529248d7 70 StringFIN += "\r\n";
ryuna 0:fb4c529248d7 71 }