今までのジョイスティックの入力を段階分けしていた方式から、アナログ値をできる限りそのまま使用する方式に変更しました。

Dependencies:   mbed-rtos mbed

Fork of ControlMain2017 by albatross

Branch:
?????
Revision:
45:df3b45a8cecc
Parent:
44:7b6f627a31da
Child:
46:53eb2ba661c5
--- a/ValueProcessor.cpp	Fri Apr 28 15:23:22 2017 +0000
+++ b/ValueProcessor.cpp	Sat Apr 29 04:13:17 2017 +0000
@@ -19,14 +19,15 @@
 int ValueProcess::WidenNeutral(int phased)
 {
     int AddNeutral = ADDITIONALPHASE / 2;
-    int neutralPhase = (PHASE_NUM + 5)/2.0;
+    int neutralPhase = (PHASE_NUM + ADDITIONALPHASE +1)/2.0;
     if(neutralPhase - AddNeutral<=phased && phased <= neutralPhase +AddNeutral)
-        phased += AddNeutral;
+        phased = neutralPhase;
     else if(phased < neutralPhase - AddNeutral)
         phased += AddNeutral;
     else if(neutralPhase +AddNeutral<phased)
         phased -= AddNeutral;
-    return phased;
+
+    return phased - AddNeutral;
 }
 
 void ValueProcess::setMaxAndMin(InputType it,float value)
@@ -60,7 +61,6 @@
 
     neutralDiff = pitchNeutral - rollNeutral; //ピッチの初期値の方がい小さいと仮定
     rollNeutral += neutralDiff;
-    rollUpperDiff = 0;
 }
 
 //ジョイスティックの中間値から上と下の幅を合わせます。値を取得するたびに呼び出してください。範囲は広い方に合わせる物とします
@@ -163,12 +163,13 @@
     MatchedRoll = MatchRange(MatchedRoll);
     MatchedPitch = MatchRange(MatchedPitch);
 
-    float FormatedRoll_R = Format2Range(SetRollPitchRacio(MatchedPitch,MatchedRoll),SetRollPitchRacio(pitchNeutral + pitchUpperDiff,rollNeutral + rollUpperDiff),SetRollPitchRacio(pitchNeutral + pitchLowerDiff,rollNeutral + rollLowerDiff));
+    float Formated_R = Format2Range(SetRollPitchRacio(MatchedPitch,MatchedRoll),SetRollPitchRacio(pitchNeutral + pitchUpperDiff,rollNeutral + rollUpperDiff),SetRollPitchRacio(pitchNeutral + pitchLowerDiff,rollNeutral + rollLowerDiff));
 
-    int phased_R =PhaseFloat(FormatedRoll_R,SetRollPitchRacio(pitchNeutral + pitchUpperDiff,rollNeutral + rollUpperDiff),SetRollPitchRacio(pitchNeutral + pitchLowerDiff,rollNeutral + rollLowerDiff));
-    *input_R = WidenNeutral(phased_R);
-    float FormatedRoll_L = Format2Range(SetRollPitchRacio(MatchedPitch, - MatchedRoll),SetRollPitchRacio(pitchNeutral + pitchUpperDiff,-rollNeutral - rollLowerDiff),SetRollPitchRacio(pitchNeutral  +pitchLowerDiff, - rollNeutral - rollUpperDiff));
-    int phased_L = PhaseFloat(FormatedRoll_L,SetRollPitchRacio(pitchNeutral + pitchUpperDiff ,- rollNeutral - rollLowerDiff),SetRollPitchRacio(pitchNeutral + pitchLowerDiff ,- rollNeutral - rollUpperDiff));
+    int phased_R=PhaseFloat(Formated_R,SetRollPitchRacio(pitchNeutral + pitchUpperDiff,rollNeutral + rollUpperDiff),SetRollPitchRacio(pitchNeutral + pitchLowerDiff,rollNeutral + rollLowerDiff));
+    // *input_R = WidenNeutral(phased_R);
+    *input_R = phased_R;
+    float Formated_L = Format2Range(SetRollPitchRacio(MatchedPitch, - MatchedRoll),SetRollPitchRacio(pitchNeutral + pitchUpperDiff,-rollNeutral - rollLowerDiff),SetRollPitchRacio(pitchNeutral  +pitchLowerDiff, - rollNeutral - rollUpperDiff));
+    int phased_L = PhaseFloat(Formated_L,SetRollPitchRacio(pitchNeutral + pitchUpperDiff ,- rollNeutral - rollLowerDiff),SetRollPitchRacio(pitchNeutral + pitchLowerDiff ,- rollNeutral - rollUpperDiff));
     *input_L = WidenNeutral(phased_L);
 
     if(*input_R < 1)