Skip to content

App Builder

After this page you can start a project, build it and try it in the emulator.

Open the studio

The App Builder is the studio, a browser-based tool for writing, generating and testing Cyber Fidget apps. There is nothing for you to install.


What it does

  1. Write or generate a C++ app using the code editor or code generator.
  2. REBUILD, under the emulator, compiles your code and starts the app emulator, a copy of the device in your browser.
  3. Try the controls with on-screen buttons, the slider, tilt, lights and sound.
  4. SEND TO MY FIDGET (SEND on a phone) adds the built app to the selected Fidget's changes. Open My Fidget to send them over the cable. A linked Fidget can also collect changes over WiFi. Check the named Fidget in the confirmation.

Getting started

  1. Go to cyberfidget.com/create/ and press + Create an app.
  2. Choose Code from Blank Template, enter an App Name, and press Create.
  3. Edit the .cpp file on the CODE tab.
  4. Press REBUILD under the emulator. On a phone, use the TEST tab.
  5. Try your app in the emulator. Choose SEND TO MY FIDGET, then open My Fidget to send the waiting changes to the connected device.

The first-app guide walks through each step. Its browser build does not require GitHub sign-in. The separate Compile action in the status bar is not needed for these examples.


Naming your app

Your app has a name you choose and a name your code uses, and they are allowed to be different.

The studio asks what you want to call it before it writes any code. The question is part of starting an app, and generating code waits until you have answered it. That is on purpose: the name you choose is what your code gets called, so choosing it first saves you hunting down a placeholder name afterwards.

Use at least one letter or number. Anything else is fair game -- spaces, capitals, whatever reads best -- and the studio works out a sensible name for the code from it. The dialog shows the Code Name that the studio derives from your chosen name.

The name you choose is the one shown at the top of the studio, on your project card, and in the NAME box in Settings. It is also the label that appears in the menu on your Cyber Fidget.

To rename it, double-click the name at the top of the studio. Type the name you want and press Enter. Press Escape, or click away, to cancel. Renaming from the NAME box in Settings does the same thing -- the two stay in step, and so does everywhere else the name appears.

The name your code uses is shown as Code name, under Device menu details in Settings. You cannot type into it, because it is read straight out of your app's code: whatever your code calls itself is what appears there. To change it, change the name in your code and this follows.

Renaming your app does not rewrite your code. That is deliberate -- if you wrote your app by hand, a rename that quietly renamed things inside it would be editing your work without asking.


When generating does not work

A failed generate keeps your prompt. The message offers Retry to send the same request again and Copy prompt to take the text elsewhere, so you don't have to retype it.

For a problem you can fix, the message offers Set up key in My account, Check key in My account, Choose model in My account or Request credits in My account. The button opens My account in a new tab, leaving your project open in the studio. Requesting credits requires a reason.

Drafts are kept in this browser until a generate succeeds, so closing the tab or reloading does not lose a request you were still writing.

An empty reply is explained. If the model sends back no code, the studio says why when it can -- for example, the model used its whole budget thinking before it wrote anything. Try again, or pick a different model.

Choosing a model

A model is the program a provider runs to write code from your description. Choose in the App Builder card on My account; check the cost and reply limits shown for each choice. The studio's Generator settings link opens this card in a new tab.

With Use my own key selected, choose a Model in this card. The Model list starts with the recommended models; once your key's models load from the provider, more choices appear under More models from your key. Refresh model list asks the provider again. See Supported models for the providers and where to get a key.


Build, restart and send

Action What it does
REBUILD Compiles your code, then runs it in the emulator
<< RESTART Starts the built app again without compiling
SEND TO MY FIDGET Adds the built app to the selected Fidget's changes; the message names it and says how to send

Build the latest code before sending. If the app is unchanged, the message says Already on your Fidget - nothing to send. If a different Fidget is plugged in, or several linked Fidgets exist and none is selected, Which Fidget? asks you to choose. Sending from My Fidget checks the device's identity before writing; it does not send to another Fidget in its place. Account changes that the cable did not carry stay waiting for that linked Fidget's WiFi check-in.

Compilation turns code into a runnable app. The studio can build on your computer or use the build server, depending on its build settings and availability. When building on your computer is available, the first build downloads about 23 MB of build tools. It takes longer while the studio fetches what it needs; later builds on the computer can take a few seconds. If the computer cannot build, the studio uses its build server; allow more time. The emulator runs the result. Editing code does not change the running copy until you rebuild.

Keep private information out of code

Builds on your computer keep your code on your computer. If the studio uses the build server instead, that build is public. Keep personal information and secrets out of your code either way.

Builds sent to the build server have a daily limit. Builds done on your own computer do not count toward it.


Emulator features

The browser emulator gives your app:

  • Display - A 128 x 64 screen with the case covering about 8 pixels at each corner.
  • Buttons - Six on-screen buttons, or keyboard shortcuts Q/E/A/D/Z/C.
  • Slider - A draggable control with the same position ranges as the device.
  • LEDs - Four lights with red, green, blue and white channels.
  • Audio - Tones, notes and sequences; browser playback has volume and mute controls.
  • Tilt - Mouse input on desktop, or device orientation where the browser supports it.

The emulator has no microphone input. Test microphone apps on a Cyber Fidget. The Console panel shows build and run messages. Studio apps cannot use Serial.println(); show your own diagnostic values on the app's screen. For details, see Browser Emulator.


App lifecycle

To light the LEDs blue while the app runs, add this fragment into the Code from Blank Template starter. The four arguments are red, green, blue and white brightness, from 0 to 255. Keep its button setup and cleanup, including setColorsOff() in begin() and end().

// Insert inside update(), just above display.display();
setDeterminedColorsAll(0, 0, 64, 0);
Full code for this step

This full code is for code name MyApp (create it with App Name "My App"); if your app has another code name, change MyApp and myApp to yours.

In the starter, nullptr means a pointer has no object. * in a declaration marks a pointer (an address), and before a pointer reads its object. & in a type refers to an existing object; before a value it gives its address. const means the code cannot change the value through that declaration.

MyApp.cpp
#include "MyApp.h"
#include "globals.h"
#include "HAL.h"
#include "MenuManager.h"

MyApp myApp(HAL::buttonManager());
MyApp* MyApp::instance = nullptr;

MyApp::MyApp(ButtonManager& btnMgr) :
    buttonManager(btnMgr), display(HAL::displayProxy()), audio(HAL::audioManager()) { instance = this; }

// begin() runs once when your app opens from the menu.
// Set things up here: hook up the buttons and start with the lights off.
void MyApp::begin() {
    registerButtonCallbacks();
    setColorsOff();
}

// update() runs about 50 times a second while your app is open.
// Clear the screen, draw what you want, then show it.
// The case hides about 8 pixels at each screen corner, so keep text and
// important pixels out of those corners.
void MyApp::update() {
    display.clear();
    display.setTextAlignment(TEXT_ALIGN_CENTER);
    display.setFont(ArialMT_Plain_16);
    display.drawString(64, 24, "MyApp");
    setDeterminedColorsAll(0, 0, 64, 0);
    display.display();
}

// end() runs when your app closes. Let go of the buttons and turn the
// lights off (if your app plays sounds, call audio.stopTone() here too).
void MyApp::end() {
    unregisterButtonCallbacks();
    setColorsOff();
}

// The bottom-left button closes your app and goes back to the menu.
void MyApp::onButtonBackPressed(const ButtonEvent& event) {
    if (event.eventType == ButtonEvent_Released) {
        instance->end();
        MenuManager::instance().returnToMenu();
    }
}

void MyApp::registerButtonCallbacks() {
    buttonManager.registerCallback(button_BottomLeftIndex, onButtonBackPressed);
}

void MyApp::unregisterButtonCallbacks() {
    buttonManager.unregisterCallback(button_BottomLeftIndex);
}

begin() runs once on opening, update() runs about 50 times per second, and end() runs on leaving. The starter already shows the screen at the end of update() and uses the bottom-left button to return to the menu.

See How an App Works for the lifecycle and Concepts for buttons, the screen, audio, lights, the slider and motion sensing.


Generating apps with 3D models

Besides flat pixel art, the studio can generate wireframe models -- 3D shapes made of nodes and straight-line struts that spin on the display, drawn like a classic vector arcade game. See 3D Models for what a wireframe model is and how to build one by hand in the studio's 3D tab.

What to ask for: describe the shape as three-dimensional, rotating, or a wireframe, and the studio generates a model instead of flat art -- for example, "a spinning wireframe crystal" or "a 3D ship that flies across the screen." Ask for flat art (a character, an icon, a background) and you'll get a sprite instead.

Spinning or facing a direction: a generated model can turn in two ways. It can spin continuously in place, like a rotating trophy. Or its facing can follow your app's own logic -- for example, a ship that banks and turns to face the direction it's moving, the way a paper airplane leans into a turn, driven by whatever your app already tracks (steering input, velocity, and so on).

Using a model you already built in the studio: open the model in the 3D tab and choose Try it in an app -- it either starts you off with a small example app showing the model spinning, or, if your project already has app code, switches to Generate with a request already filled in to add that model to your app.


See also

  • Code generator -- The optional Generate tab: make, change or explain an app from a description
  • Free use, credits and privacy -- Code generator costs, your own key and privacy rules
  • 3D Models -- Build wireframe models in the studio's 3D tab
  • Browser Emulator -- Detailed emulator guide, controls, and troubleshooting
  • Apps -- Built-in app catalog and how to add your own
  • Concepts -- Framework reference for all hardware features