From 67cac6463de93723b0cb77ab55b1dc615a7433b3 Mon Sep 17 00:00:00 2001 From: Paul Guenette Date: Wed, 13 Dec 2017 21:49:22 -0500 Subject: [PATCH] Don't reset count if we've already found the index... --- Firmware/MotorControl/low_level.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Firmware/MotorControl/low_level.c b/Firmware/MotorControl/low_level.c index 4a0eb7e0..34927e8e 100644 --- a/Firmware/MotorControl/low_level.c +++ b/Firmware/MotorControl/low_level.c @@ -530,12 +530,14 @@ void step_cb(uint16_t GPIO_Pin) { } } -void enc_index_cb(uint16_t GPIO_Pin, int index){ - setEncoderCount(&motors[index], 0); - motors[index].IndexFound = true; +// Triggered when an encoder passes over the "Index" pin +void enc_index_cb(uint16_t GPIO_Pin, int index) { + if (!motors[index].encoder.index_found) { + setEncoderCount(&motors[index], 0); + motors[index].encoder.index_found = true; + } } - void vbus_sense_adc_cb(ADC_HandleTypeDef* hadc, bool injected) { static const float voltage_scale = 3.3f * 11.0f / (float)(1 << 12); // Only one conversion in sequence, so only rank1