Skip to content

Commit 60fface

Browse files
committed
fix: TechHub fixes and additional motors suggested by @BertLindeman
workaround: hub shutdown action
1 parent 4b63eec commit 60fface

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

hub-scripts/_builtin_port_view.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
port_commands = [[] for _ in range(len(ports))]
2727

2828
from pybricks.hubs import ThisHub
29-
hub = ThisHub
29+
hub = ThisHub()
3030
try:
3131
from pybricks.hubs import PrimeHub
3232
from pybricks.parameters import Icon, Button
@@ -217,7 +217,9 @@ def device_task(port, port_index):
217217
yield from update_force_sensor(port, port_index, type_id)
218218
elif type_id in (1, 2):
219219
yield from update_dc_motor(port, port_index, type_id)
220-
elif type_id in (38, 46, 47, 48, 49, 65, 75, 76):
220+
elif type_id in (38, 46, 47, 48, 49, 65, 75, 76, 86, 87):
221+
# 86 (0x56) Technic Move hub built-in drive motor
222+
# 87 (0x56) Technic Move hub built-in drive motor
221223
yield from update_motor(port, port_index, type_id)
222224
else:
223225
yield from unknown_pup_device(port, port_index, type_id)
@@ -270,7 +272,7 @@ def battery_task():
270272
# skip cc 10 seconds before sending an update
271273
percentage = round(min(100,(hub.battery.voltage()-6000)/(8300-6000)*100))
272274
voltage = hub.battery.voltage()
273-
status = hub.charger.status()
275+
status = hub.charger.status() if hub.charger else ''
274276
data = f"pct={percentage}%\tv={voltage}mV\ts={status}"
275277
yield f"battery\t{data}"
276278

src/hubcenter/HubCenterDialog.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ const HubcenterDialog: React.FunctionComponent = () => {
145145
const handleShutdown = useEventCallback(() => {
146146
const msg = new Uint8Array(['a'.charCodeAt(0), 's'.charCodeAt(0)]);
147147
dispatch(executeAppDataCommand(msg));
148+
// TODO: workaround: should be a didExecutedAppCommand
149+
setTimeout(() => dispatch(hubcenterHideDialog()), 300);
148150
});
149151

150152
return (

0 commit comments

Comments
 (0)