···28use uc8151::{asynch::Uc8151, UpdateRegion};
29use {defmt_rtt as _, panic_probe as _};
3031-use crate::Spi0Bus;
3233//Display state
34pub static CURRENT_IMAGE: AtomicU8 = AtomicU8::new(0);
···72 .unwrap();
7374 // Create the text box and apply styling options.
000007576- let text = "Bailey Townsend\nSoftware Dev";
77 // \nWritten in rust\nRunning on a pico w";
78- let name_and_detail_box =
79- TextBox::with_textbox_style(text, name_and_detail_bounds, character_style, textbox_style);
00008081 // Draw the text box.
82 name_and_detail_box.draw(&mut display).unwrap();
···28use uc8151::{asynch::Uc8151, UpdateRegion};
29use {defmt_rtt as _, panic_probe as _};
3031+use crate::{env::env_value, helpers::easy_format, Spi0Bus};
3233//Display state
34pub static CURRENT_IMAGE: AtomicU8 = AtomicU8::new(0);
···72 .unwrap();
7374 // Create the text box and apply styling options.
75+ let display_text = easy_format::<29>(format_args!(
76+ "{}\n{}",
77+ env_value("NAME"),
78+ env_value("DETAILS")
79+ ));
80081 // \nWritten in rust\nRunning on a pico w";
82+ let name_and_detail_box = TextBox::with_textbox_style(
83+ &display_text,
84+ name_and_detail_bounds,
85+ character_style,
86+ textbox_style,
87+ );
8889 // Draw the text box.
90 name_and_detail_box.draw(&mut display).unwrap();
+18
src/env.rs
···000000000000000000
···1+use heapless::Vec;
2+3+const ENV_DATA: &str = include_str!("../.env");
4+5+pub fn env_value(key: &str) -> &'static str {
6+ for line in ENV_DATA.lines() {
7+ let parts: Vec<&str, 2> = line.split('=').collect();
8+ if parts.len() == 2 {
9+ if parts[0].trim() == key {
10+ let mut value = parts[1].trim().chars();
11+ value.next();
12+ value.next_back();
13+ return value.as_str();
14+ }
15+ }
16+ }
17+ panic!("Key: {:?} not found in .env file. May also need to provide your own .env from a copy of .env.save", key);
18+}
+14
src/helpers.rs
···00000000000000
···1+use core::fmt::Arguments;
2+use heapless::String;
3+4+/// Makes it easier to format strings in a single line method
5+pub fn easy_format<const N: usize>(args: Arguments<'_>) -> String<N> {
6+ let mut formatted_string: String<N> = String::<N>::new();
7+ let result = core::fmt::write(&mut formatted_string, args);
8+ match result {
9+ Ok(_) => formatted_string,
10+ Err(_) => {
11+ panic!("Error formatting the string")
12+ }
13+ }
14+}