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 "CubeMapping.h"
11
12using namespace Cubios::Gfx;
13
14//Applicaton initialization callback. Called once when CUB application starts
15void OnInit(Cubios::AppManager& appMgr)
16{
17 CubeMapping* theApp = new CubeMapping();
18
19 appMgr.SetApplication(theApp,"AAbbCCddEE");
20
21 theApp->InitializeResources();
22
23}
24
25
26CubeMapping::CubeMapping():offsets{180, 270, 90, 270, 0, 0}
27{
28}
29
30CubeMapping::~CubeMapping()
31{
32}
33
34void CubeMapping::InitializeResources()
35{
36 LOG_i("\n");
37 LOG_i("WOWCube SDK Example \"Topology - Cubemap\" ***\n");
38
39 LOG_i("Cubeapp is initializing...");
40 LOG_i("Cubeapp is started on module %d",this->Module);
41
42 //Load images that form a cubemap
43 images[0] = Cubios::GFX_getAssetId("front1.png");
44 images[1] = Cubios::GFX_getAssetId("front2.png");
45 images[2] = Cubios::GFX_getAssetId("front3.png");
46 images[3] = Cubios::GFX_getAssetId("front4.png");
47
48 images[4] = Cubios::GFX_getAssetId("up4.png");
49 images[5] = Cubios::GFX_getAssetId("up1.png");
50 images[6] = Cubios::GFX_getAssetId("up2.png");
51 images[7] = Cubios::GFX_getAssetId("up3.png");
52
53 images[8] = Cubios::GFX_getAssetId("left2.png");
54 images[9] = Cubios::GFX_getAssetId("left3.png");
55 images[10] = Cubios::GFX_getAssetId("left4.png");
56 images[11] = Cubios::GFX_getAssetId("left1.png");
57
58 images[12] = Cubios::GFX_getAssetId("back4.png");
59 images[13] = Cubios::GFX_getAssetId("back1.png");
60 images[14] = Cubios::GFX_getAssetId("back2.png");
61 images[15] = Cubios::GFX_getAssetId("back3.png");
62
63 images[16] = Cubios::GFX_getAssetId("right3.png");
64 images[17] = Cubios::GFX_getAssetId("right4.png");
65 images[18] = Cubios::GFX_getAssetId("right1.png");
66 images[19] = Cubios::GFX_getAssetId("right2.png");
67
68 images[20] = Cubios::GFX_getAssetId("down3.png");
69 images[21] = Cubios::GFX_getAssetId("down4.png");
70 images[22] = Cubios::GFX_getAssetId("down1.png");
71 images[23] = Cubios::GFX_getAssetId("down2.png");
72
73 LOG_i("Done.");
74}
75
76
77//This callback is called every "tick" of cubeapp application loop
78void CubeMapping::on_Tick(uint32_t currentTime, uint32_t deltaTime)
79{
80}
81
82//This callback is called every time device is about to render visuals. Use it for calling your rendering code.
83void CubeMapping::on_Render(std::array<Cubios::Screen, 3>& screens)
84{
85 Cubios::TOPOLOGY_place_t place;
86
87 for(auto it = screens.begin(); it != screens.end(); ++it)
88 {
89 Cubios::GFX_setRenderTarget(it->ID());
90
91 Cubios::TOPOLOGY_getPlace(this->Module, it->ID(), Cubios::TOPOLOGY_orientation_mode_t::ORIENTATION_MODE_MENU, &place);
92
93 //draw image at the center of a screen
94 Cubios::GFX_drawImage(images[place.face * TOPOLOGY_POSITIONS_MAX + place.position], 120, 120, 0xFF, Cubios::Gfx::Colors::black,100,100,(360 + offsets[place.face] - place.position * 90) % 360, Cubios::GFX_mirror_t::MIRROR_BLANK);
95
96 Cubios::GFX_render();
97 }
98}
99
100//The "physics" callback. Gets called recurrently with at least 33ms resolution or less depending on the load.
101void CubeMapping::on_PhysicsTick(const std::array<Cubios::Screen, 3>& screens)
102{
103}
104
105//This callback is called on programmable timer (if any)
106void CubeMapping::on_Timer(uint8_t timerID)
107{
108}
109
110//The cube topology change callback. Gets called when cube is twisted and its topological desctiption has been changed
111void CubeMapping::on_Twist(const Cubios::TOPOLOGY_twistInfo_t& twist)
112{
113}
114
115//The "inner network" callback. Gets called when WOWCube module receives a data packet from other module
116void CubeMapping::on_Message(uint32_t type, uint8_t* pkt, u32_t size)
117{
118}
119
120//The external data transfer callback. Gets called when WOWCube module receives a data over BLE from an external source
121void CubeMapping::on_ExternalMessage(uint8_t* pkt, u32_t size)
122{
123}
124
125//Screen tap callback
126void CubeMapping::on_Tap(uint32_t count)
127{
128}