Closed 9names closed 2 years ago
I agree with this but it probably needs thinking through.
I only have the pico board so any code I cobble together will be tested on that and boards/rp-pico/examples/
seems logical. However it feels wrong to duplicate essentially the same code in each of the boards examples folders, with just the GPIO pins changed. Alternatively, spreading examples of interfacing with different hardware randomly across the different boards would be even worse as it would make searching for a specific one rather tedious.
I agree that duplicating examples to each of the boards seems like a bad idea.
However it could be an option to just put them to the rp-pico
example folder. As rp-pico
is a kind of reference design for RP2040 boards, it makes sense to use it even for examples which are not rp-pico
specific. It's also quite cheap and common.
So the distinction could be:
rp2040-hal/examples/
for examples specific to RP2040 internal hardwareboards/<board>/examples
for board-specific examplesboards/rp-pico/examples
for examples using external hardware.This mixes two kinds of examples within boards/rp-pico/examples
, but I guess that can be tolerated.
I should have fleshed out the rationale a bit better, but @jannic has correctly outlined the intention here. It helps that Pico is basically a clean slate - other than the LED and USB there is basically no hardware to support.
Yes, that makes complete sense.
I suppose the next question is how much stuff should be in here as a "batteries included" repository. The vanilla Arduino sdk has sixty or so built in but raspberrypi org seems to have broken them out into different repositories see here, here and here, and this is nice.
Perhaps we should prevail on raspberrypi org to open a repository pico-rust-examples
. They really ought to have someone on their team dedicated to using rust on their hardware by now!
You missed pico-playground - that's my favourite. I started my own thing like that here for pico expansion boards since I was just accumulating small examples on my hard drive. Having each example as it's own standalone project makes it much nicer in my opinion - you don't have to pass an --example or --bin argument at the command line, you can have whatever dependencies you want, people can just copy it directly if they want something like it, etc.
The Raspberry Pi folks have been quite supportive (they even paid for @thejpster's time for a short while) but I don't think they would be interested in taking on hosting/support the rust examples repo - if we want a repo like that we should just have make one.
I like the idea of an rp-rs-playground repo containing multiple individual binary crates. I also agree the examples in the rp-hal crate should be just enough to demonstrate how to use the HAL APIs and the BSP examples should be just enough to demonstrate how to use the BSP API.
After spending more time reviewing the DHT example, I think it's probably okay? It's primarily an example of changing pin modes while talking to the hardware, so it's not really an external hardware example as much as a pin mode tutorial.
After spending more time reviewing the DHT example, I think it's probably okay? It's primarily an example of changing pin modes while talking to the hardware, so it's not really an external hardware example as much as a pin mode tutorial.
It could probably be further reduced to some "how do I simulate an open-drain GPIO on RP2040" example, without relation to DHT11. But then, having some practical motivation in an example is also nice.
having some practical motivation in an example is also nice
Agreed! I'm against having hardware in one of the examples for no reason, but there is good reason in this instance. Going to close this now as this issue has served its purpose.
The rp-hal examples should be small and specific to the RP2040 hardware. We should move anything that's really an example of interfacing with external hardware somewhere else. Moving them under the rp-pico examples would be a good first step in this process, I think.
There's only two examples that use external hardware that I can see:
347 has already ported lcd_display to rp-pico (and added some nice diagrams) so we should be able to drop rp2040-hal/examples/lcd_display.rs if we accept this PR.