Geany IDE meets arduino-cli

wwatson

Well-known member
With the advent of arduino-cli I was able to setup the Geany IDE to compile and upload sketches to a Teensy. It works with Linux and WIndows both. I have always liked using the Geany IDE mostly for it's tabbing of multiple files. Very easy to search across multiple files and I have been using it for ages. For anybody else that may be interested it's really simple to add arduino-cli to Geany.
For Linux:
Code:
mkdir ~/bin
if you don't already have it in your home directory. Make sure it's in your 'PATH' environment variable.

GET arduino-cli here:
https://arduino.github.io/arduino-cli/0.31/installation/

For Linux I used:
Code:
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh

For WIndows I just downloaded and ran "Windows.msi".

Instructions for setting up Geany to use arduino-cli are found here:
https://wiki.geany.org/howtos/configurebuildmenu

And from an older PJRC forum thread:
https://forum.pjrc.com/threads/66649-Programming-the-Teensy-4-0-with-GCC-Examples Starting at post #6.

To setup Geany open up "blink.ino". On the menu bar click "Build". At the bottom of the dialog window you will see "Set Build Commands". Click that and this dialog will appear:
Screenshot at 2023-03-08 16-26-00.png

Under "Arduino commands" in line 1. (Build) you will see the next field under "Command". Delete the complete existing entry and add:
Code:
arduino-cli compile --board-options usb=serial,speed=600,opt=o2std,keys=en-us --fqbn teensy:avr:teensy41 "%d/%f"

Then drop down to line #2 (Build Verbose) and again in the next field to the right delete the complete existing entry and add:
Code:
arduino-cli compile --verbose --board-options usb=serial,speed=600,opt=o2std,keys=en-us --fqbn teensy:avr:teensy41 "%d/%f"

Next drop down to the "Independent commands" section and optionally in line #4 first field add "Monitor" and then in the next field to the right you can add a serial monitor command. Here I added "tycommander".

Finally, drop down to the "Execute commands" section. In line #1 (Upload) clear and add:
Code:
arduino-cli upload -p /dev/ttyACM0 --fqbn teensy:avr:teensy41 "%d/%f"

Then in line #2 (Upload Verbose) clear and add:
Code:
arduino-cli upload --verbose -p /dev/ttyACM0 --fqbn teensy:avr:teensy41 "%d/%f"

To compile or upload just click "Build" on the menu bar. This will bring up a menu box to select from or you can just click on one of the build icons.

You may need to change to the serial port you are using before uploading if not using the default "/dev/ttyACM0". Also any other settings such as USB type, clock speed, FQBN and optimizations will have to be changed manually in the command line before compiling.

One other little quirk is arduino-cli uses ANSI color setting strings at the end of compilation. The Geany IDE does not handle this in it's compiler output window...

Hopefully people will find this useful. All feedback wanted:)
 
One other little quirk is arduino-cli uses ANSI color setting strings at the end of compilation. The Geany IDE does not handle this in it's compiler output window...

Add "--no-color" to the end of your build commands and the quirk disappears. From one happy Geany/arduino-cli user to another!
 
Back
Top