generated from TDD-Templates/cmake_cpputest_template_avr
styling changes
This commit is contained in:
parent
2c78ea4130
commit
0ad78b2671
27
src/main.c
27
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() {
|
||||
|
@ -119,7 +119,7 @@ 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);
|
||||
|
@ -131,8 +131,8 @@ void MotorMoveTo(uint8_t target) {
|
|||
|
||||
// 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);
|
||||
|
|
Loading…
Reference in New Issue