Skip to content

Instantly share code, notes, and snippets.

@joshgoebel
Created March 27, 2017 02:41
Show Gist options
  • Save joshgoebel/85a725919031c6776cfdd1e6ebf5ce38 to your computer and use it in GitHub Desktop.
Save joshgoebel/85a725919031c6776cfdd1e6ebf5ce38 to your computer and use it in GitHub Desktop.
void loop() {
ABWindow *window;
bool focused;
// pause render until it's time for the next frame
if (!(arduboy.nextFrame()))
return;
arduboy.clear();
// we set our cursor 5 pixels to the right and 10 down from the top
// (positions start at 0, 0)
// arduboy.setCursor(4, 9);
// then we print to screen what is in the Quotation marks ""
// arduboy.print(F("Hello, world!"));
app.tick();
// z-indexing
for (int8_t z=-1; z<10; z++) {
for (uint8_t w=0; w < MAX_WINDOWS; w++) {
window = &app.windows[w];
if (window->zIndex == z && window->live()) {
// we need to save the focus state because the event handler
// could change it out from under us
focused = window->focused;
// only the focused window receives access to button state
if (!focused) { app.pushButtons(); }
if (window->eventHandler != NULL) {
window->eventHandler(TICK_EVENT);
}
window->renderHandler();
// we pop after render so render does not have "secret" knowledge
// of buttons that the event handler does not have access to
if (!focused) { app.popButtons(); }
}
}
}
arduboy.setCursor(0,0);
// then we finaly we tell the arduboy to display what we just wrote to the display
arduboy.display();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment