Skip to content

Commit

Permalink
Tomo application class.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed Mar 17, 2024
1 parent 55a51ce commit 649dea5
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 16 deletions.
19 changes: 19 additions & 0 deletions include/tomo_app.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef TOMO_APP_H
#define TOMO_APP_H

#include <tomo_scene.h>

typedef enum {
TOMO_BLINK,
TOMO_LEFT,
TOMO_REST,
TOMO_RIGHT
} tomo_facial_animation;

class TomoApp final {
public:
static void setupUtilities();
static void run();
};

#endif
19 changes: 3 additions & 16 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
#include <scenes/tomo_blink.h>
#include <scenes/tomo_left.h>
#include <scenes/tomo_rest.h>
#include <scenes/tomo_right.h>

#include <tomo_app.h>
#include <tomo_display.h>
#include <tomo_scene.h>

void setup() {
TomoScene::initializeTouchPin();
if(!TomoDisplay::initialize())
while(true);

TomoApp::setupUtilities();
TomoDisplay::renderSplashScreen();
TomoScene::renderScene<TomoBlinkScene>(3);
TomoScene::renderScene<TomoLeftScene>(1);
TomoScene::renderScene<TomoRightScene>(1);
TomoScene::renderScene<TomoBlinkScene>(2);
TomoScene::renderScene<TomoRestScene>(1);
}

void loop() {
vTaskDelay(10);
TomoApp::run();
}
37 changes: 37 additions & 0 deletions src/tomo_app.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <scenes/tomo_blink.h>
#include <scenes/tomo_left.h>
#include <scenes/tomo_rest.h>
#include <scenes/tomo_right.h>

#include <tomo_app.h>
#include <tomo_rng_engine.h>

void TomoApp::setupUtilities() {
TomoScene::initializeTouchPin();
TomoRNGEngine::initializeEngine();

if(!TomoDisplay::initialize())
while(true);
}

void TomoApp::run() {
switch(TomoRNGEngine::get(0, 3)) {
case TOMO_BLINK:
TomoScene::renderScene<TomoBlinkScene>(
TomoRNGEngine::get(0, 6)
);
break;

case TOMO_LEFT:
TomoScene::renderScene<TomoLeftScene>(1);
break;

case TOMO_REST:
TomoScene::renderScene<TomoRestScene>(1);
break;

case TOMO_RIGHT:
TomoScene::renderScene<TomoRightScene>(1);
break;
}
}

0 comments on commit 649dea5

Please sign in to comment.