This repository was archived by the owner on Apr 12, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoperate.h
More file actions
47 lines (40 loc) · 1.29 KB
/
operate.h
File metadata and controls
47 lines (40 loc) · 1.29 KB
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
#ifndef OPERATE_H
#define OPERATE_H
#include <Arduino.h>
// Define error codes if not already defined elsewhere
#ifndef E_OK
#define E_OK 0
#endif
#ifndef E_NOK
#define E_NOK 1
#endif
class operate
{
public:
operate();
void setPin(int p, int pD); // Set PWM and direction pins for stepper
void setSpeed(int MotS); // Set stepper motor speed (delay)
void move(int m, int dir); // Move by m steps, dir: 1-F, 0-R
int home(); // Home the motor
int getCurrentPos(); // Get current position of motor
int setHoming(int homing, int motspeed, int timeout, int lswPin); // Configure homing
int setPosition(long set); // Set position of stepper motor
int setPositionLimits(long max, long min); // Set max and min limits
private:
long count; // Loop counter
int pinDir; // Direction pin
int pin; // PWM pin
int lsw; // Limit switch state
int limitSWPin; // Limit switch pin
long currpos; // Current position
int timer;
int timeouttimer; // Timeout for homing
int MotSpeed; // Unused but kept for compatibility
int MotDelay; // Motor delay for PWM
int homingAllowed; // Homing enabled/disabled
int MotSpeedforHoming; // Motor speed for homing
long setPos; // Set position
long MinLimit; // Minimum position limit
long MaxLimit; // Maximum position limit
};
#endif // OPERATE_H