Color LED tab#793
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enables the Color LED tab in the UI and migrates its Crazyflie interactions to the newer async cflib2-style APIs (async params + log streaming), aligning it with the newer connection model used by other tabs like ParamTab.
Changes:
- Enabled
ColorLEDTabin the tab loader (availablelist + import). - Reworked Color LED deck detection, param writes, and thermal throttling monitoring to use async cflib2 calls and
create_task()scheduling.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
src/cfclient/ui/tabs/__init__.py |
Uncomments/imports ColorLEDTab and adds it to the available tab list so it can be loaded. |
src/cfclient/ui/tabs/ColorLEDTab.py |
Migrates to async cflib2 param/log APIs, adds async connection setup, and implements thermal log stream reading via background tasks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Nice catch! This issue exists in the old client as well. It is fixed for the new client in 0ae1059. |
7940a4e to
5b502d1
Compare
gemenerik
left a comment
There was a problem hiding this comment.
Several places replace specific exception types with bare except Exception. The risk here is that it hides; programming mistakes, unexpected runtime issues, new exception types from cflib2. They would all be silently logged as a debug message while the code moves on. It's better to catch only the exceptions you actually expect.
| self._cf, present_decks | ||
| ) | ||
| for position, stream in streams.items(): | ||
| create_task(self._run_thermal_stream(position, stream)) |
There was a problem hiding this comment.
The thermal stream tasks created here aren't stored, so they can't be canceled on disconnect. Currently they only terminate because the Disconnected exception is caught by the general except Exception handler, but catching exceptions is meant to catch things going wrong, not to handle a normal disconnect. The disconnect path should use explicit cancellation of the task. Store the task references and cancel them in disconnected(), like with how _connected_task is handled.
There was a problem hiding this comment.
Added proper handling of the thermal_stream_tasks upon disconnection in 506a7f9.
There was a problem hiding this comment.
not this pr but this feels fragile
There was a problem hiding this comment.
Fixed in 3530d38.
Instead of retrieving a button's color by reading its stylesheet, we now store the color directly on the button using Qt's setProperty(). This happens both on preset buttons once during connection, and on custom buttons when they're created.
I replaced the broad except Exceptions with specific ones from |
3530d38 to
1ef9f60
Compare
| self._process_thermal_data(log_data.data) | ||
| except asyncio.CancelledError: | ||
| raise | ||
| except Exception as e: |
There was a problem hiding this comment.
One last trailing except Exception
| ] | ||
| for btn in color_buttons: | ||
| style = btn.styleSheet() | ||
| hex_color = style.split("background-color:")[-1].split(";")[0].strip() |
There was a problem hiding this comment.
Still has this potentially fragile parsing. Again not this PR but maybe nice to fix.
There was a problem hiding this comment.
In 6994368 I replaced the chained split() with a regex that explicitly targets the QPushButton{} block, so the parsing should be more robust now. What do you think @gemenerik?

No description provided.