1// This file is generated by WOWCube SDK project wizard
2
3#include <stdint.h>
4#include <string>
5#include <vector>
6#include <string>
7#include <memory>
8
9#include "AppManager.h"
10#include "WorkingWithEmulator.h"
11
12using namespace Cubios::Gfx;
13
14//Applicaton initialization callback. Called once when CUB application starts
15void OnInit(Cubios::AppManager& appMgr)
16{
17 WorkingWithEmulator* theApp = new WorkingWithEmulator();
18
19 appMgr.SetApplication(theApp,"AAbbCCddEE");
20
21 theApp->InitializeResources();
22
23}
24
25
26WorkingWithEmulator::WorkingWithEmulator()
27{
28}
29
30WorkingWithEmulator::~WorkingWithEmulator()
31{
32}
33
34void WorkingWithEmulator::InitializeResources()
35{
36 LOG_i("\n");
37 LOG_i("*** WOWCube SDK Example \"Working with Emulator\" ***\n");
38
39 LOG_i("Cubeapp is initializing...");
40 LOG_i("Cubeapp is started on module %d",this->Module);
41
42 //Set a timer that ticks once a second
43 this->SetTimer(Timers::myTimer,1000);
44
45 LOG_i("Done.");
46}
47
48//This callback is called every "tick" of cubeapp application loop
49void WorkingWithEmulator::on_Tick(uint32_t currentTime, uint32_t deltaTime)
50{
51 this->deltaTime = deltaTime;
52
53 if(this->deltaTime>0)
54 {
55 this->fps = 1000.0/(float)this->deltaTime;
56 }
57 else
58 {
59 this->fps = 0;
60 }
61
62 LOG_i(" Seconds passed: %d (integer value)",this->seconds);
63 LOG_i(" Current FPS: %.2f (float value)",this->fps);
64
65 std::string str = "Delta time: "+std::to_string(this->deltaTime)+" ms (string value)";
66 LOG_i(" %s",str.c_str());
67
68 LOG_i(" Delta time in HEX: 0x%x (hex value)\n",this->deltaTime);
69
70}
71
72//This callback is called every time device is about to render visuals. Use it for calling your rendering code.
73void WorkingWithEmulator::on_Render(std::array<Cubios::Screen, 3>& screens)
74{
75 for(auto it = screens.begin(); it != screens.end(); ++it)
76 {
77 Cubios::GFX_setRenderTarget(it->ID());
78 Cubios::GFX_clear(Colors::black);
79
80 Cubios::GFX_drawText(120,80, TEXT_SIZE, 0, Cubios::text_align_t::TEXT_ALIGN_CENTER, Colors::limeGreen, "CHECK");
81 Cubios::GFX_drawText(120,120, TEXT_SIZE, 0, Cubios::text_align_t::TEXT_ALIGN_CENTER, Colors::limeGreen, "THE");
82 Cubios::GFX_drawText(120,160, TEXT_SIZE, 0, Cubios::text_align_t::TEXT_ALIGN_CENTER, Colors::limeGreen, "CONSOLE");
83
84 Cubios::GFX_render();
85 }
86}
87
88//The "physics" callback. Gets called recurrently with at least 33ms resolution or less depending on the load.
89void WorkingWithEmulator::on_PhysicsTick(const std::array<Cubios::Screen, 3>& screens)
90{
91}
92
93//This callback is called on programmable timer (if any)
94void WorkingWithEmulator::on_Timer(uint8_t timerID)
95{
96 switch(timerID)
97 {
98 case Timers::myTimer:
99 {
100 this->seconds++;
101 if(this->seconds>99) this->seconds = 0;
102 }
103 break;
104 default:
105 break;
106 }
107}
108
109//The cube topology change callback. Gets called when cube is twisted and its topological desctiption has been changed
110void WorkingWithEmulator::on_Twist(const Cubios::TOPOLOGY_twistInfo_t& twist)
111{
112}
113
114//The "inner network" callback. Gets called when WOWCube module receives a data packet from other module
115void WorkingWithEmulator::on_Message(uint32_t type, uint8_t* pkt, u32_t size)
116{
117}
118
119//The external data transfer callback. Gets called when WOWCube module receives a data over BLE from an external source
120void WorkingWithEmulator::on_ExternalMessage(uint8_t* pkt, u32_t size)
121{
122}
123
124//Screen pat callback
125void WorkingWithEmulator::on_Pat(uint32_t count)
126{
127}