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 <noreply@anthropic.com>
This commit is contained in:
@@ -27,6 +27,7 @@ mod faces;
|
|||||||
mod hand_pose;
|
mod hand_pose;
|
||||||
mod palm;
|
mod palm;
|
||||||
mod printer;
|
mod printer;
|
||||||
|
mod quotes;
|
||||||
|
|
||||||
struct PreviewFrame {
|
struct PreviewFrame {
|
||||||
buffer: SharedPixelBuffer<Rgb8Pixel>,
|
buffer: SharedPixelBuffer<Rgb8Pixel>,
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ use opencv::{
|
|||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::quotes::QUOTES;
|
||||||
|
|
||||||
const DEFAULT_PRINTER: &str = "/dev/usb/lp0";
|
const DEFAULT_PRINTER: &str = "/dev/usb/lp0";
|
||||||
const DEFAULT_DOTS: usize = 576;
|
const DEFAULT_DOTS: usize = 576;
|
||||||
const DEFAULT_GAMMA: f32 = 2.0;
|
const DEFAULT_GAMMA: f32 = 2.0;
|
||||||
@@ -74,42 +76,6 @@ const KEEPSAKE_DE: &str = "Ich war dabei!";
|
|||||||
const KEEPSAKE_EN: &str = "I was there!";
|
const KEEPSAKE_EN: &str = "I was there!";
|
||||||
/// Capture time, written the German way and the same in both languages.
|
/// Capture time, written the German way and the same in both languages.
|
||||||
const STAMP_FORMAT: &str = "%d.%m.%Y, %H:%M";
|
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)
|
/// Pause between writes, leaving the head time to drain a band (8 mm of paper)
|
||||||
/// before the next one arrives.
|
/// before the next one arrives.
|
||||||
const PACE: Duration = Duration::from_millis(100);
|
const PACE: Duration = Duration::from_millis(100);
|
||||||
@@ -402,9 +368,10 @@ fn encode(
|
|||||||
job
|
job
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The German letters in the captions as single PC437 bytes, the code page the
|
/// The German letters and the middle dot in the captions as single PC437 bytes,
|
||||||
/// booth's printer starts in. Anything else non-ASCII would need a wider table
|
/// the code page the booth's printer starts in. Anything else non-ASCII would
|
||||||
/// or `ESC t`, so a test keeps the printed text within this set.
|
/// need a wider table or `ESC t`, so a test keeps the printed text within this
|
||||||
|
/// set.
|
||||||
fn code_page(character: char) -> Option<u8> {
|
fn code_page(character: char) -> Option<u8> {
|
||||||
Some(match character {
|
Some(match character {
|
||||||
'ä' => 0x84,
|
'ä' => 0x84,
|
||||||
@@ -414,6 +381,7 @@ fn code_page(character: char) -> Option<u8> {
|
|||||||
'Ö' => 0x99,
|
'Ö' => 0x99,
|
||||||
'Ü' => 0x9A,
|
'Ü' => 0x9A,
|
||||||
'ß' => 0xE1,
|
'ß' => 0xE1,
|
||||||
|
'·' => 0xFA,
|
||||||
ascii if ascii.is_ascii() => ascii as u8,
|
ascii if ascii.is_ascii() => ascii as u8,
|
||||||
_ => return None,
|
_ => return None,
|
||||||
})
|
})
|
||||||
@@ -456,7 +424,7 @@ fn first_quote() -> usize {
|
|||||||
% QUOTES.len()
|
% QUOTES.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn footer(head: &Head, stamp: &str, quote: &[&str; 2]) -> Vec<u8> {
|
fn footer(head: &Head, stamp: &str, quote: &[&str]) -> Vec<u8> {
|
||||||
let mut write = centered(head);
|
let mut write = centered(head);
|
||||||
write.extend([0x1B, b'd', 1]);
|
write.extend([0x1B, b'd', 1]);
|
||||||
write.extend(LARGE);
|
write.extend(LARGE);
|
||||||
@@ -466,8 +434,9 @@ fn footer(head: &Head, stamp: &str, quote: &[&str; 2]) -> Vec<u8> {
|
|||||||
write.extend([0x1B, b'd', 1]);
|
write.extend([0x1B, b'd', 1]);
|
||||||
text_line(&mut write, stamp);
|
text_line(&mut write, stamp);
|
||||||
write.extend([0x1B, b'd', 1]);
|
write.extend([0x1B, b'd', 1]);
|
||||||
text_line(&mut write, quote[0]);
|
for line in quote {
|
||||||
text_line(&mut write, quote[1]);
|
text_line(&mut write, line);
|
||||||
|
}
|
||||||
write.extend([0x1B, b'd', FEED_LINES]); // ESC d n: feed n lines
|
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.extend([0x1D, b'V', 66, 3]); // GS V 66 n: feed and partial cut
|
||||||
write
|
write
|
||||||
@@ -483,7 +452,7 @@ mod tests {
|
|||||||
fn printed_lines() -> impl Iterator<Item = &'static str> {
|
fn printed_lines() -> impl Iterator<Item = &'static str> {
|
||||||
[EVENT_TITLE, EVENT_PLACE, KEEPSAKE_DE, KEEPSAKE_EN, STAMP]
|
[EVENT_TITLE, EVENT_PLACE, KEEPSAKE_DE, KEEPSAKE_EN, STAMP]
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.chain(QUOTES.iter().flatten().copied())
|
.chain(QUOTES.iter().flat_map(|quote| quote.iter().copied()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn contains_line(write: &[u8], line: &str) -> bool {
|
fn contains_line(write: &[u8], line: &str) -> bool {
|
||||||
@@ -523,7 +492,7 @@ mod tests {
|
|||||||
let picked: std::collections::BTreeSet<usize> =
|
let picked: std::collections::BTreeSet<usize> =
|
||||||
(0..1000).map(|_| first_quote()).collect();
|
(0..1000).map(|_| first_quote()).collect();
|
||||||
assert!(picked.last().is_some_and(|last| *last < QUOTES.len()));
|
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:?}");
|
assert!(picked.len() > 1, "{picked:?}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
122
src/quotes.rs
Normal file
122
src/quotes.rs
Normal file
@@ -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!"],
|
||||||
|
];
|
||||||
Reference in New Issue
Block a user