-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathigpio.h
48 lines (42 loc) · 1.37 KB
/
igpio.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once
// Abstract base "interface" class
// to allow mocking out the hardware
// interface to allow the StepperMotor
// class to be used for tests
#include <stdint.h>
namespace mgo {
enum class PinState {
high,
low
};
// concrete classes can initialise / terminate
// the GPIO library in their ctors / dtors
class IGpio {
public:
// Support for stepper motors:
virtual int addMotor(int stepPin, int reversePin, int enablePin) = 0;
virtual void setStepPin(int motor, PinState) = 0;
virtual void setReversePin(int motor, PinState) = 0;
virtual void setEnablePin(int motor, PinState) = 0;
virtual void setRotaryEncoderCallback(
int pinA,
int pinB,
void (*callback)(int, int, uint32_t, void*),
void* userData)
= 0;
virtual void setLinearScaleAxis1Callback(
int pinA,
int pinB,
void (*callback)(int, int, uint32_t, void*),
void* userData)
= 0;
// General:
virtual void delayMicroSeconds(long) = 0;
virtual uint32_t getTick() = 0;
// These functions are for TESTING/FAKE only (to make the mocked linear scale appear to be
// working) and should be a no-op on non-fake IGpio-derived classes:
virtual void scaleGoToPositionMm(double mm) = 0;
virtual void scaleSetSpeedStepsPerSec(double speed) = 0;
virtual void scaleStop() = 0;
};
} // end namespace