![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
今までのジョイスティックの入力を段階分けしていた方式から、アナログ値をできる限りそのまま使用する方式に変更しました。
Fork of ControlMain2017 by
Diff: main.cpp
- Revision:
- 40:4455b8c02e46
- Parent:
- 39:9b31e207c75d
- Parent:
- 38:5bccc1c7f812
diff -r 9b31e207c75d -r 4455b8c02e46 main.cpp --- a/main.cpp Fri Apr 21 04:09:33 2017 +0000 +++ b/main.cpp Fri Apr 21 04:10:17 2017 +0000 @@ -10,7 +10,7 @@ #define THRESHOLD_OH_VALUE 0.14 #define SAMPLE_INTERVAL 0.05 -#define PHASE_NUM 15 //奇数にしてください +#define PHASE_NUM 13 //奇数にしてください #define SUM_UP_NUM 10.0 #define PITCHPERROLL 1.5 /* @@ -185,7 +185,7 @@ setMaxAndMin(enumRoll, rollPin.read()); setMaxAndMin(enumPitch, pitchPin.read()); -// pc.printf("rollN:%f rollMax:%f rollMin:%f pitchN:%f pitchMax:%f pitchUpper:%f pitchMin:%f pitchLo:%f raw:%f\r\n",rollNeutral,rollNeutral+rollUpperDiff,rollNeutral+rollLowerDiff,pitchNeutral,pitchNeutral+pitchUpperDiff,pitchUpperDiff,pitchNeutral+pitchLowerDiff,pitchLowerDiff,pitchPin.read()); + //pc.printf("rollN:%f rollMax:%f rollMin:%f pitchN:%f pitchMax:%f pitchUpper:%f pitchMin:%f pitchLo:%f raw:%f ",rollNeutral,rollNeutral+rollUpperDiff,rollNeutral+rollLowerDiff,pitchNeutral,pitchNeutral+pitchUpperDiff,pitchUpperDiff,pitchNeutral+pitchLowerDiff,pitchLowerDiff,pitchPin.read()); float MatchedRoll = MatchUpperAndLower(enumRoll, rollNeutral + rollUpperDiff,rollNeutral + rollLowerDiff,rollNeutral,rollPin.read() + neutralDiff); float MatchedPitch = MatchUpperAndLower(enumPitch, pitchNeutral + pitchUpperDiff,pitchNeutral + pitchLowerDiff,pitchNeutral,pitchPin.read()); //pc.printf("Rollmax:%f value:%f Min:%f" ,); @@ -193,9 +193,9 @@ *(int *)inputDatas_R =PhaseFloat(FormatedRoll_R,SetRollPitchRacio(pitchNeutral + pitchUpperDiff,rollNeutral + rollUpperDiff),SetRollPitchRacio(pitchNeutral + pitchLowerDiff,rollNeutral + rollLowerDiff)); float FormatedRoll_L = Format2Range(SetRollPitchRacio(MatchedPitch, - MatchedRoll),SetRollPitchRacio(pitchNeutral + pitchUpperDiff,-rollNeutral - rollLowerDiff),SetRollPitchRacio(pitchNeutral +pitchLowerDiff, - rollNeutral - rollUpperDiff)); - //pc.printf("matched:%f max:%f min:%f\n\r",(MatchedPitch - MatchedRoll) / 2.0,(pitchNeutral +pitchLowerDiff - rollNeutral - rollUpperDiff) / 2.0,(pitchNeutral + pitchUpperDiff-rollNeutral - rollLowerDiff) / 2.0); + // pc.printf("matched:%f max:%f min:%f\n\r",(MatchedPitch - MatchedRoll) / 2.0,(pitchNeutral +pitchLowerDiff - rollNeutral - rollUpperDiff) / 2.0,(pitchNeutral + pitchUpperDiff-rollNeutral - rollLowerDiff) / 2.0); *(int *)inputDatas_L = PhaseFloat(FormatedRoll_L,SetRollPitchRacio(pitchNeutral + pitchUpperDiff ,- rollNeutral - rollLowerDiff),SetRollPitchRacio(pitchNeutral + pitchLowerDiff ,- rollNeutral - rollUpperDiff)); - //pc.printf("Format:%f max:%f min:%f\n\r",FormatedRoll_L,(pitchNeutral + pitchUpperDiff - rollNeutral - rollLowerDiff) / 2.0,(pitchNeutral + pitchLowerDiff - rollNeutral - rollUpperDiff) / 2.0); + pc.printf("Format:%f max:%f min:%f ",FormatedRoll_L,(pitchNeutral + pitchUpperDiff - rollNeutral - rollLowerDiff) / 2.0,(pitchNeutral + pitchLowerDiff - rollNeutral - rollUpperDiff) / 2.0); if(*(int *)inputDatas_R < 1) *(int *)inputDatas_R = 1; else if(*(int *)inputDatas_R > PHASE_NUM) @@ -205,7 +205,7 @@ else if(*(int *)inputDatas_L > PHASE_NUM) *(int *)inputDatas_L =PHASE_NUM; - pc.printf("DR :%d DL:%d input_R:%d input_L:%d\n\r",drug_R.read(),drug_L.read(),*(int *)inputDatas_R,*(int *)inputDatas_L); + pc.printf("input_R:%d input_L:%d\n\r",*(int *)inputDatas_R,*(int *)inputDatas_L); inputDatas_R[sizeof(int)+ 2] = (char)drug_R; led4 =! led4; // pc.printf("%c",*(char *)inputDatas_R[4]);