styling changes

This commit is contained in:
jakeg00dwin 2025-02-14 13:04:06 -08:00
parent 2c78ea4130
commit 0ad78b2671
1 changed files with 15 additions and 16 deletions

View File

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