Send Image to Teensy and Draw that Image w/ Paper & Toothpick

nazeern

Member
My goal is to upload an image (pixels are just 0 or 1) so a Teensy can "draw" that image by punching holes in printer paper. (A flashlight + dark room will look cool)

I was thinking a web interface could be made with Flask, which can then accept a file upload. The Teensy will control two motors that move the paper along the X and Y axes. The state (current location of paper and locations to punch) would be stored on Flask, and commands (like move X, move Y, punch hole) would be sent to Teensy, until all holes are punched.

Curious, what tech stack / general pattern do you recommend for...
(1) a GUI
(2) storing state
(3) sending commands to Teensy

Thanks for the help!!!! : )
 
How complete are the images? A simple approach would have the Teensy poll for a new image, then do all the work offline. But that requires the image data is small enough to store locally.
 
Thanks for the response -- the image can be quite large, around 1920x1080. Even just sending one bit (0 or 1) per pixel, that's 1920x1080 = ~2e6 bits = ~5e5 bytes = 500 kB. Not sure what the memory situation is for the Teensy, but seems quite large. Maybe I can send "patches" of the image if there's a memory limitation.
 
Thanks for the response -- the image can be quite large, around 1920x1080. Even just sending one bit (0 or 1) per pixel, that's 1920x1080 = ~2e6 bits = ~5e5 bytes = 500 kB. Not sure what the memory situation is for the Teensy, but seems quite large. Maybe I can send "patches" of the image if there's a memory limitation.
2Mb is only 250KB, so that might fit in Teensy 4.0/4.1 RAM (1MB total) if you don't have too much code, which goes into RAM by default. Teensy 4.1 has pads for optional 8MB or 16MB of PSRAM, and that might be well-suited to your purpose.
 
Thanks for sharing your expertise @joepasquariello , the optional PSRAM is a great resource I hadn't considered. I currently have a Teensy 4.0, so I'm also looking into the Memory section. I'm curious to see if a 500kB image will fit in the 1MB of RAM even when it's broken into RAM1 and RAM2.

How do folks usually handle working with large arrays that don't fit on a Teensy in one piece? Is it a common pattern to send chunks of data to the Teensy to eventually process everything?
 
Thanks for sharing your expertise @joepasquariello , the optional PSRAM is a great resource I hadn't considered. I currently have a Teensy 4.0, so I'm also looking into the Memory section. I'm curious to see if a 500kB image will fit in the 1MB of RAM even when it's broken into RAM1 and RAM2.

How do folks usually handle working with large arrays that don't fit on a Teensy in one piece? Is it a common pattern to send chunks of data to the Teensy to eventually process everything?
You will not be able to have a single 500KB array in the 1MB RAM. You could break it up into two smaller arrays. One would be a static variable, and the other would be on the stack. I don't think there is any "standard" way of doing that. Another option is to store the array in flash using LittleFS. Teensy 4.0 has 2MB of Flash, so it should fit. If you can move to Teensy 4.1 you have 8MB flash, and also the option to add PSRAM and/or additional flash.
 
Back
Top