2.3 Adding a platform to Code view

aknoerig edited this page Dec 2, 2014 · 6 revisions

Since version 0.9.1b, Fritzing has another view called the Code View. This allows users to write microcontroller code inside of Fritzing and also compile and upload it from there.

In order for this to work, supported platforms must offer a command-line compilation & upload tool. This needs to be downloaded separately by the user and configured in Fritzing (under Preferences > Code View). Fritzing provides several guides to make this obvious for users.

Features

Coding support for a platform comprises the following features:

  • Syntax highlighting
  • Automatic file extension
  • Board selection
  • Code compilation & upload
  • Serial monitor

Supported platforms

Currently, code view supports the following platforms:

Adding a platform

To enable all of these features, we need to make the relevant information available through the following files. We're using Arduino here as an example:

/src/program/platformarduino.cpp|.h

Add this class for the supported platform. This is where all parameters specific to the platform are configured and the upload process is managed. Just copy and paste the Arduino or PICAXE example and adapt it to your platform.

Make sure you also include these classes in /pri/program.pri.

/src/program/programwindow.cpp

Once you have created the platform class, simply add it to the initialisation in ProgramWindow::initPlatforms()

m_platforms << new PlatformArduino() << new PlatformPicaxe();

/translations/styles/arduino.xml

This file contains the syntax description for the platform in Kate format. There are many of these available already for all kinds of languages. Try googling before you start creating a new one.