Comments (4)
It seems that only a SpiBus is implemented in rp-hal, not a SpiDevice. See here. You can implement a SpiDevice yourself. The embedded-hal-bus crate provides mechanisms to connect a SpiBus and a SpiDevice. The ExclusiveDevice seems to be the easiest way.
from epd-waveshare.
Hi! Thank you so much, that really helped me out.
Unfortunately I'm still not fully able to compile my project because I'm not sure how the DC
pin is used. My assumption is that it is the MISO
part of the SPI connection, so it makes sense that Spi::new()
takes ownership of this pin. However, Epd2in13::new()
also expects access to this DC pin, which is not possible because it was moved into Spi
before.
Here's a snippet of the relevant part of my program:
#[rp2040_hal::entry]
fn main() -> ! {
// [...]
// Set the pins to their default state
let pins = hal::gpio::Pins::new(
pac.IO_BANK0,
pac.PADS_BANK0,
sio.gpio_bank0,
&mut pac.RESETS,
);
let pin_cs = pins.gpio14.into_push_pull_output();
let pin_busy = pins.gpio12.into_floating_input();
let pin_dc = pins.gpio8.into_push_pull_output();
let pin_rst = pins.gpio13.into_push_pull_output();
// These are implicitly used by the spi driver if they are in the correct mode
let spi_mosi = pins.gpio11.into_function::<hal::gpio::FunctionSpi>(); // DIN
// This doesn't work, and it shouldn't. (It doesn't make sense to initialize the same pin twice)
// But how do I pass the same pin into `Spi` and into `Epd2in13`?
let spi_miso = pins.gpio8.into_function::<hal::gpio::FunctionSpi>(); // DC
let spi_sclk = pins.gpio10.into_function::<hal::gpio::FunctionSpi>();
let spi = hal::spi::Spi::<_, _, _, 8>::new(pac.SPI1, (spi_mosi, spi_miso, spi_sclk));
// Exchange the uninitialised SPI driver for an initialised one
let mut spi = spi.init(
&mut pac.RESETS,
clocks.peripheral_clock.freq(),
16.MHz(),
embedded_hal::spi::MODE_0,
);
let mut timer = rp2040_hal::Timer::new(pac.TIMER, &mut pac.RESETS, &clocks);
let mut spi_device = ExclusiveDevice::new(spi, pin_cs, timer);
info!("Setting up display");
let mut display = Display2in13::default();
let mut epd = Epd2in13::new(&mut spi_device, pin_busy, pin_dc, pin_rst, &mut timer, None).expect("EPD setup error");
epd.update_frame(&mut spi_device, display.buffer(), &mut timer).expect("Update frame");
epd.display_frame(&mut spi_device, &mut timer).expect("Display new frame");
loop {
cortex_m::asm::wfi();
}
}
So basically my question is: How can I pass the same DC pin into both the Spi driver and the EPD driver?
from epd-waveshare.
The pins MOSI, MISO and SCLK make the SPI bus. Together with CS (chip select) this is the SPI device. EPD needs the SPI device, BUSY, DC (to distinguish between data and control bytes, has nothing to do with SPI) and RESET. These are all different pins. Maybe the confusion is that most e-paper modules do not have a MISO pin (master in, slave out), because the e-paper does not need to send data to the host. You can leave this pin unconnected. MOSI (master out, slave in) is often described as DIN (data in) or SDI (slave data in).
from epd-waveshare.
Thank you so much for your help, it's finally working now (well, the colors are inverted and the screen is rotated 90 degrees, but I'm sure I'll figure that out later).
For future reference, the following pin mapping is tested on a Raspberry Pi Pico connected to the Waveshare 2.13" Display (Rev. 4) using the universal Driver HAT.
RPi Pico | EPD | Notes |
---|---|---|
8 | DC | |
9 | BUSY | |
10 | CLK | SCK pin of SPI bus |
11 | DIN | MOSI pin of SPI bus |
12 | not connected | MISO pin of SPI bus |
13 | RST | |
14 | CS | Chip Select for SPI bus |
Display Config
switch: B
Interface Config
switch: 4-line SPI
from epd-waveshare.
Related Issues (20)
- Problems with Pico-ePaper-7.5-B HOT 1
- epd1in54_v2 does not show anything until LUT is set. HOT 1
- Epd4in2::new() waits forever
- Proposal(s): support for display timeouts, introducing a local Error type HOT 1
- Some 1.54" display links in README 404. HOT 11
- Example 2in13bc gets stuck on `Epd2in13bc::new()` HOT 1
- Support for 12.48inch module HOT 6
- MH-ET LIVE epaper support HOT 1
- How should new devices be added? HOT 1
- Remove git dev dependencies HOT 1
- How can I retrieve the old (currently displayed) screen data?
- Cannot build example epd2in13_v2 HOT 2
- 2.9" Display - Partial Quick Refresh Support HOT 3
- Bits/Bytes in epd7in5b_v2 NUM_DISPLAY_XXXXX HOT 1
- Waveshare 7.5 (B) v3 stuck on Display7in5 HOT 6
- New release? HOT 3
- Cannot render with MonoTextStyle HOT 2
- Waveshare 1.54 V2 does not work HOT 1
- WeActStudio display support HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from epd-waveshare.