From 649dea5d2f81657ff965fff5b05cabf3b73bd3d1 Mon Sep 17 00:00:00 2001 From: nthnn Date: Mon, 18 Mar 2024 02:37:40 +0800 Subject: [PATCH] Tomo application class. --- include/tomo_app.h | 19 +++++++++++++++++++ src/main.cpp | 19 +++---------------- src/tomo_app.cpp | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 16 deletions(-) create mode 100644 include/tomo_app.h create mode 100644 src/tomo_app.cpp diff --git a/include/tomo_app.h b/include/tomo_app.h new file mode 100644 index 0000000..6acbbde --- /dev/null +++ b/include/tomo_app.h @@ -0,0 +1,19 @@ +#ifndef TOMO_APP_H +#define TOMO_APP_H + +#include + +typedef enum { + TOMO_BLINK, + TOMO_LEFT, + TOMO_REST, + TOMO_RIGHT +} tomo_facial_animation; + +class TomoApp final { +public: + static void setupUtilities(); + static void run(); +}; + +#endif \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index f504e52..2666ad1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,24 +1,11 @@ -#include -#include -#include -#include - +#include #include -#include void setup() { - TomoScene::initializeTouchPin(); - if(!TomoDisplay::initialize()) - while(true); - + TomoApp::setupUtilities(); TomoDisplay::renderSplashScreen(); - TomoScene::renderScene(3); - TomoScene::renderScene(1); - TomoScene::renderScene(1); - TomoScene::renderScene(2); - TomoScene::renderScene(1); } void loop() { - vTaskDelay(10); + TomoApp::run(); } \ No newline at end of file diff --git a/src/tomo_app.cpp b/src/tomo_app.cpp new file mode 100644 index 0000000..baa5c83 --- /dev/null +++ b/src/tomo_app.cpp @@ -0,0 +1,37 @@ +#include +#include +#include +#include + +#include +#include + +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( + TomoRNGEngine::get(0, 6) + ); + break; + + case TOMO_LEFT: + TomoScene::renderScene(1); + break; + + case TOMO_REST: + TomoScene::renderScene(1); + break; + + case TOMO_RIGHT: + TomoScene::renderScene(1); + break; + } +} \ No newline at end of file