FolkComputer / folk

🎁 Physical computing system.
https://folk.computer
Apache License 2.0
75 stars 4 forks source link

Add receipt printer driver #169

Closed ppkn closed 1 week ago

ppkn commented 1 month ago

Adds a simple receipt printer driver. On my system I have these claims in my setup.folk

Claim tm-l90 is the default printer
Claim tm-l90 is a receipt printer
Claim tm-l90 is at 192.168.0.156
Claim tm-l90 has tag geometry {tagSize 30mm top 24mm right 28.5mm left 14mm bottom 75.5mm}

I tried to use a nested When initially, but I wasn't able to do an early return and it was behaving weird if the printer claims were retracted/reclaimed e.g. if they were on a printed program that went missing and came back.

ppkn commented 1 month ago

@osnr How do we want to handle previously printed programs? We currently have code that throws an error when you try to reprint an existing program.

osnr commented 1 month ago

@osnr How do we want to handle previously printed programs? We currently have code that throws an error when you try to reprint an existing program.

Empirically, I think that safeguard is pretty important (it's easy to end up in terrible situations where you accidentally stomp your old programs and your printed programs are inaccurate). I guess the useful application of this is if you want to fully replace an old program, both source and layout? But then you should just delete the files by hand, maybe.

ppkn commented 1 week ago

I think the previously printed program safeguard is the last thing I want to resolve before merging this.

it's easy to end up in terrible situations where you accidentally stomp your old programs and your printed programs are inaccurate

I'm not sure I follow. If you have an existing program open in web-editor, there's nothing that prevents stomping old programs (code). In which case, I feel like someone would actually want the updated code printed.

Maybe the distinction is that we want to see if the code requested to print is different than what exists on disk?

New program
just save and print
Code is the same as $id.folk
Allow to reprint
Code is different from $id.folk
??? maybe throw an error and require a save before printing?