[Feature] Hub state encoding #1859
Labels
enhancement
New feature or request
software: pybricks-code
Issues with https://code.pybricks.com application
software: pybricks-micropython
Issues with Pybricks MicroPython firmware (or EV3 runtime)
Originally posted by @laurensvalk in pybricks/pybricks-code#2315 (comment)
These implementation details are probably worth discussing here in a separate issue. Pre-formatted strings sounded nice at first, but we'll also be applying device-specific visuals such as the motor angle or detected color. So if we're going to unpack and parse the strings in Pybricks Code anyway, we should probably come up with a protocol after all. Then it can be packet-based too, avoiding streaming issues.
As with any protocol, this means we'd need something properly versioned, so Pybricks Code knows how to display it. Maybe it needs to be part of the existing hub protocol version.
Information we need to send for each port:
Motors:
Ultrasonic sensor:
Color Sensor:
Note: I'm thinking we should perhaps not show the rounded color like
Color.RED
. Because this creates the impression that only the default colors are possible. It would be great to do something interactive with the detectable colors, but that is perhaps for a future version. Maybe just show the HSV as-is for now?And so on. In essence, what we have already done in the port script, but we'd need to formalize it. Perhaps something like:
It is the same for internal things like the gyro, but with a special ID representing itself, and an identifier for the internal device.
And for the reverse, setting data:
This is primarily for setting the mode. And for setting the motor position (more on that later).
(At this point, should we just implement it in C, or go for the whole LWP3 protocol? 😄 Nah, probably not.)
The text was updated successfully, but these errors were encountered: