mirror of
https://github.com/Vale54321/schafkop-neu.git
synced 2025-12-15 11:29:32 +01:00
refactor: structure pico project
This commit is contained in:
22
pico/lib/Stepper/Stepper.h
Normal file
22
pico/lib/Stepper/Stepper.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
class Stepper {
|
||||
protected:
|
||||
int steps_per_rev;
|
||||
virtual void step(int steps, bool direction) = 0;
|
||||
|
||||
public:
|
||||
void step_rev(double revs, bool direction){
|
||||
if(revs == 0.0) return;
|
||||
if(revs < 0.0){
|
||||
direction = !direction;
|
||||
revs = -revs;
|
||||
}
|
||||
|
||||
long total_steps = (long)(revs * steps_per_rev + 0.5);
|
||||
if(total_steps <= 0) return;
|
||||
|
||||
step((int)total_steps, direction);
|
||||
}
|
||||
|
||||
virtual ~Stepper() {}
|
||||
};
|
||||
Reference in New Issue
Block a user