Repository navigation
Expand file tree
/
Copy pathgcode.h
More file actions
executable file
·148 lines (105 loc) · 2.64 KB
/
Copy pathgcode.h
File metadata and controls
executable file
·148 lines (105 loc) · 2.64 KB
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
// Header gaurd
#ifndef GCODE_H
#define GCODE_H
// Definitions
#define ALLOW_HOST_COMMANDS false
// Parameters
#define PARAMETER_G_OFFSET 1
#define PARAMETER_M_OFFSET (1 << 1)
#define PARAMETER_T_OFFSET (1 << 2)
#define PARAMETER_S_OFFSET (1 << 3)
#define PARAMETER_P_OFFSET (1 << 4)
#define PARAMETER_X_OFFSET (1 << 5)
#define PARAMETER_Y_OFFSET (1 << 6)
#define PARAMETER_Z_OFFSET (1 << 7)
#define PARAMETER_F_OFFSET (1 << 8)
#define PARAMETER_E_OFFSET (1 << 9)
#define PARAMETER_N_OFFSET (1 << 10)
#define PARAMETER_HOST_COMMAND_OFFSET (1 << 11)
#define VALID_CHECKSUM_OFFSET (1 << 12)
// Types
typedef uint16_t gcodeParameterOffset;
// Gcode class
class Gcode {
// Public
public:
// Parse command
void parseCommand(const char *command);
// Clear command
void clearCommand();
// Is empty
bool isEmpty() const;
// Has parameter G
bool hasParameterG() const;
// Get parameter G
uint8_t getParameterG() const;
// Has parameter M
bool hasParameterM() const;
// Get parameter M
uint16_t getParameterM() const;
// Has parameter T
bool hasParameterT() const;
// Get parameter T
uint8_t getParameterT() const;
// Has parameter S
bool hasParameterS() const;
// Get parameter S
int32_t getParameterS() const;
// Has parameter P
bool hasParameterP() const;
// Get parameter P
int32_t getParameterP() const;
// Has parameter X
bool hasParameterX() const;
// Get parameter X
float getParameterX() const;
// Has parameter Y
bool hasParameterY() const;
// Get parameter Y
float getParameterY() const;
// Has parameter Z
bool hasParameterZ() const;
// Get parameter Z
float getParameterZ() const;
// Has parameter F
bool hasParameterF() const;
// Get parameter F
float getParameterF() const;
// Has parameter E
bool hasParameterE() const;
// Get parameter E
float getParameterE() const;
// Has parameter N
bool hasParameterN() const;
// Get parameter N
uint64_t getParameterN() const;
#if ALLOW_HOST_COMMANDS == true
// Has host command
bool hasHostCommand() const;
// Get host command
const char *getHostCommand() const;
#endif
// Has valid checksum
bool hasValidChecksum() const;
// Is parsed
bool isParsed;
// Command parameters
gcodeParameterOffset commandParameters;
// Values
uint8_t valueG;
uint16_t valueM;
uint8_t valueT;
int32_t valueS;
int32_t valueP;
float valueX;
float valueY;
float valueZ;
float valueF;
float valueE;
uint64_t valueN;
// Host command
#if ALLOW_HOST_COMMANDS == true
char hostCommand[UINT8_MAX + 1];
#endif
};
#endif