-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathmain.cpp
112 lines (90 loc) · 1.89 KB
/
main.cpp
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
// (c) 2011, Christopher "ScribbleJ" Jansen
// Licence: GPL or whatever.
#include "GcodeQueue.h"
#include "Host.h"
#include "Temperature.h"
#include "Time.h"
#include <avr/interrupt.h>
#include "Globals.h"
#include "Eeprom.h"
#ifdef USE_MARLIN
#include "Marlin.h"
#endif
#ifdef HAS_LCD
#include "LCDKeypad.h"
extern LCDKeypad LCDKEYPAD;
#endif
#ifdef HAS_SD
#include "SDCard.h"
#endif
#include "config.h"
void mainloop()
{
// TODO: check to see whether interleaving calls to GCODES.handlenext really gains me anything.
for (;;) {
// Checks to see if gcodes are waiting to run and runs them if so.
GCODES.handlenext();
// Rather than interleaving, we'll just run it twice in succession, to catch instances where it
// wants an immediate rerun, otherwise assume it's good 'till we get back.
GCODES.handlenext();
GCODES.checkaxes();
// Checks to see if recieve buffer has enough data to parse, and sends it to
// GcodeQueue.h for processing if so.
HOST.scan_input();
// Updates temperature information; scans temperature sources
TEMPERATURE.update();
// Manage Eeprom operations
eeprom::update();
#ifdef HAS_LCD
// Update LCD, read keypresses, etc.
LCDKEYPAD.handleUpdates();
#endif
#ifdef HAS_SD
// Manage SD card operations
sdcard::update();
#endif
#ifdef HAS_BT
// Look for incoming data
BT.scan_input();
#endif
#ifdef USE_MARLIN
Marlin::update();
#endif
}
}
int main(void)
{
sei();
init_time();
#ifdef HAS_SD
sdcard::reset();
#ifdef SD_AUTORUN
if(sdcard::autorun())
{
HOST.write("AUTORUN GOOD\n");
#ifdef HAS_BT
BT.write("AUTORUN GOOD\n");
#endif
}
else
{
HOST.write("AUTORUN FAIL\n");
#ifdef HAS_BT
BT.write("AUTORUN FAIL\n");
#endif
eeprom::beginRead();
}
#endif
#else
eeprom::beginRead();
#endif
HOST.write_P(PSTR("start\n"));
#ifdef HAS_BT
BT.write_P(PSTR("start\n"));
#endif
#ifdef USE_MARLIN
Marlin::init();
#endif
mainloop();
return 0;
}