Init display
This commit is contained in:
parent
b8c6004d31
commit
113d976502
|
@ -360,6 +360,7 @@ name = "soldering-iron"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cortex-m-rt",
|
||||
"fugit",
|
||||
"panic-halt",
|
||||
"rp-pico",
|
||||
"ssd1306",
|
||||
|
|
|
@ -7,6 +7,7 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
cortex-m-rt = "0.7.3"
|
||||
fugit = "0.3.7"
|
||||
panic-halt = "0.2.0"
|
||||
rp-pico = "0.7.0"
|
||||
ssd1306 = "0.8.0"
|
||||
|
|
45
src/main.rs
45
src/main.rs
|
@ -1,11 +1,56 @@
|
|||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use fugit::RateExtU32;
|
||||
|
||||
use panic_halt as _;
|
||||
|
||||
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]
|
||||
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 {}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue