Switch to persistent printer with queue
This commit is contained in:
parent
0ea4cf1d22
commit
6555e9c0bd
14 changed files with 221 additions and 76 deletions
|
|
@ -1,3 +1,4 @@
|
|||
mod backlog;
|
||||
mod calendar;
|
||||
mod cells;
|
||||
mod chat_message;
|
||||
|
|
@ -11,21 +12,23 @@ mod typst;
|
|||
use showbits_common::widgets::{FontStuff, HasFontStuff};
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
use crate::printer::Printer;
|
||||
use crate::persistent_printer::PersistentPrinter;
|
||||
|
||||
pub use self::{
|
||||
calendar::CalendarDrawing, cells::CellsDrawing, chat_message::ChatMessageDrawing,
|
||||
egg::EggDrawing, image::ImageDrawing, photo::PhotoDrawing, text::TextDrawing,
|
||||
tictactoe::TicTacToeDrawing, typst::TypstDrawing,
|
||||
backlog::BacklogDrawing, calendar::CalendarDrawing, cells::CellsDrawing,
|
||||
chat_message::ChatMessageDrawing, egg::EggDrawing, image::ImageDrawing, photo::PhotoDrawing,
|
||||
text::TextDrawing, tictactoe::TicTacToeDrawing, typst::TypstDrawing,
|
||||
};
|
||||
|
||||
pub const FEED: f32 = 64.0;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Context {
|
||||
font_stuff: FontStuff,
|
||||
}
|
||||
|
||||
pub trait Drawing {
|
||||
fn draw(&self, printer: &mut Printer, ctx: &mut Context) -> anyhow::Result<()>;
|
||||
fn draw(&self, printer: &mut PersistentPrinter, ctx: &mut Context) -> anyhow::Result<()>;
|
||||
}
|
||||
|
||||
pub struct Command(Box<dyn Drawing + Send>);
|
||||
|
|
@ -44,12 +47,12 @@ impl HasFontStuff for Context {
|
|||
|
||||
pub struct Drawer {
|
||||
rx: mpsc::Receiver<Command>,
|
||||
printer: Printer,
|
||||
printer: PersistentPrinter,
|
||||
ctx: Context,
|
||||
}
|
||||
|
||||
impl Drawer {
|
||||
pub fn new(rx: mpsc::Receiver<Command>, printer: Printer) -> Self {
|
||||
pub fn new(rx: mpsc::Receiver<Command>, printer: PersistentPrinter) -> Self {
|
||||
Self {
|
||||
rx,
|
||||
printer,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue