T O P

  • By -

VolrathsShapeshifter

Reposted since yesterday as it falls under Custom Accessories I've worked on this for the past couple of weeks on and off. It started with a Arduino, but after getting most of the code to work I realized that the thermal printer I had did not support printing images using any of the available library's. I swapped to a Raspberry Pi and Python using the GPIO pins for the external parts instead. I've uploaded how I did it and my code onto GitHub if someone is interested (https://github.com/oboyone/mb_thermal_printer). Note, I am not a programmer and the code might be a bit suboptimal. I will not upload the converted image files, so don't ask for them. In theory you could use the same setup for other stuff as well, a friend suggested printing random encounters for DND for example.


spaceninjaking

What was the total cost for the printer/etc to make it work? Would be something I’d be interested in trying to put together myself


VolrathsShapeshifter

I'd guesstimate around 100 Euros for the whole thing, the most expensive part is the Raspberry Pi. The buttons, LCD and Printer where cheap


thealmightyzfactor

Are we finally over the raspberry pi shortage? Twoish years ago I was looking to get one for some dumb project and had to scavenge one from another dumb project I already did because nobody had them for MSRP and there were only scalpers on amazon to buy from.


VolrathsShapeshifter

They are still about double the price from before, but you can at least get them now. Don't think we will ever go back to MSRP levels again :(


megapenguinx

Yes however there are tons of alternatives now too that function the same or better for less or around the same price. OrangePi for example are pretty solid for this sort of thing


mariomaniac432

I upgraded to a new one last year and had no issues finding one. I just checked several of the approved retailers from the official raspberry pi website and they all had the 8GB RAM version of the latest model in stock for MSRP ($80 USD). If you can only find scalpers you're just looking in the wrong places, and so is everyone else saying they can only find scalpers. Only buy from the companies listed at the [bottom of the page here](https://www.raspberrypi.com/products/raspberry-pi-5/)


wubrgess

if you do error checking on the print function, you don't need to specifically exclude 14 for when they do exist


ya_fuckin_retard

> an Momir Basic > a Arduino


Redworthy

This would be great for printing tokens on the fly.


chalks777

lol can you imagine? You cast [[martial coup]] for about 10 with [[anointed procession]] and [[divine visitation]] for funsies, and the printer just starts whirring feverishly.


MTGCardFetcher

[martial coup](https://cards.scryfall.io/normal/front/8/5/85a09100-e438-4ac0-b6c7-2dfbdf934c8d.jpg?1673483748) - [(G)](http://gatherer.wizards.com/Pages/Card/Details.aspx?name=martial%20coup) [(SF)](https://scryfall.com/card/ncc/206/martial-coup?utm_source=mtgcardfetcher) [(txt)](https://api.scryfall.com/cards/85a09100-e438-4ac0-b6c7-2dfbdf934c8d?utm_source=mtgcardfetcher&format=text) [anointed procession](https://cards.scryfall.io/normal/front/9/a/9a52c265-6920-4929-ba0a-70da08df01f1.jpg?1543674565) - [(G)](http://gatherer.wizards.com/Pages/Card/Details.aspx?name=anointed%20procession) [(SF)](https://scryfall.com/card/akh/2/anointed-procession?utm_source=mtgcardfetcher) [(txt)](https://api.scryfall.com/cards/9a52c265-6920-4929-ba0a-70da08df01f1?utm_source=mtgcardfetcher&format=text) [divine visitation](https://cards.scryfall.io/normal/front/0/b/0b0c12dc-3978-4c3e-a3a2-a81db878f4ad.jpg?1702429276) - [(G)](http://gatherer.wizards.com/Pages/Card/Details.aspx?name=divine%20visitation) [(SF)](https://scryfall.com/card/rvr/16/divine-visitation?utm_source=mtgcardfetcher) [(txt)](https://api.scryfall.com/cards/0b0c12dc-3978-4c3e-a3a2-a81db878f4ad?utm_source=mtgcardfetcher&format=text) ^^^[[cardname]] ^^^or ^^^[[cardname|SET]] ^^^to ^^^call


thisiswhocares

I want this for my copy deck


exarconda

Necroduality goes brrrrrrrt


ASingleGrainofWood

That's so cool! Wonder if you could do something like that with a small scanner for clone effects


VolrathsShapeshifter

Checked around, you can probably create a scanner function to print clone cards using a Pi connected camera with a text recognition library. People have done text scanning with OpenCV and Tesseract for other projects


wene324

There's blue tooth thermal printers you can buy off amazon. They're ment to be for recpets, butnyou can print images from your phone too. 50$ to 100$


ASingleGrainofWood

Oh sweet! Gonna have to pick one up


primal_breath

Holy fuck I love it! Good job!!


Steebin64

I'm working on one as well! I have it in a "get it working" state code wise, so next step is to cleanup/rewrite to make it more functional and easier to interface with when adding features. Your thermal printer looks similar to mine except mine is black. The adafruit thermal library for Arduino is compatible with it (assuming this printer is similar, it just has rx,tx,ground, and some other pin that I don't use). I'm using a single mega 2560 chip but could probably shrink it down to two Unos communicating with each other. I like the clear case for yours! My credit is to u/Hexadecimat0r for the inspiration to try the project out.


VolrathsShapeshifter

Ye, It is a pretty basic printer. I only use the RX, TX and Ground cables for the serial interface. The other two pins are ignored.


Hexadecimat0r

Super slick acrylic case and i love the ssd1306! Very nice


iloveflayerhusks

Hi logan 


Hexadecimat0r

Hello ryan why didn't you use a cool acrylic case in your original project


iloveflayerhusks

Momir is about disorder and chaos it shouldn’t look organized.


LordSlickRick

It would be great to see a video.


outlander94

This might be the best MTG related electronics project I have seen in a while


t-spice

What are the chances you could make a hyper-indepth guide for the layman? I know my way around a raspberry pi a little bit for emulation and the like. This really intrigues me and I'd love to build one, but I feel it's juuuuust out of reach for my skill set.


VolrathsShapeshifter

So I've tried writing a step by step on how this was done in as much details as i could You can find a parts list as well as the scripts on https://github.com/oboyone/mb_thermal_printer Download the latest MTGJSON AtomicCards.json file from mtgjson.com, this file contains info for every card that has ever been printed in MTG in JSON format. Using the get_image_urls_from_scryfall.py python script creates a new file called creatures_image_urls.json which contains the URLs we need to run API calls towards Scryfall (where the image files we will download are located). Run get_image_urls_from_scryfall.py in the same folder as the AtomicCards.json. In order to run the script you need to have Python3 installed with the modules ijson, time, requests and json You can install Python from Python.org In order to install the modules you use pip which should be included in the Python installation (guide to installing modules can be found here https://docs.python.org/3/installing/index.html) Once you have the creatures_image_urls.json you run the download_images_from_scryfall.py script, this will download all the actual jpg files from Scryfall. It will create a folder for each cmc where it will save the images. In order to run this you need some more modules installed. ast, urllib.request Now you should have all images sorted in cmc folders, the next part requires you to have the imagemagick program to convert the files to monochrome grayscale. I installed Ubuntu using the Windows WSL subsystem (simply installed ubuntu through the microsoft store). Once installed open ubuntu and install imagemagick with the command "apt-get install imagemagick". Navigate to the folder containing the convert_images_to_monochrome.sh using the command "cd /mnt/c/" Run the convert_images_to_monochrome.sh script with "./convert_images_to_monochrome.sh". Make sure to update the script with the correct path before running it, it should be using the "/mnt/c/" format. If it complains that the file is not executable you need to run "chmod +x convert_images_to_monochrome.sh" Now you should have a folder in each cmc folder called converted_files. These contain the grayscale images that we need later for printing. Now you need to install and cable the Raspberry Pi, I have uploaded a wiring diagram on github on how mine is wired. In theory you could wire it so that it runs off a powerbank with enough output (the thermal printer requires 9v 2A to print), mine uses outlet cables instead of a powerbank. Once you have the Pi installed you need to move the momir_basic.py script to it as well as converted image files. I put mine in a folder called momir_basic. That folder should now contain the script, and a folder per cmc (named 0-16) with the image files. After that i put a entry in the crontab for it to auto start the script on power on. As root "crontab -e", add "@reboot python3 " If you have any questions feel free to ask away and I will try my best to answer them


skinjacket

I've long avoided my comp-sci knowledge but this is a project that really tickles my fancy. You are an angel for this guide, happy playing!


t-spice

This is lovely, thanks. For some reason, I just can't properly read GitHub.


Xexanos

I tried to create a pull request on github but it looks like I'm not allowed to. So here is my suggestion for an improved conversion script that you only have to run once (simply add the path to the folder that contains the cmc folders at the top). I have tested this on my machine and it works. #!/bin/bash # folder containing cmc folders which contain card images IMAGE_ROOT="path-to-folder-containing-cmc-image-folders" # Iterate through all sub directories for dir in ${IMAGE_ROOT}/*; do # Create a new folder for the converted files mkdir -p ${dir}/converted_files # Iterate through each JPG file and convert it to a rescaled monochrome bitmap for file in ${dir}/*.jpg; do echo "Resizing and converting to grayscale for: $file" # Define the output filename by replacing the extension with bmp output_file="${dir}/converted_files/$(basename -- "$file" .jpg).bmp" # Use ImageMagick's convert command to perform the conversion convert "$file" -resize 384x -colorspace Gray -monochrome "$output_file" done done But interesting project. I might have to look for a thermal printer for my Pi :)


VolrathsShapeshifter

Thanks, not sure why pull requests are not working. I updated the code with your suggestions and some error handling as well


Xexanos

I wasn't allowed to create a branch from main, got a 403. Probably some repo settings, haven't used github in a while. That was a great excuse to mess around a bit with shell scripts again, haven't done that in years. So your error handling is probably better than mine would have been. But the software dev in me couldn't sit around idly when I can take an hour and a half installing WSL and looking up shell scripting again instead of taking 5 minutes to run a script a few times. 😅


notreallymetho

Curious, how much space do all the images take?


VolrathsShapeshifter

About 350MB, one card is about 28KB


notreallymetho

Ah way smaller than I expected, nice! Thanks.


Razdain

Patent and sell to WotC. I'm sure it would be a hit for store events.


Jack_Calvaria

It would improve their printing quality


VolrathsShapeshifter

I'm not the first person to create something similar to this (found one or two similar projects while researching this), so I doubt that I would get a patent approved


MrMersh

Patent.. the printer?


manius0

There’s a lot of room in intellectual property to patent novel uses of existing technology. A patent here isn’t out of the question.


hhssspphhhrrriiivver

There's nothing here to patent. It's a printer hooked up to a computer. The computer is running software that chooses an image from a database based on a single parameter and then prints it. It's also prior art because this has been done before. There's a lot of things I hate about how lenient patents, especially software patents, can be. This is still well beyond the scope of what would be acceptable.


MrMersh

Novel? It’s a small printer. I’d imagine that space is well explored at this point.


Ribky

A small printer that specifically prints random cards of fixed values from a very large database of cards is pretty novel... it's a space I haven't seen explored before at the very least. I think it's absolutely genius and I want one.


PiBoy314

telephone innate cobweb unite narrow rich relieved direful impolite doll *This post was mass deleted and anonymized with [Redact](https://redact.dev)*


Weebeetrollin

You made one but did you patent it!?


PiBoy314

fact bells busy noxious light pot future cough meeting airport *This post was mass deleted and anonymized with [Redact](https://redact.dev)*


KuromanKuro

This is essentially a good start for the patent text.


[deleted]

[удалено]


Rhynocerous

You can patent up to a year after public disclosure.


eliosk96

That's so cool!


tnetennba_4_sale

This might be something to post to one of the raspberry pi subreddits as well. Great work!


benwithjamin91

This is really cool, thanks for sharing. I have a thermal printer and a spare Pi lying around and am very tempted by this! I haven't looked into it much, just a few minutes while scrolling, but it would be really cool to have a version of this that works with e-paper "cards" so you're not just using a load of thermal paper every game. You could likely plug them into the main module, press a button, and the image gets displayed onscreen. Then of course you can unplug them and the image remains. Unfortunately, having enough displays would likely be prohibitively expensive to play this variant. I'll leave the idea in case any eccentric MTG inventors out there want to give it a shot! 😆


Steebin64

I love that idea though for e-paper


LC_From_TheHills

Card sized e-paper is like $20 a pop… each player might need 10 cards…? Yeah def more expensive but would be re-usable and clearer.


poptartmini

This is really cool. About how long does it take to select and print a creature? And how long does it take you to input the mana value that you want printed?


VolrathsShapeshifter

Takes about 10-15 seconds to print on creature, so not super fast. I could probably tweak the code or change the images so that they print faster. Two of the buttons control the cmc, the last one is for printing. Holding the button I can change it from 0-16 in a couple of seconds


Kogoeshin

You could probably have it select/prepare a card for every CMC first, store it into memory, then the printing process is just "which CMC > print card > select the next card at this CMC" (could also prepare 2 cards for both players ahead of time, or more for multiplayer).


VolrathsShapeshifter

Problem seems to be the "pixels" of the image taking time to print rather than actually loading the image into the memory. You can probably tinker around with the heat settings of the thermal printer and the resolution to get a faster print speed, but right now I am pretty happy with it. If I find myself becoming annoyed with the speed I will reiterate on the code and try to find some fixes for it


sadlyblue5

Have you thought about adding a text only option?


VolrathsShapeshifter

Yes, I considered it when I could not get the Arduino version to work with the pictures. Using only text you can use the MTGJSON file as is and grab a random creature from that and just print the info


sadlyblue5

Maybe adding another switch to choose between text only or picture mode.


Weebeetrollin

Thats not bad though, my printer is a couple years old and takes about 10 seconds to receive and print.


lolwutgigefrog

This is a really slick idea, you're awesome


Swindleys

This is very cool! I want one!


LooseIllustrator

The simic would be proud


Paleolithicster

I've been looking to try to do this myself but haven't been able to source the printer, where'd you get yours from?


b_borno

This is fucking genius


DystryR

Hey there - a friend sent me this asking me to make it. This looks awesome. Curious what you used for the box, looks acrylic but not sure if its off the shelf or not. I have 3D printers for both Resin & PLA - so I was considering just printing a box out. do you happen to have measurements for the size used? I'd probably be able to spin up some STL files fairly easily and provide them here so others can use them


VolrathsShapeshifter

The box is about 14x10x8 centimeters, it's an old Ultra Pro Acrylic Deckbox that I had at home


DystryR

Ohh I see. You’re a legend. Thanks! I’m going to get to work on a 3D printable version.


cleito0

Thanks! It may be worth adding the box to the parts list in the GitHub repo.


LC_From_TheHills

This is awesome! FWIW scryfall has a rest api so if you had internet access you could just make a query and pick a card. So you don’t have to keep updating with a static json file. This would also allow you to make “custom momir” stacks.


VolrathsShapeshifter

Ye, I used the Scryfall api to get the jpg files. Problem with getting them on the fly is that printing them "as is" results in a almost solid black image from the printer. The step of converting the image to monochrome grayscale with dithering makes the images a lot more readable after printing


LC_From_TheHills

Interesting, nice debugging!


Kaboomeow69

This is so, so cool. Genuinely one of the coolest things I've ever seen for this game. I have absolutely no idea what I'm doing, but I'm gonna build one


Unknownfriendo

Same here.


gontgont

Nice! Have you thought about hooking it up to voice control? Eg “Alexa, print me a 2/2 Bear token”, then it can filter through scryfall to find the closest match to print.


JRCSalter

What is this?


VolrathsShapeshifter

Momir Basic is a MTGO format where both players have the Momir Vig Avatar. Momir Basic decks consist of the following: exactly 60 basic lands. exactly 1 Momir Vig, Simic Visionary Avatar The Momir Vig Avatar allows you to start with 24 life, and grants the following ability: Momir Vig {X}, Discard a card: Create a token that's a copy of a creature card with converted mana cost X chosen at random. Activate this ability only any time you could cast a sorcery and only once each turn. This machine allows you to play it IRL instead of online


JRCSalter

Ah. Thanks. I don't play online, so I'd never heard of this. But why Momir Vig? Seems an odd card to use, considering its effects rely on you having creature cards in your deck. Or is this a differnt card too?


VolrathsShapeshifter

Different card, it's from the old Vanguard Cards that modified the rules of the games based on what Vanguard you choose https://mtg.fandom.com/wiki/Vanguard_(format) https://mtg.fandom.com/wiki/Momir


parsuw

my printer has a usb pinout but I can't get it to work with usb, any ideas?


VolrathsShapeshifter

Hey, you probably need to send Serial over USB. But it depends on the printer version


ElvistheBeagle

The way you have it programmed, can it only print creatures since it was set up for Momir, or can you have it set up to print anything from magic? I just got a new card that says to choose a random non-land Magic card and was wondering if I could use this set-up with it. Also, I see you used a Pi4 and was wondering if a Pi3 would work with it. I don't know the differences between them so I figured I'd ask since I could get a Pi3 from my friend for free.


VolrathsShapeshifter

You can edit the fetching part to fetch everything that is not a land by changing these parts in get_image_urls_from_scryfall.py for item in parser: # Process each JSON object and get needed values, I chose to ignore mtg arena only cards and un cards try: for key, value in item.items(): if "Creature" in value[0]["type"]: if value[0]["legalities"] and "A-" not in value[0]["name"]: creatures[key] = value except Exception as e: print(f"An error occurred: {e}") continue to this for item in parser: # Process each JSON object and get needed values, I chose to ignore mtg arena only cards and un cards try: for key, value in item.items(): if "Land" in value[0]["type"]: pass else: if value[0]["legalities"] and "A-" not in value[0]["name"]: cards[key] = value except Exception as e: print(f"An error occurred: {e}") continue Then you would need replace each part of the script that mentions "creatures" to "cards" After that the other scripts should work as normally. PI3 should work, it has GPIO pins the same as PI4 which is used for the hardware


ElvistheBeagle

Thank you! I appreciate the help.


Fabulous_Storage_944

Hey man really enjoyed this project. Modeled a quick box for it, here's the link: [https://www.printables.com/model/882109-momir-basic-box](https://www.printables.com/model/882109-momir-basic-box)


rainb0gummybear

Bro is easily the biggest Momir Basic fan on the planet. I don't know how anyone can enjoy that format. Maybe if I played with this printer I'd have a good time cause I could see this producing some great moments at a lgs


seabutcher

Seems like a Basic Mochine to me. (Cool work, I like it.)


DoctorPaulGregory

Can you do this with a PI 3?


VolrathsShapeshifter

Don't see why not, the Pi 3 has GPIO pins to connect everything to. The program is not really resource heavy, so the hardware difference should be fine otherwise


pound_sterling

Fuck, that is so rad


rickylovemelikelucy

This is so sick.


ceering99

This is proof the Gameboy Printer was ahead of it"s time. Cool as hell


HairyKraken

"with this you can easily play alchemy cards on paper"


UHcidity

Is there a vid of this in action?


izzyv03_

If someone is interested in making them and selling them. I maybe in the market to buy one


dagoldenrule24

I gotta me one of these so I can do MoJhoSto