-
Notifications
You must be signed in to change notification settings - Fork 4
Feature/example: Add M5Unified compatible example sketch (v0.0.3) #7
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: master
Are you sure you want to change the base?
Conversation
Place Serial.println(encoder_value) inside the conditional block (if statement) to print the value only when a change occurs. This prevents continuous output and prints the encoder value only when it has been updated.
Fix: Display cutoff for values over 4 digits.
Replaced canvas.drawString with canvas.println/print for display output. This removes fixed coordinate dependencies, allowing for automatic text wrapping and easier porting to M5 controllers with different screen sizes.
| cfg.clear_display = true; | ||
| cfg.serial_baudrate = 115200; | ||
| M5.begin(cfg); | ||
| sensor.begin(); |
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.
When connecting the ATOMS3 and STM32F030F4P6 using the included cable, you may need to explicitly specify the pins.
// G2=SDA, G1=SCL
Wire.begin(2, 1);
sensor.begin(&Wire);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.
@ssknaoya, thank you for testing the operation with ATOMS3 and for sharing this valuable information. Since I don't own an ATOMS3, your cooperation is extremely helpful!
The fact that the I2C port had to be explicitly specified for ATOMS3 to function correctly suggests that we need to improve how the I2C port is designated.
While specifying Wire.begin(2, 1); might be the simplest solution for just the ATOMS3, as a sample sketch for a library, the ideal approach is to have common source code that works across different M5Unified controllers without hardware-specific port number designation.
I will look into ways to allow the current combination of M5Unified and the Unit Encoder library to operate without requiring explicit I2C port number specification.
Thank you again for the feedback!
Enhance the sample sketch to improve compatibility across M5Unified devices, specifically addressing the I2C initialization behavior on ATOMS3. By ensuring the proper I2C context is available before `sensor.begin()`, the example now runs reliably on ATOMS3 and maintains compatibility with other controllers without device-specific pin declarations.
|
@ssknaoya, I've implemented a fix based on your valuable feedback regarding the I2C initialization issue on ATOMS3. Thank you again for bringing that to my attention! |
Move Wire.begin() into the conditional block to correctly initialize either external or default I2C pins. Simplify the sensor.begin() call to only take the Wire instance, removing redundant pin parameters. This improves code clarity and maintains device compatibility.
This PR introduces a new example sketch to demonstrate the use of the Unit Encoder with the M5Unified library. This is intended to offer a modern and unified way for users to integrate the Unit Encoder across different M5Stack host devices.
Status and Request for Collaboration
I kindly request the community to help confirm the operation on one other M5Unified host (e.g., Basic, M5StickC Plus, CoreS3, M5Paper, etc.).
Your confirmation (or bug report) in the comments would be greatly appreciated.
Changes Included
library.propertiesandlibrary.json.Quick way to get the code (for Testers)
To test this branch locally, please follow the steps appropriate for your environment.
git clone https://github.com/ito55/M5Unit-Encodercd M5Unit-Encodergit switch feature/example-m5unified