mirror of
https://github.com/LegitCamper/picocalc-os-rs.git
synced 2025-12-27 15:55:25 +00:00
text wrong?
This commit is contained in:
@@ -4,12 +4,14 @@ use embassy_rp::{
|
|||||||
peripherals::{PIN_13, PIN_14, PIN_15, SPI1},
|
peripherals::{PIN_13, PIN_14, PIN_15, SPI1},
|
||||||
spi::{Async, Blocking, Spi},
|
spi::{Async, Blocking, Spi},
|
||||||
};
|
};
|
||||||
use embassy_time::{Delay, Timer};
|
use embassy_time::{Delay, Instant, Timer};
|
||||||
use embedded_graphics::{
|
use embedded_graphics::{
|
||||||
Drawable, Pixel,
|
Drawable, Pixel,
|
||||||
|
mono_font::{MonoTextStyle, ascii::FONT_6X10},
|
||||||
pixelcolor::{Rgb565, raw::RawU16},
|
pixelcolor::{Rgb565, raw::RawU16},
|
||||||
prelude::{DrawTarget, OriginDimensions, Point, Primitive, RawData, RgbColor, Size},
|
prelude::{DrawTarget, OriginDimensions, Point, Primitive, RawData, RgbColor, Size},
|
||||||
primitives::{PrimitiveStyle, Rectangle},
|
primitives::{PrimitiveStyle, Rectangle, StyledDrawable},
|
||||||
|
text::{Text, TextStyle},
|
||||||
};
|
};
|
||||||
use embedded_hal_bus::spi::ExclusiveDevice;
|
use embedded_hal_bus::spi::ExclusiveDevice;
|
||||||
use st7365p_lcd::{FrameBuffer, Orientation, ST7365P};
|
use st7365p_lcd::{FrameBuffer, Orientation, ST7365P};
|
||||||
@@ -21,15 +23,14 @@ pub async fn display_task(spi: Spi<'static, SPI1, Async>, cs: PIN_13, data: PIN_
|
|||||||
spi_device,
|
spi_device,
|
||||||
Output::new(data, Level::Low),
|
Output::new(data, Level::Low),
|
||||||
Some(Output::new(reset, Level::High)),
|
Some(Output::new(reset, Level::High)),
|
||||||
true,
|
|
||||||
false,
|
false,
|
||||||
|
true,
|
||||||
320,
|
320,
|
||||||
320,
|
320,
|
||||||
);
|
);
|
||||||
display.init(&mut Delay).await.unwrap();
|
display.init(&mut Delay).await.unwrap();
|
||||||
display.init(&mut Delay).await.unwrap();
|
display.set_custom_orientation(0x40).await.unwrap();
|
||||||
display.set_address_window(0, 0, 319, 319).await.unwrap();
|
|
||||||
display.set_custom_orientation(0x40).await.unwrap(); // inverts X axis (reverts the natural mirroring)
|
|
||||||
let mut framebuffer: FrameBuffer<
|
let mut framebuffer: FrameBuffer<
|
||||||
320,
|
320,
|
||||||
320,
|
320,
|
||||||
@@ -38,16 +39,35 @@ pub async fn display_task(spi: Spi<'static, SPI1, Async>, cs: PIN_13, data: PIN_
|
|||||||
Output<'_>,
|
Output<'_>,
|
||||||
> = FrameBuffer::new(display);
|
> = FrameBuffer::new(display);
|
||||||
|
|
||||||
let thin_stroke = PrimitiveStyle::with_stroke(Rgb565::RED, 20);
|
Text::new(
|
||||||
|
"PicoCalc Test\nLine 2\n Line 3 - and 1/2",
|
||||||
Rectangle::new(Point::new(10, 10), Size::new(100, 100))
|
Point { x: 100, y: 100 },
|
||||||
.into_styled(thin_stroke)
|
MonoTextStyle::new(&FONT_6X10, Rgb565::BLUE),
|
||||||
|
)
|
||||||
.draw(&mut framebuffer)
|
.draw(&mut framebuffer)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
Rectangle::new(Point::new(0, 0), Size::new(50, 50))
|
||||||
|
.draw_styled(
|
||||||
|
&PrimitiveStyle::with_stroke(Rgb565::RED, 10),
|
||||||
|
&mut framebuffer,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
Rectangle::new(Point::new(0, 100), Size::new(50, 50))
|
||||||
|
.draw_styled(
|
||||||
|
&PrimitiveStyle::with_stroke(Rgb565::RED, 10),
|
||||||
|
&mut framebuffer,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
Timer::after_millis(500).await;
|
Timer::after_millis(500).await;
|
||||||
info!("drawing");
|
let start = Instant::now();
|
||||||
framebuffer.draw().await.unwrap();
|
framebuffer.draw().await.unwrap();
|
||||||
|
info!(
|
||||||
|
"Took {}ms to write framebuffer to screen",
|
||||||
|
Instant::now().duration_since(start).as_millis()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
11
src/main.rs
11
src/main.rs
@@ -22,7 +22,6 @@ use embassy_time::Timer;
|
|||||||
use embedded_hal_bus::spi::ExclusiveDevice;
|
use embedded_hal_bus::spi::ExclusiveDevice;
|
||||||
use embedded_sdmmc::asynchronous::{File, SdCard, ShortFileName, VolumeIdx, VolumeManager};
|
use embedded_sdmmc::asynchronous::{File, SdCard, ShortFileName, VolumeIdx, VolumeManager};
|
||||||
use static_cell::StaticCell;
|
use static_cell::StaticCell;
|
||||||
use talc::*;
|
|
||||||
|
|
||||||
mod peripherals;
|
mod peripherals;
|
||||||
use peripherals::{keyboard::KeyEvent, peripherals_task};
|
use peripherals::{keyboard::KeyEvent, peripherals_task};
|
||||||
@@ -33,16 +32,6 @@ embassy_rp::bind_interrupts!(struct Irqs {
|
|||||||
I2C1_IRQ => i2c::InterruptHandler<I2C1>;
|
I2C1_IRQ => i2c::InterruptHandler<I2C1>;
|
||||||
});
|
});
|
||||||
|
|
||||||
static mut ARENA: [u8; 300_000] = [0; 300_000];
|
|
||||||
|
|
||||||
#[global_allocator]
|
|
||||||
static ALLOCATOR: Talck<spin::Mutex<()>, ClaimOnOom> = Talc::new(unsafe {
|
|
||||||
// if we're in a hosted environment, the Rust runtime may allocate before
|
|
||||||
// main() is called, so we need to initialize the arena automatically
|
|
||||||
ClaimOnOom::new(Span::from_array(core::ptr::addr_of!(ARENA).cast_mut()))
|
|
||||||
})
|
|
||||||
.lock();
|
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
async fn main(spawner: Spawner) {
|
async fn main(spawner: Spawner) {
|
||||||
let p = embassy_rp::init(Default::default());
|
let p = embassy_rp::init(Default::default());
|
||||||
|
|||||||
Reference in New Issue
Block a user