Notepad++ User Defined Language for Arduino

// This is an update to an earlier thread I created that had become muddled with my running commentary trying to get Arduino language support in Notepad++

After several attempts to configure a Arduino bias user defined language for Notepad++ (NPP) I managed to get something close to what I wanted (all the core and standard library keywords) but some keywords would not highlight as expected and I put this down to limitations of the otherwise excellent NPP user language lexicon. I was going to give up at that but then had the idea of adding Arduino keywords to NPP's built in C++ lexicon. This does seem to work better but at the expense of confusing the C++ language for pure C++ programming. My final solution was to download a portable version of NPP and perform my Arduino C++ additions on this copy so I have a normal C++ version to fall back on if needed.
If your interested then download and extract a portable version of NPP via here Notepad++ Portable (development text editor) | PortableApps.com
Load it up, configure it to you liking and install any plugins you use.
Open Style Configurator (Settings->Style Configurator...)
Under 'Language' select 'C++' and then select 'INSTRUCTION WORD' under 'Style'. This should show two text boxes on the right called 'Default keywords' & 'User-defined keywords'.
Copy & paste the line below that begins 'abs accept' into the 'User-defined keywords' text box.
Under 'Style' select 'TYPE WORD' and copy & paste the below line beginning 'ANALOG_MESSAGE' into the 'User-defined keywords' text box.
Under 'User ext.' type 'ino' (without the ' markers) into the box provided
Finally, click 'Save & Close' button and you should now have a portable Arduino bias C++ editor in NPP

INSTRUCTIONS

abs accept acos Adafruit_GFX Adafruit_ST7735 analogRead analogReference analogWrite answerCall asin atan atan2 attach attached attachGPRS attachInterrupt autoscroll available background begin beginPacket beginSMS beginTransmission begnWrite bit bitClear bitRead bitSet bitWrite blink blinkVersion BSSID byte callbackFunction ceil changePIN char checkPIN checkPUK checkReg circle class clear click Client close config connect connected const constrain cos createChar cursor degrees delay delayMicroseconds detach detachInterrupt digitalRead digitalWrite direction disconnect display double draw drawBitmap drawChar drawCircle drawCircleHelper drawFastHLine drawFastVLine drawLine drawPixel drawRect drawRoundRect drawTriangle EEPROM encryptionType end endPacket endSMS endTransmission endWrite Esplora Ethernet EthernetClient EthernetServer exists exp File fill fillCircle fillCircleHelper fillRect fillRoundRect fillScreen fillTriangle find findUntil Firmata float floor flush gatewayIP gatVoiceCallStatus getBand getCurrentCarrier getIMEI getPINUsed getResult getRotation getSignalStrength getSocket getvoiceCallStatus GPRS GSM GSM_SMS GSMBand GSMClient GSMModem GSMPIN GSMScanner GSMServer GSMVoiceCall hangCall height highByte home image int int16_t int32_t int64_t interrupts invertDisplay IPAddress isListening isPIN isPressed isValid Keyboard leftToRight LiquidCrystal listen loadImage localIP log long loop lowByte macAddress map max micros millis min mkdir Mouse move newColor NewSoftSerial noAutoscroll noBlink noCursor noDisplay noFill noInterrupts noStroke noTone null onReceive onRequest open overflow parseFloat parseInt parsePacket peek PImage pinMode point position press print printFirmwareVersion println printVersion private processInput prog_char prog_int16_t prog_int32_t prog_int64_t prog_int8_t prog_uchar prog_uint16_t prog_uint32_t prog_uint64_t prog_uint8_t prog_void PROGMEM protected public pulseIn quad radians random randomSeed read readAccelerometer readBlue readButton readBytes readBytesUntil readGreen readJoystickButton readJoystickSwitch readJoystickX readJoystickY readLightSensor readMicrophone readMicroseconds readNetworks readRed readSlider readTemperature ready receive rect register release releaseAll remoteIP remoteNumber remotePort remove requestFrom retrieveCallingNumber rightToLeft rmdir round RSSI scrollDisplayLeft scrollDisplayRight SD seek send sendAnalog sendDigital sendDigitalPort sendDigitalPortPair sendString sendSysex Serial Serial1 Serial2 Serial3 Server Servo setBand setBitOrder setClockDivider setCursor setDataMode setDNS setFirmwareNameAndVersion setFirmwareVersion setPINUsed setRotation setSpeed setTextColor setTextSize setTextWrap setTimeout setup shiftIn shiftOut short shutdown signed sin size speed SPI sq sqrt SSID static status step Stepper stop stringCallbackFunction stroke subnetMask switchPIN sysexCallbackFunction systemResetCallbackFunction tan text textSize textWrap TFT tone transfer triangle uint16_t uint32_t uint64_t uint8_t unsigned version voiceCall void width WiFi WiFiClient WiFiServer WiFiUDP Wire write writeBlue writeGreen writeMicroseconds writeRed writeRGB

TYPES

ANALOG_MESSAGE ANALOG_PORT BIN CALLING CH_JOYSTICK_SW CH_JOYSTICK_X CH_JOYSTICK_Y CH_LIGHT CH_MIC CH_SLIDER CH_SWITCH_1 CH_SWITCH_2 CH_SWITCH_3 CH_SWITCH_4 CH_TEMPERATURE CHANGE CONNECTING DEC DEFAULT DEGREES_C DEGREES_F DIGITAL_MESSAGE END_SYSEX ERROR EsploraTFT EXTERNAL FALLING FILE_READ FILE_WRITE GPRS_READY GSM_MODE_DCS GSM_MODE_EGSM GSM_MODE_EGSM_DCS GSM_MODE_GSM850_EGSM_DCS_PCS GSM_MODE_GSM850_PCS GSM_MODE_PCS GSM_MODE_UNDEFINED GSM_READY HALF_PI HEX HIGH IDLE IDLE_CALL INPUT INPUT_PULLUP INTERNAL INTERNAL1V1 INTERNAL2V56 JOYSTICK_BASE JOYSTICK_DOWN JOYSTICK_LEFT JOYSTICK_UP LOW LSBFIRST MAX_CHANNELS MAX_DATA_BYTES MSBFIRST OCT OUTPUT PI PRESSED PWM RECEIVINGCALL RELEASED REPORT_ANALOG REPORT_DIGITAL REPORT_VERSION RISING SERIAL_5E1 SERIAL_5E2 SERIAL_5N1 SERIAL_5N2 SERIAL_5O1 SERIAL_5O2 SERIAL_6E1 SERIAL_6E2 SERIAL_6N1 SERIAL_6N2 SERIAL_6O1 SERIAL_6O2 SERIAL_7E1 SERIAL_7E2 SERIAL_7N1 SERIAL_7N2 SERIAL_7O1 SERIAL_7O2 SERIAL_8E1 SERIAL_8E2 SERIAL_8N1 SERIAL_8N2 SERIAL_8O1 SERIAL_8O2 SET_PIN_MODE SPI_CLOCK_DIV128 SPI_CLOCK_DIV16 SPI_CLOCK_DIV2 SPI_CLOCK_DIV32 SPI_CLOCK_DIV4 SPI_CLOCK_DIV64 SPI_CLOCK_DIV8 SPI_MODE0 SPI_MODE1 SPI_MODE2 SPI_MODE3 START_SYSEX SWITCH_1 SWITCH_2 SWITCH_3 SWITCH_4 SWITCH_DOWN SWITCH_LEFT SWITCH_RIGHT SWITCH_UP SYSTEM_RESET TALKING TOTAL_ANALOG_PINS TOTAL_DIGITAL_PINS TOTAL_PORTS TRANSPARENT_CONNECTED TWO_PI X_AXIS Y_AXIS Z_AXIS

04/03/2013 Edit to update install instructions.
06/06/2013 Updated to IDE 1.0.5

Hi Riva,

Sorry for my english.

At first thanks for your contribution.

Did you try NppExec to compile sources with Arduino ?

My script to execute is :

"C:\tools\arduino\arduino-1.0.3\arduino.exe" "$(FULL_CURRENT_PATH)"

and now it works fine !

Hi FideleCastor,

I don't try and compile arduino projects from within NPP as I think you need batch scripts to do that.
What I do though is within the Arduino IDE preferences I have ticked the 'Use External Editor'.
When I want to edit & compile code I load it into the Arduino IDE and open it in NPP, write/modify my code in NPP and save it. Then clicking verify/upload in the Arduino IDE automatically reloads the modified file and compiles it.

EDIT:
What is the -run on the end of your run command for?

Thanks Riva,

Perhaps , it will be sufficient also for me to do like your compiling process !
The "-run" was given in the script example for launching tcc.exe (see the guide of using NppExec)

Nice job with this, it came in handy quite a bit!.

Just to note, your missing "String" and "word" from your instructions list.

ThievingSix:
Just to note, your missing "String" and "word" from your instructions list.

Thanks for pointing out the error ThievingSix, I have updated the instructions to include the missing words.
Glad you find it helpful, if only Arduino IDE's were as good as NPP

Thank you so much gentlemen for your hard work. I'm using npp now thanks to you guys. Keep up the good work!

This seems to work well for me as I interpreted your instructions, but I tripped on one line...

You say copy from the line below starting at "boolean byte"
And yet, there's no boolean byte in anything you wrote.

Kinnishian:
This seems to work well for me as I interpreted your instructions, but I tripped on one line...

You say copy from the line below starting at "boolean byte"
And yet, there's no boolean byte in anything you wrote.

Thanks Kinnishian for pointing this out. Now fixed.

The perils of doing updates and not re-reading the instructions :blush:

Cool :), I'm glad I wasn't just clueless. haha, I looked over that page many times.

Anyhow, thank you for this post! I tried the eclipse plugin but it was more than I needed. I also just mariaMole, but it didn't have function/bracket & comment minimizing. This was the perfect balance of lightweight addition to the arduino IDE. I fixed up a big .ino and really enjoyed the notepad presentation. Far less scrolling up and down :stuck_out_tongue:

Thank you
I was thinking of doing something like that
Nice work

CrazySail alias MadKart 8)

Hi,

To be honest, I'm messing about with the best solution, for me, with Arduino.

I am investigating your solution for notepad++, which is nice, I use notepad++ as the external editor, then compile and upload with Arduino IDE, and it works well, gives the benefits of a mature editor with the Arduion IDE.

However, the Arduino IDE upgrades and you are busy, and so now the question, how do I change your code to deal with new methods, such as.

int intMinute = inputString.substring(2,4).toInt();

All the best

Ian

ijm51000:
However, the Arduino IDE upgrades and you are busy, and so now the question, how do I change your code to deal with new methods, such as.
int intMinute = inputString.substring(2,4).toInt();

Hi Ian,
Glad you and others find the NPP definitions useful. It's true I have not added any new keywords for 1.0.4 as I'm still 1.0.3.
What part(s) of the example you supplied above are arduino keywords? All you need to do is add them to the INSTRUCTIONS list and add/replace this list as instructed above to NPP.
I will hopefully get round to upgrading to 1.0.4 and altering this list within a few weeks.

Hi Riva,

Thank you for the advice I will give it a go, the new keywords are

substring & toInt

toInt is included in 1.03 and 1.04, though not documented, or not much anyway, but it does what it says on the tin.

Also, do you know if it is possible to have NPP, when it loads an .ino file start an instance of the Arduino IDE with the same file name?

All the best

Ian

ijm51000:
Also, do you know if it is possible to have NPP, when it loads an .ino file start an instance of the Arduino IDE with the same file name?

I have not tried but it may be possible to use the Run menu to launch the arduino IDE with the same file loaded into NPP. See http://npp-community.tuxfamily.org/documentation/notepad-user-manual/commands

EDIT: Ignore below as I noticed it 1.5.2 that has command line build and not 1.0.4 :blush:
Also I noticed that 1.0.4 has command line build so maybe you can trigger a build from NPP instead of flipping to the IDE and pressing build.

Hi Riva,

I have been all round the net expecting it to be complicated, but you where right it's as simple as placing the following in the run command

C:\arduino-1.0.4\arduino.exe $(FULL_CURRENT_PATH)

This added to your extensions list and the SourceCookifier plugin and it is probably as much of a development environment as I need.

I also added the extra commands and they now work.

Thanks for all the help

Ian

Glad you got it working as you wanted. I noticed CodeBlocks have an Arduino Uploader that can compile & upload arduino sketches. You could maybe get this to work with NPP or switch to using Codeblocks if it meets your needs.

Hi Riva,

I have tried CodeBlocks, Eclipse and Atmel studio and a few others, they are good and all have benefits, but by the time you setup a new project it feels like you could have written a new version of windows:) I am sure if you are working full time on Atmel products these IDE's would have a big advantage and I will probably revisit CodeBlocks as it was the best fit for me.

However at the moment for me using NPP in conjunction with Arduino IDE set to external editor has a lot of benefits in a simple to use setup.

Keyword highlighting
code folding
own functions, defines, vars listed in a right hand panel which you can jump to with a double click
Run and load Arduino IDE with current file from NPP, which means with a couple of clicks you can setup board type, com port, compile & run
And quite a few more not listed.

Also Arduino 1.5 as you pointed out in a previous post, is on its way with extra features and using the method above; upgrading should not be too big a problem(he says stupidly :slight_smile: just change the directory.

The Arduino IDE is called by a lot of people for lacking this and that feature but does IMHO a very good job of what it is designed to do, hide a lot of tedious detail that would stop a lot of none technical people getting involved in the project, while at the same time letting the user get more and more involved in the more technical details if they so wish.

All the best

Ian

Yes I also tried codeblocks but for most projects I do on Arduino the NPP/IDE combination suits best. I just hope they don't go the route of processing IDE and remove the 'use external editor' option.

Hi Riva,

Got a bit worried after your last reply and downloaded 1.5.2 just to check you can still use an external editor with that version and the answer is yes, the external editor option is the same as 1.04.

Yesterday I also tried komodo edit as it is cross platform and, quickly managed to get a rough User Defined Language plugin built(cut and paste from NPP), then looked at syntax highlighting at which point it was reconfirmed for me anyway that NPP & Arduino IDE are a good middle ground.

All the best

Ian