From b93a01f8c5fd0d963c7cbd7d786688000e294a4e Mon Sep 17 00:00:00 2001 From: jakeg00dwin Date: Mon, 24 Feb 2025 18:05:29 -0800 Subject: [PATCH] Added the rampdown distance as a define in the `main.h` file. --- inc/main.h | 2 ++ src/main.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/inc/main.h b/inc/main.h index a5dde62..cb02140 100644 --- a/inc/main.h +++ b/inc/main.h @@ -49,9 +49,11 @@ #define SPEED_PIN PB2 // Pin 7/ADC1 #define BUTTON_PIN PB4 // Pin 3 - Button input +#define MOTOR_RAMPDOWN_DIST 16 #define MOTOR_PULSE 6 //uS motor base pulse + /*The timing of "ticks" is dependent on the AVR timer's counter register * so for an 8bit register the maximum value is 256. Given we stick with * a 1Mhz cpu frequency can use this formula to calculate the number of diff --git a/src/main.c b/src/main.c index 1d07564..ff44432 100644 --- a/src/main.c +++ b/src/main.c @@ -150,7 +150,7 @@ void MotorMoveTo(uint8_t target) { delta = diff(target, pos); //Impliment a ramp down when near target position. - if(delta <= 6){ + if(delta <= MOTOR_RAMPDOWN_DIST){ //Ignore speed value and set for 50% speed. on_delay = 127; } @@ -284,7 +284,7 @@ static void UpdateButtonOutput(btn_state *b) { if (b->is_active) { /*If already in saved position then go back to original pos.*/ - if(diff(MotorGetSavedPos((uint8_t *)POSITION1_ADR), ReadFader()) <= 2){ + if(diff(MotorGetSavedPos((uint8_t *)POSITION1_ADR), ReadFader()) <= 3){ MotorMoveTo(MotorGetSavedPos((uint8_t *)POSITION2_ADR)); } else{