feat(display): DrawText with built-in Spleen 8x16 font (BSD-2)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use server_framework::{Decode, Encode};
|
||||
use types::display::text::Text;
|
||||
use types::display::{Color, Dimension, ScreenCoord};
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
@@ -7,6 +8,7 @@ pub enum DisplayRequest {
|
||||
Clear { color: Color },
|
||||
Flush,
|
||||
GetDimensions,
|
||||
DrawText(Text),
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
@@ -27,6 +29,7 @@ impl Encode for DisplayRequest {
|
||||
DisplayRequest::Clear { color } => [1, color.raw() as usize, 0, 0],
|
||||
DisplayRequest::Flush => [2, 0, 0, 0],
|
||||
DisplayRequest::GetDimensions => [3, 0, 0, 0],
|
||||
DisplayRequest::DrawText(t) => t.words(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,7 +48,7 @@ impl Decode for DisplayRequest {
|
||||
1 => Some(DisplayRequest::Clear { color: Color::from_raw(words[1] as u32) }),
|
||||
2 => Some(DisplayRequest::Flush),
|
||||
3 => Some(DisplayRequest::GetDimensions),
|
||||
_ => None,
|
||||
_ => Text::from_words(words).map(DisplayRequest::DrawText),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user