HandsON-BuildHat-API 1.0.6__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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: HandsON-BuildHat-API
3
- Version: 1.0.6
3
+ Version: 1.0.7
4
4
  Summary: A third-party API for controlling LEGO SPIKE devices
5
5
  Author-email: HaNeul Jung <hnjung@handsontech.co.kr>
6
6
  License: Proprietary - Personal/Educational Use Only
@@ -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,7 +1,7 @@
1
1
 
2
2
  [project]
3
3
  name = "HandsON-BuildHat-API"
4
- version = "1.0.6"
4
+ version = "1.0.7"
5
5
  description = "A third-party API for controlling LEGO SPIKE devices"
6
6
  authors = [
7
7
  { name="HaNeul Jung", email="hnjung@handsontech.co.kr" }
@@ -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
@@ -93,7 +93,7 @@ class _SerialManager:
93
93
  serial = None
94
94
 
95
95
  for i in _serial_port:
96
- try: serial = Serial(port=i, baudrate=115200, timeout=0.1)
96
+ try: serial = Serial(port=i, baudrate=115200, timeout=0.02)
97
97
  except: pass
98
98
  else: break
99
99
 
@@ -128,6 +128,7 @@ class _ModuleParent:
128
128
  if data == b'': continue
129
129
 
130
130
  if _Availability.checksum_check(data): return data
131
+ if ((len(data) == 1) and (data[0] == 0x04)): return data
131
132
 
132
133
  def _send_data(self, byte:bytes) -> None:
133
134
  com = byte
@@ -209,7 +210,7 @@ class Motor(_ModuleParent):
209
210
 
210
211
  def stop(self) -> None:
211
212
  com = bytes((_ConstValue.TRA_DATA + self._PORT, _ConstValue.MOTOR_STOP, 0, 0))
212
- self._send_data(com)
213
+ self._get_data(com)
213
214
 
214
215
  def start(self, speed:int) -> None:
215
216
  if not speed in range(-100, 101):
@@ -219,7 +220,7 @@ class Motor(_ModuleParent):
219
220
  else: sw = 0
220
221
 
221
222
  com = bytes((_ConstValue.TRA_DATA + self._PORT, _ConstValue.MOTOR_PWM, abs(speed), sw))
222
- self._send_data(com)
223
+ self._get_data(com)
223
224
 
224
225
  def run_to_position(self, degrees, speed) -> None:
225
226
  if not speed in range(0, 101):
@@ -231,7 +232,7 @@ class Motor(_ModuleParent):
231
232
  else: target = degrees & 0xFFFF
232
233
 
233
234
  com = bytes((_ConstValue.TRA_DATA + self._PORT, _ConstValue.MOTOR_ABS, speed, (target & 0xFF), (target >> 8)))
234
- self._send_data(com)
235
+ self._get_data(com)
235
236
 
236
237
  def run_for_degrees(self, degrees, speed) -> None:
237
238
  if not speed in range(0, 101):
@@ -244,7 +245,7 @@ class Motor(_ModuleParent):
244
245
  else: target = degrees & 0xFFFFFFFF
245
246
 
246
247
  com = bytes((_ConstValue.TRA_DATA + self._PORT, _ConstValue.MOTOR_REL, speed, (target & 0xFF), (target >> 8) & 0xFF, (target >> 16) & 0xFF, (target >> 24) & 0xFF))
247
- self._send_data(com)
248
+ self._get_data(com)
248
249
 
249
250
  def get_speed(self) -> int:
250
251
  command = [_ConstValue.GET_DATA + self._PORT]
@@ -272,7 +273,7 @@ class MotorPair(_ModuleParent):
272
273
  def stop(self) -> None:
273
274
  for i in self._PORTs:
274
275
  com = bytes((_ConstValue.TRA_DATA + i, _ConstValue.MOTOR_PWM, 0, 0))
275
- self._send_data(com)
276
+ self._get_data(com)
276
277
 
277
278
  def start(self, steering, speed) -> None:
278
279
  if not steering in range(-100, 101):
@@ -290,7 +291,7 @@ class MotorPair(_ModuleParent):
290
291
  else: sw = 0
291
292
 
292
293
  com = bytes((_ConstValue.TRA_DATA + motor, _ConstValue.MOTOR_PWM, abs(speed), sw))
293
- self._send_data(com)
294
+ self._get_data(com)
294
295
 
295
296
  def move(self, degrees, steering, speed) -> None:
296
297
  if not steering in range(-100, 101):
@@ -313,7 +314,7 @@ class MotorPair(_ModuleParent):
313
314
  if count == 1: target = ~target
314
315
 
315
316
  com = bytes((_ConstValue.TRA_DATA + motor, _ConstValue.MOTOR_REL, speed, (target & 0xFF), (target >> 8) & 0xFF, (target >> 16) & 0xFF, (target >> 24) & 0xFF))
316
- self._send_data(com)
317
+ self._get_data(com)
317
318
 
318
319
 
319
320
  def move_tank(self, degrees, left_speed, right_speed) -> None:
@@ -335,7 +336,7 @@ class MotorPair(_ModuleParent):
335
336
  if count == 1: target = ~target
336
337
 
337
338
  com = bytes((_ConstValue.TRA_DATA + motor, _ConstValue.MOTOR_REL, speed, (target & 0xFF), (target >> 8) & 0xFF, (target >> 16) & 0xFF, (target >> 24) & 0xFF))
338
- self._send_data(com)
339
+ self._get_data(com)
339
340
 
340
341
  def start_tank(self, left_speed, right_speed) -> None:
341
342
  if not left_speed in range(-100, 101) or not right_speed in range(-100, 101):
@@ -351,4 +352,4 @@ class MotorPair(_ModuleParent):
351
352
  else: sw = 0
352
353
 
353
354
  com = bytes((_ConstValue.TRA_DATA + motor, _ConstValue.MOTOR_PWM, abs(speed), sw))
354
- self._send_data(com)
355
+ self._get_data(com)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: HandsON-BuildHat-API
3
- Version: 1.0.6
3
+ Version: 1.0.7
4
4
  Summary: A third-party API for controlling LEGO SPIKE devices
5
5
  Author-email: HaNeul Jung <hnjung@handsontech.co.kr>
6
6
  License: Proprietary - Personal/Educational Use Only
@@ -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 버전을 사용