fdsaf
Diff: hallsensor_software_decoder.h
- Revision:
- 3:a969ae9954a8
- Parent:
- 2:b041de36c002
- Child:
- 4:8ce9fbe46da2
--- a/hallsensor_software_decoder.h Wed Mar 27 03:02:26 2019 +0000 +++ b/hallsensor_software_decoder.h Wed Mar 27 03:08:46 2019 +0000 @@ -28,7 +28,7 @@ WheelState_t wheelState1, wheelState2; -void init_CN(){ +void init_CN() { HallA_1.rise(&CN_ITR); HallA_1.fall(&CN_ITR); HallB_1.rise(&CN_ITR); @@ -53,10 +53,10 @@ wheelState1.state = (wheelState1.hallA << 1) + (wheelState1.hallA ^ wheelState1.hallB) + 1; - if(wheelState1.state == 1){ - if(wheelState1.prestate == 4){ + if(wheelState1.state == 1) { + if(wheelState1.prestate == 4) { wheelState1.direction = true; - } else if(state_1_old != 1){ + } else if(wheelState1.prestate != 1) { wheelState1.direction = false; } } @@ -68,15 +68,15 @@ } } else { - if(wheelState1.state > wheelState.prestate){ + if(wheelState1.state > wheelState1.prestate) { wheelState1.direction = true; - }else if(wheelState1.state < wheelState.prestate){ + } else if(wheelState1.state < wheelState1.prestate) { wheelState1.direction = false; } } /* do nothing if state ain't change */ - if(wheelState1.state != wheelState.prestate){ + if(wheelState1.state != wheelState1.prestate) { if(wheelState1.direction) { ++wheelState1.numStateChange; } else {