-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpolargraph.h
58 lines (45 loc) · 1.19 KB
/
polargraph.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
49
50
51
52
53
54
55
56
57
58
#ifndef __POLARGRAPH_H__
#define __POLARGRAPH_H__
/* Measurements (mm)*/
#define X_MAX 445
#define Y_MAX 350
#define STEP_MULT 8
#define PULLEY_RADIUS 43 //update this
#define PULLEY_CIRC (2 * PULLEY_RADIUS * PI)
#define STEPS_PER_ROT 200 * STEP_MULT
//steps = distance * mm_to_steps_pulley
#define mm_to_steps_pulley double(STEPS_PER_ROT) / double(PULLEY_CIRC);
/* Structs */
struct pos {
int16_t x;
int16_t y;
pos& operator=(const pos& a) {
x = a.x;
y = a.y;
return *this;
}
bool operator==(const pos& a) const {
return (x == a.x && y == a.y);
}
String toString() {
return String("(" + String(x) + "," + String(y) + ")");
}
int16_t * toArray() {
int16_t arr[2] = {x, y};
return arr;
}
};
/* Public Polargraph Functions */
void setupPolargraph();
bool loopPolargraph(); //returns true if at a good stopping point to check IoT, like the end of a drawing or not drawing
bool addToBuffer(pos * pos_new);
void clearBuffer();
int getBufferSize();
pos getCurrentPos();
void resetPos();
double getLeftLength();
double getRightLength();
double getDistance(pos p1, pos p2);
boolean getIsDrawing();
void setIsDrawing(boolean drawing);
#endif //__POLARGRAPH_H__