Add Arduino Compatible IDE's To The Applications List

by Visual Micro 21. January 2019 05:06

It is possible to add an Applications.txt file containing additional IDE entries in the Visual Micro Applications list.

The default "My Visual Micro" location is "MyDocuments\Visual Micro". Please note that it is possible to override this location in "Tools>Options>Visual Micro"

An Applications.txt file can be placed in "[My Visual Micro]\Micro Platforms"

Copy the following properties into an Applications.txt located in the "[My Visual Micro]\Micro Platforms" folder.

The items in bold must be changed for each application. The TestIDE. ide prefix to EVERY key must be changed to a new value for each board.

Example: Paste all of the keys below into a new Applications.txt. The values of keys in the first section. Blank lines are ignored. # can be used to "comment" an entire line.

TestIDE.name=Test IDE 1.8
TestIDE.ide.hint=Another IDE for Visual Micro
TestIDE.ide.location.key=TestIDE
TestIDE.ide.location.ide.winreg=Test IDE Application Path
TestIDE.ide.location.sketchbook.winreg=Arduino Default Sketchbook

TestIDE.ide.location.sketchbook.preferences=sketchbook.path
TestIDE.ide.platforms.basedon=arduino16x
TestIDE.ide.exe_name=arduino
TestIDE.ide.platformswithoutpackage=false
TestIDE.ide.includes.fallback=wprogram.h
TestIDE.ide.extension=ino
TestIDE.ide.extension.fallback=pde
TestIDE.ide.versionGTEQ=160
TestIDE.ide.hosts=atmel
TestIDE.vm.debug=true
TestIDE.software=ARDUINO
TestIDE.ide.location.preferences.arduinoData={runtime.sketchbook.path}\ArduinoData
TestIDE.ide.location.preferences=%VM_APPDATA_LOCAL%\arduino15\preferences.txt
TestIDE.ide.location.preferences_fallback=%VM_APPDATA_ROAMING%\arduino15\preferences.txt
TestIDE.ide.location.contributions=%VM_APPDATA_LOCAL%\arduino15
TestIDE.ide.location.contributions_fallback=%VM_APPDATA_ROAMING%\arduino15
TestIDE.ide.contributions.boards.allow=true
TestIDE.ide.contributions.boards.ignore_unless_rewrite_found=true
TestIDE.ide.contributions.libraries.allow=true
TestIDE.ide.contributions.boards.support.urls.wiki=https://github.com/arduino/Arduino/wiki/Unofficial-list-of-3rd-party-boards-support-urls
TestIDE.ide.create_platforms_from_boardsTXT.teensy=build.core

NB: The .winreg keys represent the name of a key in the windows registry. The registry keys are created below "HKCU\Software\Visual Micro\Locations"

NB: The sketchbook.winreg can optionally be changed to provide a different sketch book folder storage key.


Arduino Custom Build Events and Hooks

by Visual Micro 20. March 2017 04:37

Arduino supports many different build events. Visual Micro supports the same events and more. If you can't find an event that meets your needs then please make a request to our forum. Build events are normally placed in the arduino platform.txt system which can be quite convoluted and difficult to test. Licensed users of Visual Micro can opt to use  local project board.txt instead of the usual Arduino locations. The advantage is easier development and testing along with events that are specific to a single project. When making changes to a local board.txt click the "Save" button pior to testing a new build.

The full Arduino build specification is listed here. Visual Micro also provides the following additionl events:-

  • Pre upload event
  • Error during upload event
  • Post upload event (only executes if no error was encountered)

Paste the following into a board.txt to see an attempt to run events. Obviously the example will produce an error because the .bat file will be missing but you will see how it works :)

# before upload event - example

recipe.hooks.deploy.preupload.pattern=cmd.exe /c "c:\hooks_test\test_pre.bat" "{build.path}"  "{build.project_name}" "{build.project_path}"

# upload failed event - example

recipe.hooks.deploy.errorupload.pattern=cmd.exe /c "c:\hooks_test\test_error.bat" "{build.path}"  "{build.project_name}" "{build.project_path}"

# upload complete event - example

recipe.hooks.deploy.postupload.pattern=cmd.exe /c "c:\hooks_test\test_post.bat" "{build.path}"  "{build.project_name}" "{build.project_path}"

Improve Intellisense Library Discovery And Build Speed

by Visual Micro 14. January 2016 23:32

Jan 2017 - Licenced users have a new Parallel Build option. The option builds all files in each folder at the same time (as usual, only when they need to be built). 

Feb 2017 - All users now benefit from intelligent caching of the library discovery mechanisim described below. The 2nd time a project is compiled will be much faster and even faster the third time. Release compilation is always 1-1.5 seconds faster than debug.

15th January 2016 Visual Micro adopted (optional/default) the Arduino 1.6.6 + gcc based library discovery system.

  • This feature does not assist with intellisense, only with compile. Please read the important note at the bottom of this page about intellisense for Arduino libraries

Overview

The new system allows library authors to reference other libraries without need to #include those libraries in the project_name.ino

An example is the Microsoft AzureIoT Arduino Library that reference the SPI, RTCZero and WiFi libraries.

This new automatic discovery of related libraries is a useful feature for new users but causes significant delay during compilation.

Experienced users can switch off the "library in library" includes discovery by unchecking the "Visual Micro>Deep Library Search" menu item.

The setting is per project. A global setting might be implement in future versions based on user feedback.

The difference in compile time between an empty AzureIot library project 1) with the new Arduino 1.6.6+ system is 7 seconds and 2) without the new system using the older Arduino rexex system.

Using the older system by unticking the "Deep Library search" menu item and then adding #includes for the required libs (to the project_name.ino) will compile in less than 1 second.

 

The following applies to versions of Visual Micro older than 1607.7

Important: Intellisense does NOT use the deep search facility. ALL libraries that are used by the .ino or .cpp code must be #included in the project_name.ino

Viual Micro uses the older regex system to determine includes for intellisense purposes. This is because it can take many seconds to scan library sources which would disrupt the Ide during code writing.

Hopefully as the next few months progress we manage to optimize and add intelligence to the "deep scan" enabling its use for intellisense.

In the meantime, if intellisense is not discovering libraries, please #include any required libraries directly into the project_name.ino code. (Then click Save or Build to force an intellisense refresh)

 

Advanced Arduino - Local Libraries and Sub Folders Structure

by Visual Micro 24. October 2015 17:17

This is intial document providing example of the different source code folder structures that can be applied to Arduino projects

The only rule concerning structure is that the master .ino source code must reside in the project folder. Both must have the same name.

Linked source code files are also support. Project referenced are not yet supported.

.ino code file names do not need to be #included in any source files

.ino files are combined into a single temp folder .cpp during compile, prototypes are automatically created for .ino code unless "auto prototypes" =False in the project properties.

If .ino files are "linked" from other projects they must not contain duplicate method names such as "setup()" and "loop()"

Source from outside of the project can not be debugged (yet)

Local libraies override all other library repositories. For example copying the EEPROM library to a local sketch libarary will ensure the local version is always compiled.

Known issue: Click build clean after moving files or folders within the solution explorer.

Three new useful things in Visual Studio

by Visual Micro 6. October 2015 06:09

Visual Studio 2015 comes with many new features and improvements in the IDE, the debugger or language compilers. Obviously, there are more than three things I like in the new IDE, but three things have caught my attention from the very beginning.

The Error Window

vs2015error1
One of the things that bothered me the most about the error window was the mixture of errors/warnings/messages from both MSBuild and IntelliSense. But I don’t usually care about the later and their presence in the error window is usually annoying me. This is now fixed and you can select to see messages from Build, IntelliSense or both.
vs2015error2
In addition to this you can apply even more filtering:

  • You can select the source of the messages: Entire Solution, Current Project, Open Documents or Current Document.
    vs2015error3
  • You can search the error list, and the search includes the text in all the output list columns (Code, Description, Project, File or Line).
    vs2015error4
  • You can individually show or hide Errors, Warnings and Message (but this feature has been available for many years).

The Find in Files Append

In Visual Studio 2015 they have implemented an append feature, were you could append your search results to one of the existing two windows.

vs2015find1

As a result the old search results are not discarded, but aggregated in a the form of a tree list in the search results window.

vs2015find2
vs2015find3

Though this is not what exactly I was expecting it provides the feature I was looking for with probably minimal changes to the Visual Studio IDE.

The Inline Create Definition (for C++)

I’m not sure how this feature is actually called, but what it does is creating a definition for a function in the source file from the declaration in the header and displays it in a boxed document inside the header document. Here is an example:

You declare a function/method in a header file. Visual Studio figures out the definition is missing.
vs2015inline1
Use the Quick Actions (CTRL + .) to create a definition of the symbol in the source file.
vs2015inline2
The definition is added to the source file that is opened as a document in a box just below the function declaration.
vs2015inline3
I find this very useful to get going with a new function. Of course for writing larger functions you’ll probably switch to the actual document tab where the source file is opened.

With these new features only Visual Studio has become much more productive for me. And there are plenty more.

How to create collapsible regions in Arduino code

by Visual Micro 8. April 2015 15:02
#pragma region lets you specify a block of code that you can expand or collapse when using the outlining feature of the Visual Studio Code Editor
#pragma region name
#pragma endregion comment

Parameters

comment(optional)

A comment that will display in the code editor.

name(optional)

The name of the region. This name will display in the code editor.

Remarks

#pragma endregion marks the end of a #pragma region block.

#region block must be terminated with #pragma endregion.

Example

// pragma_directives_region.cpp
#pragma region Region_1
void Test() {}
void Test2() {}
void Test3() {}
#pragma endregion Region_1

int main() {}



How to add Arduino source code #region blocks

by Visual Micro 27. July 2014 06:08
#pragma region RegionName
void setup()
{

  /* add setup code here */

}

void loop()
{

  /* add main program code here */

}
#pragma endregion 

tested with vs2010


How to override the Arduino build or upload events

by Visual Micro 5. February 2014 14:08

Visual Micro uses the flexible build configuration system process of the Arduino Ide and also supports the extensions of Teensy and some other hardware manufacturers.

Teensy Example #1 - Extend the upload process

The boards.txt that is installed under the teensyIde/hardware/ avr or teensy folders contains a list of boards. You can copy these entries enaming the first part of each board property. For example Teensy3.name= becomes MyTeensy3.name

Each board entry defines the uploader exe name. The uploader exe is passed a few paramaters such as com port mcu etc. as normal program args[]

So it is easy to set the upload to use a different uploader program which might first call the "real upload" and then can then run any windows program as required or show it's own form/user controls. 

Teensy Example #2 - Replace the standard process

Instead of adding a custom boards.txt entry the existing compile or upload command supplied with the Arduino Ide can be renamed and a small windows program can be used in its place. The windows program can call the renamed original first, causing compile or upload to occurr prior to performing other tasks or launching another program.

Manual Controls

It is also possible to add your own short cuts and menu items to Visual Studio that run macros or programs. You can also register external tools.

Debugger Extensions

The Visual Micro debugger is the first component in Visual Micro that supports open source extensions. You can read more about adding your own C# or VB graphical extensions in the wiki

Python Tools for Visual Studio (PTVS)

by Visual Micro 10. January 2014 08:48

Visual Studio is a useful tool for programming Arduino but now we can also code in python for the Arduino Yun

This is a great article with links to the free download of ptvs

Arduino Yun Python Tools In Visual Studio (click to zoom)

 

 

Preparing a project to use the Serial Port in either Release or Debug mode

by Visual Micro 29. August 2013 10:57

This document applies more to boards such as Maple than Arduino but is a useful reference for all

Arduino is quite tollerant but boards such as Maple will crash if we use the SerialUSB.begin() command in our code more than once. Since the debugger, whichever port is it using, issues a SerialUSB.begin() we need our user code to only issue a SerialUSB.begin() when in release mode (non-debug)

The examples below show how to conditionally add code to a project based upon the release/debug (Micro Debug=True) setting using a define called VM_DEBUG.

Another example shown below is the use of a delay when the board first starts. Normally Arduino boards do not need this delay but we found that boards such as maple only work reliably over serial with an initial delay. The debugger automatically enforces this delay so the example shows how to add the delay for normal release mode use of the serial port. The example shows a 2 second delay (2000 milis)

void setup()

{

//     pinMode(BOARD_LED_PIN, OUTPUT);

//if we are not starting in debug mode we can optionally do stuff

//maple gets very upset if both the debugger and user code issue a "begin()" request

//so for maple we let the debugger initialise the port

//for arduino it doesn't matter so much. we can use the project property called RemoteSpeed to force the debugger to use something other than 115200

#if !defined(VM_DEBUG)

//maple uses SerialUSB by default

       SerialUSB.begin();

//for arduino and hardware that requires a baud rate

       //Serial.begin(115200); 

//maple likes this delay for Serial or the first serial messages are lost

       delay(2000);           

//an example

       SerialUSB.println("Starting Maple in release mode");

//for arduino/teensy/msp430

       //Serial.println("Starting Arduino in release mode");

#endif

}

void loop()

{

// Turn the LED from off to on, or on to off   

//toggleLED();          

#if defined(VM_DEBUG)

       SerialUSB.println("Running in debug mode");

#else

       SerialUSB.println("Running in release mode");

#endif

       delay(200);

}

//The example above also demonstrates use of the Visual Micro "Debug Mode" define (VM_DEBUG)

Arduino Advanced Build Examples

by Visual Micro 2. May 2013 12:26

Note: In releases after in 1305.01 arduino 1.5 build {variables} can optionally be used

This document is draft and subject to change. Currently using diydrones apm example

##############################################################

apm_1280.name=APM Arduino Mega 1280

apm_1280.upload.protocol=arduino

apm_1280.upload.maximum_size=126976

apm_1280.upload.speed=57600

apm_1280.bootloader.low_fuses=0xFF

apm_1280.bootloader.high_fuses=0xDA

apm_1280.bootloader.extended_fuses=0xF5

apm_1280.bootloader.path=atmega

apm_1280.bootloader.file=ATmegaBOOT_168_atmega1280.hex

apm_1280.bootloader.unlock_bits=0x3F

apm_1280.bootloader.lock_bits=0x0F

apm_1280.build.mcu=atmega1280

apm_1280.build.f_cpu=16000000L

apm_1280.build.core=arduino

apm_1280.build.variant=mega

apm_1280.build.option1=-mcall-prologues

apm_1280.build.linkoption1=-mcall-prologues

##############################################################

mytest1.name=APM Arduino Mega 2560 

mytest1.upload.protocol=wiring

mytest1.upload.maximum_size=258048

mytest1.upload.speed=115200

mytest1.bootloader.low_fuses=0xFF

mytest1.bootloader.high_fuses=0xD8

mytest1.bootloader.extended_fuses=0xFD

mytest1.bootloader.path=stk500v2

mytest1.bootloader.file=stk500boot_v2_mega2560.hex

mytest1.bootloader.unlock_bits=0x3F

mytest1.bootloader.lock_bits=0x0F

mytest1.build.mcu=atmega2560

mytest1.build.f_cpu=16000000L

mytest1.build.core=arduino

mytest1.build.variant=mega

mytest1.build.option1=-mcall-prologues

mytest1.build.linkoption1=-mcall-prologues

##############################################################

apm1_1280HAL.name=Arduino Mega 1280 HAL (Apm 1)

apm1_1280HAL.upload.protocol=arduino

apm1_1280HAL.upload.maximum_size=126976

apm1_1280HAL.upload.speed=57600

apm1_1280HAL.bootloader.low_fuses=0xFF

apm1_1280HAL.bootloader.high_fuses=0xDA

apm1_1280HAL.bootloader.extended_fuses=0xF5

apm1_1280HAL.bootloader.path=atmega

apm1_1280HAL.bootloader.file=ATmegaBOOT_168_atmega1280.hex

apm1_1280HAL.bootloader.unlock_bits=0x3F

apm1_1280HAL.bootloader.lock_bits=0x0F

apm1_1280HAL.build.mcu=atmega1280

apm1_1280HAL.build.f_cpu=16000000L

apm_SITL.build.nocore=true

apm_SITL.build.noarchive=true

apm1_1280HAL.build.option1=-mcall-prologues

apm1_1280HAL.build.option2=-DCONFIG_HAL_BOARD=HAL_BOARD_APM1

apm1_1280HAL.build.option3=-DEXCLUDECORE

apm1_1280HAL.build.linkoption1=-mcall-prologues

apm1_1280HAL.build.noarchive=true

##############################################################

apm1_2560HAL.name=Arduino Mega 2560 HAL (Apm 1)

apm1_2560HAL.upload.protocol=wiring

apm1_2560HAL.upload.maximum_size=258048

apm1_2560HAL.upload.speed=115200

apm1_2560HAL.bootloader.low_fuses=0xFF

apm1_2560HAL.bootloader.high_fuses=0xD8

apm1_2560HAL.bootloader.extended_fuses=0xFD

apm1_2560HAL.bootloader.path=stk500v2

apm1_2560HAL.bootloader.file=stk500boot_v2_mega2560.hex

apm1_2560HAL.bootloader.unlock_bits=0x3F

apm1_2560HAL.bootloader.lock_bits=0x0F

apm1_2560HAL.build.mcu=atmega2560

apm1_2560HAL.build.f_cpu=16000000L

apm1_2560HAL.build.nocore=true

apm1_2560HAL.build.noarchive=true

apm1_2560HAL.build.option1=-mcall-prologues

apm1_2560HAL.build.option2=-DCONFIG_HAL_BOARD=HAL_BOARD_APM1

apm1_2560HAL.build.option3=-DEXCLUDECORE

apm1_2560HAL.build.linkoption1=-mcall-prologues

apm1_2560HAL.build.noarchive=true

##############################################################

apm2_2560HAL.name=Arduino Mega 2560 HAL (Apm 2)

apm2_2560HAL.upload.protocol=wiring

apm2_2560HAL.upload.maximum_size=258048

apm2_2560HAL.upload.speed=115200

apm2_2560HAL.bootloader.low_fuses=0xFF

apm2_2560HAL.bootloader.high_fuses=0xD8

apm2_2560HAL.bootloader.extended_fuses=0xFD

apm2_2560HAL.bootloader.path=stk500v2

apm2_2560HAL.bootloader.file=stk500boot_v2_mega2560.hex

apm2_2560HAL.bootloader.unlock_bits=0x3F

apm2_2560HAL.bootloader.lock_bits=0x0F

apm2_2560HAL.build.mcu=atmega2560

apm2_2560HAL.build.f_cpu=16000000L

apm2_2560HAL.build.nocore=true

apm2_2560HAL.build.noarchive=true

apm2_2560HAL.build.option1=-mcall-prologues

apm2_2560HAL.build.option2=-DCONFIG_HAL_BOARD=HAL_BOARD_APM2

apm2_2560HAL.build.option3=-DEXCLUDECORE

apm2_2560HAL.build.linkoption1=-mcall-prologues

apm2_2560HAL.build.noarchive=true

##############################################################

apm_SITL.name=Apm SITL

apm_SITL.upload.protocol=wiring

apm_SITL.upload.maximum_size=258048

apm_SITL.upload.speed=115200

apm_SITL.bootloader.low_fuses=0xFF

apm_SITL.bootloader.high_fuses=0xD8

apm_SITL.bootloader.extended_fuses=0xFD

apm_SITL.bootloader.path=stk500v2

apm_SITL.bootloader.file=stk500boot_v2_mega2560.hex

apm_SITL.bootloader.unlock_bits=0x3F

apm_SITL.bootloader.lock_bits=0x0F

apm_SITL.build.mcu=atmega2560

apm_SITL.build.f_cpu=

apm_SITL.build.core=

apm_SITL.build.nocore=true

apm_SITL.build.noarchive=true

apm_SITL.build.noeep=true

apm_SITL.build.nohex=true

apm_SITL.build.nosize=true

apm_SITL.build.toolset=cygwin

apm_SITL.build.architecture=

apm_SITL.build.toolchain.path=

apm_SITL.build.command.gcc=gcc-?

apm_SITL.build.command.g++=g++-?

apm_SITL.build.command.link=g++-?

apm_SITL.build.command.run="%SKETCH_BUILD_PATH%\%SKETCH%.exe"

apm_SITL.build.default.cpp.options=-g -DF_CPU=   -Wa,-adhlns="%SOURCE_BUILD_PATH%\%SOURCE_FILE%.lst" -O0 -g -Wformat -Wall -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wformat=2 -Wno-reorder -MD -MT "%SOURCE_BUILD_PATH%\%SOURCE_FILE_W_EXT%.o" -ffunction-sections -fdata-sections -fno-exceptions -fsigned-char -c -I"%SKETCH_PATH%" 

apm_SITL.build.default.c.options=-g  -DF_CPU= -Wa,-adhlns="%SOURCE_BUILD_PATH%\%SOURCE_FILE%.lst" -O0 -g -Wformat -Wall -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wformat=2 -Wno-reorder -MD -MT "%SOURCE_BUILD_PATH%\%SOURCE_FILE_W_EXT%.o" -ffunction-sections -fdata-sections -fsigned-char -c -I"%SKETCH_PATH%" 

apm_SITL.build.default.s.options=-g  -assembler-with-cpp -DF_CPU= -Wa,-adhlns="%SOURCE_BUILD_PATH%\%SOURCE_FILE%.lst" -O0 -g  -MD -MT "%SOURCE_BUILD_PATH%\%SOURCE_FILE_W_EXT%.o" -c -I"%SKETCH_PATH%" 

apm_SITL.build.option1=-DCONFIG_HAL_BOARD=HAL_BOARD_AVR_SITL

apm_SITL.build.option2=-DSKETCH="\"%SKETCH%\""

apm_SITL.build.option3=-D_GNU_SOURCE

apm_SITL.build.default.link.options=-g -D_GNU_SOURCE -O0 -g -Wformat -Wall -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wformat=2 -Wl,--gc-sections -Wl,-Map -Wl,"%SOURCE_BUILD_PATH%\%SKETCH%.map" -o "%SOURCE_BUILD_PATH%\%SKETCH%.exe"