···2828use uc8151::{asynch::Uc8151, UpdateRegion};
2929use {defmt_rtt as _, panic_probe as _};
30303131-use crate::Spi0Bus;
3131+use crate::{env::env_value, helpers::easy_format, Spi0Bus};
32323333//Display state
3434pub static CURRENT_IMAGE: AtomicU8 = AtomicU8::new(0);
···7272 .unwrap();
73737474 // Create the text box and apply styling options.
7575+ let display_text = easy_format::<29>(format_args!(
7676+ "{}\n{}",
7777+ env_value("NAME"),
7878+ env_value("DETAILS")
7979+ ));
75807676- let text = "Bailey Townsend\nSoftware Dev";
7781 // \nWritten in rust\nRunning on a pico w";
7878- let name_and_detail_box =
7979- TextBox::with_textbox_style(text, name_and_detail_bounds, character_style, textbox_style);
8282+ let name_and_detail_box = TextBox::with_textbox_style(
8383+ &display_text,
8484+ name_and_detail_bounds,
8585+ character_style,
8686+ textbox_style,
8787+ );
80888189 // Draw the text box.
8290 name_and_detail_box.draw(&mut display).unwrap();
+18
src/env.rs
···11+use heapless::Vec;
22+33+const ENV_DATA: &str = include_str!("../.env");
44+55+pub fn env_value(key: &str) -> &'static str {
66+ for line in ENV_DATA.lines() {
77+ let parts: Vec<&str, 2> = line.split('=').collect();
88+ if parts.len() == 2 {
99+ if parts[0].trim() == key {
1010+ let mut value = parts[1].trim().chars();
1111+ value.next();
1212+ value.next_back();
1313+ return value.as_str();
1414+ }
1515+ }
1616+ }
1717+ panic!("Key: {:?} not found in .env file. May also need to provide your own .env from a copy of .env.save", key);
1818+}
+14
src/helpers.rs
···11+use core::fmt::Arguments;
22+use heapless::String;
33+44+/// Makes it easier to format strings in a single line method
55+pub fn easy_format<const N: usize>(args: Arguments<'_>) -> String<N> {
66+ let mut formatted_string: String<N> = String::<N>::new();
77+ let result = core::fmt::write(&mut formatted_string, args);
88+ match result {
99+ Ok(_) => formatted_string,
1010+ Err(_) => {
1111+ panic!("Error formatting the string")
1212+ }
1313+ }
1414+}