-
Notifications
You must be signed in to change notification settings - Fork 231
feat: Enhance Badge with Adjustable Brightness Support #1271
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
base: flutter_app
Are you sure you want to change the base?
feat: Enhance Badge with Adjustable Brightness Support #1271
Conversation
Reviewer's Guide by SourceryThis pull request introduces brightness control functionality for both virtual and connected badges. It includes a toggle to enable/disable brightness control, a slider to set the LED intensity, and integration of brightness rendering on the virtual badge. The brightness level is managed using a provider, and the badge data transfer process has been updated to include brightness information. Sequence diagram for setting brightnesssequenceDiagram
participant User
participant HomeScreen
participant BadgeBrightnessProvider
participant BleBrightnessService
participant BluetoothDevice
User->HomeScreen: Adjusts brightness slider
HomeScreen->BadgeBrightnessProvider: setBrightness(brightnessLevel)
activate BadgeBrightnessProvider
BadgeBrightnessProvider->BleBrightnessService: setBrightness(brightnessLevel)
activate BleBrightnessService
alt isConnected == true
BleBrightnessService->BluetoothDevice: Writes brightness value
activate BluetoothDevice
BluetoothDevice-->>BleBrightnessService: Acknowledgment
deactivate BluetoothDevice
else isConnected == false
BleBrightnessService-->>BadgeBrightnessProvider: Returns false
end
BleBrightnessService-->>BadgeBrightnessProvider: Returns success
deactivate BleBrightnessService
BadgeBrightnessProvider-->>HomeScreen: Notifies listeners
deactivate BadgeBrightnessProvider
HomeScreen->HomeScreen: Rebuilds UI with new brightness
Updated class diagram for BadgeBrightnessProviderclassDiagram
class BadgeBrightnessProvider {
-BleBrightnessService _bleBrightnessService
-double _brightness
-bool _isConnected
-String _errorMessage
-bool _isBrightnessVisible
+double brightness
+bool isConnected
+String errorMessage
+bool isBrightnessVisible
+BadgeBrightnessProvider(BleBrightnessService bleBrightnessService)
-Future<void> _initialize()
+void toggleBrightnessVisibility(bool value)
+Future<bool> connectToDevice(String deviceId)
+Future<bool> setBrightness(double brightnessLevel)
+Future<void> getCurrentBrightness()
+Future<void> disconnect()
+void dispose()
}
class BleBrightnessService {
+Future<bool> connectToDevice(String deviceId)
+Future<bool> setBrightness(int brightnessLevel)
+Future<int?> getCurrentBrightness()
+Future<void> disconnect()
}
BadgeBrightnessProvider -- BleBrightnessService : depends on
Updated class diagram for BadgePaintclassDiagram
class BadgePaint {
-BadgeUtils badgeUtils
-List~List~bool~~ grid
-double brightness
+BadgePaint(List~List~bool~~ grid, double brightness)
+void paint(Canvas canvas, Size size)
+bool shouldRepaint(BadgePaint oldDelegate)
}
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @samruddhi-Rahegaonkar - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider adding a loading state to the UI while connecting to the badge, to improve user experience.
- The
YOUR_DEVICE_ID
string should be replaced with a persistent storage lookup.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
@@ -304,8 +442,11 @@ class _HomeScreenState extends State<HomeScreen> | |||
speedDialProvider.getOuterValue(), | |||
modeValueMap[animationProvider | |||
.getAnimationIndex()], | |||
null, | |||
false); | |||
brightnessProvider.brightness.round() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (bug_risk): Suspicious cast from int to Map<String, dynamic>.
The call to badgeData.checkAndTransfer is passing brightnessProvider.brightness.round() casted to Map<String, dynamic>? even though brightness.round() produces an int. If the intent is to pass brightness as a parameter, consider wrapping it in a map (e.g., {"brightness": brightnessProvider.brightness.round()}) rather than casting an int. Ensure the parameter type expected by checkAndTransfer is correctly respected.
Build StatusBuild successful. APKs to test: https://github.com/fossasia/badgemagic-app/actions/runs/14384460232/artifacts/2920793486. Screenshots (Android)
Screenshots (iPhone)
Screenshots (iPad)
|
@adityastic Just to confirm, is this change meant to address the issue referenced? because i guess for this we need Live polling option in our App to connect badge to app for long hours. |
@Jhalakupadhyay what do you think on this ? |
The brightness is controlled by the badge itself by using the existing button so we don't have to do anything on the app |
Ohkay! so there is no need to add brightness control to badge it already has that feature ? |
@Jhalakupadhyay should i close PR then ? |
Yes because managing brightness at the app is unnecessary and badge brightness is handled by the firmware. |
Ohkay! i did it cause i saw the issue #866 does this refer to anything different that i solved ? |
Ahh I see we would need to controll it from the app according to the new firmware docs but before that we would need to have the streaming feature ready let's focus on that first. |
Yeah! we need Live rendering! and our app should connect to the badge for long hours right ? |
Yeah kind of let's just focus on that first then we can have the rest of the features in place |
@Jhalakupadhyay The work i have did it aligns to the issue ? |
Sure! So i will be continuing to work on it ! so i guess #1242 |
Fixes #866
Changes
Screenshots / Recordings
video.mp4
Checklist:
constants.dart
without hard coding any value.Summary by Sourcery
Add brightness control support for virtual and connected badges, enabling users to adjust LED intensity through a slider and toggle
New Features:
Enhancements: