-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathloopchecks.pde
117 lines (87 loc) · 2.99 KB
/
loopchecks.pde
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/**
* RoboPaint RT - Draw loop check functions (not for drawing)
*/
// Manage checking if the brush needs servicing, and moving to the next path
void checkServiceBrush() {
if (serviceBrush() == false)
if (millis() > NextMoveTime)
{
boolean actionItem = false;
int intTemp = -1;
if ((ToDoList.length > (indexDone + 1)) && (Paused == false))
{
actionItem = true;
intTemp = ToDoList[1 + indexDone];
indexDone++;
}
if (actionItem)
{ // Perform next action from ToDoList::
if (segmentQueued)
drawQueuedSegment(); // Draw path segment to screen
if (intTemp >= 0)
{ // Move the carriage to paint a path segment! ("This is where the magic happens....")
int x2 = floor(intTemp / 10000);
int y2 = intTemp - 10000 * x2;
int x1 = round( float(x2 - MousePaperLeft) * MotorStepsPerPixel);
int y1 = round( float(y2 - MousePaperTop) * MotorStepsPerPixel);
MoveToXY(x1, y1);
if (BrushDown == true) {
if (lastPosition == -1)
lastPosition = intTemp;
queueSegmentToDraw(lastPosition, intTemp);
lastPosition = intTemp;
}
/*
IF next item in ToDoList is ALSO a move, then calculate the next move and queue it to the EBB at this time.
Save the duration of THAT move as "SubsequentWaitTime."
When the first (pre-existing) move completes, we will check to see if SubsequentWaitTime is defined (i.e., >= 0).
If SubsequentWaitTime is defined, then (1) we add that value to the NextMoveTime:
NextMoveTime = millis() + SubsequentWaitTime;
SubsequentWaitTime = -1;
We also (2) queue up that segment to be drawn.
We also (3) queue up the next move, if there is one that could be queued. We do
*/
}
else
{
lastPosition = -1; // For drawing
intTemp = -1 * intTemp;
if ((intTemp > 9) && (intTemp < 20))
{ // Change paint color
intTemp -= 10;
}
else if ((intTemp >= 20) && (intTemp < 30))
{ // Get water from dish
intTemp -= 20;
}
else if (intTemp == 30)
{
raiseBrush();
}
else if (intTemp == 31)
{
lowerBrush();
}
else if (intTemp == 35)
{
MoveToXY(0, 0);
}
}
}
}
}
// Manage checking mouse position for highlights
void checkHighlights() {
boolean doHighlightRedraw = false;
// Manage highlighting of text buttons
if ((mouseY >= MousePaperBottom) || (mouseY < MousePaperTop) )
{
if ((mouseY <= height) && (mouseX >= (MousePaperLeft - 50)))
{
redrawButtons();
}
}
if (doHighlightRedraw) {
//redrawHighlight();
}
}