Init display

This commit is contained in:
Luca 2023-07-10 17:34:30 +02:00
parent b8c6004d31
commit 113d976502
3 changed files with 47 additions and 0 deletions

1
Cargo.lock generated
View File

@ -360,6 +360,7 @@ name = "soldering-iron"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"cortex-m-rt", "cortex-m-rt",
"fugit",
"panic-halt", "panic-halt",
"rp-pico", "rp-pico",
"ssd1306", "ssd1306",

View File

@ -7,6 +7,7 @@ edition = "2021"
[dependencies] [dependencies]
cortex-m-rt = "0.7.3" cortex-m-rt = "0.7.3"
fugit = "0.3.7"
panic-halt = "0.2.0" panic-halt = "0.2.0"
rp-pico = "0.7.0" rp-pico = "0.7.0"
ssd1306 = "0.8.0" ssd1306 = "0.8.0"

View File

@ -1,11 +1,56 @@
#![no_std] #![no_std]
#![no_main] #![no_main]
use fugit::RateExtU32;
use panic_halt as _; use panic_halt as _;
use rp_pico::entry; use rp_pico::entry;
use rp_pico::hal::clocks::{self, Clock};
use rp_pico::hal::i2c::I2C;
use rp_pico::hal::{Sio, Watchdog};
use rp_pico::pac::Peripherals;
use rp_pico::Pins;
use ssd1306::prelude::*;
use ssd1306::{I2CDisplayInterface, Ssd1306};
#[entry] #[entry]
fn main() -> ! { fn main() -> ! {
let mut p = Peripherals::take().unwrap();
let mut watchdog = Watchdog::new(p.WATCHDOG);
let clocks = clocks::init_clocks_and_plls(
rp_pico::XOSC_CRYSTAL_FREQ,
p.XOSC,
p.CLOCKS,
p.PLL_SYS,
p.PLL_USB,
&mut p.RESETS,
&mut watchdog,
)
.ok()
.unwrap();
let sio = Sio::new(p.SIO);
let pins = Pins::new(p.IO_BANK0, p.PADS_BANK0, sio.gpio_bank0, &mut p.RESETS);
let i2c = I2C::i2c0(
p.I2C0,
pins.gpio16.into_mode(),
pins.gpio17.into_mode(),
400.kHz(),
&mut p.RESETS,
clocks.peripheral_clock.freq(),
);
let mut display = Ssd1306::new(
I2CDisplayInterface::new_custom_address(i2c, 0x78),
DisplaySize128x64,
DisplayRotation::Rotate0,
)
.into_buffered_graphics_mode();
display.init().unwrap();
loop {} loop {}
} }