app: minor, calibrate dial steps

This commit is contained in:
King Kévin 2022-08-11 14:13:24 +02:00
parent 55ac60e080
commit b7670d1e24
1 changed files with 3 additions and 3 deletions

View File

@ -83,8 +83,8 @@ static bool drv8825_reached = false; /**< set when the goal is reached */
// dials position info // dials position info
#define DIAL_SWITCH_PIN PB4 /**< pin connected to reed switch, connected to ground when the hour dial is nearby */ #define DIAL_SWITCH_PIN PB4 /**< pin connected to reed switch, connected to ground when the hour dial is nearby */
#define DIAL_CYCLE_STEPS 11904U /**< number of steps for the hour dial to make a round */ #define DIAL_CYCLE_STEPS 4200U /**< number of steps for the hour dial to make a round */
#define DIAL_MIDNIGHT_STEPS 6557U /**< number of steps after dial detection for dials to show midnight */ #define DIAL_MIDNIGHT_STEPS 3207U /**< number of steps after dial detection for dials to show midnight */
static volatile uint32_t dial_steps = 0; /**< set to drv8825_steps when dial is nearby */ static volatile uint32_t dial_steps = 0; /**< set to drv8825_steps when dial is nearby */
#define WSMATRIX_HEIGHT (2 * 8) /**< WS2812b panel height, in pixels */ #define WSMATRIX_HEIGHT (2 * 8) /**< WS2812b panel height, in pixels */
@ -1233,7 +1233,7 @@ void GPIO_EXTI_ISR(DIAL_SWITCH_PIN)(void)
if (gpio_get(GPIO_PORT(DIAL_SWITCH_PIN), GPIO_PIN(DIAL_SWITCH_PIN))) { // be sure the pin is actually low if (gpio_get(GPIO_PORT(DIAL_SWITCH_PIN), GPIO_PIN(DIAL_SWITCH_PIN))) { // be sure the pin is actually low
return; return;
} }
if (drv8825_steps > dial_steps + 1000) { // ignore going away debounce if (drv8825_steps > DIAL_CYCLE_STEPS / 4) { // ignore going away debounce
dial_steps = drv8825_steps; // remember on which step we are dial_steps = drv8825_steps; // remember on which step we are
drv8825_steps = 0; // restart step counter drv8825_steps = 0; // restart step counter
} }