rising
This commit is contained in:
108
Cargo.lock
generated
108
Cargo.lock
generated
@ -172,14 +172,13 @@ checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43"
|
||||
|
||||
[[package]]
|
||||
name = "buoyant"
|
||||
version = "0.6.0-alpha.1"
|
||||
version = "0.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbc36827a22794f33600a539fc2f16e6c535f9de5cf26509f8ce7ddb666cda1b"
|
||||
dependencies = [
|
||||
"embedded-graphics",
|
||||
"embedded-graphics-core",
|
||||
"embedded-touch",
|
||||
"fixed",
|
||||
"fixed-macro",
|
||||
"heapless",
|
||||
"heapless 0.8.0",
|
||||
"paste",
|
||||
"u8g2-fonts",
|
||||
]
|
||||
@ -228,7 +227,7 @@ dependencies = [
|
||||
"embedded-graphics",
|
||||
"embedded-graphics-simulator",
|
||||
"embedded-sprites",
|
||||
"heapless",
|
||||
"heapless 0.9.2",
|
||||
"profont",
|
||||
"tinybmp",
|
||||
]
|
||||
@ -353,16 +352,6 @@ dependencies = [
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "embedded-touch"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "93d19cf3f85ec63a8bdfc213ba3e3f1375acbb4ea9322060d3dded4afa5a8d6e"
|
||||
dependencies = [
|
||||
"fixed",
|
||||
"fixed-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equator"
|
||||
version = "0.4.2"
|
||||
@ -433,53 +422,6 @@ version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844"
|
||||
|
||||
[[package]]
|
||||
name = "fixed"
|
||||
version = "1.29.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "707070ccf8c4173548210893a0186e29c266901b71ed20cd9e2ca0193dfe95c3"
|
||||
dependencies = [
|
||||
"az",
|
||||
"bytemuck",
|
||||
"half",
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fixed-macro"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fd0c48af8cb14e02868f449f8a2187bd78af7a08da201fdc78d518ecb1675bc"
|
||||
dependencies = [
|
||||
"fixed",
|
||||
"fixed-macro-impl",
|
||||
"fixed-macro-types",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fixed-macro-impl"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c93086f471c0a1b9c5e300ea92f5cd990ac6d3f8edf27616ef624b8fa6402d4b"
|
||||
dependencies = [
|
||||
"fixed",
|
||||
"paste",
|
||||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fixed-macro-types"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "044a61b034a2264a7f65aa0c3cd112a01b4d4ee58baace51fead3f21b993c7e4"
|
||||
dependencies = [
|
||||
"fixed",
|
||||
"fixed-macro-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "1.1.5"
|
||||
@ -541,6 +483,16 @@ dependencies = [
|
||||
"byteorder",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heapless"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad"
|
||||
dependencies = [
|
||||
"hash32",
|
||||
"stable_deref_trait",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heapless"
|
||||
version = "0.9.2"
|
||||
@ -847,30 +799,6 @@ dependencies = [
|
||||
"zerocopy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
|
||||
dependencies = [
|
||||
"proc-macro-error-attr",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error-attr"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.103"
|
||||
@ -1198,12 +1126,6 @@ dependencies = [
|
||||
"embedded-graphics",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.19.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb"
|
||||
|
||||
[[package]]
|
||||
name = "u8g2-fonts"
|
||||
version = "0.7.2"
|
||||
|
||||
@ -5,7 +5,8 @@ edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
#buoyant = "0.6.0-alpha.0"
|
||||
buoyant = {path = "buoyant" }
|
||||
buoyant = "0.5.3"
|
||||
#buoyant = {path = "buoyant" }
|
||||
embedded-graphics = "0.8.1"
|
||||
embedded-graphics-simulator = "0.8.0"
|
||||
embedded-sprites = "0.2.0"
|
||||
|
||||
BIN
assets/indic-rising.bmp
Normal file
BIN
assets/indic-rising.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
97
assets/indic-rising.svg
Normal file
97
assets/indic-rising.svg
Normal file
@ -0,0 +1,97 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="10"
|
||||
height="20"
|
||||
viewBox="0 0 10 20"
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
inkscape:version="1.4.2 (ebf0e940d0, 2025-05-08)"
|
||||
sodipodi:docname="indic-rising.svg"
|
||||
inkscape:export-filename="indic-rising.svg"
|
||||
inkscape:export-xdpi="102.28008"
|
||||
inkscape:export-ydpi="102.28008"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<sodipodi:namedview
|
||||
id="namedview1"
|
||||
pagecolor="#000000"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:export-bgcolor="#080808ff"
|
||||
inkscape:zoom="32"
|
||||
inkscape:cx="3.46875"
|
||||
inkscape:cy="9.15625"
|
||||
inkscape:window-width="1916"
|
||||
inkscape:window-height="1032"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="layer1" />
|
||||
<defs
|
||||
id="defs1" />
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="matrix(0.10139507,0,0,0.10139507,4.4930246,0.14783758)">
|
||||
<rect
|
||||
style="fill:#080808;fill-opacity:1;stroke:none;stroke-width:95.2216;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.2;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
|
||||
id="rect4"
|
||||
width="98.624123"
|
||||
height="197.24825"
|
||||
x="-44.312061"
|
||||
y="-1.4580333" />
|
||||
<rect
|
||||
style="fill:#3e3e3e;fill-opacity:1;stroke:none;stroke-width:10.4178;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.2;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="rect3"
|
||||
width="92.56852"
|
||||
height="34.62767"
|
||||
x="-41.28426"
|
||||
y="79.852249"
|
||||
rx="10.363558"
|
||||
ry="15.606441" />
|
||||
<path
|
||||
sodipodi:type="star"
|
||||
style="fill:#00e565;fill-opacity:1;stroke:#080808;stroke-width:6.94267343;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.2;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
|
||||
id="path1"
|
||||
inkscape:flatsided="true"
|
||||
sodipodi:sides="3"
|
||||
sodipodi:cx="25.63151"
|
||||
sodipodi:cy="24.391275"
|
||||
sodipodi:r1="55.859524"
|
||||
sodipodi:r2="27.929762"
|
||||
sodipodi:arg1="0.52359878"
|
||||
sodipodi:arg2="1.5707963"
|
||||
inkscape:rounded="0.1"
|
||||
inkscape:randomized="0"
|
||||
d="m 74.007276,52.321038 c -4.837576,8.378928 -91.913956,8.378928 -96.751533,-1e-6 -4.837577,-8.378929 38.700614,-83.789285 48.375767,-83.789285 9.675153,0 53.213343,75.410357 48.375766,83.789286 z"
|
||||
inkscape:transform-center-y="-12.4031"
|
||||
transform="matrix(0.82051985,0,0,0.88816373,-16.031162,29.570393)" />
|
||||
<path
|
||||
sodipodi:type="star"
|
||||
style="fill:#3e3e3e;fill-opacity:1;stroke:#080808;stroke-width:6.94267343;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.2;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
|
||||
id="path1-1"
|
||||
inkscape:flatsided="true"
|
||||
sodipodi:sides="3"
|
||||
sodipodi:cx="25.63151"
|
||||
sodipodi:cy="24.391275"
|
||||
sodipodi:r1="55.859524"
|
||||
sodipodi:r2="27.929762"
|
||||
sodipodi:arg1="0.52359878"
|
||||
sodipodi:arg2="1.5707963"
|
||||
inkscape:rounded="0.1"
|
||||
inkscape:randomized="0"
|
||||
d="m 74.007276,52.321038 c -4.837576,8.378928 -91.913956,8.378928 -96.751533,-1e-6 -4.837577,-8.378929 38.700614,-83.789285 48.375767,-83.789285 9.675153,0 53.213343,75.410357 48.375766,83.789286 z"
|
||||
inkscape:transform-center-y="12.403106"
|
||||
transform="matrix(-0.82051985,0,0,-0.88816373,26.031162,164.76177)" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.9 KiB |
83
src/main.rs
83
src/main.rs
@ -1,29 +1,33 @@
|
||||
#![feature(unsafe_cell_access)]
|
||||
|
||||
mod images;
|
||||
mod triangle;
|
||||
|
||||
use core::fmt::Write;
|
||||
use std::{cell::UnsafeCell, mem::MaybeUninit};
|
||||
use std::cell::UnsafeCell;
|
||||
use std::mem::MaybeUninit;
|
||||
|
||||
use buoyant::{primitives::Point, render::StrokedShape, view::prelude::*};
|
||||
use embedded_graphics::{
|
||||
pixelcolor::{Rgb565, Rgb888},
|
||||
prelude::*,
|
||||
};
|
||||
use embedded_graphics_simulator::{OutputSettings, SimulatorDisplay, Window};
|
||||
use embedded_sprites::{include_image, sprite::Sprite};
|
||||
use buoyant::primitives::Point;
|
||||
use buoyant::render::StrokedShape;
|
||||
use buoyant::view::prelude::*;
|
||||
use embedded_graphics::pixelcolor::Rgb565;
|
||||
use embedded_graphics::pixelcolor::Rgb888;
|
||||
use embedded_graphics::prelude::*;
|
||||
use embedded_graphics_simulator::OutputSettings;
|
||||
use embedded_graphics_simulator::SimulatorDisplay;
|
||||
use embedded_graphics_simulator::Window;
|
||||
use embedded_sprites::include_image;
|
||||
use embedded_sprites::sprite::Sprite;
|
||||
use heapless::format;
|
||||
use profont::{PROFONT_12_POINT, PROFONT_14_POINT, PROFONT_18_POINT, PROFONT_24_POINT};
|
||||
use profont::PROFONT_12_POINT;
|
||||
use profont::PROFONT_14_POINT;
|
||||
use profont::PROFONT_18_POINT;
|
||||
use profont::PROFONT_24_POINT;
|
||||
use tinybmp::Bmp;
|
||||
|
||||
use crate::triangle::Triangle;
|
||||
|
||||
const BACKGROUND_COLOR: Rgb565 = Rgb565::BLACK;
|
||||
const DEFAULT_COLOR: Rgb565 = Rgb565::WHITE;
|
||||
|
||||
fn main()
|
||||
{
|
||||
fn main() {
|
||||
images::prepare_images();
|
||||
|
||||
let mut window = Window::new("Hello World", &OutputSettings::default());
|
||||
@ -38,8 +42,7 @@ fn main()
|
||||
window.show_static(&display);
|
||||
}
|
||||
|
||||
fn hello_view() -> impl View<Rgb565>
|
||||
{
|
||||
fn hello_view() -> impl View<Rgb565> {
|
||||
VStack::new((
|
||||
HStack::new((
|
||||
main_menu_indicator(MenuIndicatorType::Temperature(31.5)),
|
||||
@ -58,22 +61,18 @@ fn hello_view() -> impl View<Rgb565>
|
||||
const FRAME_STROKE: u32 = 2;
|
||||
const FRAME_COLOR: Rgb565 = Rgb565::new(5, 9, 5);
|
||||
|
||||
pub enum MenuIndicatorType
|
||||
{
|
||||
pub enum MenuIndicatorType {
|
||||
Temperature(f32),
|
||||
Humidity(f32),
|
||||
Co2(u32),
|
||||
Voc(u32),
|
||||
}
|
||||
|
||||
impl MenuIndicatorType
|
||||
{
|
||||
impl MenuIndicatorType {
|
||||
pub fn get_corresponding_icon(
|
||||
&self,
|
||||
) -> &'static std::thread::LocalKey<UnsafeCell<MaybeUninit<Bmp<'static, Rgb565>>>>
|
||||
{
|
||||
match self
|
||||
{
|
||||
) -> &'static std::thread::LocalKey<UnsafeCell<MaybeUninit<Bmp<'static, Rgb565>>>> {
|
||||
match self {
|
||||
MenuIndicatorType::Temperature(_) => &images::TEMPERATURE_ICON,
|
||||
MenuIndicatorType::Humidity(_) => &images::HUMIDITY_ICON,
|
||||
MenuIndicatorType::Co2(_) => &images::CO2_ICON,
|
||||
@ -81,10 +80,8 @@ impl MenuIndicatorType
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_corresponding_unit_string(&self) -> &'static str
|
||||
{
|
||||
match self
|
||||
{
|
||||
pub fn get_corresponding_unit_string(&self) -> &'static str {
|
||||
match self {
|
||||
MenuIndicatorType::Temperature(_) => "C",
|
||||
MenuIndicatorType::Humidity(_) => "%",
|
||||
MenuIndicatorType::Co2(_) => "ppm",
|
||||
@ -92,10 +89,8 @@ impl MenuIndicatorType
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_value_str(&self) -> heapless::String<16>
|
||||
{
|
||||
match self
|
||||
{
|
||||
pub fn get_value_str(&self) -> heapless::String<16> {
|
||||
match self {
|
||||
MenuIndicatorType::Temperature(temp) => format!(16; "{:.1}", temp).unwrap(),
|
||||
MenuIndicatorType::Humidity(hum) => format!(16; "{:.1}", hum).unwrap(),
|
||||
MenuIndicatorType::Co2(co2) => format!(16; "{}", co2).unwrap(),
|
||||
@ -104,8 +99,7 @@ impl MenuIndicatorType
|
||||
}
|
||||
}
|
||||
|
||||
fn main_menu_indicator(indicator_type: MenuIndicatorType) -> impl View<Rgb565>
|
||||
{
|
||||
fn main_menu_indicator(indicator_type: MenuIndicatorType) -> impl View<Rgb565> {
|
||||
Rectangle
|
||||
.corner_radius(10)
|
||||
.stroked(FRAME_STROKE)
|
||||
@ -145,23 +139,16 @@ fn main_menu_indicator(indicator_type: MenuIndicatorType) -> impl View<Rgb565>
|
||||
})
|
||||
}
|
||||
|
||||
pub enum Tendency
|
||||
{
|
||||
pub enum Tendency {
|
||||
Rising,
|
||||
Steady,
|
||||
Falling,
|
||||
}
|
||||
|
||||
fn tendency_indicator(tendency: Tendency) -> impl View<Rgb565>
|
||||
{
|
||||
VStack::new((
|
||||
StrokedShape::new(
|
||||
Triangle::new(Point::new(0, 5), Point::new(10, 0), Point::new(0, 10)),
|
||||
10,
|
||||
),
|
||||
StrokedShape::new(
|
||||
Triangle::new(Point::new(0, 5), Point::new(10, 0), Point::new(0, 10)),
|
||||
10,
|
||||
),
|
||||
))
|
||||
fn tendency_indicator(tendency: Tendency) -> impl View<Rgb565> {
|
||||
Rectangle
|
||||
.foreground_color(Rgb565::WHITE)
|
||||
.flex_frame()
|
||||
.with_min_size(10, 20)
|
||||
.with_max_size(10, 20)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user