Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #324 to enable more than one HallSensor #331

Merged
merged 2 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/communication/StepDirListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
#include "../common/foc_utils.h"


#if !defined(TARGET_RP2040) && !defined(_SAMD21_) && !defined(_SAMD51_) && !defined(_SAME51_) && !defined(ARDUINO_UNOR4_WIFI) && !defined(ARDUINO_UNOR4_MINIMA) && !defined(NRF52_SERIES) && !defined(ARDUINO_ARCH_MEGAAVR)
#define PinStatus int
#endif


/**
* Step/Dir listenner class for easier interraction with this communication interface.
*/
Expand Down Expand Up @@ -53,7 +48,7 @@ class StepDirListener
int pin_step; //!< step pin
int pin_dir; //!< direction pin
long count; //!< current counter value - should be set to 0 for homing
PinStatus polarity = RISING; //!< polarity of the step pin
decltype(RISING) polarity = RISING; //!< polarity of the step pin

private:
float* attached_variable = nullptr; //!< pointer to the attached variable
Expand Down
1 change: 0 additions & 1 deletion src/sensors/HallSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ void HallSensor::updateState() {
hall_state = new_hall_state;

int8_t new_electric_sector = ELECTRIC_SECTORS[hall_state];
static Direction old_direction;
if (new_electric_sector - electric_sector > 3) {
//underflow
direction = Direction::CCW;
Expand Down
1 change: 1 addition & 0 deletions src/sensors/HallSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class HallSensor: public Sensor{

// whether last step was CW (+1) or CCW (-1).
Direction direction;
Direction old_direction;

void attachSectorCallback(void (*onSectorChange)(int a) = nullptr);

Expand Down