-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathgcode.h
executable file
·148 lines (105 loc) · 2.93 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
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 guard
#ifndef GCODE_H
#define GCODE_H
// Definitions
#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 final {
// Public
public:
// Parse command
void parseCommand(const char *command) noexcept;
// Clear command
void clearCommand() noexcept;
// Is empty
bool isEmpty() const noexcept;
// Has parameter G
bool hasParameterG() const noexcept;
// Get parameter G
uint8_t getParameterG() const noexcept;
// Has parameter M
bool hasParameterM() const noexcept;
// Get parameter M
uint16_t getParameterM() const noexcept;
// Has parameter T
bool hasParameterT() const noexcept;
// Get parameter T
uint8_t getParameterT() const noexcept;
// Has parameter S
bool hasParameterS() const noexcept;
// Get parameter S
int32_t getParameterS() const noexcept;
// Has parameter P
bool hasParameterP() const noexcept;
// Get parameter P
int32_t getParameterP() const noexcept;
// Has parameter X
bool hasParameterX() const noexcept;
// Get parameter X
float getParameterX() const noexcept;
// Has parameter Y
bool hasParameterY() const noexcept;
// Get parameter Y
float getParameterY() const noexcept;
// Has parameter Z
bool hasParameterZ() const noexcept;
// Get parameter Z
float getParameterZ() const noexcept;
// Has parameter F
bool hasParameterF() const noexcept;
// Get parameter F
float getParameterF() const noexcept;
// Has parameter E
bool hasParameterE() const noexcept;
// Get parameter E
float getParameterE() const noexcept;
// Has parameter N
bool hasParameterN() const noexcept;
// Get parameter N
uint64_t getParameterN() const noexcept;
// Check if host commands are enabled
#if ENABLE_HOST_COMMANDS == true
// Has host command
bool hasHostCommand() const noexcept;
// Get host command
const char *getHostCommand() const noexcept;
#endif
// Has valid checksum
bool hasValidChecksum() const noexcept;
// 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;
// Check if host commands are enabled
#if ENABLE_HOST_COMMANDS == true
// Host command
char hostCommand[UINT8_MAX + 1];
#endif
};
#endif