TextMate Bundle for Arduino 0017

TextMate Bundle to build and upload Arduino sketches

Far be it from me in any way, shape or form to criticize the Arduino IDE which is simple, easy to use and works flawlessly (at least I have never had any problems). However, there are times when I find it preferable to write the Arduino sketches in TextMate (which is the text editor for Mac, in case you didn't know) since it has better... well, text editing functions. Until yesterday I frequently wrote/edited the sketches in TextMate and then copied the text over to the Arduino IDE in order to upload the sketch.
There are several guides on compiling and uploading from the command line and also several TextMate bundles for doing this but I couldn't get any of them to work on my setup (Mac OS X 10.6.1, Arduino Duemilanove and Arduino 0017) so I had to hack one together myself using bits and pieces from the other available bundles and documentation from various forums.

Here it is: TextMate bundle for Arduino 0017

This bundle assumes that the Arduino IDE version 0017 is installed in /Applications and it named "Arduino". If this is not the case you need to change a path in the makefile (refer to the section about messing with the Makefile).

How to use it

  • Extract the zip and double-click the .tmbundle file to install it in TextMate (which, of course, you will need to have installed beforehand).
  • Create a new document in TextMate, write some Arduino code (or copy/paste in the sample Blink code) and save the file with a .pde extension
  • Hit Cmd-R to compile and upload the sketch

You can also hit Cmd-B just to compile without uploading (to check your syntax).

Note that a folder named "applet" will be created in the same location as the .pde file during compilation. (You can delete it if you want or leave it in place.)

MCU and F_CPU settings
The Makefile needs to know what AVR processor and which clock speed to compile to. The defaults are ATmega328 and 16 MHz (i.e. a standard Arduino Duemilanove).
These values can be overridden by setting other values in TextMate's preferences. In the TextMate preferences, choose the "Advanced" tab and click "Shell Variables". Add the following variables to override the default values:

Variable Value
TM_ARDUINO_MCU atmega328p|atmega168|...
TM_ARDUINO_F_CPU 16000000|8000000|...

For example, the following settings will compile for an ATmega168 running at 8 MHz:
TextMate preferences

If one or both of the above variables are deleted or disabled, the default values will be used.

Messing with the Makefile
If you need to change something in the Makefile (e.g. the path to the Arduino tools) go right ahead and do it.
The Makefile is located in the bundle. The bundle is located in ~/Library/Application Support/TextMate/Bundles. Option-click and choose "Show Package Contents" and then open the "Support" folder and edit the Makefile to your heart's content.

5 comments on "TextMate Bundle for Arduino 0017"
Jens Willy Johannsen says:

Sometimes, you will get an error about "undefined reference to `__cxa_pure_virtual'".
To fix this, simple add this line at the top of your .pde file:

extern "C" void __cxa_pure_virtual() {}

Pyrou says:

Great work, I get working a simple blink example (after some tricks, like the $PATH modification), so It's working..

But now ! Any idea about how to make working external lib like EEPROM.h?

I tried to modify the makefile, (adding a -I [path/to/hardware/libraries/EEPROM/] in the compile command; but in this case, EEPROM.cpp isn't linked, so I get some error like ** applet/blink.cpp:29: undefined reference to `EEPROM' **

So I'm definitively not sure that adding all .cpp I need in the compile command is the right way. And including the .cpp in the sketch is really ugly.

Pls.. help :)

Sean says:

Worked nearly flawlessly with 0018. Here's the patch in case you're interested.

Jens Willy Johannsen says:

Cool. Thanks.

darkomen says:

I have the next error

make -f '/Users/darkomen/Library/Application Support/TextMate/Bundles/Arduino.tmbundle/Support/Makefile' F_CPU=16000000 MCU=atmega328p TARGET=untitled.
make -f '/Users/darkomen/Library/Application Support/TextMate/Bundles/Arduino.tmbundle/Support/Makefile' F_CPU=16000000 MCU=atmega328p TARGET=untitled. upload

can someone help me?

Leave a Reply