-
Joystick fixed with bamboo skewer
05/31/2015 at 17:34 • 0 commentsBamboo skewer, hot glue, a Dremel, and a drill are all it took for me to fix this broken Atari controller (mentioned in my previous project log).
-
Arduino IDE "includes" solved
05/31/2015 at 16:13 • 0 commentsI wrote most of the code for this before I had the hardware. To do so I wrote a "hardware emulator" using the SDL2 library. This is great because I could work on it when all I with me was a computer.
The problem came when I went to load it onto the Teensy 3.1 using the Arduino IDE. I had abstracted out all of the display and control specific stuff so that portability would be easy. But when I tried to compile, there were "undefined" errors for every function.
I had correctly included the prototypes for each function in the header files, so I assumed the issue was that the linker wasn't pulling in the .c files. When I changed the name of the .c files to .cpp it work. How frustrating!
Turns out the issue is that Arduino is compiling the .ino files as C++. This causes two issues:
C Functions must be declared with EXTERN
The .c files were getting included, but I need to tell the compiler to treat my C functions as C and not as C++. There is a helpful thread on the Arduino forums that shares the answer. You need to wrap function definitions within header files in some magic:
#ifdef __cplusplus extern "C"{ #endif void cFunctionPrototype1(void); void cFunctionPrototype2(void); #ifdef __cplusplus } // extern "C" #endif
C99 won't work with C++
I also like to define local variable in "for" loops using the C99 standard. That won't work at all with a C++ compile (apparently):
for (uint8_t i = 0; i<7; i++) { }
needs to be:
uint8_t i; for (i = 0; i<7; i++) { }
-
Oh Noes... Crappy Joystick Design
05/30/2015 at 18:55 • 0 commentsI took this project to the LayerOne conference with me last week and a lot of people had a fun time trying it out. Unfortunately the Atari joystick broke. I don't think it was overused, and cracking it open it just looks like poor engineering:
You can see the little white "wing" that is hinged on the bottom of the white joystick plastic. This hing is integral to pushing down on the PCB clicky buttons so super-glue is not an option.
I've ordered another one, but I'd like to have 2 anyway. I think it may be possible to repair this with a couple of bamboo skewers and some hot glue. If I have success with that I'll post a project log as an update.