From 39e055eb0e0653cb7131fcf44f289b6859e93205 Mon Sep 17 00:00:00 2001 From: bankosegger Date: Sun, 15 Nov 2026 22:01:26 +0100 Subject: [PATCH 1/2] feat: add more quotes to the printed slips Move the quotes into their own module and add 67 English-only ones: good times, Winfnachten, winf.at, studying at TU Wien, getting involved and receipt jokes. A quote is now a list of printed lines instead of a fixed German/English pair, and the middle dot is sent as its PC437 byte. Co-Authored-By: Claude Sonnet 5.5 --- src/main.rs | 1 + src/printer.rs | 57 ++++++----------------- src/quotes.rs | 122 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 136 insertions(+), 44 deletions(-) create mode 100644 src/quotes.rs diff --git a/src/main.rs b/src/main.rs index fabf94d..e07fc41 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,6 +27,7 @@ mod faces; mod hand_pose; mod palm; mod printer; +mod quotes; struct PreviewFrame { buffer: SharedPixelBuffer, diff --git a/src/printer.rs b/src/printer.rs index 0ad3fb8..6e7bf15 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -52,6 +52,8 @@ use opencv::{ prelude::*, }; +use crate::quotes::QUOTES; + const DEFAULT_PRINTER: &str = "/dev/usb/lp0"; const DEFAULT_DOTS: usize = 576; const DEFAULT_GAMMA: f32 = 2.0; @@ -74,42 +76,6 @@ const KEEPSAKE_DE: &str = "Ich war dabei!"; const KEEPSAKE_EN: &str = "I was there!"; /// Capture time, written the German way and the same in both languages. const STAMP_FORMAT: &str = "%d.%m.%Y, %H:%M"; -/// One is printed per slip. Each line is short enough for a single 80 mm line; -/// on 58 mm paper the longer ones wrap. -const QUOTES: [[&str; 2]; 8] = [ - [ - "Analysis bestanden. Wunder gibt es doch.", - "Passed Analysis. Miracles do happen.", - ], - [ - "Im Freihaus gibt es Kaffee und Hoffnung.", - "The Freihaus serves coffee and hope.", - ], - [ - "TISS sagt nein. Mein Herz sagt auch nein.", - "TISS says no. So does my heart.", - ], - [ - "WINF: zwei Fächer, eine Deadline.", - "WINF: two subjects, one deadline.", - ], - [ - "Karlsplatz: der schönste Umweg zur Uni.", - "Karlsplatz: the prettiest detour to class.", - ], - [ - "Prüfungswoche: Schlafen ist optional.", - "Exam week: sleeping is optional.", - ], - [ - "Die Bibliothek kennt alle meine Ausreden.", - "The library has heard all my excuses.", - ], - [ - "Mathe ist einfach, sagt die Mathematik.", - "Maths is easy, says maths.", - ], -]; /// Pause between writes, leaving the head time to drain a band (8 mm of paper) /// before the next one arrives. const PACE: Duration = Duration::from_millis(100); @@ -402,9 +368,10 @@ fn encode( job } -/// The German letters in the captions as single PC437 bytes, the code page the -/// booth's printer starts in. Anything else non-ASCII would need a wider table -/// or `ESC t`, so a test keeps the printed text within this set. +/// The German letters and the middle dot in the captions as single PC437 bytes, +/// the code page the booth's printer starts in. Anything else non-ASCII would +/// need a wider table or `ESC t`, so a test keeps the printed text within this +/// set. fn code_page(character: char) -> Option { Some(match character { 'ä' => 0x84, @@ -414,6 +381,7 @@ fn code_page(character: char) -> Option { 'Ö' => 0x99, 'Ü' => 0x9A, 'ß' => 0xE1, + '·' => 0xFA, ascii if ascii.is_ascii() => ascii as u8, _ => return None, }) @@ -456,7 +424,7 @@ fn first_quote() -> usize { % QUOTES.len() } -fn footer(head: &Head, stamp: &str, quote: &[&str; 2]) -> Vec { +fn footer(head: &Head, stamp: &str, quote: &[&str]) -> Vec { let mut write = centered(head); write.extend([0x1B, b'd', 1]); write.extend(LARGE); @@ -466,8 +434,9 @@ fn footer(head: &Head, stamp: &str, quote: &[&str; 2]) -> Vec { write.extend([0x1B, b'd', 1]); text_line(&mut write, stamp); write.extend([0x1B, b'd', 1]); - text_line(&mut write, quote[0]); - text_line(&mut write, quote[1]); + for line in quote { + text_line(&mut write, line); + } write.extend([0x1B, b'd', FEED_LINES]); // ESC d n: feed n lines write.extend([0x1D, b'V', 66, 3]); // GS V 66 n: feed and partial cut write @@ -483,7 +452,7 @@ mod tests { fn printed_lines() -> impl Iterator { [EVENT_TITLE, EVENT_PLACE, KEEPSAKE_DE, KEEPSAKE_EN, STAMP] .into_iter() - .chain(QUOTES.iter().flatten().copied()) + .chain(QUOTES.iter().flat_map(|quote| quote.iter().copied())) } fn contains_line(write: &[u8], line: &str) -> bool { @@ -523,7 +492,7 @@ mod tests { let picked: std::collections::BTreeSet = (0..1000).map(|_| first_quote()).collect(); assert!(picked.last().is_some_and(|last| *last < QUOTES.len())); - // Not all eight on a coarse clock, but a slip must not be predictable. + // Not all of them on a coarse clock, but a slip must not be predictable. assert!(picked.len() > 1, "{picked:?}"); } diff --git a/src/quotes.rs b/src/quotes.rs new file mode 100644 index 0000000..58b60c1 --- /dev/null +++ b/src/quotes.rs @@ -0,0 +1,122 @@ +//! Quotes printed under each photo, one per slip. + +/// One is printed per slip, one printed line per entry. The first eight are +/// German with the English underneath; the rest are English only. Each line is +/// short enough for a single 80 mm line (longer quotes are split by hand); on +/// 58 mm paper the longer ones wrap. +pub const QUOTES: &[&[&str]] = &[ + &[ + "Analysis bestanden. Wunder gibt es doch.", + "Passed Analysis. Miracles do happen.", + ], + &[ + "Im Freihaus gibt es Kaffee und Hoffnung.", + "The Freihaus serves coffee and hope.", + ], + &[ + "TISS sagt nein. Mein Herz sagt auch nein.", + "TISS says no. So does my heart.", + ], + &[ + "WINF: zwei Fächer, eine Deadline.", + "WINF: two subjects, one deadline.", + ], + &[ + "Karlsplatz: der schönste Umweg zur Uni.", + "Karlsplatz: the prettiest detour to class.", + ], + &[ + "Prüfungswoche: Schlafen ist optional.", + "Exam week: sleeping is optional.", + ], + &[ + "Die Bibliothek kennt alle meine Ausreden.", + "The library has heard all my excuses.", + ], + &[ + "Mathe ist einfach, sagt die Mathematik.", + "Maths is easy, says maths.", + ], + // The good times. + &["Good times, good people."], + &["Glad you came."], + &["A night to remember."], + &["Here for the good times."], + &["Made it out tonight."], + &["Look at us go."], + &["This one's a keeper."], + &["Smile, you earned it."], + &["Friends first, deadlines later."], + &["Great company, as always."], + &["Not bad for a weeknight."], + &["Still better than studying."], + &["Zero regrets."], + &["Camera loves us."], + &["Nailed it."], + &["The good old days, right now."], + &["Best seats in the house."], + &["Proof that we have a social life."], + &["Group project, actually fun."], + &["Exams can wait."], + &["We clean up nicely."], + &["Told you it would be fun."], + &["Save the date, we're doing this again."], + &["You had to be there. Luckily, we were."], + &["Photo or it didn't happen."], + &["Passed with distinction."], + &["Attendance: voluntary. Mood: excellent."], + &["See you at the next one."], + // Winfnachten. + &["Merry Winfnachten!"], + &["Winfnachten: the most wonderful night", "of the semester."], + &["All I want for Winfnachten is to pass my exams."], + &["Winfnachten spirit: confirmed."], + &["On the nice list. Mostly."], + &["Dear Santa, I studied. Sort of."], + &["Have yourself a merry little Winfnachten."], + &["See you next Winfnachten."], + // winf.at. + &["Check out what's next at winf.at"], + &["More events, more photos: winf.at"], + &["Liked tonight? There's more at winf.at"], + &["Find your next event at winf.at"], + &["Brought to you by FSWinf · winf.at"], + &["Your student body at TU Wien: winf.at"], + &["Stay in the loop: winf.at"], + &["This photo was made by volunteers.", "Meet them at winf.at"], + // Studying at TU Wien. + &["Questions about your studies? Ask us: winf.at"], + &["Stuck on your study plan? We can help: winf.at"], + &["Need a place to study?", "Visit our study room: winf.at"], + &["New at TU Wien? Start here: winf.at"], + &["First semester? Join our E-Tuts: winf.at"], + &[ + "Business Informatics or Data Science?", + "We've got you: winf.at", + ], + // Getting involved. + &["Want to help run the next one? Join us: winf.at"], + &[ + "Come to a Fachschaft meeting.", + "Everyone's welcome: winf.at", + ], + &["We're students, just like you. Say hi: winf.at"], + &["Got ideas for the next event? Tell us: winf.at"], + // The receipt. + &["Receipt for one great night."], + &["Proof of attendance."], + &["Keep this receipt. No returns on good memories."], + &["Thank you for celebrating with us."], + &["Paid in full: one great evening."], + &["Total: priceless."], + &["Memories: 1x. Regrets: 0x."], + &["Items: good friends, good times.", "Total: worth it."], + &["No refunds. No regrets."], + &["Valid forever."], + &[ + "This receipt is not tax deductible.", + "Sorry, business students.", + ], + &["Customer copy. The memories are yours."], + &["Thank you, come again!"], +]; -- 2.49.1 From a465c5c88fad6b538f6c51ee17beb800842b3eed Mon Sep 17 00:00:00 2001 From: bankosegger Date: Sun, 15 Nov 2026 22:02:31 +0100 Subject: [PATCH 2/2] refactor: drop the original German/English quotes Only the English quotes remain. Adapt the caption test to quotes of any line count and check that the list wraps round. Co-Authored-By: Claude Sonnet 5.5 --- src/printer.rs | 15 ++++++++------- src/quotes.rs | 37 ++----------------------------------- 2 files changed, 10 insertions(+), 42 deletions(-) diff --git a/src/printer.rs b/src/printer.rs index 6e7bf15..8fc27d6 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -24,8 +24,9 @@ //! band and are not stored by the printer (no memory switch writes). //! //! Each photo is captioned with the event name and place above it, and a -//! keepsake line, the capture date and time and one of `QUOTES` below it, in -//! German with the English directly underneath. The timestamp is the system +//! keepsake line, the capture date and time and one of `QUOTES` below it. The +//! captions are in German with the English directly underneath, the quotes in +//! English only. The timestamp is the system //! clock in local time, so the booth's clock has to be right for it to mean //! anything. Text goes out in the printer's own code page (PC437), since it //! prints UTF-8 bytes as separate glyphs; see `code_page`. @@ -619,16 +620,16 @@ mod tests { width_bytes: 1, data: vec![0; 1], }; - let job = encode(&bitmap, &Head::default(), 2, STAMP, 6); + let last = QUOTES.len() - 1; + let job = encode(&bitmap, &Head::default(), 2, STAMP, last); assert!(contains_line(&job[0], EVENT_TITLE) && contains_line(&job[0], EVENT_PLACE)); assert!(contains_line(&job[2], KEEPSAKE_DE) && contains_line(&job[2], KEEPSAKE_EN)); assert!(contains_line(&job[2], STAMP)); // Consecutive copies get consecutive quotes, wrapping round the list. - assert!(contains_line(&job[2], QUOTES[6][0]) && contains_line(&job[2], QUOTES[6][1])); - assert!(contains_line(&job[5], QUOTES[7][0]) && contains_line(&job[5], QUOTES[7][1])); + assert!(QUOTES[last].iter().all(|line| contains_line(&job[2], line))); + assert!(QUOTES[0].iter().all(|line| contains_line(&job[5], line))); assert!( - encode(&bitmap, &Head::default(), 1, STAMP, QUOTES.len() - 1)[2] - .ends_with(&footer(&Head::default(), STAMP, "ES[QUOTES.len() - 1])[1..]) + job[2].ends_with(&footer(&Head::default(), STAMP, QUOTES[last])[1..]) ); // The real stamp is as wide as the one used here. let now = Local::now().format(STAMP_FORMAT).to_string(); diff --git a/src/quotes.rs b/src/quotes.rs index 58b60c1..7159bf1 100644 --- a/src/quotes.rs +++ b/src/quotes.rs @@ -1,42 +1,9 @@ //! Quotes printed under each photo, one per slip. -/// One is printed per slip, one printed line per entry. The first eight are -/// German with the English underneath; the rest are English only. Each line is -/// short enough for a single 80 mm line (longer quotes are split by hand); on +/// One is printed per slip, one printed line per entry, in English. Each line +/// is short enough for a single 80 mm line (longer quotes are split by hand); on /// 58 mm paper the longer ones wrap. pub const QUOTES: &[&[&str]] = &[ - &[ - "Analysis bestanden. Wunder gibt es doch.", - "Passed Analysis. Miracles do happen.", - ], - &[ - "Im Freihaus gibt es Kaffee und Hoffnung.", - "The Freihaus serves coffee and hope.", - ], - &[ - "TISS sagt nein. Mein Herz sagt auch nein.", - "TISS says no. So does my heart.", - ], - &[ - "WINF: zwei Fächer, eine Deadline.", - "WINF: two subjects, one deadline.", - ], - &[ - "Karlsplatz: der schönste Umweg zur Uni.", - "Karlsplatz: the prettiest detour to class.", - ], - &[ - "Prüfungswoche: Schlafen ist optional.", - "Exam week: sleeping is optional.", - ], - &[ - "Die Bibliothek kennt alle meine Ausreden.", - "The library has heard all my excuses.", - ], - &[ - "Mathe ist einfach, sagt die Mathematik.", - "Maths is easy, says maths.", - ], // The good times. &["Good times, good people."], &["Glad you came."], -- 2.49.1