driver

Dependencies:   HMC6352 PID mbed

Fork of ver3_1_0 by ryo seki

Committer:
yusuke_robocup
Date:
Fri Jan 24 06:27:03 2014 +0000
Revision:
1:3b61675573b1
Parent:
0:bde8ed56b164
driver

Who changed what in which revision?

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