diff --git a/src/main.c b/src/main.c index 2159e1f..7af6517 100644 --- a/src/main.c +++ b/src/main.c @@ -101,10 +101,10 @@ uint16_t ReadADC(void) { */ static inline uint8_t diff(uint8_t a, uint8_t b) { - if(a > b){ - return a - b; - } - return b - a; + if (a > b) { + return a - b; + } + return b - a; } void MotorSetSavePos() { @@ -118,8 +118,8 @@ uint8_t MotorGetSavedPos(void) { } void MotorMoveTo(uint8_t target) { - - uint8_t pos = (uint8_t)(ReadADC() >> 2); + + uint8_t pos = (uint8_t)(ReadADC() >> 2); while (diff(target, pos) > 8) { pos = (uint8_t)(ReadADC() >> 2); @@ -128,11 +128,11 @@ void MotorMoveTo(uint8_t target) { } else { MotorMove(0); } - + // The delay ratio controlls the PWM waveforms. //_delay_ms(5); - // MotorCoast(); - // _delay_ms(5); + // MotorCoast(); + // _delay_ms(5); } return; @@ -212,7 +212,7 @@ static void UpdateButtonInput(btn_state *b) { static void UpdateButtonOutput(btn_state *b) { /*If the button is actually pressed.*/ if (b->is_pressed) { - b->is_active = 1; + b->is_active = 1; /*If this is a new event.*/ if (!b->is_long_pressed && !b->timer_enabled) { @@ -242,12 +242,11 @@ static void UpdateButtonOutput(btn_state *b) { } /*If the button pres was a short one.*/ else if (!b->is_long_pressed) { - if(b->is_active) { - MotorMoveTo(MotorGetSavedPos()); - } - else{ - MotorCoast(); - } + if (b->is_active) { + MotorMoveTo(MotorGetSavedPos()); + } else { + MotorCoast(); + } } b->is_active = 0; ClearButtonTimer(b);