4
4
5
5
from .mbus import i2c1
6
6
from .module_helper import ModuleError
7
- import struct
8
7
from micropython import const
9
- import re , math
8
+ import re
9
+ import math
10
10
import time
11
11
12
12
@@ -49,7 +49,7 @@ def __init__(
49
49
50
50
params:
51
51
address:
52
- note: The I2C address of the device.
52
+ note: The I2C address of the device.
53
53
"""
54
54
55
55
self .i2c = i2c1
@@ -70,7 +70,7 @@ def g_code(self, command):
70
70
71
71
params:
72
72
command:
73
- note: The G-code command.
73
+ note: The G-code command.
74
74
"""
75
75
self .i2c .writeto (self .addr , command + "\n " )
76
76
return self .get_code_time (command )
@@ -83,10 +83,10 @@ def get_code_time(self, code) -> int:
83
83
84
84
params:
85
85
code:
86
- note: The G-code command
86
+ note: The G-code command
87
87
88
88
return:
89
- note: The estimated time of the command.
89
+ note: The estimated time of the command.
90
90
91
91
"""
92
92
x_value = re .search (r"X-*\d+" , code )
@@ -116,13 +116,13 @@ def turn(self, x=None, y=None, z=None, speed=None) -> int:
116
116
117
117
params:
118
118
x:
119
- note: The position of the X motor, 1.6=360°.
119
+ note: The position of the X motor, 1.6=360°.
120
120
y:
121
- note: The position of the Y motor, 1.6=360°.
121
+ note: The position of the Y motor, 1.6=360°.
122
122
z:
123
- note: The position of the Z motor, 1.6=360°.
123
+ note: The position of the Z motor, 1.6=360°.
124
124
speed:
125
- note: The speed of the motor.
125
+ note: The speed of the motor.
126
126
"""
127
127
command = "G1"
128
128
command += " X{}" .format (x ) if x is not None else ""
@@ -140,11 +140,11 @@ def set_mode(self, mode):
140
140
141
141
params:
142
142
mode:
143
- note: The mode of the motor.
144
- field: dropdown
145
- options:
146
- Absolute: GRBLModule.MODE_ABSOLUTE
147
- Relative: GRBLModule.MODE_RELATIVE
143
+ note: The mode of the motor.
144
+ field: dropdown
145
+ options:
146
+ Absolute: GRBLModule.MODE_ABSOLUTE
147
+ Relative: GRBLModule.MODE_RELATIVE
148
148
"""
149
149
self .mode = mode
150
150
if mode == self .MODE_ABSOLUTE :
@@ -160,13 +160,13 @@ def init(self, x_step=None, y_step=None, z_step=None, acc=None):
160
160
161
161
params:
162
162
x_step:
163
- note: The step of the X motor.
163
+ note: The step of the X motor.
164
164
y_step:
165
- note: The step of the Y motor.
165
+ note: The step of the Y motor.
166
166
z_step:
167
- note: The step of the Z motor.
167
+ note: The step of the Z motor.
168
168
acc:
169
- note: The acceleration of the motor.
169
+ note: The acceleration of the motor.
170
170
"""
171
171
if x_step :
172
172
self .i2c .writeto (self .addr , "$0={}\n " .format (x_step ))
@@ -197,7 +197,7 @@ def get_message(self) -> str:
197
197
en: Get the message.
198
198
cn: 获取消息。
199
199
return:
200
- note: The message string.
200
+ note: The message string.
201
201
"""
202
202
i2c_data = ""
203
203
while True :
@@ -214,7 +214,7 @@ def get_status(self) -> str:
214
214
en: Get the status.
215
215
cn: 获取状态。
216
216
return:
217
- note: The status string.
217
+ note: The status string.
218
218
"""
219
219
self .flush ()
220
220
self .i2c .writeto (self .addr , "@" )
@@ -226,7 +226,7 @@ def get_idle_state(self) -> bool:
226
226
en: Get the idle state.
227
227
cn: 获取空闲状态。
228
228
return:
229
- note: The idle state.
229
+ note: The idle state.
230
230
"""
231
231
return self .get_status ()[0 ] == "I"
232
232
@@ -236,7 +236,7 @@ def get_lock_state(self) -> bool:
236
236
en: Get the lock state.
237
237
cn: 获取锁定状态。
238
238
return:
239
- note: The lock state.
239
+ note: The lock state.
240
240
"""
241
241
return self .get_status ()[0 ] == "A"
242
242
0 commit comments