diff --git a/Cargo.toml b/Cargo.toml index a74e935..f50c280 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -73,6 +73,7 @@ opt-level = "z" name = "blinky" path = "src/demo/blinky.rs" + [[bin]] name = "web" path = "src/demo/web.rs" @@ -80,3 +81,18 @@ path = "src/demo/web.rs" # [[bin]] # name = "my_bin" # path = "path/to/my/bin" + + +#name = "ex4" +#path = "src/exercitii/ex4.rs" +#[[bin]] +#name = "i2c" +#path = "src/exercitii/i2c.rs" + +#[[bin]] +#name = "spi" +#path = "src/exercitii/spi.rs" + +[[bin]] +name = "memgame" +path = "src/exercitii/memory_game.rs" \ No newline at end of file diff --git a/src/exercitii/ex1.rs b/src/exercitii/ex1.rs new file mode 100644 index 0000000..2707838 --- /dev/null +++ b/src/exercitii/ex1.rs @@ -0,0 +1,27 @@ +#![no_std] +#![no_main] + +use embassy_rp::gpio::{Level, Output}; +use embassy_time::Timer; +use embassy_executor::Spawner; +use {defmt_rtt as _, panic_probe as _}; +use defmt::info; + +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let peripherals = embassy_rp::init(Default::default()); + + let mut pin4: Output = Output::new(peripherals.PIN_4, Level::Low); + let mut pin5: Output = Output::new(peripherals.PIN_5, Level::Low); + + loop{ + pin4.set_high(); + info!("Green led on!"); + Timer::after_millis(500).await; + pin4.set_low(); + info!("Red led on!"); + pin5.set_high(); + Timer::after_secs(1).await; + pin5.set_low(); + } +} diff --git a/src/exercitii/ex2.rs b/src/exercitii/ex2.rs new file mode 100644 index 0000000..24d7bcc --- /dev/null +++ b/src/exercitii/ex2.rs @@ -0,0 +1,65 @@ +#![no_std] +#![no_main] + +use embassy_embedded_hal::SetConfig; +use embassy_rp::{config, gpio::{Level, Output}, peripherals}; +use embassy_time::Timer; +use embassy_executor::Spawner; +use embassy_usb::msos::ConfigurationSubsetHeader; +use {defmt_rtt as _, panic_probe as _}; +use defmt::info; +use embassy_rp::pwm::Config as ConfigPwm; +use embassy_rp::pwm::Pwm; + +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let peripherals = embassy_rp::init(Default::default()); + + // let mut pin0: Output = Output::new(peripherals.PIN_0, Level::High); + // let mut pin1: Output = Output::new(peripherals.PIN_1, Level::High); + // let mut pin2: Output = Output::new(peripherals.PIN_2, Level::High); + + let mut config: ConfigPwm = Default::default(); + config.top = 0x8000; + config.compare_a = 0; + config.compare_b = 0; + + let procent = config.top / 10; + + let mut pwm = Pwm::new_output_ab( // output A + peripherals.PWM_SLICE0, // channel 0 + peripherals.PIN_0, // pin 0 + peripherals.PIN_1, + config.clone() + ); + + + let mut pwm2 = Pwm::new_output_a( // output A + peripherals.PWM_SLICE1, // channel 1 + peripherals.PIN_2, // pin 2 + config.clone() + ); + + loop{ + Timer::after_secs(1).await; + + if config.compare_a >= config.top + { + info!("Reset intensity!"); + config.compare_a = 0; + config.compare_b = 0; + pwm.set_config(&config); + pwm2.set_config(&config); + continue; + } + + + info!("Decrease intensity!"); + config.compare_a += procent as u16; + config.compare_b += procent as u16; + + pwm.set_config(&config); + pwm2.set_config(&config); + } + +} diff --git a/src/exercitii/ex3.rs b/src/exercitii/ex3.rs new file mode 100644 index 0000000..b0b01d2 --- /dev/null +++ b/src/exercitii/ex3.rs @@ -0,0 +1,79 @@ +#![no_std] +#![no_main] + +use embassy_embedded_hal::SetConfig; +use embassy_futures::select; +use embassy_rp::{config, gpio::{Level, Output}, peripherals}; +use embassy_time::Timer; +use embassy_executor::Spawner; +use embassy_usb::msos::ConfigurationSubsetHeader; +use fixed::const_fixed_from_int; +use {defmt_rtt as _, panic_probe as _}; +use defmt::info; +use embassy_rp::pwm::Config as ConfigPwm; +use embassy_rp::pwm::Pwm; +use embassy_rp::gpio::{Input, Pull}; +use embassy_futures::select::{select, Either::First, Either::Second}; + +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let peripherals = embassy_rp::init(Default::default()); + + // let mut pin0: Output = Output::new(peripherals.PIN_0, Level::High); + // let mut pin1: Output = Output::new(peripherals.PIN_1, Level::High); + // let mut pin2: Output = Output::new(peripherals.PIN_2, Level::High); + + let mut config: ConfigPwm = Default::default(); + config.top = 0x8000; + config.compare_a = config.top; + config.compare_b = config.top; + + let procent = config.top / 10; + + let mut pwm = Pwm::new_output_ab( // output A + peripherals.PWM_SLICE0, // channel 0 + peripherals.PIN_0, // pin 0 + peripherals.PIN_1, + config.clone() + ); + + let mut pwm2 = Pwm::new_output_a( // output A + peripherals.PWM_SLICE1, // channel 1 + peripherals.PIN_2, // pin 2 + config.clone() + ); + + let mut buttonA = Input::new(peripherals.PIN_12, Pull::Up); + let mut buttonB = Input::new(peripherals.PIN_13, Pull::Up); + + loop{ + let select = select(buttonA.wait_for_falling_edge(), buttonB.wait_for_falling_edge()).await; + match select{ + First(()) => { + if config.compare_a < procent + { continue; } + config.compare_a -= procent; + config.compare_b -= procent; + }, + Second(()) => { + if config.compare_a > config.top - procent + { continue; } + config.compare_a += procent; + config.compare_b += procent; + } + } + pwm.set_config(&config); + pwm2.set_config(&config); + } + +} + +// #[embassy_executor::task] +// async fn increase_intensity() +// { +// if(config.compare_a < procent) +// { +// return; +// } +// config.compare_a -= procent as u16; +// } \ No newline at end of file diff --git a/src/exercitii/ex4.rs b/src/exercitii/ex4.rs new file mode 100644 index 0000000..d7e0735 --- /dev/null +++ b/src/exercitii/ex4.rs @@ -0,0 +1,133 @@ +#![no_std] +#![no_main] + +use core::i32; + +use embassy_embedded_hal::SetConfig; +use embassy_rp::{config, gpio::{Input, Output, Pull}, peripherals::{self, PIN_12}}; +use embassy_time::Timer; +use embassy_executor::Spawner; +use embassy_usb::msos::ConfigurationSubsetHeader; +use {defmt_rtt as _, panic_probe as _}; +use defmt::info; +use embassy_rp::pwm::Config as ConfigPwm; +use embassy_rp::pwm::Pwm; +use embassy_futures::select::{select, select4, Either::{self, First, Second}}; +use embassy_sync::channel::Channel; +use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; + + +static CHANNEL: Channel = Channel::new(); + +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let peripherals = embassy_rp::init(Default::default()); + + let mut config: ConfigPwm = Default::default(); + config.top = 0x8000; + config.compare_a = 0; + config.compare_b = 0; + + + //66,227,250 - BLEU + + //PIN0 = RED + //PIN1 = GREEN + //PIN2 = BLUE + + //255,61,203 - ROZ + + let mut config1: ConfigPwm = Default::default(); + config1.top = config.top; + config1.compare_a = config.top / 100 * 74; + config1.compare_b = config.top / 100 * 11; + + let mut config2: ConfigPwm = Default::default(); + config2.top = config.top; + config2.compare_a = config.top / 100 * 2; + config2.compare_b = 0; + + let mut config1ROZ: ConfigPwm = Default::default(); + config1ROZ.top = config.top; + config1ROZ.compare_a = 0; + config1ROZ.compare_b = config.top / 100 * 75; + + let mut config2ROZ: ConfigPwm = Default::default(); + config2ROZ.top = config.top; + config2ROZ.compare_a = config.top / 100 * 20; + config2ROZ.compare_b = 0; + + //106,248,68 - VERDE DESCHIS + + let mut config1VERDE: ConfigPwm = Default::default(); + config1VERDE.top = config.top; + config1VERDE.compare_a = config.top / 100 * 58; + config1VERDE.compare_b = config.top / 100 * 3; + + let mut config2VERDE: ConfigPwm = Default::default(); + config2VERDE.top = config.top; + config2VERDE.compare_a = config.top / 100 * 73; + config2VERDE.compare_b = 0; + + let procent = config.top / 10; + + let mut pwm = Pwm::new_output_ab( // output A + peripherals.PWM_SLICE0, // channel 0 + peripherals.PIN_0, // pin 0 + peripherals.PIN_1, + config.clone() + ); + + + let mut pwm2 = Pwm::new_output_a( // output A + peripherals.PWM_SLICE1, // channel 1 + peripherals.PIN_2, // pin 2 + config.clone() + ); + + let mut buttonA = Input::new(peripherals.PIN_12, Pull::Up); + let mut buttonB = Input::new(peripherals.PIN_13, Pull::Up); + let mut buttonX = Input::new(peripherals.PIN_14, Pull::Up); + let mut buttonY = Input::new(peripherals.PIN_15, Pull::Up); + + + _spawner.spawn(button_pressed(buttonA, 0)).unwrap(); + _spawner.spawn(button_pressed(buttonB, 1)).unwrap(); + _spawner.spawn(button_pressed(buttonX, 2)).unwrap(); + _spawner.spawn(button_pressed(buttonY, 3)).unwrap(); + + + + loop{ + let value = CHANNEL.receive().await; + info!("Received {}", value); + match value { + 0 => { + pwm.set_config(&config); + pwm2.set_config(&config); + }, + 1 => { + pwm.set_config(&config1); + pwm2.set_config(&config2); + }, + 2 => { + pwm.set_config(&config1ROZ); + pwm2.set_config(&config2ROZ); + }, + 3 => { + pwm.set_config(&config1VERDE); + pwm2.set_config(&config2VERDE); + }, + _ => break + } + } + +} + +#[embassy_executor::task(pool_size = 4)] +async fn button_pressed(mut button: Input<'static>, but: i32) { + loop { + button.wait_for_falling_edge().await; + CHANNEL.send(but).await; + } +} \ No newline at end of file diff --git a/src/exercitii/i2c.rs b/src/exercitii/i2c.rs new file mode 100644 index 0000000..e2204ad --- /dev/null +++ b/src/exercitii/i2c.rs @@ -0,0 +1,95 @@ +#![no_std] +#![no_main] + +use cortex_m::asm::nop; +use defmt::info; +use embassy_time::Timer; +use embedded_hal_async::i2c::I2c as _; +use embassy_rp::peripherals::I2C0; +use embassy_executor::Spawner; +use embassy_rp::{bind_interrupts, config}; +use embassy_rp::i2c::{I2c, InterruptHandler as I2CInterruptHandler, Config as I2cConfig}; +use {defmt_rtt as _, panic_probe as _}; +use embassy_rp::pwm::Config as ConfigPwm; +use embassy_rp::pwm::Pwm; + +bind_interrupts!(struct Irqs { + I2C0_IRQ => I2CInterruptHandler; +}); + +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let peripherals = embassy_rp::init(Default::default()); + + let mut config1: ConfigPwm = Default::default(); + config1.top = 0x8000; + config1.compare_a = 0; + config1.compare_b = 0; + + let mut config2: ConfigPwm = Default::default(); + config2.top = config1.top; + config2.compare_a = 0; + config2.compare_b = 0; + + let mut pwm = Pwm::new_output_ab( // output A + peripherals.PWM_SLICE0, // channel 0 + peripherals.PIN_0, // pin 0 + peripherals.PIN_1, + config1.clone() + ); + + let mut pwm2 = Pwm::new_output_a( // output A + peripherals.PWM_SLICE1, // channel 1 + peripherals.PIN_2, // pin 2 + config2.clone() + ); + + let sda = peripherals.PIN_20; + let scl = peripherals.PIN_21; + let mut i2c = I2c::new_async(peripherals.I2C0, scl, sda, Irqs, I2cConfig::default()); + + const TARGET_ADDR: u8 = 0x50; + let tx_buf1 = [0x00, 0x00, 0xf2, 0xa5, 0x15,0x27, 0x8b, 0x68, 0x6b, 0x91, 0x24, 0x32, 0x85, 0xc3, 0x25, 0xf0, 0xc6, 0x9c, 0x62, 0xfe, 0x34, 0x95, 0x35, 0x95, 0x4f, 0x61, 0x82, 0xcc, 0x07, 0xbf, 0x5f, 0xba ]; + + i2c.write(TARGET_ADDR, &tx_buf1).await.unwrap(); + + info!("Wrote: {:?}", tx_buf1); + + let mem_address = [0x00, 0x00]; + let mut rx_buf = [0x00u8; 3]; + + loop { + Timer::after_secs(2).await; + i2c.write_read(TARGET_ADDR, &mem_address, &mut rx_buf).await.unwrap(); + + info!("Read: {:?}", rx_buf); + change_color(rx_buf, config1.clone(), config2.clone(), &mut pwm, &mut pwm2); + + for i in 0..9 + { + Timer::after_millis(500).await; + i2c.read(TARGET_ADDR, &mut rx_buf).await.unwrap(); + info!("Read: {:?} Color number {}", rx_buf, i+2); + change_color(rx_buf, config1.clone(), config2.clone(), &mut pwm, &mut pwm2); + } + } +} + +fn change_color(arr: [u8; 3], mut config1: ConfigPwm, mut config2: ConfigPwm, pwm: &mut Pwm, pwm2: &mut Pwm) +{ + let mut procent: u16 = arr[0] as u16 * 100 / 255; + + procent = 100 - procent; + config1.compare_a = config1.top / 100 * procent as u16; + + procent = arr[1] as u16 * 100 / 255; + procent = 100 - procent; + config1.compare_b = config1.top / 100 * procent as u16; + + procent = arr[2] as u16 * 100 / 255; + procent = 100 - procent; + config2.compare_a = config2.top / 100 * procent as u16; + + pwm.set_config(&config1); + pwm2.set_config(&config2); +} \ No newline at end of file diff --git a/src/exercitii/memory_game.rs b/src/exercitii/memory_game.rs new file mode 100644 index 0000000..5f6b772 --- /dev/null +++ b/src/exercitii/memory_game.rs @@ -0,0 +1,213 @@ +#![no_std] +#![no_main] + +use embassy_executor::Spawner; +use defmt::info; +//use embassy_rp::peripherals; +use embassy_time::Timer; +use rand::RngCore; +use {defmt_rtt as _, panic_probe as _}; +use ipw_embedded::display::SPIDeviceInterface; +use embedded_graphics::{pixelcolor::Rgb565, text::Text}; +use embedded_graphics::prelude::Point; +use embedded_graphics::mono_font::ascii:: FONT_10X20; +use embedded_graphics::mono_font::MonoTextStyle; +use embedded_graphics::Drawable; +use embassy_rp::i2c::{I2c, InterruptHandler as I2CInterruptHandler, Config as I2cConfig}; +use {defmt_rtt as _, panic_probe as _}; +use embassy_rp::gpio::{Level, Output, Input, Pull}; +use embassy_rp::bind_interrupts; +use embedded_hal_async::i2c::I2c as _; +use embassy_rp::peripherals::I2C0; +use embassy_sync::channel::Channel; +use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; +use embassy_rp::clocks::RoscRng; + +bind_interrupts!(struct Irqs { + I2C0_IRQ => I2CInterruptHandler; +}); + + +static CHANNEL: Channel = Channel::new(); + +#[embassy_executor::main] +async fn main(spawner: Spawner) +{ + let peripherals = embassy_rp::init(Default::default()); + + let miso = peripherals.PIN_4; + let display_cs = peripherals.PIN_17; + let mosi = peripherals.PIN_19; + let clk = peripherals.PIN_18; + let rst = peripherals.PIN_0; + let dc = peripherals.PIN_16; + let mut display_config = embassy_rp::spi::Config::default(); + display_config.frequency = 64_000_000; + display_config.phase = embassy_rp::spi::Phase::CaptureOnSecondTransition; + display_config.polarity = embassy_rp::spi::Polarity::IdleHigh; + + // Init SPI + let spi: embassy_rp::spi::Spi<'_, _, embassy_rp::spi::Blocking> = + embassy_rp::spi::Spi::new_blocking( + peripherals.SPI0, + clk, + mosi, + miso, + display_config.clone(), + ); + let spi_bus: embassy_sync::blocking_mutex::Mutex< + embassy_sync::blocking_mutex::raw::NoopRawMutex, + _, + > = embassy_sync::blocking_mutex::Mutex::new(core::cell::RefCell::new(spi)); + + let display_spi = embassy_embedded_hal::shared_bus::blocking::spi::SpiDeviceWithConfig::new( + &spi_bus, + embassy_rp::gpio::Output::new(display_cs, embassy_rp::gpio::Level::High), + display_config, + ); + + let dc = embassy_rp::gpio::Output::new(dc, embassy_rp::gpio::Level::Low); + let rst = embassy_rp::gpio::Output::new(rst, embassy_rp::gpio::Level::Low); + let di = SPIDeviceInterface::new(display_spi, dc); + + // Init ST7789 LCD + let mut display = st7789::ST7789::new(di, rst, 240, 240); + display.init(&mut embassy_time::Delay).unwrap(); + display + .set_orientation(st7789::Orientation::Portrait) + .unwrap(); + use embedded_graphics::draw_target::DrawTarget; + display.clear(embedded_graphics::pixelcolor::RgbColor::BLACK).unwrap(); + // ************************************************************************ + + let color = Rgb565::new(255, 255, 0); + // Write welcome message + let style = MonoTextStyle::new(&FONT_10X20, color); + Text::new("Prepare for the memory game!", Point::new(36, 190), style) + .draw(&mut display) + .unwrap(); + + let sda = peripherals.PIN_20; + let scl = peripherals.PIN_21; + let mut i2c = I2c::new_async(peripherals.I2C0, scl, sda, Irqs, I2cConfig::default()); + + + const TARGET_ADDR: u8 = 0x50; + let tx_buf1 = [0x00u8; 3]; + i2c.write(TARGET_ADDR, &tx_buf1).await.unwrap(); + + let mut led_green: Output = Output::new(peripherals.PIN_2, Level::Low); + let mut led_red: Output = Output::new(peripherals.PIN_1, Level::Low); + + let buttona = Input::new(peripherals.PIN_12, Pull::Up); + let buttonb = Input::new(peripherals.PIN_13, Pull::Up); + let buttonx = Input::new(peripherals.PIN_14, Pull::Up); + let buttony = Input::new(peripherals.PIN_15, Pull::Up); + + + spawner.spawn(button_pressed(buttona, 0 as u8)).unwrap(); + spawner.spawn(button_pressed(buttonb, 1 as u8)).unwrap(); + spawner.spawn(button_pressed(buttonx, 2 as u8)).unwrap(); + spawner.spawn(button_pressed(buttony, 3 as u8)).unwrap(); + let butt_dict = ['A','B','X','Y']; + + let mut button_index = 0; + let mut arr = [0x00u8; 4]; + let mut score = 0; + loop { + if button_index == 4 + { + button_index = 0; + score += 1; + info!("Your score is: {}", score); + led_green.set_high(); + Timer::after_secs(2).await; + led_green.set_low(); + } + if button_index == 0 + { + arr = generate_random_sequence(); + for i in 0..4 + { + display.clear(embedded_graphics::pixelcolor::RgbColor::BLACK).unwrap(); + if arr[i] == 0 + { + Text::new("A", Point::new(36, 190), style).draw(&mut display).unwrap(); + } else + if arr[i] == 1 + { + Text::new("B", Point::new(36, 190), style).draw(&mut display).unwrap(); + } else + if arr[i] == 2 + { + Text::new("X", Point::new(36, 190), style).draw(&mut display).unwrap(); + } else + if arr[i] == 3 + { + Text::new("Y", Point::new(36, 190), style).draw(&mut display).unwrap(); + } + Timer::after_millis(500).await; + } + display.clear(embedded_graphics::pixelcolor::RgbColor::BLACK).unwrap(); + } + + CHANNEL.clear(); + let value = CHANNEL.receive().await; + info!("Pressed button {}", butt_dict[value as usize]); + + if value == arr[button_index] + { + button_index += 1; + info!("Pressed correct button!"); + led_green.set_high(); + Timer::after_millis(300).await; + led_green.set_low(); + + }else { + + button_index = 0; + led_red.set_high(); + info!("Pressed incorrect button!"); + display.clear(embedded_graphics::pixelcolor::RgbColor::BLACK).unwrap(); + Text::new("INCORRECT BUTTON", Point::new(36, 190), style).draw(&mut display).unwrap(); + Timer::after_secs(2).await; + led_red.set_low(); + + + CHANNEL.clear(); + let mut buff = [0x00u8]; + i2c.write_read(TARGET_ADDR, &[0x00u8; 2], &mut buff).await.unwrap(); + if score > buff[0] + { + let mut tx_buff = [0x00u8; 3]; + tx_buff[2] = score as u8; + i2c.write(TARGET_ADDR, &tx_buff).await.unwrap(); + info!("New highscore: {}", score); + } + + score = 0; + } + } +} + +#[embassy_executor::task(pool_size = 4)] +async fn button_pressed(mut button: Input<'static>, but: u8) { + loop { + button.wait_for_falling_edge().await; + CHANNEL.send(but).await; + } +} + +fn generate_random_sequence()->[u8; 4] +{ + let mut arr = [0x00u8; 4]; + + RoscRng.fill_bytes(&mut arr); + + for i in 0..4 + { + arr[i] %= 4; + } + + return arr; +} \ No newline at end of file diff --git a/src/exercitii/spi.rs b/src/exercitii/spi.rs new file mode 100644 index 0000000..3e077ea --- /dev/null +++ b/src/exercitii/spi.rs @@ -0,0 +1,74 @@ +#![no_std] +#![no_main] + +use cyw43::new; +use embassy_executor::Spawner; +use defmt::info; +use embassy_rp::peripherals; +use embassy_time::Timer; +use {defmt_rtt as _, panic_probe as _}; +use ipw_embedded::display::SPIDeviceInterface; +use embedded_graphics::{pixelcolor::Rgb565, text::Text}; +use embedded_graphics::prelude::Point; +use embedded_graphics::mono_font::ascii::FONT_7X13_BOLD; +use embedded_graphics::mono_font::MonoTextStyle; +use embedded_graphics::Drawable; + +#[embassy_executor::main] +async fn main(spawner: Spawner) +{ + let peripherals = embassy_rp::init(Default::default()); + + let miso = peripherals.PIN_4; + let display_cs = peripherals.PIN_17; + let mosi = peripherals.PIN_19; + let clk = peripherals.PIN_18; + let rst = peripherals.PIN_0; + let dc = peripherals.PIN_16; + let mut display_config = embassy_rp::spi::Config::default(); + display_config.frequency = 64_000_000; + display_config.phase = embassy_rp::spi::Phase::CaptureOnSecondTransition; + display_config.polarity = embassy_rp::spi::Polarity::IdleHigh; + + // Init SPI + let spi: embassy_rp::spi::Spi<'_, _, embassy_rp::spi::Blocking> = + embassy_rp::spi::Spi::new_blocking( + peripherals.SPI0, + clk, + mosi, + miso, + display_config.clone(), + ); + let spi_bus: embassy_sync::blocking_mutex::Mutex< + embassy_sync::blocking_mutex::raw::NoopRawMutex, + _, + > = embassy_sync::blocking_mutex::Mutex::new(core::cell::RefCell::new(spi)); + + let display_spi = embassy_embedded_hal::shared_bus::blocking::spi::SpiDeviceWithConfig::new( + &spi_bus, + embassy_rp::gpio::Output::new(display_cs, embassy_rp::gpio::Level::High), + display_config, + ); + + let dc = embassy_rp::gpio::Output::new(dc, embassy_rp::gpio::Level::Low); + let rst = embassy_rp::gpio::Output::new(rst, embassy_rp::gpio::Level::Low); + let di = SPIDeviceInterface::new(display_spi, dc); + + // Init ST7789 LCD + let mut display = st7789::ST7789::new(di, rst, 240, 240); + display.init(&mut embassy_time::Delay).unwrap(); + display + .set_orientation(st7789::Orientation::Portrait) + .unwrap(); + use embedded_graphics::draw_target::DrawTarget; + display.clear(embedded_graphics::pixelcolor::RgbColor::BLACK).unwrap(); + // ************************************************************************ + + let color = Rgb565::new(255, 255, 0); + // Write welcome message + let style = MonoTextStyle::new(&FONT_7X13_BOLD, color); + Text::new("Welcome to Rust Workshop!", Point::new(36, 190), style) + .draw(&mut display) + .unwrap(); + +} \ No newline at end of file