WOWCube Docs logo
WOWCube Docs
Mission Control
Section Shortcuts
APIExamplesSourceWOWConnectChangelog
Filters
SDK and language defaults persist in cookies.
SDK version
Navigation Tree
Collapsed by default, focused on the active path.
Made byMcKay Seamons
GitHub
  1. Home
  2. Docs
  3. Examples
  4. DeviceOrientation.cpp
Mission NodeSDK 6.3C++topologyProject Included

DeviceOrientation.cpp

Example: DeviceOrientation.cpp

Examples / SDK 6.3 / C++ / topology / Device Orientation / project / src
DeviceOrientation.cpp
CPP
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 "DeviceOrientation.h"
11
12//Applicaton initialization callback. Called once when CUB application starts
13void OnInit(Cubios::AppManager& appMgr)
14{
15 DeviceOrientation* theApp = new DeviceOrientation();
16
17 appMgr.SetApplication(theApp,"AAbbCCddEE");
18
19 theApp->InitializeResources();
20
21}
22
23
24DeviceOrientation::DeviceOrientation()
25{
26}
27
28DeviceOrientation::~DeviceOrientation()
29{
30}
31
32void DeviceOrientation::InitializeResources()
33{
34 LOG_i("\n");
35 LOG_i("WOWCube SDK Example \"Topology - Orientation\" ***\n");
36
37 LOG_i("Cubeapp is initializing...");
38 LOG_i("Cubeapp is started on module %d",this->Module);
39
40 this->first = Cubios::GFX_getAssetId("0.png");
41 this->second = Cubios::GFX_getAssetId("1.png");
42 this->third = Cubios::GFX_getAssetId("2.png");
43 this->fourth = Cubios::GFX_getAssetId("3.png");
44
45 this->iconPos.X = 120;
46 this->iconPos.Y = 120;
47
48 LOG_i("Done.");
49}
50
51//This callback is called every "tick" of cubeapp application loop
52void DeviceOrientation::on_Tick(uint32_t currentTime, uint32_t deltaTime)
53{
54}
55
56//This callback is called every time device is about to render visuals. Use it for calling your rendering code.
57void DeviceOrientation::on_Render(std::array<Cubios::Screen, 3>& screens)
58{
59 int face = Cubios::TOPOLOGY_getFace(Cubios::TOPOLOGY_orientation_t::ORIENTATION_UP);
60
61 Cubios::TOPOLOGY_faceletInfo_t facelet;
62
63 for(auto it = screens.begin(); it != screens.end(); ++it)
64 {
65 Cubios::GFX_setRenderTarget(it->ID());
66 Cubios::GFX_clear(Cubios::Gfx::Colors::black);
67
68 for (int screenPositionIndex = 0; screenPositionIndex < TOPOLOGY_POSITIONS_MAX; screenPositionIndex++)
69 {
70 Cubios::TOPOLOGY_getFacelet(face, screenPositionIndex,Cubios::TOPOLOGY_orientation_mode_t::ORIENTATION_MODE_MENU,&facelet);
71
72 if(this->Module == facelet.module && it->ID() == facelet.screen)
73 {
74 switch(screenPositionIndex)
75 {
76 case 0: Cubios::GFX_drawImage(this->first,120,120, 0xFF, Cubios::Gfx::Colors::black,100, 100, 180, Cubios::GFX_mirror_t::MIRROR_BLANK); break;
77 case 1: Cubios::GFX_drawImage(this->second,120,120, 0xFF, Cubios::Gfx::Colors::black,100, 100, 90, Cubios::GFX_mirror_t::MIRROR_BLANK); break;
78 case 2: Cubios::GFX_drawImage(this->third,120,120, 0xFF, Cubios::Gfx::Colors::black,100, 100, 0, Cubios::GFX_mirror_t::MIRROR_BLANK); break;
79 case 3: Cubios::GFX_drawImage(this->fourth,120,120, 0xFF, Cubios::Gfx::Colors::black,100, 100, 270, Cubios::GFX_mirror_t::MIRROR_BLANK); break; default:
80 break;
81
82 }
83 }
84 }
85
86 Cubios::GFX_render();
87 }
88}
89
90//The "physics" callback. Gets called recurrently with at least 33ms resolution or less depending on the load.
91void DeviceOrientation::on_PhysicsTick(const std::array<Cubios::Screen, 3>& screens)
92{
93}
94
95//This callback is called on programmable timer (if any)
96void DeviceOrientation::on_Timer(uint8_t timerID)
97{
98}
99
100//The cube topology change callback. Gets called when cube is twisted and its topological desctiption has been changed
101void DeviceOrientation::on_Twist(const Cubios::TOPOLOGY_twistInfo_t& twist)
102{
103}
104
105//The "inner network" callback. Gets called when WOWCube module receives a data packet from other module
106void DeviceOrientation::on_Message(uint32_t type, uint8_t* pkt, u32_t size)
107{
108}
109
110//The external data transfer callback. Gets called when WOWCube module receives a data over BLE from an external source
111void DeviceOrientation::on_ExternalMessage(uint8_t* pkt, u32_t size)
112{
113}
114
115//Screen pat callback
116void DeviceOrientation::on_Pat(uint32_t count)
117{
118}
Wrapped for easier reading. Turn wrap off to inspect exact line lengths.
Context Rail

Project files

DeviceOrientation.cpp
project/src/DeviceOrientation.cpp
DeviceOrientation.h
project/src/DeviceOrientation.h
wowcubeapp-build.json
project/wowcubeapp-build.json
Context Rail

Related nodes

DeviceOrientation.h
Examples / SDK 6.3 / C++ / topology / Device Orientation / project / src
Device Orientation
Examples / SDK 6.3 / C++ / topology
info.json
Examples / SDK 6.3 / C++ / topology / Device Orientation
wowcubeapp-build.json
Examples / SDK 6.3 / C++ / topology / Device Orientation / project
Previous Node
info.json
Examples / SDK 6.3 / C++ / topology / Device Orientation
Next Node
DeviceOrientation.h
Examples / SDK 6.3 / C++ / topology / Device Orientation / project / src