Add integration instructions and example for Qt Creator

This commit is contained in:
Valeriy Koval
2015-04-15 16:42:12 +03:00
parent b26856e04d
commit 7918f912c4
12 changed files with 181 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

View File

@ -9,6 +9,7 @@ IDE Integration
ide/arduino
ide/eclipse
ide/energia
ide/qtcreator
ide/sublimetext
ide/vim
ide/visualstudio

113
docs/ide/qtcreator.rst Normal file
View File

@ -0,0 +1,113 @@
.. _ide_qtcreator:
Qt Creator
==========
The `Qt Creator <https://github.com/qtproject/qt-creator>`_ is an open source cross-platform integrated development environment. The editor includes such features as syntax highlighting for various languages, project manager, integrated version control systems, rapid code navigation tools and code autocompletion.
This software can be used with:
* all availalbe :ref:`platforms`
* all availalbe :ref:`frameworks`
Refer to the `Sublime Text Documentation <http://doc.qt.io/qtcreator/>`_
page for more detailed information.
.. contents::
Integration
-----------
Setup New Project
^^^^^^^^^^^^^^^^^
First of all, let's create new project from Qt Creator Start Page: ``New Project`` or using ``Menu: File → New File or Project``, then select project with ``Empty Qt Project`` type (``Other Project → Empty Qt Project``), fill ``Name``, ``Create in``.
.. image:: ../_static/ide-platformio-qtcreator-1.png
On the next steps select any available kit and click Finish button.
.. image:: ../_static/ide-platformio-qtcreator-2.png
Secondly, we need to configure project with PlatformIO source code builder (click on Projects label on left menu or ``Ctrl+5`` shortcut):
.. image:: ../_static/ide-platformio-qtcreator-3.png
Thirdly, we need to add directories with header files using project file. Please fill this file with the next contents:
.. code-block:: none
win32 {
HOMEDIR += $$(USERPROFILE)
}
else {
HOMEDIR += $$(PWD)
}
INCLUDEPATH += "$$HOMEDIR/.platformio/packages/framework-arduinoavr/cores/arduino"
INCLUDEPATH += "$$HOMEDIR/.platformio/packages/toolchain-atmelavr/avr/include"
win32:INCLUDEPATH ~= s,/,\\,g
.. image:: ../_static/ide-platformio-qtcreator-4.png
First program in Qt Creator
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Simple "Blink" project will consist from two files:
1. Main "C" source file named ``main.c`` must be located in the ``src`` directory.
Let's create new text file named ``main.c`` using ``Menu: New File or Project → General → Text File``:
.. image:: ../_static/ide-platformio-qtcreator-5.png
Copy the source code which is described below to file ``main.c``.
.. code-block:: c
#include "Arduino.h"
#define WLED 13 // Most Arduino boards already have an LED attached to pin 13 on the board itself
void setup()
{
pinMode(WLED, OUTPUT); // set pin as output
}
void loop()
{
digitalWrite(WLED, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(WLED, LOW); // set the LED off
delay(1000); // wait for a second
}
2. Project Configuration File named ``platformio.ini`` must be located in the project root directory.
.. image:: ../_static/ide-platformio-qtcreator-6.png
Copy the source code which is described below to it.
.. code-block:: none
#
# Project Configuration File
#
# A detailed documentation with the EXAMPLES is located here:
# http://docs.platformio.org/en/latest/projectconf.html
#
# A sign `#` at the beginning of the line indicates a comment
# Comment lines are ignored.
[env:arduino_uno]
platform = atmelavr
framework = arduino
board = uno
Conclusion
----------
Taking everything into account, we can build project with shortcut ``Ctrl+Shift+B`` or using ``Menu: Build → Build All``:
.. image:: ../_static/ide-platformio-qtcreator-7.png

View File

@ -0,0 +1,23 @@
#
# Project Configuration File
#
# A detailed documentation with the EXAMPLES is located here:
# http://docs.platformio.org/en/latest/projectconf.html
#
# A sign `#` at the beginning of the line indicates a comment
# Comment lines are ignored.
# Simple and base environment
# [env:mybaseenv]
# platform = %INSTALLED_PLATFORM_NAME_HERE%
# framework =
# board =
#
# Automatic targets - enable auto-uploading
# targets = upload
[env:arduino_uno]
platform = atmelavr
framework = arduino
board = uno

View File

@ -0,0 +1,19 @@
win32 {
HOMEDIR += $$(USERPROFILE)
}
else {
HOMEDIR += $$(PWD)
}
INCLUDEPATH += "$$HOMEDIR/.platformio/packages/framework-arduinoavr/cores/arduino"
INCLUDEPATH += "$$HOMEDIR/.platformio/packages/toolchain-atmelavr/avr/include"
win32:INCLUDEPATH ~= s,/,\\,g
# DEFINES += __AVR_ATmega328__
OTHER_FILES += \
platformio.ini
SOURCES += \
src/main.c

View File

@ -0,0 +1,25 @@
#include "Arduino.h"
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
int led = 1; // blink 'digital' pin 1 - AKA the built in red LED
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH);
delay(1000);
digitalWrite(led, LOW);
delay(1000);
}