Pressing the buttons

Pressing the buttons

Nibble has 7 main clickable buttons, 1 reset button, and 1 power switch. It's quite simple - you press the button and something happens.

Only the main 7 buttons are programmable, while the remaining two always have the same function.

The buttons have tiny white text next to them so you know which is which.

On the left side of the console there are directional buttons and the menu button, while on the right side A and B buttons.

We're going to focus here on using the functions of drawing on the screen, but this time we're controlling it with a simple press of a button.

This gives us much more flexibility and dramatically improves the possibilities of a program.
Before we begin, add the "begin nibble variant" block:


This program is really simple - it changes the color of the screen and writes a simple text when a button has been pressed.

The screen color and the text are different depending on the button that has been pressed.

The system that is used on Nibble is called the callback system, meaning that the button presses are small events that trigger whenever a button press has been detected.

That way there is no checking whether the button has been pressed or not in the loop section, but rather only when a button has been pressed a button press function is called.
Remember to include the "Time" block inside these buttons to specify how much time will pass between each action.

Another thing you must never forget while using the buttons, is to include the "Scan buttons" inside the "Loop forever" block to ensure that your buttons are being scanned at all times.


Holding the buttons and multiple functions

Now we go a bit more advanced.

Besides activating the button on press and release, you can also activate it after holding it down for a certain amount of time.

Firstly, we fill the frame with white. 

Then, we look for the "When button pressed/released" blocks and drag it into the drawing section.

What will happen when a certain event is triggered, the display will change the color.

Also, don't forget to include the "Scan buttons" block at the end.

Click the Run button and check it out.



If you want to put the stock firmware back onto your device, you can click the Restore firmware button in the top right corner on CircuitBlocks.