forked from tinkersprojects/G-Code-Arduino-Library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gcode.h
74 lines (56 loc) · 1.65 KB
/
gcode.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef gcode_h
#define gcode_h
#if ARDUINO >= 100
#include <Arduino.h>
#else
#include <WProgram.h>
#include <wiring.h>
#endif
#define gcode_Buffer_version 2.0
#ifndef gcode_Buffer_size
#define gcode_Buffer_size 20
#endif
typedef void (*CallbackFunction) ();
typedef struct commandscallback {
String value;
CallbackFunction Callback;
};
class gcode
{
public:
// SETUP
gcode();
gcode(void (*CallBack)());
gcode(int numbercommands, commandscallback *commandscallbacks_temp);
gcode(int numbercommands, commandscallback *commandscallbacks_temp, void (*CallBack)());
void begin();
void begin(int bitrate);
void begin(String nextComandcomment);
void begin(int bitrate, String nextComandcomment);
// SEND
void comment(String comment);
void command(char number, double values);
// receive
bool available();
bool availableSD(char inChar);
bool available(char inChar);
bool availableValue(char commandLetter);
double GetValue(char commandLetter);
void clearBuffer();
private:
String nextComandcommentString;
bool nextRead = false;
bool restIsComment = false;
bool validCommand = false;
commandscallback *commandscallbacks;
int NumberOfCommands = 0;
CallbackFunction runCallback;
//double commandsList[gcode_Buffer_size];
String commandBuffer;
struct BufferFormat {
char command;
double Value;
} BufferList[gcode_Buffer_size];
int BufferListCount = -1;
};
#endif