Signed-off-by: Slendi <slendi@socopon.com>
This commit is contained in:
BIN
src/assets/Ubuntu-B.ttf
Normal file
BIN
src/assets/Ubuntu-B.ttf
Normal file
Binary file not shown.
20
src/main.rs
20
src/main.rs
@@ -170,18 +170,23 @@ struct SingerApp {
|
||||
tx: Sender<SerialCommand>,
|
||||
rx: Receiver<SerialStatus>,
|
||||
connected: Option<String>,
|
||||
font: Font,
|
||||
}
|
||||
|
||||
impl SingerApp {
|
||||
pub fn new() -> Self {
|
||||
pub fn new(gfx: &mut Graphics) -> Self {
|
||||
let (tx_cmd, rx_cmd) = mpsc::channel();
|
||||
let (tx_status, rx_status) = mpsc::channel();
|
||||
Self::spawn_serial_worker(rx_cmd, tx_status);
|
||||
let font = gfx
|
||||
.create_font(include_bytes!("assets/Ubuntu-B.ttf"))
|
||||
.expect("failed to load embedded font");
|
||||
Self {
|
||||
song_state: None,
|
||||
tx: tx_cmd,
|
||||
rx: rx_status,
|
||||
connected: None,
|
||||
font,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,12 +266,21 @@ impl SingerApp {
|
||||
};
|
||||
draw.rect((14.0, 14.0), (20.0, 20.0)).color(status_color);
|
||||
|
||||
let status_text = match &self.connected {
|
||||
Some(name) => format!("Serial connected: {name}"),
|
||||
None => "Serial disconnected".to_string(),
|
||||
};
|
||||
draw.text(&self.font, &status_text)
|
||||
.position(44.0, 30.0)
|
||||
.size(22.0)
|
||||
.color(Color::BLACK);
|
||||
|
||||
gfx.render(&draw);
|
||||
}
|
||||
}
|
||||
|
||||
fn setup(_gfx: &mut Graphics) -> SingerApp {
|
||||
SingerApp::new()
|
||||
fn setup(gfx: &mut Graphics) -> SingerApp {
|
||||
SingerApp::new(gfx)
|
||||
}
|
||||
|
||||
fn update(_app: &mut notan::app::App, state: &mut SingerApp) {
|
||||
|
||||
Reference in New Issue
Block a user