forked from Nyarmith/clock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClock.ino
75 lines (55 loc) · 1.54 KB
/
Clock.ino
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
#include "ClockAPI.h"
//#include "TimeUtils.h"
//#include "PathUtils.h"
// -- MAIN LOGIC BEGIN
//RTC_Interface rtcClock_;
//BoardPathMapper pathMapper_;
//HourPosMapper hourPosMapper_;
Gantry gantry_;
HourHand hourHand_;
void setup()
{
initClockPins();
// rtcClock_.init(globTime_);
//Serial.begin(9600);
gantry_.init();
hourHand_.init();
pinMode(13, OUTPUT);
}
uint32_t prev_sync_micros{0}, cur_micros{0};
constexpr uint32_t sync_duration_micros = 60 * 1000000;
void loop()
{
// time from boot measured in micros
// update glob time once per minute, where the minute is tracked with
Point<pos_t> start_pt{10,10};
Point<pos_t> start_pt1{50,10};
Point<pos_t> dest_pt{100,100};
bool at_dest = false;
while (!gantry_.chase_point(start_pt, micros()));
{ }
while (!gantry_.chase_point(start_pt1, micros()));
{ }
while (!gantry_.chase_point(dest_pt, micros()));
{ }
while (!gantry_.chase_point(start_pt1, micros()));
{ }
delay(1000);
//while (true) {}
//while (!gantry_.chase_point(dest_pt, micros()));
//{ }
// if (cur_micros - prev_sync_micros > sync_duration_micros)
// {
// globTime_.sync(globTime_,dt);
// }
// if (lastTime == 0) lastTime = time;
// unsigned dt = time - lastTime;
// lastTime = time;
//
// globTime_.addMillis(dt);
// rtcClock_.sync(globTime_, dt);
//auto gpos = pathMapper_.getPos(globTime_);
//auto hpos = hourPosMapper_.getPos(globTime_);
//gantry_.moveTo(gpos);
//hourHand_.moveTo(hpos);
}