Skip to content

Commit

Permalink
Merge pull request #11 from alberto-abarzua/feat/hall_effect
Browse files Browse the repository at this point in the history
feat (firmware): add hall effect endstop support
  • Loading branch information
alberto-abarzua authored Oct 12, 2023
2 parents 743278b + 2637650 commit 959ea50
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
31 changes: 23 additions & 8 deletions firmware/components/movement/endstops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,31 @@ HallEffectSensor::HallEffectSensor(int8_t pin) : EndStop(pin) {}

HallEffectSensor::~HallEffectSensor() {}



#ifdef ESP_PLATFORM

void HallEffectSensor::hardware_setup() {
gpio_config_t io_conf;
io_conf.intr_type = GPIO_INTR_DISABLE;
io_conf.mode = GPIO_MODE_INPUT;
io_conf.pin_bit_mask = 1ULL << this->pin; // Assuming GPIO23
io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
io_conf.pull_up_en = GPIO_PULLUP_DISABLE;
gpio_config(&io_conf);
}

bool HallEffectSensor::hardware_read_state() {
int state = gpio_get_level((gpio_num_t)this->pin); // Assuming GPIO23
return state == 0;
}

#else

void HallEffectSensor::hardware_setup() {
// pinMode(this->pin, INPUT_PULLUP);
}

bool HallEffectSensor::hardware_read_state() {
// int8_t state = digitalRead(this->pin);
// if (state != this->last_state) {
// this->last_state = state;
// return true;
// }
// return false;
return true;
}
}
#endif
2 changes: 1 addition & 1 deletion firmware/components/movement/include/movement.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#define PI 3.14159265358979323846

class EndStop {
private:
protected:
int8_t pin;

public:
Expand Down

0 comments on commit 959ea50

Please sign in to comment.