callioperoberta

Bug in if statement of roberta language programming a Calliope mini?


I am trying to program on the newly released Calliope mini computer platform (https://calliope.cc/) using one of the offered editors Roberta, a graphical interface (https://lab.open-roberta.org/).

A simple program which checks whether a key is pressed and outputs a hello world message does not operate properly. At the same time, a direct output of the message works, as well as an output and an if statement which uses an "always true" condition (1==1).

Other editors such as https://miniedit.calliope.cc/ can handle the key input without problems, so I can exclude any hardware issues.

For me it seems that Roberta contains a bug in the key handling in connection with if statements.

Has anyone observed similar behavior?

There seems to be no user forum for Roberta so far.

Screenshot and code attached. Thanks for any hints!

#define _GNU_SOURCE

#include "MicroBit.h" 
#include <array>
#include <stdlib.h>
MicroBit uBit;


int initTime = uBit.systemTime(); 


int main() 
{
    uBit.init();

    if ( uBit.buttonA.isPressed() ) {
        uBit.display.scroll(ManagedString("Hallo"));
    }
    release_fiber();
} 

Sample code in graphical IDE


Solution

  • You should put your code into an endless loop:

    int main() 
    {
        uBit.init();
    
        while ( true ) {
            if ( uBit.buttonA.isPressed() ) {
                uBit.display.scroll(ManagedString("Hallo"));
            }
            uBit.sleep(1);
        }
        release_fiber();
    }