Add plotted forecast

This commit is contained in:
Felix Suchert 2022-08-06 16:45:30 +02:00
parent 83b3946d2f
commit 985b42c20b
Signed by: feliix42
GPG key ID: 24363525EA0E8A99
3 changed files with 259 additions and 3 deletions

230
Cargo.lock generated
View file

@ -14,6 +14,24 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234"
[[package]]
name = "aho-corasick"
version = "0.7.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5"
dependencies = [
"memchr",
]
[[package]]
name = "atomic-polyfill"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e14bf7b4f565e5e717d7a7a65b2a05c0b8c96e4db636d6f780f03b15108cdd1b"
dependencies = [
"critical-section",
]
[[package]] [[package]]
name = "autocfg" name = "autocfg"
version = "0.1.8" version = "0.1.8"
@ -35,12 +53,39 @@ version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b7e4c2464d97fe331d41de9d5db0def0a96f4d823b8b32a2efd503578988973" checksum = "7b7e4c2464d97fe331d41de9d5db0def0a96f4d823b8b32a2efd503578988973"
[[package]]
name = "bare-metal"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5deb64efa5bd81e31fcd1938615a6d98c82eafcbcd787162b6f63b91d6bac5b3"
dependencies = [
"rustc_version 0.2.3",
]
[[package]]
name = "bare-metal"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8fe8f5a8a398345e52358e18ff07cc17a568fbca5c6f73873d3a62056309603"
[[package]] [[package]]
name = "base64" name = "base64"
version = "0.13.0" version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
[[package]]
name = "bit_field"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcb6dd1c2376d2e096796e234a70e17e94cc2d5d54ff8ce42b28cef1d0d359a4"
[[package]]
name = "bitfield"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719"
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "1.3.2" version = "1.3.2"
@ -98,6 +143,18 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
[[package]]
name = "cortex-m"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd20d4ac4aa86f4f75f239d59e542ef67de87cce2c282818dc6e84155d3ea126"
dependencies = [
"bare-metal 0.2.5",
"bitfield",
"embedded-hal",
"volatile-register",
]
[[package]] [[package]]
name = "crc32fast" name = "crc32fast"
version = "1.3.2" version = "1.3.2"
@ -107,6 +164,18 @@ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
] ]
[[package]]
name = "critical-section"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95da181745b56d4bd339530ec393508910c909c784e8962d15d722bacf0bcbcd"
dependencies = [
"bare-metal 1.0.0",
"cfg-if 1.0.0",
"cortex-m",
"riscv",
]
[[package]] [[package]]
name = "crossbeam-channel" name = "crossbeam-channel"
version = "0.5.6" version = "0.5.6"
@ -213,6 +282,17 @@ dependencies = [
"void", "void",
] ]
[[package]]
name = "embedded-plots"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d855c9092b75232d45ce8d28a997e095ed5e171280b425934abf246d7512d669"
dependencies = [
"embedded-graphics",
"heapless",
"itertools",
]
[[package]] [[package]]
name = "float-cmp" name = "float-cmp"
version = "0.8.0" version = "0.8.0"
@ -249,6 +329,28 @@ dependencies = [
"nix", "nix",
] ]
[[package]]
name = "hash32"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67"
dependencies = [
"byteorder",
]
[[package]]
name = "heapless"
version = "0.7.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f6733da246dc2af610133c8be0667170fd68e8ca5630936b520300eee8846f9"
dependencies = [
"atomic-polyfill",
"hash32",
"rustc_version 0.4.0",
"spin",
"stable_deref_trait",
]
[[package]] [[package]]
name = "hermit-abi" name = "hermit-abi"
version = "0.1.19" version = "0.1.19"
@ -295,6 +397,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"embedded-graphics", "embedded-graphics",
"embedded-graphics-simulator", "embedded-graphics-simulator",
"embedded-plots",
"linux-embedded-hal", "linux-embedded-hal",
"profont", "profont",
"ssd1675", "ssd1675",
@ -310,6 +413,15 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "itertools"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"
dependencies = [
"either",
]
[[package]] [[package]]
name = "jpeg-decoder" name = "jpeg-decoder"
version = "0.1.22" version = "0.1.22"
@ -355,6 +467,16 @@ dependencies = [
"void", "void",
] ]
[[package]]
name = "lock_api"
version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53"
dependencies = [
"autocfg 1.1.0",
"scopeguard",
]
[[package]] [[package]]
name = "memchr" name = "memchr"
version = "2.3.4" version = "2.3.4"
@ -661,6 +783,62 @@ dependencies = [
"rand_core 0.3.1", "rand_core 0.3.1",
] ]
[[package]]
name = "regex"
version = "1.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a26af418b574bd56588335b3a3659a65725d4e636eb1016c2f9e3b38c7cc759"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.6.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244"
[[package]]
name = "riscv"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6907ccdd7a31012b70faf2af85cd9e5ba97657cc3987c4f13f8e4d2c2a088aba"
dependencies = [
"bare-metal 1.0.0",
"bit_field",
"riscv-target",
]
[[package]]
name = "riscv-target"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88aa938cda42a0cf62a20cfe8d139ff1af20c2e681212b5b34adb5a58333f222"
dependencies = [
"lazy_static",
"regex",
]
[[package]]
name = "rustc_version"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
dependencies = [
"semver 0.9.0",
]
[[package]]
name = "rustc_version"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
dependencies = [
"semver 1.0.13",
]
[[package]] [[package]]
name = "scoped_threadpool" name = "scoped_threadpool"
version = "0.1.9" version = "0.1.9"
@ -697,6 +875,27 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "semver"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
dependencies = [
"semver-parser",
]
[[package]]
name = "semver"
version = "1.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93f6841e709003d68bb2deee8c343572bf446003ec20a583e76f7b15cebf3711"
[[package]]
name = "semver-parser"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
[[package]] [[package]]
name = "serial-core" name = "serial-core"
version = "0.4.0" version = "0.4.0"
@ -729,15 +928,31 @@ dependencies = [
"nix", "nix",
] ]
[[package]]
name = "spin"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f6002a767bff9e83f8eeecf883ecb8011875a21ae8da43bffb817a57e78cc09"
dependencies = [
"lock_api",
]
[[package]] [[package]]
name = "ssd1675" name = "ssd1675"
version = "0.5.0" version = "0.5.0"
source = "git+https://github.com/Feliix42/ssd1675#89b973b815906f4fe0feaba013b69eebe82d58b5"
dependencies = [ dependencies = [
"embedded-graphics", "embedded-graphics",
"embedded-hal", "embedded-hal",
"libm", "libm",
] ]
[[package]]
name = "stable_deref_trait"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
[[package]] [[package]]
name = "sysfs_gpio" name = "sysfs_gpio"
version = "0.6.1" version = "0.6.1"
@ -777,6 +992,12 @@ dependencies = [
"nom", "nom",
] ]
[[package]]
name = "vcell"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002"
[[package]] [[package]]
name = "version_check" name = "version_check"
version = "0.9.4" version = "0.9.4"
@ -789,6 +1010,15 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
[[package]]
name = "volatile-register"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ee8f19f9d74293faf70901bc20ad067dc1ad390d2cbf1e3f75f721ffee908b6"
dependencies = [
"vcell",
]
[[package]] [[package]]
name = "weezl" name = "weezl"
version = "0.1.7" version = "0.1.7"

View file

@ -9,10 +9,11 @@ authors = ["Felix Wittwer <dev@felixwittwer.de>"]
[dependencies] [dependencies]
embedded-graphics = "0.7.1" embedded-graphics = "0.7.1"
embedded-plots = "0.2.0"
tinybmp = "0.3.3" tinybmp = "0.3.3"
profont = "0.5.0" profont = "0.5.0"
#ssd1675 = { git = "https://github.com/Feliix42/ssd1675" } ssd1675 = { git = "https://github.com/Feliix42/ssd1675" }
ssd1675 = { path = "../ssd1675" } #ssd1675 = { path = "../ssd1675" }
linux-embedded-hal = { version = "0.3.2", optional = true } linux-embedded-hal = { version = "0.3.2", optional = true }
embedded-graphics-simulator = { version = "0.3.0", optional = true } embedded-graphics-simulator = { version = "0.3.0", optional = true }

View file

@ -1,6 +1,11 @@
use embedded_graphics::{ use embedded_graphics::{
draw_target::DrawTarget, image::Image, mono_font::MonoTextStyle, prelude::*, text::Text, draw_target::DrawTarget, image::Image, mono_font::MonoTextStyle, prelude::*, text::Text,
}; };
use embedded_plots::{
axis::Scale,
curve::{Curve, PlotPoint},
single_plot::SinglePlot,
};
use profont::{ use profont::{
PROFONT_12_POINT, PROFONT_14_POINT, PROFONT_24_POINT, PROFONT_7_POINT, PROFONT_9_POINT, PROFONT_12_POINT, PROFONT_14_POINT, PROFONT_24_POINT, PROFONT_7_POINT, PROFONT_9_POINT,
}; };
@ -81,7 +86,7 @@ where
.expect("error drawing text"); .expect("error drawing text");
Text::new( Text::new(
&format!("UV\nIdx"), &format!("UV\nIndex"),
Point::new(44, 93), Point::new(44, 93),
MonoTextStyle::new(&PROFONT_7_POINT, Color::Black), MonoTextStyle::new(&PROFONT_7_POINT, Color::Black),
) )
@ -90,4 +95,24 @@ where
// TODO(feliix42): use test data to draw a forecast using // TODO(feliix42): use test data to draw a forecast using
// https://crates.io/crates/embedded-plots // https://crates.io/crates/embedded-plots
let data: [f32; 24] = [
19.65, 19.32, 18.95, 18.55, 17.84, 16.44, 15.25, 14.29, 14.43, 15.07, 16.34, 18.06, 19.8,
21.39, 22.81, 23.8, 24.4, 24.78, 24.76, 24.43, 23.74, 21.67, 18.88, 17.43,
];
let data_points: Vec<PlotPoint> = data
.into_iter()
.enumerate()
.map(|(x, y)| PlotPoint {
x: x as i32,
y: y.round() as i32,
})
.collect();
let curve = Curve::from_data(&data_points);
let plot = SinglePlot::new(&curve, Scale::RangeFraction(4), Scale::RangeFraction(3))
.into_drawable(Point::new(100, 54), Point::new(206, 94))
.set_color(Color::Black);
plot.draw(display).expect("Failed to draw the temperature plot");
} }