Hacking [Tutorial] Printing Spla2n Posts with an Arduino/Teensy Board!

Which AVR are you using?


  • Total voters
    55
D

Deleted User

Guest
this wasnt my brightest moment. I need to use the sleep
 
Last edited by ,

dj505

Inexperienced Romhacker
OP
Member
Joined
Oct 4, 2014
Messages
556
Trophies
0
Location
Most likely at the arcade
Website
www.youtube.com
XP
844
Country
Canada
This will work with this arduino uno correct?

https://www.amazon.com/Arduino-Uno-...qid=1515373164&sr=8-4&keywords=Arduino+Uno+R3

edit: better yet this comes with a bunch of stuff..which I assume will work as well since it comes with an uno r3..is anyone able to confirm this?

https://www.amazon.com/OSOYOO-proje...73334&sr=1-5&keywords=arduino+uno+r3+ethernet
Yes, it should work. Although if you're getting one specifically for doing this project, I'd recommend getting a cheaper Teensy board clone from eBay or something, although it's up to you
 
D

Deleted User

Guest
Yes, it should work. Although if you're getting one specifically for doing this project, I'd recommend getting a cheaper Teensy board clone from eBay or something, although it's up to you
Looking to expand out of this a bit, as I am already using a teensy but that is a bit limited and all of its parts seem to be in the EU haha

Thank you for confirming :) The parts should be here tuesday. As long as I know that it should work with this project I have a jumping off point!
 

dpad_5678

Ape weak on own. Ape strong in unity.
Member
Joined
Nov 19, 2015
Messages
2,219
Trophies
1
XP
2,880
Country
United States
Sorry to rewrite a message, but is anyone having any luck importing this project into the Arduino IDE? Would be great for custom controllers so we could use functions such as digitalRead, etc to trigger controller button inputs.
 

dj505

Inexperienced Romhacker
OP
Member
Joined
Oct 4, 2014
Messages
556
Trophies
0
Location
Most likely at the arcade
Website
www.youtube.com
XP
844
Country
Canada
Sorry to rewrite a message, but is anyone having any luck importing this project into the Arduino IDE? Would be great for custom controllers so we could use functions such as digitalRead, etc to trigger controller button inputs.
That would be pretty neat for sure! I haven't seen anything like that done yet but I don't imagine it would be too difficult. I'd give it a shot myself but I don't have the time right now.
 
D

Deleted User

Guest
Any idea why the make file wont generate for an arduino?

It ends with

[obj/Joystick.o] Error 1

20ztfte.png
 
Last edited by ,

Talik13

New Member
Newbie
Joined
Jul 25, 2018
Messages
3
Trophies
0
Age
33
XP
43
Country
United States
I'm having the same issue as Sasori.

Here's how I have it set up:

SwitchFightstick [Folder]

[All Contents of Splatmeme-Printer-master]
LUFA [folder with all it's contents]

I have set the LUFA_PATH equal to the exact LUFA folder location (within the LUFA folder). I'm using an Arduino R3 so I also changed at90usb1286 to atmega16u2. I have installed all the necessary components and made sure to add the Paths as instructed.

But I keep getting an error around joystick.c

Below is the CMD outuput:



C:\SwitchFightstick>make
0 [main] sh 10372 sync_with_child: child 12804(0x1A8) died before initialization with status code 0xC0000142
236 [main] sh 10372 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable
0 [main] sh 28324 sync_with_child: child 24828(0x1B4) died before initialization with status code 0xC0000142
142 [main] sh 28324 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable
0 [main] sh 23336 sync_with_child: child 21328(0x1B4) died before initialization with status code 0xC0000142
288 [main] sh 23336 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable
[INFO] : Begin compilation of project "Joystick"...

avr-gcc (WinAVR 20100110) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[GCC] : Compiling C file "Joystick.c"
avr-gcc -c -pipe -gdwarf-2 -g2 -mmcu=atmega16u2 -fshort-enums -fno-inline-small-functions -fpack-struct -Wall -fno-strict-aliasing -funsigned-char -funsigned-bitfields -ffunction-sections -I. -DARCH=ARCH_AVR8 -DF_CPU=16000000UL -mrelax -fno-jump-tables -x c -Os -std=gnu99 -Wstrict-prototypes -DUSE_LUFA_CONFIG_HEADER -IConfig/ -DZIG_ZAG_PRINTING -I. -IC:\SwitchFightstick\LUFA\LUFA/.. -DARCH=ARCH_AVR8 -DBOARD=BOARD_NONE -DF_USB=16000000UL -MMD -MP -MF obj/Joystick.d Joystick.c -o obj/Joystick.o
Assembler messages:
Fatal error: can't create obj/Joystick.o: No such file or directory
Joystick.c: In function 'SetupHardware':
Joystick.c:56: warning: implicit declaration of function 'clock_prescale_set'
Joystick.c:56: error: 'clock_div_1' undeclared (first use in this function)
Joystick.c:56: error: (Each undeclared identifier is reported only once
Joystick.c:56: error: for each function it appears in.)

Any advice would be very helpful as I'm very new to programming in general!
 
D

Deleted User

Guest
I'm having the same issue as Sasori.

Here's how I have it set up:

SwitchFightstick [Folder]

[All Contents of Splatmeme-Printer-master]
LUFA [folder with all it's contents]

I have set the LUFA_PATH equal to the exact LUFA folder location (within the LUFA folder). I'm using an Arduino R3 so I also changed at90usb1286 to atmega16u2. I have installed all the necessary components and made sure to add the Paths as instructed.

But I keep getting an error around joystick.c

Below is the CMD outuput:



C:\SwitchFightstick>make
0 [main] sh 10372 sync_with_child: child 12804(0x1A8) died before initialization with status code 0xC0000142
236 [main] sh 10372 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable
0 [main] sh 28324 sync_with_child: child 24828(0x1B4) died before initialization with status code 0xC0000142
142 [main] sh 28324 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable
0 [main] sh 23336 sync_with_child: child 21328(0x1B4) died before initialization with status code 0xC0000142
288 [main] sh 23336 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable
[INFO] : Begin compilation of project "Joystick"...

avr-gcc (WinAVR 20100110) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[GCC] : Compiling C file "Joystick.c"
avr-gcc -c -pipe -gdwarf-2 -g2 -mmcu=atmega16u2 -fshort-enums -fno-inline-small-functions -fpack-struct -Wall -fno-strict-aliasing -funsigned-char -funsigned-bitfields -ffunction-sections -I. -DARCH=ARCH_AVR8 -DF_CPU=16000000UL -mrelax -fno-jump-tables -x c -Os -std=gnu99 -Wstrict-prototypes -DUSE_LUFA_CONFIG_HEADER -IConfig/ -DZIG_ZAG_PRINTING -I. -IC:\SwitchFightstick\LUFA\LUFA/.. -DARCH=ARCH_AVR8 -DBOARD=BOARD_NONE -DF_USB=16000000UL -MMD -MP -MF obj/Joystick.d Joystick.c -o obj/Joystick.o
Assembler messages:
Fatal error: can't create obj/Joystick.o: No such file or directory
Joystick.c: In function 'SetupHardware':
Joystick.c:56: warning: implicit declaration of function 'clock_prescale_set'
Joystick.c:56: error: 'clock_div_1' undeclared (first use in this function)
Joystick.c:56: error: (Each undeclared identifier is reported only once
Joystick.c:56: error: for each function it appears in.)

Any advice would be very helpful as I'm very new to programming in general!
I fixed it by compiling via linux(specifically a raspberry pi)
 

Talik13

New Member
Newbie
Joined
Jul 25, 2018
Messages
3
Trophies
0
Age
33
XP
43
Country
United States
I'm having the same issue as Sasori.

Here's how I have it set up:

SwitchFightstick [Folder]

[All Contents of Splatmeme-Printer-master]
LUFA [folder with all it's contents]

I have set the LUFA_PATH equal to the exact LUFA folder location (within the LUFA folder). I'm using an Arduino R3 so I also changed at90usb1286 to atmega16u2. I have installed all the necessary components and made sure to add the Paths as instructed.

But I keep getting an error around joystick.c

Below is the CMD outuput:



C:\SwitchFightstick>make
0 [main] sh 10372 sync_with_child: child 12804(0x1A8) died before initialization with status code 0xC0000142
236 [main] sh 10372 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable
0 [main] sh 28324 sync_with_child: child 24828(0x1B4) died before initialization with status code 0xC0000142
142 [main] sh 28324 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable
0 [main] sh 23336 sync_with_child: child 21328(0x1B4) died before initialization with status code 0xC0000142
288 [main] sh 23336 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable
[INFO] : Begin compilation of project "Joystick"...

avr-gcc (WinAVR 20100110) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[GCC] : Compiling C file "Joystick.c"
avr-gcc -c -pipe -gdwarf-2 -g2 -mmcu=atmega16u2 -fshort-enums -fno-inline-small-functions -fpack-struct -Wall -fno-strict-aliasing -funsigned-char -funsigned-bitfields -ffunction-sections -I. -DARCH=ARCH_AVR8 -DF_CPU=16000000UL -mrelax -fno-jump-tables -x c -Os -std=gnu99 -Wstrict-prototypes -DUSE_LUFA_CONFIG_HEADER -IConfig/ -DZIG_ZAG_PRINTING -I. -IC:\SwitchFightstick\LUFA\LUFA/.. -DARCH=ARCH_AVR8 -DBOARD=BOARD_NONE -DF_USB=16000000UL -MMD -MP -MF obj/Joystick.d Joystick.c -o obj/Joystick.o
Assembler messages:
Fatal error: can't create obj/Joystick.o: No such file or directory
Joystick.c: In function 'SetupHardware':
Joystick.c:56: warning: implicit declaration of function 'clock_prescale_set'
Joystick.c:56: error: 'clock_div_1' undeclared (first use in this function)
Joystick.c:56: error: (Each undeclared identifier is reported only once
Joystick.c:56: error: for each function it appears in.)

Any advice would be very helpful as I'm very new to programming in general!

Okay, so I managed to get it farther by manually adding an obj folder and a blank file called "joystick.o"

here's where it's getting stuck now:

[LNK] : Linking object files into "Joystick.elf"
avr-gcc obj/Joystick.o obj/Descriptors.o obj/image.o obj/HIDParser.o obj/Device_AVR8.o obj/EndpointStream_AVR8.o obj/Endpoint_AVR8.o obj/Host_AVR8.o obj/PipeStream_AVR8.o obj/Pipe_AVR8.o obj/USBController_AVR8.o obj/USBInterrupt_AVR8.o obj/ConfigDescriptors.o obj/DeviceStandardReq.o obj/Events.o obj/HostStandardReq.o obj/USBTask.o -o Joystick.elf -lm -Wl,-Map=Joystick.map,--cref -Wl,--gc-sections -Wl,--relax -mmcu=atmega16u2
obj/Joystick.o: file not recognized: File truncated
make: *** [Joystick.elf] Error 1

--------------------- MERGED ---------------------------

So I was able to get it working but it seems that the brush it selects is the larger one which the image turns into a mess after. How can i fix that

Excuse me, but what did you do to get it working? I'm having a similar error
 

JeSuisNerd

Member
Newcomer
Joined
Jan 29, 2012
Messages
6
Trophies
0
XP
91
Country
United States
Okay, forgive me for being dumb but will this adapter work for my Uno R3? The instructions don't really help with that.

adafruit DOT com/product/284

EDIT: I'm actually dumb, for some reason I had it in my head that the USB port for programming the board would not also be able to connect to the switch. Carry on.
 
Last edited by JeSuisNerd,

Type_O_Dev

Developer
Developer
Joined
Dec 12, 2017
Messages
683
Trophies
0
XP
1,459
Country
United States
Disclaimer: Yes, I have written a very similar tutorial to this one in the past. However, many changes have been made since then, and a complete rewrite is necessary to document them all without errors. Also, this is not a beginner project! If you do not have experience using boards such as the Arduino or Teensy, as well as the Windows command line, this may not be for you. A lot of debugging and troubleshooting will likely be necessary. With that in mind, let's get started!

For those of you who may not know what this is all about, this is what I'm talking about:

This allows you to use any atmega32u4 or at90usb1286 board (as well as the Arduino Uno R3) to draw Splatoon 2 posts automatically. You can take images off the internat and convert them for use, or you can draw your own material on the PC itself and convert it to be drawn on the Switch automatically.

You'll need:
- One of the following:
- An atmega32u4 board such as the Teensy 2.0 or Arduono Lenardo
- An at90usb1286 board such as the Teensy 2.0++
- An Arduino Uno R3
-
LightningStalker's Splatmeme Printer repo
- LUFA (Lightweight USB Framework for AVRs)
- Gimp
- MinGW for Windows
- Python 2.7
- A USB C to USB A adapter to plug the Teensy into the Switch while in handheld mode (using the dock's ports can cause issues)

Here are a few boards to choose from. All the following should work:

Remember, you're not limited to just the boards you find on here. Any board you find out in the wild that uses an atmega32u4, at90usb1286, or atmega16u2 should work. These are just some that I found that are on the cheaper side, but should work just fine.

Canada:
Xcsource Teensy 2.0++ from Amazon (I'm using this one currently)
Sodial Teensy 2.0 from Amazon
Xcsource Pro Micro from Amazon
no-name Pro Micro from AliExpress
Beetle atmega32u4 mini dev board from AliExpress


USA: (I'm in Canada and don't usually order from US-based sites so I apologize for inaccuracies)
HiLetgo Pro Micro from Amazon
OSOYOO Pro Micro from Amazon
TENSTAR ROBOT Pro Micro from AliExpress
Beetle atmega32u4 mini dev board from AliExpress

Setting up the repository for use
First off, you'll want to acually get the stuff up and running. Here's how you do that.
  1. Make a directory where you'll store everything. Something simple is fine, but I have mine in
    Code:
    C:\SwitchFightstick
  2. Open up the Splatmeme Printer .zip and go into the splatmeme-printer-master folder. Select everything inside that and extract it to the directory you made in step 1.
  3. Open up the LUFA zip and rename the "lufa-LUFA-170418" folder to "LUFA", then extract it to the directory you made in step 1.
  4. Install Python 2.7, then go to the directory it was installed to (should be C:\Python27) and find python.exe. Rename it to python2.exe and copy it to the directory you made in step 1.
  5. Install MinGW, and if it asks for packes to install alongside it, select the "basic" package (name may very, but it's something like that).
  6. Open up the Start menu on Windows and search for "path"; one of the results should be "Edit the system environment variables". Select that.
  7. At the bottom, press the "Environment variables" button.
  8. Under "System variables" (the bottom window), find "Path" and click Edit.
  9. Press "New" and add MinGW's bin directory, which should be
    Code:
    C:\MinGW\bin
    .
You should now be finished setting up.

Converting your image
Here we'll actually convert the image to a format you can use with the printer. This is where Gimp comes in.
  1. Open up Gimp and press Ctrl+N to make a new canvas. Make it 320 pixels wide and 120 pixels tall.
  2. Paste your image onto the canvas and use the resize and move tools to make it fit, or draw something entirely of your own if you like. As long as it fits on the canvas.
  3. Go to the "Image" menu on the top bar, hit "Mode" and select "Indexed"
  4. On the window that pops up, make sure you select "Use black and white (1-bit) palette" and set dithering to normal. Don't change anything else. If it doesn't look good, hit undo and mess with the contrast and stuff until it looks the way you want it.
  5. Once the image is as you want it, hit File > Export as... and navigate to the folder you made at the beginning of this guide.
  6. Set the image format as "Raw image data (.data)" and name it "image.data" (really, you can name it whatever you want as long as it ends in .data)
  7. Open up a command line and navigate to the directory you saved it to (should be the same as the one you made at the beginning of this guide)
  8. Run the command
    Code:
    python2 bin2c.py image.data
    , replacing
    Code:
    image.data
    with whatever you named it. You should now have a file called
    Code:
    image.c
    .
The image is now ready to be printed!

Programming your board
This part actually varies between boards. Select the one based on which board you have.

atmega32u4:
You'll need:
- Arduino IDE

Steps:
  1. In the directory you made, find the file simply called "makefile" and open it up in your favorite text editor.
  2. Find the line that says
    Code:
    at90usb1286
    and change it to
    Code:
    atmega32u4
  3. Open up the Arduino IDE after plugging in your board and go to File > Preferences and select
    Code:
    Show verbose output during: upload
  4. Upload any sketch; doesn't matter which. You'll need part of the output shown in the command line for the next step.
  5. Find the line with the
    Code:
    avrdude
    command and copy the entire command itself and paste it into the command line. Don't hit enter yet.
  6. Replace the parts of the command that point to the directory and files and stuff with the directory you made as well as "Joystick.hex" as the target.
  7. Make sure the
    Code:
    -P/dev/xx
    portion shows the correct port number where xx is.
  8. Quickly double tap the reset button on the board and press enter on the command line. Might take a couple tries to get the right timing, but it'll work.
You can now plug your board into the Switch and begin! It should automatically select the right tool and positioning of the cursor.

at90usb1286:

You'll need:
- The Teensy Loader program
  1. Unzip teensy_loader_cli.exe into the repo directory.
  2. Open a command line and navigate to the repo directory.
  3. You should already have the image.c file you made in the last portion of this guide. Run the command
    Code:
    make
    and it should beign to compile. If you get an error, open up the makefile in a text editor again and make sure the LUFA path is set correctly, as well as everything else.
  4. Run the command
    Code:
    teensy_loader_cli -mmcu=at90usb1286 -w Joystick.hex
    , then press the button on your Teensy. It should upload.
You can now plug your board into the Switch and begin! It should automatically select the right tool and positioning of the cursor.

Arduino Uno R3:

You'll need:
- Set the Arduino to DFU mode (note that to get the original Arduino functionality back, you'll need to re-flash the original firmware)
  1. Open up the makefile in your favorite text editor and replace
    Code:
    at90usb1286
    with
    Code:
    atmega16u2
  2. Open up a command line and navigate to the folder, then run the command
    Code:
    make
    . You should be left with a Joystick.hex file along with multiple others that you won't need.
  3. Follow these instructions to flash the .hex file to the Uno while it's in DFU mode
You can now plug your board into the Switch and begin! It should automatically select the right tool and positioning of the cursor.

Troubleshooting / Common Issues
Image is inverted:
  • Go back into the image in GIMP: Colors > Map > Rearrange Colormap
  • (drag/drop) swap positions of black & white.
  • export, build, make, transfer, print!
And you're done! I've only personally tested the at90usb1286 portion of the guide, which worls flawlessly. It's up to you guys to test the rest of it! If you have any issues or questions, feel free to ask, and I'll help as much as I can.

Edit: Please excuse the formatting with the code windows, I expected them to be inline text and not separate boxes haha

I have seen a similar guide in a few sites and my primary question is can we do this with a raspberry pi with usb gadget support.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Xdqwerty @ Xdqwerty: Out of nowhere I got several scars on my forearm and part of my arm and it really itches.