mirror of
https://github.com/kittywitch/esp32-c3-meepy.git
synced 2026-02-09 07:59:18 -08:00
chore: reformat
This commit is contained in:
parent
f3310667d9
commit
239e5368be
2 changed files with 49 additions and 53 deletions
4
rustfmt.toml
Normal file
4
rustfmt.toml
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
style_edition = "2021"
|
||||||
|
imports_granularity = "One"
|
||||||
|
group_imports = "StdExternalCrate"
|
||||||
|
reorder_imports = true
|
||||||
74
src/main.rs
74
src/main.rs
|
|
@ -1,53 +1,35 @@
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
use esp_backtrace as _;
|
use {
|
||||||
use embedded_graphics::{
|
display_interface_spi::{SPIInterface, *},
|
||||||
mono_font::{
|
embedded_graphics::{
|
||||||
ascii::FONT_8X13,
|
mono_font::{ascii::FONT_8X13, MonoFont, MonoTextStyle},
|
||||||
MonoTextStyle,
|
|
||||||
MonoFont,
|
|
||||||
},
|
|
||||||
pixelcolor::Rgb565,
|
pixelcolor::Rgb565,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
primitives::{
|
primitives::{Line, PrimitiveStyle, PrimitiveStyleBuilder, Rectangle, Triangle},
|
||||||
Line,
|
text::{Alignment, Text},
|
||||||
PrimitiveStyle,
|
|
||||||
PrimitiveStyleBuilder,
|
|
||||||
Rectangle,
|
|
||||||
Triangle,
|
|
||||||
},
|
},
|
||||||
text::{
|
embedded_hal_bus::spi::{ExclusiveDevice, NoDelay},
|
||||||
Alignment,
|
esp_backtrace as _,
|
||||||
Text,
|
esp_hal::{
|
||||||
},
|
clock::CpuClock,
|
||||||
};
|
|
||||||
use display_interface_spi::{SPIInterface, *};
|
|
||||||
use embedded_hal_bus::spi::{ExclusiveDevice, NoDelay};
|
|
||||||
use esp_hal::{
|
|
||||||
rng::Rng,
|
|
||||||
timer::timg::TimerGroup,
|
|
||||||
delay::Delay,
|
delay::Delay,
|
||||||
gpio::{
|
gpio::{AnyPin, Input, InputPin, Level, Output, OutputConfig, OutputPin},
|
||||||
OutputPin, InputPin,
|
init, main,
|
||||||
AnyPin, Level, Input, Output, OutputConfig},
|
peripherals::{Peripherals, ADC1, SPI2},
|
||||||
peripherals::{ADC1, Peripherals, SPI2},
|
rng::Rng,
|
||||||
spi::{
|
spi::{
|
||||||
master::{Config, Spi},
|
master::{Config, Spi},
|
||||||
Mode,
|
Mode,
|
||||||
},
|
},
|
||||||
clock::CpuClock,
|
|
||||||
time::Rate,
|
time::Rate,
|
||||||
|
timer::timg::TimerGroup,
|
||||||
Blocking,
|
Blocking,
|
||||||
main,
|
},
|
||||||
init,
|
esp_println::println,
|
||||||
|
ili9341::{DisplaySize240x320, Ili9341, Orientation},
|
||||||
};
|
};
|
||||||
use ili9341::{
|
|
||||||
DisplaySize240x320,
|
|
||||||
Ili9341,
|
|
||||||
Orientation,
|
|
||||||
};
|
|
||||||
use esp_println::println;
|
|
||||||
|
|
||||||
esp_bootloader_esp_idf::esp_app_desc!();
|
esp_bootloader_esp_idf::esp_app_desc!();
|
||||||
|
|
||||||
|
|
@ -63,18 +45,27 @@ pub struct TFT<'spi> {
|
||||||
|
|
||||||
impl<'spi> TFT<'spi> {
|
impl<'spi> TFT<'spi> {
|
||||||
fn draw_target(&mut self) -> DrawFlipper<'_, 'spi> {
|
fn draw_target(&mut self) -> DrawFlipper<'_, 'spi> {
|
||||||
DrawFlipper { display: &mut self.display }
|
DrawFlipper {
|
||||||
|
display: &mut self.display,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DrawFlipper<'a,'spi> { display: &'a mut Ili<'spi>, }
|
struct DrawFlipper<'a, 'spi> {
|
||||||
|
display: &'a mut Ili<'spi>,
|
||||||
|
}
|
||||||
impl<'a, 'spi> DrawTarget for DrawFlipper<'a, 'spi> {
|
impl<'a, 'spi> DrawTarget for DrawFlipper<'a, 'spi> {
|
||||||
type Error = <Ili<'spi> as DrawTarget>::Error;
|
type Error = <Ili<'spi> as DrawTarget>::Error;
|
||||||
type Color = <Ili<'spi> as DrawTarget>::Color;
|
type Color = <Ili<'spi> as DrawTarget>::Color;
|
||||||
fn draw_iter<I>(&mut self, pixels: I) -> Result<(), Self::Error>
|
fn draw_iter<I>(&mut self, pixels: I) -> Result<(), Self::Error>
|
||||||
where I: IntoIterator<Item = Pixel<Self::Color>> {
|
where
|
||||||
|
I: IntoIterator<Item = Pixel<Self::Color>>,
|
||||||
|
{
|
||||||
let width = self.bounding_box().size.width as i32;
|
let width = self.bounding_box().size.width as i32;
|
||||||
self.display.draw_iter(pixels.into_iter().map(|mut p| { p.0.x = width - p.0.x; p }))
|
self.display.draw_iter(pixels.into_iter().map(|mut p| {
|
||||||
|
p.0.x = width - p.0.x;
|
||||||
|
p
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<'a> Dimensions for DrawFlipper<'a, '_> {
|
impl<'a> Dimensions for DrawFlipper<'a, '_> {
|
||||||
|
|
@ -110,7 +101,8 @@ impl<'spi> TFT<'spi> {
|
||||||
&mut Delay::new(),
|
&mut Delay::new(),
|
||||||
Orientation::Landscape,
|
Orientation::Landscape,
|
||||||
DisplaySize240x320,
|
DisplaySize240x320,
|
||||||
).unwrap();
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
TFT { display }
|
TFT { display }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue