Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Bluetooth light UI. Use SPIKE Prime Bluetooth Light. #261

Merged
merged 6 commits into from
Sep 3, 2024

Conversation

laurensvalk
Copy link
Member

@laurensvalk laurensvalk commented Aug 23, 2024

tl;dr: Use a subset of original light UI when Bluetooth is off (instead of inventing something new) so we don't lock ourselves into something when we release the upcoming beta.


#247 introduced the ability to toggle Bluetooth on and off. The main light UI was kept unchanged, and a blue (on) and red (off) Bluetooth light was added. As already stated in that issue and pull request, this UI was not ideal since there are too many lights, which can be confusing for users and competition judges. So we'd have to come up with something else before we can release the firmware in beta.

Instead of adding new lights, this PR makes it a subset of the existing UI. When Bluetooth is off, the hub status light is off when it would otherwise be on or blink (when connected or advertising). There is no light indication around the Bluetooth light. This seems fairly intuitive. We could potentially still have the red light around the Bluetooth button when off, or save this for when we redo the whole light UI.

See updated below.

@coveralls
Copy link

coveralls commented Aug 23, 2024

Coverage Status

coverage: 56.044% (+0.1%) from 55.947%
when pulling 71af9a4 on bluetooth-light-2
into f41537c on master.

@laurensvalk
Copy link
Member Author

While we are touching this code, I've also fixed the standard light animation so that it always starts from the beginning when the user program starts.

@laurensvalk
Copy link
Member Author

laurensvalk commented Sep 2, 2024

This refactors the status light patterns:

It split the single pbsys_status_light_indication_t into separate pbsys_status_light_indication_ble_t and pbsys_status_light_indication_warning_t. On hubs with separate main and bluetooth lights, these can be displayed separately. On hubs with one light, the warnings can overlay/override the bluetooth state.

Overall, the behavior on Move/City/Technic/Essential Hub is mostly the same as before. While we are doing this, the patterns are slightly tweaked for better visibility across hubs.

On Prime Hub, this moves all Bluetooth state information to the Bluetooth light. This also disables the blue fading animation and the blue blinking shutdown animation on the main button, which now look out of place. This information is also conveyed by the 5x5 light matrix.

Not sure I am entirely happy with this implementation, but it should be a step in the right direction. Could potentially be refactored further with pybricks/support#1798.

@laurensvalk laurensvalk changed the title Bluetooth light UI Refactor Bluetooth light UI. Use SPIKE Prime Bluetooth Light. Sep 2, 2024
Copy link
Member

@dlech dlech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

lib/pbio/include/pbio/protocol.h Show resolved Hide resolved
The connected idle state (blue) was a special case that acted as a default.

The default is now to have no light at all, so we can distinguish BLE connected from disconnected, and potentially distinguish from USB connected if we choose different patterns.
The main status light not blinking is enough of an indicator for now that Bluetooth is off. This way we don't have to introduce new UIs yet that get locked in the upcoming release.

When we do create a new UI, we can now use the status flags instead of poking at the lights directly from the sys/bluetooth driver.
This ensures that the animation looks consistent
when you start a program, rather than picking up
where it stopped last time.

This makes it easier to see that a program was
started when you run it while connected, since the
light always switches from solid to off and then
fades.
These are never used, implemented, or documented, so they can be removed.
This separates the combined status light patterns
into Bluetooth patterns with warning pattern
overlays.

On hubs with a separate Bluetooth light, these
can be displayed separately.

This also simplifies the warning light. Instead
of having three orange patterns with different
meanings, this introduces a single orange pattern
for low battery and a red patterm for high current.
The Prime Hub Bluetooth LED is not very bright, so
the short blink is hardly visible. This makes it
longer. Also change other warning patterns to
match.

Also stop advertising on shutdown request instead
of shutdown, so that the Bluetooth light does not
keep blinking during shutdown. This also gives
a more intuitive response when connected, since
Pybricks Code now becomes disconnected
relatively sooner, matching hun shutdown.
@laurensvalk laurensvalk merged commit 71af9a4 into master Sep 3, 2024
38 checks passed
@laurensvalk
Copy link
Member Author

This completes the initial refactoring and the main light changes. Further light changes are being discussed in pybricks/support#1716

@dlech dlech deleted the bluetooth-light-2 branch September 3, 2024 13:20
@laurensvalk laurensvalk mentioned this pull request Sep 6, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants