Use Sublime Text as an Arduino IDE replacement.

Using Frank_B's Compile.cmd with needed local system edits ON WINDOWS I got this working on my current sketch.
<edit> copied Compile.cmd to second sketch folder and from SublimeText3 it worked there as well, and it prompts on first use of Ctrl+B

Add this to SublimeText : C:\Users\yourNameHere\AppData\Roaming\Sublime Text 3\Packages\User\Teensy.sublime-build
{ I got this with answer found here : stackoverflow … how-to-compile-and-run-c-in-sublime-text-3 :: see '1. Create a new build system in Sublime: Tools > Build System > New Build System...'}

Using 'tools / build system / Teensy' then Ctrl+Shift+B allows selecting the desired compilation type: 1,2,3.
Once one is chosen hitting 'Ctrl+B' will rebuild with that option.
Code:
{
	"shell_cmd": ".\\Compile.cmd 1",
	 "variants":
    [
     {
      "name": "Clean",
      "shell_cmd": ".\\Compile.cmd 2",
     },
     {
      "name": "Verify",
      "shell_cmd": ".\\Compile.cmd 0",
     }
   ]


}

Edited areas for use of Compile.cmd are:
Code:
rem Edit these paths:

set arduino=T:\arduino-1.8.8
set TyTools=T:\TyComm
set libs=T:\tCode\libraries

rem *******************************
rem Set Teensy-specific variables here:
rem

set model=teensy36
rem set model=teensy35
rem set model=teensy32
rem set model=teensyLC

rem set speed=180
rem set speed=240
set speed=256

rem set opt=o2std
rem set opt=o3lto
set opt=o3purelto

rem set usb=rawhid
set usb=serial
rem set usb=audio
rem set usb=serialmidiaudio

rem set keys=de-de
set keys=en-us

Edited below to get the TEMP files INTO the temp directory rather than at ROOT:
Code:
set temp1="%temp%\\arduino_build_%sketchname%"
set temp2="%temp%\\arduino_cache_%sketchname%"

Also there was a forward slash here made to \:
Code:
"%temp1%\%sketchname%.%model%.hex"
 
Last edited:
Sounds like you have had better luck with it, than I have. I stopped using stino awhile ago, as it was causing sublimetext to crash. I think they were holding open file handles for every include file or the like in my arduino folders folder, plus maybe one for each hardware object.
 
Sounds like you have had better luck with it, than I have. I stopped using stino awhile ago, as it was causing sublimetext to crash. I think they were holding open file handles for every include file or the like in my arduino folders folder, plus maybe one for each hardware object.

STINO? Who's using Stino anymore? Post #76 is just SublimeText3 executing FrankB's Compile.cmd with Ctrl+B to run the Arduino Build process.

No use of the IDE - or Stino - just building inside ST3 with a copy of Compile.cmd in the Sketch folder beside the .INO.

Just have an INO file open in ST3 - or any file in 'that' Sketch directory (including Compile.cmd) :: With Ctrl+B, Frank's CMD file opens in that folder and compiles all the INO's in there by Arduino Rules. [Or just double click the Compile.cmd in 'File explorer' and it runs with the supplied settings.]

In a single instance of ST3 I have THREE unique INO's open, each in IDE format with Compile.CMD in that folder. With each INO tab open in turn 'Ctrl+B' compiles and uploads with TyComm. And the IDE is closed.

KurtE - try the steps with info from post #76 to set up local system links … did I miss anything?
 
How does it print the warnings/errors? In a new window, or coloured?
They are printed to stderr by the builder, and the ATOM-Plugin opens a nice window with these messages only.

2018-12-16 20_46_24-Start.png
 
Last edited:
Probably a way it should be working better - it is a robust tool I've just scanned the tip of … python based … This looks telling - build-arbitrary-options

<edit> : just manually set C++ parsing in the 'View \ Syntax' - and the output is colorized - … need to trigger recurring setting ...
 
Last edited:
Dynamic Compile.cmd creation from 'Tools Menu' selection for Windows

On Windows system I worked up a Batch file :: TSet.cmd

included here :: with Selective Subdirectory Save : MOVED TO https://github.com/Defragster/Tset

<EDIT>: Updated to ver05 - On exit choices are shown for Y to accept and N to restart :: So run the Tset.Cmd and 5 keypresses gives an (updated) Compile.cmd for use in any editor or the Command line. Sample output updated.
> Tested to build LC, 3.2, 3.5 and 3.6. You are not prevented from making bad combinations WRT to Speed , etc.
<EDIT>: Updated to ver04 - missing item in USB prompt list … T_3.2 ID was wrong

Extract those in an easy to get to place. Like C:\Foo. From the Sketch folder execute :: C:\Foo\Tset.cmd

{ You must CUSTOMIZE file: TSet.cmd1 for your system paths } And if you don't like English edit "TSet.cmd2" { rem set keys=de-de }. What it does it take your answers and sandwiches it between the two halves of the original FrankB Compile.cmd and generate that custom file in the current directory.

Press 5 keys as Prompted to select :: Teensy, Speed, Optimize, USB : and added key to accept and exit or restart if not as desired

On completion in the current directory will be :: Compile.cmd

Running that will build for selected Teensy : LC, 3.2, 3.5, 3.6, Speed { … }
No I did not try all 14 million combinations - please advise if I made a typo. KUDOS to FrankB … and Yet another 'AMAZING WORK' to PAUL and PJRC … typing out those tedious lines isn't a drop in the bucket of the exhaustive and extensive work done by PJRC!!

Updated ST3 Build to include 'Tools Set':
Code:
{
 	"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",	
	"selector": "source.c++", 	
	"shell_cmd": ".\\Compile.cmd 1",

	 "variants":
    [
     {
      "name": "Clean",
      "shell_cmd": ".\\Compile.cmd 2",
     },
     {
      "name": "Verify",
      "shell_cmd": ".\\Compile.cmd 0",
     },
     {
      "name": "Tools Set",
      "shell_cmd": "start t:\\tcode\\TSet01\\TSet.cmd",
     }
   ]
}

To use in ST3 with Desired Sketch.INO open:
  1. Ctrl+Shift+B
  2. Select : Tools Set
  3. Answer the four prompts - the file Compile.cmd is ready for use.
  4. Ctrl+Shift+B
  5. Select : Teensy
  6. Repeat Rebuild with : Ctrl+B [or F7 key ]
  7. ReRun : Ctrl+Shift+B 'Tools Set' as desired to change the build params.

This is what a session looks like: >t:\tcode\TSet\TSet.cmd
Code:
=============================================  MODEL
        1 :: LC
        2 :: 3.2/3.1
        3 :: 3.5
        4 :: 3.6

Which Teensy [1,2,3,4]?4
============================================= Speed
        1 :: 96 Mhz
        2 :: 120 Mhz
        3 :: 144 Mhz
        4 :: 168 Mhz
        5 :: 180 Mhz
        6 :: 192 Mhz
        7 :: 216 Mhz
        8 :: 240 Mhz
        9 :: 256 Mhz
        a :: 2 Mhz
        b :: 16 Mhz
        c :: 24 Mhz
        d :: 48 Mhz
        e :: 72 Mhz

What Speed [1,2,3,4,5,6,7,8,9,A,B,C,D,E]?5
============================================= OPTIMIZE
        1 :: Faster
        2 :: Faster with LTO
        3 :: Fast
        4 :: Fast with LTO
        5 :: Fastest
        6 :: Fastest + pure-code
        7 :: Fastest with LTO
        8 :: Fastest + pure-code with LTO
        9 :: Debug
        a :: Debug with LTO
        b :: Smallest Code
        c :: Smallest Code with LTO

Optimize Level [1,2,3,4,5,6,7,8,9,A,B,C]?8
============================================= USB
        1 :: serial
        2 :: keyboard
        3 :: touch
        4 :: hidtouch
        5 :: hid
        6 :: serialhid
        7 :: midi
        8 :: midi4
        9 :: midi16
        a :: serialmidi
        b :: serialmidi4
        c :: serialmidi16
        d :: audio
        e :: serialmidiaudio
        f :: serialmidi16audio
        g :: mtp
        h :: rawhid
        i :: flightsim
        j :: flightsimjoystick
        k :: everything
        l :: disable

What USB [1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L]?1
=============================================  Tools Selettions
MODEL :: teensy36
SPEED :: 180
OPTIMIZE :: o3purelto
USB :: serial
=============================================  CONFIRM
        Y :: Yes :: Accept
        N :: No :: RESTART

Accept [Y,N]?

It should work. Note file extension '.cmd' must be on the 'TSet.cmd' when executed. it is how I cheated to find the #1 and #2 files to concatenate.
 
Last edited:
@Frank (Kurt?): With a couple minor changes the user could OPTIONALLY choose to make a sketch subdirectory of %model% to store the Compile.cmd.

Then running Compile.cmd from Teensy31 or TeensyLC would build ..\ThatSketch.ino using settings unique to that Teensy. This would allow using the same sketch for any Teensy as desired - switching back and forth between saved settings.

Under SublimeText the user could open .\ThatSketch\TeensyLC\Compile.cmd and then do the Ctrl+B and it would actually use that CMD file to build the ..\ThatSketch.ino

I'm not sure if/how that would work for ATOM or other?

It would be a bit odd to edit the INO then open and switch to the Compile.CMD file 'By Teensy' - though easier than Two open Instances of the IDE or having multiple copies of the source - or doing a Clean build or setting change all the time - but I just confirmed with these two files open

T:\tCode\FORUM\DHRYSTONE_HOLD\teensy31\Compile.cmd

and

T:\tCode\FORUM\DHRYSTONE_HOLD\teensy36\Compile.cmd

I just hit BUILD in either one and TyCommander even sends them to the Correct Previously chosen Teensy - even though the SKETCH.ino name is the same! And each gets a unique TEMP folder for faster rebuilding too.

Again - this would be an optional selection - and it works correctly with minor change to your original and what I have added:
============================================= Tools Selettions
MODEL :: teensy36
SPEED :: 256
OPTIMIZE :: o3purelto
USB :: serial
============================================= CONFIRM
Y :: Yes :: Accept
N :: No :: RESTART
S :: Save to teensy36 Subdirectory

Accept [Y,N,S]?

BTW Frank: Your CMD uses this "set myfolder=%~dp0" when "set myfolder=.\" would work for you. [I noticed because it broke my effort to build in "CD .." and had to edit]
BUT That could work better for my work as noted above : "Note file extension '.cmd' must be on the 'TSet.cmd' when executed. it is how I cheated to find the #1 and #2 files to concatenate. "
 
Last edited:
Hi @defragster,

Looks like you are making some progress. I have not had a chance to play with it yet. I thought about trying yesterday, but could not get to my main computer and my portable that I was going to try it on, is a MAC, and then sort of figured the batch files might now work on it ;)

But over time and puppy bigger and I trust in my office, to not eat the power cords, or some wire jumper that fell on ground or have accident... And I am working on only a couple of projects, then this will be great. Currently I am jumping all over everywhere, including several different processors and a lot of the time, working on either Example programs or shared programs, so I need to do these without any modifications to the project for building for something other than the Arduino IDE, and I need it to work on Windows, Mac, Linux and in some cases ARM Linux...

Example: I would like to help out on some of the ROS2 work with the Turtlebot 3, and now specifically with Ros2Arduino, stuff. There is a new release of it: https://discourse.ros.org/t/ros2arduino-discussion-for-development-ros2-library-for-arduino/6498 Which I have verified that compiles for Teensy as well as Robotis OpenCR and Arduino Zero... But would like to build up an actual example with hardware that actually does something... (But this also depends on previous paragraph :lol: ). Maybe build a version of the Lidar controller code, for the newer lidar controller that uses an LC (https://www.getsurreal.com/product/xv-lidar-controller-v1-2/), I purchased the updated controller to convert it from Teensy 2 to the Teensy LC, but have not had much chance to play with it.
 
Dynamic Compile.cmd creation from 'Tools Menu' selection for Windows

It works perfectly well - for instance one copy of SublimeT open with 6 sketches you can control tab between them and each compiles and uploads to same or different Teensys.

@Frank - do you have any edits or updates to the November Compile.cmd?

Here is the New Version
with Selective Subdirectory Save : MOVED TO https://github.com/Defragster/Tset

Renamed TsetT. In the zip are the three component parts TsetT.cmd and similarly named parts 1 and 2 of the modified FrankB Compile.cmd. Also included are two examples of Compile.cmd created from within SublimeT one in the Sketch directory and the one in the teensy36 Subdirectory. The only difference is a single '.' on one line. { CD. or CD.. } { just noticed there is an accidental teensy36 subdirectory in the zip from running older version from within subdir file }

As noted for SublimeT opening the Compile.cmd in the proper folder then builds properly using the 'cd..'.
 
Last edited:
Hi Tim,
that worked :) Nice tool!

Code:
set arduino=T:\arduino-1.8.8
set TyTools=T:\TyComm
set libs=T:\tCode\libraries
obviously, libs is not always a subfolder of documents\arduino\.. learned something new :)

no, no changes.
 
Can you upload the batches to github? It's bit easier then, to stay informed about changes. You can add my batch, too.. i hope I dont have to add a "licence" for the few lines .. lol..
 
Glad it works and you like it!

Can you upload the batches to github? It's bit easier then, to stay informed about changes. You can add my batch, too.. i hope I dont have to add a "licence" for the few lines .. lol..

I can - but it is horrible to use … there is half an hour of my life I'll never get back … three simple files … made a dir in a dir twice then got it right - but never published the files because the deleted repository already exists ??? WTf … Had to drag them to the web by browser as the desktop app is just non-functional.

https://github.com/Defragster/Tset

Indeed as far as libraries … indeed it is a subdirectory of Sketchbook I found. Works well with IDE UnZip installs So all my work is in sketchbook==T:\Tcode and libraries is a subfolder there and it works perfectly. Then I can back up or move all my system with just a recursive copy of T:\TCODE
 
Thanks for the github STAR Frank! Now I know you found it. I put in forum link to your posting - I didn't include your original .CMD - except it is there in the two halves with your name still present … and I didn't pick a license - so none :) :?

<Edit>: Thanks Again Frank! Getting to not suffer the IDE and enjoy SublimeText makes me glad I paid for a license!

As far as SublimeText I just found I had installed 'package' "SublimeAStyleFormatter" so Ctrl+Alt+F does a CODE formatting to the "A" style - whatever that is, it is better than random stuff that shows up after some cut/paste/edit.

Now I just need to have it parse and highlight the Compile output :: FOUND IT here !!!!!

Update for :: C:\Users\YourNameHere\AppData\Roaming\Sublime Text 3\Packages\User\Teensy.sublime-build
Code:
{
	"shell_cmd": ".\\Compile.cmd 1",
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.c, source.c++",

	 "variants":
    [
     {
      "name": "Clean",
      "shell_cmd": ".\\Compile.cmd 2",
     },
     {
      "name": "New Sketch",
      "shell_cmd": "start T:\\Programs\\TSet\\open_new.cmd",
     },
     {
      "name": "Verify",
      "shell_cmd": ".\\Compile.cmd 0",
     },
     {
      "name": "Tools Set",
      "shell_cmd": "start T:\\Programs\\TSet\\TSet.cmd[B] $file_name[/B]",
     }
   ]
}

I removed a SemiColon and the console window is the same - but this popped up in my Source code window!!!! :) :) :) :)
< if the error is not in the current file clicking the console line with the file in error opens it to the annotated error >
Sublimet_Error.PNG

Then I wonder - what if I have MULTIPLE errors and the answer looks like this:
Sublimet_ErrorX3.PNG

This is just too much fun - simple errors that are a chore in the IDE should be easier to fix now:
Sublimet_ErrorX2.PNG

Setting up on another computer: ( from post #76 )
Tools > Build System > New Build System
Using 'tools / build system / Teensy' then Ctrl+Shift+B allows selecting the desired compilation type: 1,2,3.
 
Last edited:
I found my problem! I was having an issue where the Arduino IDE would build, but Sublime would fail with missing declarations of variables.
I have a dozen sketches in a folder called MyProject. The main sketch is called MyProject.ino and this is where most globals and libraries are included.
If I rename MyProject.ino to zzzMyProject.ino the Sublime build is successful!
I really do not know why this is but suspect the last file (alphabetically) in the folder is the first to be built?, and the other sketches depend upon definitions in that main Sketch.

Does the batch file try to compile the file with an identical name to the current folder first? (this is how my small brain thinks it should work) Or should I be managing my sketches by renaming all child sketches to a .h or .cpp or some other method?

Thanks for the brilliant work.

Darcy
 
As far as I know, the original Arduino uses the first .ino it finds in a folder and by default wants the name of the info to be the same as the folder (am I right?). The batch tries to mimic that and uses first ino file it finds. Using different inos in a folder is not supported. (can Arduino handle that somehow?)
What "first" exactly means (by Arduino) is unclear.. I don't know. Anyway, it's safe as long there is not more than one per folder.

@Defragster: wow that looks great. Maybe I should use Sublime..
 
Last edited:
Arduino appends multiple inos into a big cpp file

So it appears Arduino always has the 'Main' .ino file as the first tab, no matter which .ino you actually open. All other files in that folder are automatically opened as tabs. The compile is apparently done in tab order, so 'Main' ino is at the top, and the other ino's are appended in alphabetical order. It looks like the batch file is doing it in reverse-alphabetical order, but then again I guess this may be OS or folder-option dependent.
Anyway, now I know my main sketch just needs to start with a 'z' I am 'v' happy!
 
...
@Defragster: wow that looks great. Maybe I should use Sublime..

KurtE uses it and I decided to try it - Sublime Text may be downloaded and evaluated for free, however a license must be purchased for continued use. Licenses are per-user, rather than per-machine … $80

The thing I required was being able to search all of All installed TeensyDuino :: T:\arduino-1.8.8\hardware\teensy\avr\{ … }

It does that global 'project'/folder search - like my 1990's work editor - and also (like that editor) highlights 'definitions' and hovering lists a jump box for definitions and references.

Those the main things I've learned - mostly because they are intuitive and obvious. It has a bazillion options ...

Having your Compile.cmd with TyComm being able to 'not open IDE' is Awesome - especially since I looked up those items in Post #90! Having the 'Error Here' boxes looks nice - I always forget semi-colons :)

It seemed the "Tset.cmd' batch file I wrote with some 'Choice' commands would work - so I did that … then extended to 'model' subdirectories seeing how SublimeText ran the build command worked well. BTW the subdirectory name doesn't matter - there could be multiple unique 'teensy36_xyz' directories and being in the "teensy36_xyz\Compile.cmd" in that folder would set the choices then it just does 'CD ..' and builds from there.

Tset.cmd could be altered to provide a processor specific list of speeds - it would just take duplicating the list to unique 'goto GetSpeed#' blocks - leaving the choices the same and just removing the unsupported speeds by model. Teensy_LC has only two options and also reduced Optimize options.

@Darcy - my samples and usually are single .ino - added files are usually .cpp - didn't try one of those. If refinement is needed under SublimeText it should be doable to add a second Param to Compile.com to pass the name of the main.ino for special treatment.
 
Kurt - have you given this a try from Sublime? I tried to get the SublimeAStyleFormatter working on my Surfacebook and it is failing?

I have some local mods to add T_3.0 to the Compile.cmd creator - and I added an abort key at the end - and I show the FULL paths for the resulting file after I found I ended up making one in subdirectory of a subdirectory. I did a reduced T_LC speed list - not sure it is worth it to compound the goto spaghetti - though I found a cool way to do that.

Is there a way and interest by somebody that would find a way to do a Linux script version?
 
Hi @defragster - Not yet - Still busy with puppy, and not getting much time in my office to use my Windows machine. The portable I use is a MAC and it looks like this is Windows specific. Hopefully soon.

And to everyone Merry Christmas!
 
Hi @defragster - Not yet - Still busy with puppy, and not getting much time in my office to use my Windows machine. The portable I use is a MAC and it looks like this is Windows specific. Hopefully soon.

And to everyone Merry Christmas!

Cool - just wondering if it had gotten any more coverage and might need anything else under sublime - or there were any other cool parts I missed. Really odd that AStyleFormatter won't run the same on this Surface … not sure how I accidentally got it working sometime in the last year.

Also figured you'd have an idea if the core builder triggering Frank did would port to a Linux script.

Thanks and indeed to everyone Merry Christmas!
 
Code:
{
	"shell_cmd": ".\\Compile.cmd 1",
[B]    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.c, source.c++",
[/B]    
	 "variants":
    [
     {
      "name": "Clean",
      "shell_cmd": ".\\Compile.cmd 2",
     },
     {
      "name": "Verify",
      "shell_cmd": ".\\Compile.cmd 0",
     },
     {
      "name": "Tools Set",
      "shell_cmd": "start T:\\Programs\\TSet\\TSetT.cmd",
     }
   ]
}

Code above is from post #90.
Seemed to be happily working with quick test at work, but had problems getting my home machine working. Problem was the final line in the above code that points to TSetT.cmd. The file from GITHUB is called TSet.cmd and the typo? had me stumped for a while...

A second gotcha was that my path was C:\\Program Files (x86)\\Tset and I think the spaces or the brackets are not compatible with Sublime?

Darcy
 
For Windows users - Sublime (or other) updated the post with github link in it : Use-Sublime-Text-as-an-Arduino-IDE-replacement

Updated details in ReadMe.md on github.

@Darcy - opps on the TsetT - that was a test distinction on local machine. And opps again - just seeing this:: You can specify "c:\progra~2" for C:\\Program Files (x86)

Added a "NEW" command in Build list - noted in SublimeText.txt on github. Given [2] correct directory edits - it allows creating an IDE style NEW.INO in sketchbook [ or a subfolder ] with a name you give at prompt - in same name folder, will offer to create the Compile.CMD there and then open it ( if *.ino is opened with SublimeText ).
 
Back
Top