HandsON-BuildHat-API 1.0.5__tar.gz → 1.0.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: HandsON-BuildHat-API
3
- Version: 1.0.5
3
+ Version: 1.0.7
4
4
  Summary: A third-party API for controlling LEGO SPIKE devices
5
- Author-email: HaNeul Jung <caffeine.reload@gmail.com>
5
+ Author-email: HaNeul Jung <hnjung@handsontech.co.kr>
6
6
  License: Proprietary - Personal/Educational Use Only
7
7
  Classifier: Programming Language :: Python :: 3
8
8
  Classifier: License :: Other/Proprietary License
@@ -17,7 +17,7 @@ HandsON Build Hat API
17
17
  =======
18
18
  **Production** : HandsON Technology co., ltd.
19
19
  **Author** : HaNeul Jung (hnjung@handsontech.co.kr)
20
- **Last Update** : 2025-08-29
20
+ **Last Update** : 2025-09-01
21
21
 
22
22
  ## 주의
23
23
  2025-08-27 이전 판매된 빌드햇 제품의 경우 1.0.4 버전을 사용
@@ -2,7 +2,7 @@ HandsON Build Hat API
2
2
  =======
3
3
  **Production** : HandsON Technology co., ltd.
4
4
  **Author** : HaNeul Jung (hnjung@handsontech.co.kr)
5
- **Last Update** : 2025-08-29
5
+ **Last Update** : 2025-09-01
6
6
 
7
7
  ## 주의
8
8
  2025-08-27 이전 판매된 빌드햇 제품의 경우 1.0.4 버전을 사용
@@ -1,10 +1,10 @@
1
1
 
2
2
  [project]
3
3
  name = "HandsON-BuildHat-API"
4
- version = "1.0.5"
4
+ version = "1.0.7"
5
5
  description = "A third-party API for controlling LEGO SPIKE devices"
6
6
  authors = [
7
- { name="HaNeul Jung", email="caffeine.reload@gmail.com" }
7
+ { name="HaNeul Jung", email="hnjung@handsontech.co.kr" }
8
8
  ]
9
9
  license = {text = "Proprietary - Personal/Educational Use Only"}
10
10
  readme = "README.md"
@@ -9,8 +9,8 @@ from serial import Serial
9
9
  import time
10
10
 
11
11
  class _ConstButtonID:
12
- STOP = 0
13
- START = 1
12
+ START = 0
13
+ STOP = 1
14
14
 
15
15
  LEFT = 2
16
16
  RIGHT = 3
@@ -37,9 +37,11 @@ class _ConstValue:
37
37
 
38
38
  ALL_PORT = 0b1111
39
39
 
40
- MOTOR_PWM_MODE = 0
41
- MOTOR_ABS_MODE = 1
42
- MOTOR_REL_MODE = 2
40
+ MOTOR_STOP = 0
41
+ MOTOR_PWM = 1
42
+ MOTOR_ABS = 2
43
+ MOTOR_REL = 3
44
+ MOTOR_BRAKE = 255
43
45
 
44
46
  class _PORT:
45
47
  PORT = {
@@ -91,7 +93,7 @@ class _SerialManager:
91
93
  serial = None
92
94
 
93
95
  for i in _serial_port:
94
- try: serial = Serial(port=i, baudrate=115200, timeout=0.1)
96
+ try: serial = Serial(port=i, baudrate=115200, timeout=0.02)
95
97
  except: pass
96
98
  else: break
97
99
 
@@ -126,6 +128,7 @@ class _ModuleParent:
126
128
  if data == b'': continue
127
129
 
128
130
  if _Availability.checksum_check(data): return data
131
+ if ((len(data) == 1) and (data[0] == 0x04)): return data
129
132
 
130
133
  def _send_data(self, byte:bytes) -> None:
131
134
  com = byte
@@ -206,8 +209,8 @@ class Motor(_ModuleParent):
206
209
  self._module_check(self._PORT, (_ConstModuleID.SMALL_MOTOR, _ConstModuleID.MEDIUM_MOTOR, _ConstModuleID.LARGE_MOTOR))
207
210
 
208
211
  def stop(self) -> None:
209
- com = bytes((_ConstValue.TRA_DATA + self._PORT, _ConstValue.MOTOR_PWM_MODE, 0, 0))
210
- self._send_data(com)
212
+ com = bytes((_ConstValue.TRA_DATA + self._PORT, _ConstValue.MOTOR_STOP, 0, 0))
213
+ self._get_data(com)
211
214
 
212
215
  def start(self, speed:int) -> None:
213
216
  if not speed in range(-100, 101):
@@ -216,8 +219,8 @@ class Motor(_ModuleParent):
216
219
  if speed > 0: sw = 1
217
220
  else: sw = 0
218
221
 
219
- com = bytes((_ConstValue.TRA_DATA + self._PORT, _ConstValue.MOTOR_PWM_MODE, abs(speed), sw))
220
- self._send_data(com)
222
+ com = bytes((_ConstValue.TRA_DATA + self._PORT, _ConstValue.MOTOR_PWM, abs(speed), sw))
223
+ self._get_data(com)
221
224
 
222
225
  def run_to_position(self, degrees, speed) -> None:
223
226
  if not speed in range(0, 101):
@@ -228,8 +231,8 @@ class Motor(_ModuleParent):
228
231
  if degrees >= 0: target = degrees
229
232
  else: target = degrees & 0xFFFF
230
233
 
231
- com = bytes((_ConstValue.TRA_DATA + self._PORT, _ConstValue.MOTOR_ABS_MODE, speed, (target & 0xFF), (target >> 8)))
232
- self._send_data(com)
234
+ com = bytes((_ConstValue.TRA_DATA + self._PORT, _ConstValue.MOTOR_ABS, speed, (target & 0xFF), (target >> 8)))
235
+ self._get_data(com)
233
236
 
234
237
  def run_for_degrees(self, degrees, speed) -> None:
235
238
  if not speed in range(0, 101):
@@ -241,8 +244,8 @@ class Motor(_ModuleParent):
241
244
  if degrees >= 0: target = degrees
242
245
  else: target = degrees & 0xFFFFFFFF
243
246
 
244
- com = bytes((_ConstValue.TRA_DATA + self._PORT, _ConstValue.MOTOR_REL_MODE, speed, (target & 0xFF), (target >> 8) & 0xFF, (target >> 16) & 0xFF, (target >> 24) & 0xFF))
245
- self._send_data(com)
247
+ com = bytes((_ConstValue.TRA_DATA + self._PORT, _ConstValue.MOTOR_REL, speed, (target & 0xFF), (target >> 8) & 0xFF, (target >> 16) & 0xFF, (target >> 24) & 0xFF))
248
+ self._get_data(com)
246
249
 
247
250
  def get_speed(self) -> int:
248
251
  command = [_ConstValue.GET_DATA + self._PORT]
@@ -269,8 +272,8 @@ class MotorPair(_ModuleParent):
269
272
 
270
273
  def stop(self) -> None:
271
274
  for i in self._PORTs:
272
- com = bytes((_ConstValue.TRA_DATA + i, _ConstValue.MOTOR_PWM_MODE, 0, 0))
273
- self._send_data(com)
275
+ com = bytes((_ConstValue.TRA_DATA + i, _ConstValue.MOTOR_PWM, 0, 0))
276
+ self._get_data(com)
274
277
 
275
278
  def start(self, steering, speed) -> None:
276
279
  if not steering in range(-100, 101):
@@ -287,8 +290,8 @@ class MotorPair(_ModuleParent):
287
290
  if speed > 0: sw = 1
288
291
  else: sw = 0
289
292
 
290
- com = bytes((_ConstValue.TRA_DATA + motor, _ConstValue.MOTOR_PWM_MODE, sw, abs(speed)))
291
- self._send_data(com)
293
+ com = bytes((_ConstValue.TRA_DATA + motor, _ConstValue.MOTOR_PWM, abs(speed), sw))
294
+ self._get_data(com)
292
295
 
293
296
  def move(self, degrees, steering, speed) -> None:
294
297
  if not steering in range(-100, 101):
@@ -310,8 +313,8 @@ class MotorPair(_ModuleParent):
310
313
 
311
314
  if count == 1: target = ~target
312
315
 
313
- com = bytes((_ConstValue.TRA_DATA + motor, _ConstValue.MOTOR_REL_MODE, speed, (target & 0xFF), (target >> 8) & 0xFF, (target >> 16) & 0xFF, (target >> 24) & 0xFF))
314
- self._send_data(com)
316
+ com = bytes((_ConstValue.TRA_DATA + motor, _ConstValue.MOTOR_REL, speed, (target & 0xFF), (target >> 8) & 0xFF, (target >> 16) & 0xFF, (target >> 24) & 0xFF))
317
+ self._get_data(com)
315
318
 
316
319
 
317
320
  def move_tank(self, degrees, left_speed, right_speed) -> None:
@@ -332,8 +335,8 @@ class MotorPair(_ModuleParent):
332
335
 
333
336
  if count == 1: target = ~target
334
337
 
335
- com = bytes((_ConstValue.TRA_DATA + motor, _ConstValue.MOTOR_REL_MODE, speed, (target & 0xFF), (target >> 8) & 0xFF, (target >> 16) & 0xFF, (target >> 24) & 0xFF))
336
- self._send_data(com)
338
+ com = bytes((_ConstValue.TRA_DATA + motor, _ConstValue.MOTOR_REL, speed, (target & 0xFF), (target >> 8) & 0xFF, (target >> 16) & 0xFF, (target >> 24) & 0xFF))
339
+ self._get_data(com)
337
340
 
338
341
  def start_tank(self, left_speed, right_speed) -> None:
339
342
  if not left_speed in range(-100, 101) or not right_speed in range(-100, 101):
@@ -348,5 +351,5 @@ class MotorPair(_ModuleParent):
348
351
  if speed > 0: sw = 1
349
352
  else: sw = 0
350
353
 
351
- com = bytes((_ConstValue.TRA_DATA + motor, _ConstValue.MOTOR_PWM_MODE, sw, abs(speed)))
352
- self._send_data(com)
354
+ com = bytes((_ConstValue.TRA_DATA + motor, _ConstValue.MOTOR_PWM, abs(speed), sw))
355
+ self._get_data(com)
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: HandsON-BuildHat-API
3
- Version: 1.0.5
3
+ Version: 1.0.7
4
4
  Summary: A third-party API for controlling LEGO SPIKE devices
5
- Author-email: HaNeul Jung <caffeine.reload@gmail.com>
5
+ Author-email: HaNeul Jung <hnjung@handsontech.co.kr>
6
6
  License: Proprietary - Personal/Educational Use Only
7
7
  Classifier: Programming Language :: Python :: 3
8
8
  Classifier: License :: Other/Proprietary License
@@ -17,7 +17,7 @@ HandsON Build Hat API
17
17
  =======
18
18
  **Production** : HandsON Technology co., ltd.
19
19
  **Author** : HaNeul Jung (hnjung@handsontech.co.kr)
20
- **Last Update** : 2025-08-29
20
+ **Last Update** : 2025-09-01
21
21
 
22
22
  ## 주의
23
23
  2025-08-27 이전 판매된 빌드햇 제품의 경우 1.0.4 버전을 사용