-
Notifications
You must be signed in to change notification settings - Fork 245
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
pimoroni display pack 2 example #395
Conversation
Oops - sorry about that. I thought that clippy lint didn't apply to no_std crates? This is no longer a correctness issue, so you could just disable the clippy warning. Or add |
See rp-rs#408 for reasoning why this is sensible.
Perfect ty @jannic |
@jgmartin unfortunately, this branch needs an update: |
// Configure button inputs | ||
// 12 - A button | ||
let _a_pin = pins.gpio12.into_floating_input(); | ||
// 13 - B button | ||
let _b_pin = pins.gpio13.into_floating_input(); | ||
// 14 - X button | ||
let _x_pin = pins.gpio14.into_floating_input(); | ||
// 15 - Y button | ||
let _y_pin = pins.gpio15.into_floating_input(); |
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.
These switches do not have external pull-ups, you should enable the internal ones or you'll never be able to detect a button press.
// Configure button inputs | |
// 12 - A button | |
let _a_pin = pins.gpio12.into_floating_input(); | |
// 13 - B button | |
let _b_pin = pins.gpio13.into_floating_input(); | |
// 14 - X button | |
let _x_pin = pins.gpio14.into_floating_input(); | |
// 15 - Y button | |
let _y_pin = pins.gpio15.into_floating_input(); | |
// Configure button inputs | |
// The push-buttons connect their respective pin to ground, this is often referred to as "active-low" | |
// Since the board does not have external pull-up resistors, enable internal pull-up on each input | |
// 12 - A button | |
let _a_pin = pins.gpio12.into_pull_up_input(); | |
// 13 - B button | |
let _b_pin = pins.gpio13.into_pull_up_input(); | |
// 14 - X button | |
let _x_pin = pins.gpio14.into_pull_up_input(); | |
// 15 - Y button | |
let _y_pin = pins.gpio15.into_pull_up_input(); |
This example is also compatible with Pimoroni Display Pack (1.0) as well - the pinout for LED, buttons and LCD controller for both is the same. |
No problem I will do this and test it. |
|
||
// Setup SPI | ||
let spi_cs = pins.gpio17.into_push_pull_output(); | ||
let spi_miso = pins.gpio16.into_push_pull_output(); |
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.
This pin is not used as miso so I'd suggest giving it an name matching its use. eg: di_data_command
// Configure button inputs | ||
// 12 - A button | ||
let _a_pin = pins.gpio12.into_pull_up_input(); | ||
// 13 - B button | ||
let _b_pin = pins.gpio13.into_pull_up_input(); | ||
// 14 - X button | ||
let _x_pin = pins.gpio14.into_pull_up_input(); | ||
// 15 - Y button | ||
let _y_pin = pins.gpio15.into_pull_up_input(); |
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.
Those pins are not used (and are not configured for the purpose of another peripheral) so I think they should be removed from the example.
Alternatively, the example could draw on the display which button is pressed (as a letter or any other symbol).
/// External high-speed crystal on the Raspberry Pi Pico board is 12 MHz. Adjust | ||
/// if your board has a different frequency | ||
const XTAL_FREQ_HZ: u32 = 12_000_000u32; |
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.
The definition provided by the rp_pico
crate should be used instead.
This PR should be moved to https://github.com/rp-rs/rp-hal-boards. |
adds an example of using the pimoroni display pack 2.0 with embedded_graphics.