Got it working my changing cabling and allocating buffer on the heap
This commit is contained in:
70
src/main.rs
70
src/main.rs
@@ -1,13 +1,13 @@
|
|||||||
use embedded_graphics::{mono_font::MonoTextStyleBuilder, prelude::Point, Drawable, text::{Baseline, Text, TextStyleBuilder}};
|
use embedded_graphics::{mono_font::MonoTextStyleBuilder, prelude::Point, Drawable, text::{Baseline, Text, TextStyleBuilder}};
|
||||||
use epd_waveshare::{color::Color, epd7in5_v2::Epd7in5, prelude::WaveshareDisplay};
|
use epd_waveshare::{color::Color, epd7in5_v2::Epd7in5, prelude::WaveshareDisplay};
|
||||||
use esp_idf_hal::{delay::{Delay, Ets}, gpio::PinDriver, spi::{config, Spi, SpiDriver, SpiDriverConfig}};
|
use esp_idf_hal::{delay::{Delay, Ets}, gpio::{Gpio19, PinDriver}, spi::{config, Spi, SpiDriver, SpiDriverConfig}};
|
||||||
use esp_idf_svc::hal::{prelude::*, spi::SpiDeviceDriver};
|
use esp_idf_svc::hal::{prelude::*, spi::SpiDeviceDriver};
|
||||||
use embedded_hal::delay::DelayNs;
|
use embedded_hal::delay::DelayNs;
|
||||||
|
|
||||||
|
|
||||||
//static mut display: epd_waveshare::epd7in5_v2::Display7in5 = epd_waveshare::epd7in5_v2::Display7in5::default();
|
//static mut display: epd_waveshare::epd7in5_v2::Display7in5 = epd_waveshare::epd7in5_v2::Display7in5::default();
|
||||||
|
|
||||||
static FRAMEBUF: [u8; 48000] = [1; 48000];
|
//static FRAMEBUF: [u8; 48000] = [63; 48000];
|
||||||
fn main() {
|
fn main() {
|
||||||
// It is necessary to call this function once. Otherwise some patches to the runtime
|
// It is necessary to call this function once. Otherwise some patches to the runtime
|
||||||
// implemented by esp-idf-sys might not link properly. See https://github.com/esp-rs/esp-idf-template/issues/71
|
// implemented by esp-idf-sys might not link properly. See https://github.com/esp-rs/esp-idf-template/issues/71
|
||||||
@@ -15,20 +15,20 @@ fn main() {
|
|||||||
|
|
||||||
// Bind the log crate to the ESP Logging facilities
|
// Bind the log crate to the ESP Logging facilities
|
||||||
esp_idf_svc::log::EspLogger::initialize_default();
|
esp_idf_svc::log::EspLogger::initialize_default();
|
||||||
|
|
||||||
log::info!("Hello, world!");
|
|
||||||
log::info!("Just logging something again");
|
|
||||||
|
|
||||||
let peripherals = Peripherals::take().unwrap();
|
let peripherals = Peripherals::take().unwrap();
|
||||||
|
|
||||||
log::info!("Took peripherals");
|
log::info!("Took peripherals");
|
||||||
|
|
||||||
let busy = PinDriver::input(peripherals.pins.gpio4).unwrap();
|
let busy = PinDriver::input(peripherals.pins.gpio17).unwrap();
|
||||||
let rst = PinDriver::output(peripherals.pins.gpio16).unwrap();
|
let rst = PinDriver::output(peripherals.pins.gpio16).unwrap();
|
||||||
let dc = PinDriver::output(peripherals.pins.gpio17).unwrap();
|
let cs = peripherals.pins.gpio5; // y
|
||||||
let cs = peripherals.pins.gpio5;
|
let clk = peripherals.pins.gpio18; // y
|
||||||
let clk = peripherals.pins.gpio18;
|
let mosi = peripherals.pins.gpio23; // y
|
||||||
let mosi = peripherals.pins.gpio23;
|
let miso = peripherals.pins.gpio19; // aka. dc
|
||||||
|
|
||||||
|
|
||||||
|
let dc = PinDriver::output(miso).unwrap();
|
||||||
|
|
||||||
|
|
||||||
log::info!("Initialized pins");
|
log::info!("Initialized pins");
|
||||||
|
|
||||||
@@ -36,10 +36,10 @@ fn main() {
|
|||||||
let config = config::Config::new();
|
let config = config::Config::new();
|
||||||
|
|
||||||
let mut spi = SpiDeviceDriver::new_single(
|
let mut spi = SpiDeviceDriver::new_single(
|
||||||
peripherals.spi3,
|
peripherals.spi2, // 2 oder 3?
|
||||||
clk,
|
clk,
|
||||||
peripherals.pins.gpio21,
|
mosi,
|
||||||
Some(mosi),
|
Option::<Gpio19>::None,
|
||||||
Some(cs),
|
Some(cs),
|
||||||
&SpiDriverConfig::default(),
|
&SpiDriverConfig::default(),
|
||||||
&config
|
&config
|
||||||
@@ -47,7 +47,9 @@ fn main() {
|
|||||||
|
|
||||||
log::info!("Initialized spi interface");
|
log::info!("Initialized spi interface");
|
||||||
|
|
||||||
//static mut display: epd_waveshare::epd7in5_v2::Display7in5 = epd_waveshare::epd7in5_v2::Display7in5::default();
|
// Allocating on the stack makes the chip crash. We gotta put it on the heap
|
||||||
|
let mut display = Box::new(epd_waveshare::epd7in5_v2::Display7in5::default());
|
||||||
|
display.set_rotation(epd_waveshare::prelude::DisplayRotation::Rotate180);
|
||||||
|
|
||||||
let mut delay = Ets;
|
let mut delay = Ets;
|
||||||
|
|
||||||
@@ -57,45 +59,21 @@ fn main() {
|
|||||||
log::info!("Created display object");
|
log::info!("Created display object");
|
||||||
|
|
||||||
|
|
||||||
//draw_text(&mut display, "Hello esp", 5, 50);
|
draw_text(&mut display, "Hello esp", 5, 50);
|
||||||
log::info!("Draw text done");
|
log::info!("Draw text done");
|
||||||
|
|
||||||
|
|
||||||
let res = epd7in5.update_and_display_frame(&mut spi, &FRAMEBUF, &mut delay);
|
let res = epd7in5.update_and_display_frame(&mut spi, &*display.buffer(), &mut delay);
|
||||||
|
|
||||||
|
|
||||||
if let Err(e) = res{
|
if let Err(e) = res{
|
||||||
log::info!("{}", e);
|
log::info!("{}", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* let mut i = 0;
|
|
||||||
loop{
|
|
||||||
let d = &mut delay;
|
|
||||||
d.delay_ms(500);
|
|
||||||
log::info!("Loop {}", i);
|
|
||||||
i += 1;
|
|
||||||
|
|
||||||
if i == 5{
|
|
||||||
//let data = display.buffer();
|
|
||||||
|
|
||||||
/* for d in data{
|
|
||||||
log::info!("{}", d)
|
|
||||||
} */
|
|
||||||
|
|
||||||
}
|
|
||||||
} */
|
|
||||||
|
|
||||||
/*
|
|
||||||
// Get SpiDevice trait implementation
|
|
||||||
//let mut spi_device = spi.into_device();
|
|
||||||
|
|
||||||
// let mut epd7in5 = Epd7in5::new(spi, busy, dc, rst, delay, delay_us)
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_text(display: &mut epd_waveshare::epd7in5_v2::Display7in5, text: &str, x: i32, y: i32) {
|
fn draw_text(display: &mut epd_waveshare::epd7in5_v2::Display7in5, text: &str, x: i32, y: i32) {
|
||||||
let style = MonoTextStyleBuilder::new()
|
let style = MonoTextStyleBuilder::new()
|
||||||
.font(&embedded_graphics::mono_font::ascii::FONT_6X10)
|
.font(&embedded_graphics::mono_font::ascii::FONT_10X20)
|
||||||
.text_color(Color::White)
|
.text_color(Color::White)
|
||||||
.background_color(Color::Black)
|
.background_color(Color::Black)
|
||||||
.build();
|
.build();
|
||||||
@@ -103,5 +81,5 @@ fn draw_text(display: &mut epd_waveshare::epd7in5_v2::Display7in5, text: &str, x
|
|||||||
let text_style = TextStyleBuilder::new().baseline(Baseline::Top).build();
|
let text_style = TextStyleBuilder::new().baseline(Baseline::Top).build();
|
||||||
|
|
||||||
// The problem:
|
// The problem:
|
||||||
//let _ = Text::with_text_style(text, Point::new(x, y), style, text_style).draw(display);
|
let _ = Text::with_text_style(text, Point::new(x, y), style, text_style).draw(display);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user