-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
22300ac
commit 15ad22a
Showing
11 changed files
with
497 additions
and
55 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
[workspace] | ||
members = [ | ||
"esp32c3_nostd" | ||
"esp32c3_nostd", | ||
"display_themes", | ||
"airquamon_domain" | ||
] | ||
|
||
resolver = "2" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
name = "airquamon_domain" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#![no_std] | ||
|
||
pub struct Data { | ||
pub co2: u16, | ||
pub temperature: f32, | ||
pub humidity: f32, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[package] | ||
name = "display_themes" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
embedded-graphics = "0.8" | ||
heapless = "0.7.16" | ||
airquamon_domain = { path = "../airquamon_domain" } | ||
epd-waveshare = { path = "/home/brendan/dev/projects/epd-waveshare" } | ||
|
||
[dev-dependencies] | ||
embedded-graphics-simulator = "0.5.0" | ||
epd-waveshare = { path = "/home/brendan/dev/projects/epd-waveshare", features = ["graphics"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use embedded_graphics::prelude::*; | ||
use embedded_graphics_simulator::{SimulatorDisplay, Window, OutputSettingsBuilder}; | ||
use epd_waveshare::color::TriColor; | ||
use display_themes::{Theme, Theme1}; | ||
use airquamon_domain::Data; | ||
|
||
|
||
fn main() -> Result<(), core::convert::Infallible> { | ||
let mut display = SimulatorDisplay::<TriColor>::new(Size::new(296, 128)); | ||
|
||
let data = Data{ | ||
co2: 459, | ||
temperature: 20.59, | ||
humidity: 57.42, | ||
}; | ||
|
||
let mut theme1 = Theme1::new(); | ||
theme1.draw(&data, &mut display).unwrap(); | ||
|
||
let output_settings = OutputSettingsBuilder::new() | ||
.scale(2) | ||
.build(); | ||
Window::new("Airquamon Simulator", &output_settings).show_static(&display); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#![no_std] | ||
|
||
use airquamon_domain::Data; | ||
use embedded_graphics::prelude::*; | ||
|
||
mod theme_1; | ||
pub use theme_1::Theme1; | ||
|
||
pub trait Theme<COLOR> | ||
where | ||
COLOR: PixelColor, | ||
{ | ||
fn draw<DRAWTARGET: DrawTarget<Color = COLOR>>(&mut self, data: &Data, display: &mut DRAWTARGET) -> Result<(), DRAWTARGET::Error>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
use crate::Theme; | ||
use airquamon_domain::Data; | ||
use embedded_graphics::{ | ||
mono_font::MonoTextStyleBuilder, | ||
prelude::*, | ||
primitives::{Line, PrimitiveStyle}, | ||
text::{Baseline, Text, TextStyleBuilder}, | ||
}; | ||
use epd_waveshare::color::TriColor; | ||
use heapless::String; | ||
use core::fmt::Write; | ||
|
||
pub struct Theme1 { | ||
display_text: String<60>, | ||
} | ||
|
||
impl Theme1 { | ||
pub fn new() -> Self { | ||
Theme1 { | ||
display_text: String::new(), | ||
} | ||
} | ||
} | ||
|
||
impl Theme<TriColor> for Theme1 | ||
{ | ||
fn draw<DRAWTARGET: DrawTarget<Color = TriColor>>(&mut self, data: &Data, display: &mut DRAWTARGET) -> Result<(), DRAWTARGET::Error> { | ||
self.display_text.clear(); | ||
write!(self.display_text, "CO2: {0} ppm | {1:#.2} °C | {2:#.2} %", data.co2, data.temperature, data.humidity).expect("Error occurred while trying to write in String"); | ||
let _ = Line::new(Point::new(5, 50), Point::new(291, 50)) | ||
.into_styled(PrimitiveStyle::with_stroke(TriColor::Chromatic, 4)) | ||
.draw(display); | ||
draw_text(display, &self.display_text, 5, 10)?; | ||
Ok(()) | ||
} | ||
} | ||
|
||
fn draw_text<DRAWTARGET>(display: &mut DRAWTARGET, text: &str, x: i32, y: i32) -> Result<(), DRAWTARGET::Error> | ||
where | ||
DRAWTARGET: DrawTarget<Color = TriColor> { | ||
let style = MonoTextStyleBuilder::new() | ||
.font(&embedded_graphics::mono_font::ascii::FONT_8X13_BOLD) | ||
.text_color(TriColor::Black) | ||
.background_color(TriColor::White) | ||
.build(); | ||
|
||
let text_style = TextStyleBuilder::new().baseline(Baseline::Top).build(); | ||
|
||
Text::with_text_style(text, Point::new(x, y), style, text_style).draw(display)?; | ||
Ok(()) | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters