rp-hal icon indicating copy to clipboard operation
rp-hal copied to clipboard

add Adafruit Macropad macros

Open mutantbob opened this issue 3 years ago • 2 comments

Add a bunch of macros in the adafruit-macropad board crate to make it easier to construct working peripheral objects.

With this patch your main() can start like this:

let mut pac = pac::Peripherals::take().unwrap();
let core = pac::CorePeripherals::take().unwrap();
let mut watchdog = Watchdog::new(pac.WATCHDOG);
let clocks = macropad_clocks!(pac, watchdog);
let mut delay = cortex_m::delay::Delay::new(core.SYST, clocks.system_clock.freq().integer());
let pins = macropad_pins!(pac);
let timer = Timer::new(pac.TIMER, &mut pac.RESETS);
//
let mut disp = macropad_oled!(pins, clocks, delay, pac);
let mut led_pin = pins.led.into_push_pull_output();
let mut neopixels = macropad_neopixels!(pins, clocks, timer, pac);
//
let mut rotary = macropad_rotary_encoder!(pins);
let keys = macropad_keypad!(pins);

mutantbob avatar Jul 21 '22 19:07 mutantbob

I could use some help figuring out how to make the CI checks pass. It looks like cargo test --doc --target x86_64-unknown-linux-gnu is malfunctioning.

if I remove the code sample from the top of macro.rs the test passes fine, but then the user of the library will not be able to benefit from the example.

mutantbob avatar Aug 02 '22 19:08 mutantbob

You could add the ignore attribute to the code block. https://doc.rust-lang.org/rustdoc/write-documentation/documentation-tests.html#attributes That way, it stays part of the documentation, but won't be run as a doc test.

jannic avatar Aug 02 '22 22:08 jannic

This PR should be moved to https://github.com/rp-rs/rp-hal-boards. I am closing it here but be assured these changes would be welcome over there :) .

ithinuel avatar May 13 '23 03:05 ithinuel