Creating a simple program Nibble

Creating a simple program 

After creating a new empty PlatformIO project you're ready for the next step.


Preparation

The PlatformIO project structure consists of the following:
  • platformio.ini (Project Configuration File)
  • src directory where you should place source code (*.h, *.c, *.cpp, *.S, *.ino, etc.)
  • lib directory can be used for the project-specific (private) libraries
Now, you need to download the necessary libraries and configuration files from our GitHub repository and place them in your project directory.


Writing a simple program

We're now going to write a simple program. Here's a quick example:


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#include <Arduino.h>
#include <Nibble.h>

Display* display;
Sprite* sprite;

void setup() {
  Nibble.begin();

  display = Nibble.getDisplay();
  sprite = display->getBaseSprite();
  sprite->clear(TFT_BLACK);
  sprite->setTextColor(TFT_WHITE);
  sprite->setTextFont(2);
  sprite->setCursor(0,0);
  sprite->print("Hello World!");
  display->commit();
}
void loop() {
  delay(1000);
}


Next steps

Turn on your Nibble and plug it into your computer with a USB cable.
Click the Upload button on the bottom left part of the screen (arrow pointing to the right).

Click on the arrow pointing to the right

You have now uploaded your code on the Nibble!