#include "Pokitto.h"
Pokitto::Core mygame;
int main () {
mygame.begin();
while (mygame.isRunning()) {
if (mygame.update()) {
mygame.display.setColor(1); // set text color - let's make all texts in different color!
mygame.display.println("Button test"); // println prints a row of text and goes to the next row (=enter)
mygame.display.setColor(2);
if (mygame.buttons.aBtn()) mygame.display.println("A");
mygame.display.setColor(3);
if (mygame.buttons.bBtn()) mygame.display.println("B");
mygame.display.setColor(4);
if (mygame.buttons.cBtn()) mygame.display.println("C");
mygame.display.setColor(5);
if (mygame.buttons.upBtn()) mygame.display.println("Up");
mygame.display.setColor(6);
if (mygame.buttons.downBtn()) mygame.display.println("Down");
mygame.display.setColor(7);
if (mygame.buttons.leftBtn()) mygame.display.println("Left");
mygame.display.setColor(8);
if (mygame.buttons.rightBtn()) mygame.display.println("Right");
}
}
return 0; // report success - doing this at the end of main is a good habit
}
#include "Pokitto.h"
Pokitto::Core mygame;
int main () {
mygame.begin();
while (mygame.isRunning()) {
if (mygame.update()) {
mygame.display.print("Idemo do kraja");
}
if (mygame.buttons.aBtn())
{
mygame.display.print("A");
}
if (mygame.buttons.bBtn())
{
mygame.display.print("B");
}
if (mygame.buttons.cBtn())
{
mygame.display.print("C");
}
if (mygame.buttons.upBtn())
{
mygame.display.print("Up");
}
if (mygame.buttons.downBtn())
{
mygame.display.print("Down");
}
if (mygame.buttons.leftBtn())
{
mygame.display.print("Left");
}
if (mygame.buttons.rightBtn())
{
mygame.display.print("Right");
}
}
return 0; // this is "good programming manners"
}
Would be best to enable some warnings flags (e.g. -Wall or the dreaded -pedantic) to the compiler tells you thatâs wrong, including function supposed to be returning a value but not only
Some people think itâs more âidiomaticâ to not have a return 0; if no error codes are being returned at any point.
Iâm in the camp that believes adding a return 0; to main is good practice, and I certainly think itâll make things easier for beginners because they wonât be asking "how come main doesnât need to return 0;".
(To be honest, this is one of those times where I disagree with the standard - I think void main(void) ought to be allowed, precisely because of situations like this.)
There is actually a very good reason for adding the return statement.
Pokitto programs can also be compiled on Code::Blocks into Windows/Linux/Mac targets. Even though on an embedded hardware the return statement has no effect, performing a clean exit is certainly a better idea on a multitasking OS.