Pages: [1] 2   Go Down
Author Topic: Notepad++ User Defined Language for Arduino  (Read 18256 times)
0 Members and 1 Guest are viewing this topic.
Norfolk UK
Offline Offline
Faraday Member
**
Karma: 69
Posts: 2549
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

// 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 http://portableapps.com/apps/development/notepadpp_portable
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
Code:
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
Code:
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

« Last Edit: January 11, 2014, 05:19:23 am by Riva » Logged


Yvelines Sud
Offline Offline
Newbie
*
Karma: 1
Posts: 45
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 !
« Last Edit: February 20, 2013, 01:26:58 pm by FideleCastor » Logged

Norfolk UK
Offline Offline
Faraday Member
**
Karma: 69
Posts: 2549
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
« Last Edit: February 15, 2013, 05:18:17 am by Riva » Logged


Yvelines Sud
Offline Offline
Newbie
*
Karma: 1
Posts: 45
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

Norfolk UK
Offline Offline
Faraday Member
**
Karma: 69
Posts: 2549
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged


Offline Offline
Full Member
***
Karma: 2
Posts: 148
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 37
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Norfolk UK
Offline Offline
Faraday Member
**
Karma: 69
Posts: 2549
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley-red
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 37
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Cool smiley, 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 smiley-razz
Logged

Montreal
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

CrazySail alias MadKart smiley-cool
Logged

Haiti
Offline Offline
Newbie
*
Karma: 0
Posts: 44
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

Norfolk UK
Offline Offline
Faraday Member
**
Karma: 69
Posts: 2549
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


Haiti
Offline Offline
Newbie
*
Karma: 0
Posts: 44
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Norfolk UK
Offline Offline
Faraday Member
**
Karma: 69
Posts: 2549
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley-red
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.
« Last Edit: April 11, 2013, 11:07:23 am by Riva » Logged


Pages: [1] 2   Go Up
Jump to: