-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
Add Widgets Example Sketch #262
Conversation
Include various widgets and custom characters for LCD menu. Set up main screen with different item widgets handling input and displaying data.
WalkthroughThe pull request introduces a new Arduino sketch file, Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant LCD
participant Menu
participant Widget
User->>LCD: Start interaction
LCD->>Menu: Display main menu
Menu->>User: Show options (Buy, Sell, etc.)
User->>Menu: Select an option
Menu->>Widget: Trigger corresponding widget
Widget->>User: Request input
User->>Widget: Provide input
Widget->>LCD: Display selected values
Possibly related PRs
Suggested labels
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 5
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
📒 Files selected for processing (1)
- examples/Widgets/Widgets.ino (1 hunks)
🧰 Additional context used
🪛 GitHub Check: spell-check
examples/Widgets/Widgets.ino
[failure] 36-36:
tollerance ==> tolerance
[failure] 36-36:
tollerance ==> tolerance
🔇 Additional comments (2)
examples/Widgets/Widgets.ino (2)
1-13
: LGTM! Well-organized includes and constants.
The code follows best practices with:
- Logical organization of includes from core to specific components
- Clear constant definitions for LCD dimensions
65-75
: LGTM! Clean setup and loop implementation.
The setup and loop functions are well-organized and focused on their specific responsibilities.
- Fix tolerance spelling in Quantity widget lambda function - Change Freq widget ranges to not allow wrapping
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.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
📒 Files selected for processing (1)
- examples/Widgets/Widgets.ino (1 hunks)
🧰 Additional context used
📓 Learnings (1)
examples/Widgets/Widgets.ino (1)
Learnt from: forntoh
PR: forntoh/LcdMenu#262
File: examples/Widgets/Widgets.ino:14-17
Timestamp: 2024-10-29T23:12:27.533Z
Learning: The user prefers not to include ASCII art comments for custom characters in their code.
🔇 Additional comments (5)
examples/Widgets/Widgets.ino (5)
1-14
: LGTM! Well-organized includes and constants.
The code follows good practices by:
- Including all necessary headers
- Using constants for LCD configuration
- Making the I2C address configurable via LCD_ADDR constant
15-18
: LGTM! Clean custom character definitions.
The bit patterns for plusMinus (±) and euro (€) characters are correctly defined.
19-22
: LGTM! Well-structured constant arrays.
The arrays are appropriately defined and initialized.
60-64
: LGTM! Proper hardware initialization sequence.
The components are initialized in the correct order using the defined constants.
66-76
:
Add error handling in setup function.
The setup function should include error handling for Serial and custom character initialization.
Consider adding error handling:
void setup() {
Serial.begin(9600);
+ // Wait for Serial to be ready (optional, remove if not debugging)
+ while (!Serial && millis() < 3000); // Wait up to 3 seconds
+
renderer.begin();
menu.setScreen(mainScreen);
- lcd.createChar(2, plusMinus);
- lcd.createChar(3, euro);
+ // Verify custom character creation
+ if (!lcd.createChar(2, plusMinus) || !lcd.createChar(3, euro)) {
+ Serial.println(F("Failed to create custom characters"));
+ }
}
Likely invalid or redundant comment.
Memory usage change @ bbb3347
Click for full report table
Click for full report CSV
|
e0c7078
to
27c4d46
Compare
Added a new test file with detailed steps for simulating various widget interactions and edits.
27c4d46
to
b33b2a8
Compare
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.
Actionable comments posted: 5
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
📒 Files selected for processing (1)
- test/Widgets.test.yml (1 hunks)
🧰 Additional context used
🪛 yamllint
test/Widgets.test.yml
[error] 166-166: no new line character at the end of file
(new-line-at-end-of-file)
🔇 Additional comments (2)
test/Widgets.test.yml (2)
1-3
: LGTM: Test metadata is well-defined.
The test configuration includes essential metadata fields.
49-90
: Verify decimal precision handling in Quantity widget.
The test should explicitly verify:
- Decimal precision limits
- Cursor wraparound behavior when moving left/right
✅ Verification successful
Let me search for more specific implementation details about the Quantity widget and float handling.
Let me check the specific implementation of WidgetRange to understand the decimal precision and cursor behavior better.
Let me check one final thing about the Quantity widget's specific implementation.
Based on the code analysis from the test file and WidgetRange implementation, I can now provide a final response:
Decimal precision and cursor behavior are correctly implemented
The test adequately verifies the decimal precision handling:
- It tests decimal increments (0.10 steps) in the first decimal place
- It verifies cursor movement between integer and decimal parts
- The implementation in WidgetRange template class properly handles:
- Value constraints through min/max bounds
- Precise stepping through the templated
step
parameter - Cursor movement between positions
The test case demonstrates proper decimal precision by:
- Incrementing decimals (1.10 -> 1.20 -> 1.30 -> 1.40 -> 1.50)
- Moving cursor between decimal/integer parts (right/left)
- Verifying both increment/decrement operations maintain precision
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for decimal precision configuration in the codebase
rg -A 2 "decimal.*precision|float.*format" --type cpp
Length of output: 265
Script:
#!/bin/bash
# Search for Quantity widget implementation and float handling
ast-grep --pattern 'class $_ {
$$$
float $$$
$$$
}'
# Also search for relevant method implementations
rg -l "Quantity.*Widget|WidgetRange" --type cpp
# Look for cursor movement implementation
rg -A 3 "right|left.*cursor" --type cpp
Length of output: 5445
Script:
#!/bin/bash
# Check WidgetRange implementation
cat src/widget/WidgetRange.h
# Look for increment/decrement implementations that handle decimal precision
rg -A 5 "increment|decrement" src/widget/WidgetRange.h
# Search for any float formatting or precision handling
rg -A 3 "format.*float|sprintf|dtostrf" --type cpp
Length of output: 7184
Script:
#!/bin/bash
# Look for Quantity widget format string and initialization
rg -A 5 "Quantity.*Widget.*format|WIDGET_RANGE.*float" --type cpp
# Check BaseWidgetValue implementation for cursor handling
cat src/BaseWidgetValue.h
Length of output: 149
Showcase
Only 3 buttons used UP, DOWN and ENTER
Screen.Recording.2024-10-30.at.13.50.24.mov