-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathofApp.cpp
More file actions
104 lines (77 loc) · 2.55 KB
/
Copy pathofApp.cpp
File metadata and controls
104 lines (77 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include "ofApp.h"
int const dataCount = 5;
//--------------------------------------------------------------
void ofApp::setup(){
ofBackground(0, 0, 0);
data = new DataBox[dataCount];
data_Button = new ButtonBox[dataCount];
/*initialize all data boxes*/
string dataNames[5] = { "Position", "Velocity", "Acceleration", "Altitude", "Temperature" };
for (int i = 0; i < dataCount; i++)
{
data[i].set(200, 100, ofGetWidth()/2, 105*(i+1), 30, 30, 30); //load to the left side
data[i].setOpen(true);
data[i].setName(dataNames[i]);
data[i].loadFont("Exo-Light.otf", 20);
}
for (int i = 0; i < dataCount; i++)
{
data_Button[i].setBox(0, i*55, 200, 50);
data_Button[i].setOpen(true);
data_Button[i].setColor(0, 0, 255);
data_Button[i].setName(dataNames[i]);
data_Button[i].loadFont("Exo-Light.otf", 20);
}
serial.setup("COM4", 9600);
}
//--------------------------------------------------------------
void ofApp::update(){
char sbyte = serial.readByte();
int ibyte = sbyte - '0';
data[1].setData(ibyte, ibyte, ibyte);
}
//--------------------------------------------------------------
void ofApp::draw(){
for (int i = 0; i < dataCount; i++)
{
data[i].draw();
data_Button[i].drawBox();
}
}
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
}
//--------------------------------------------------------------
void ofApp::keyReleased(int key){
}
//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){
mouseX = x;
mouseY = y;
}
//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){
mouseX = x;
mouseY = y;
}
//--------------------------------------------------------------
void ofApp::mouseEntered(int x, int y){
}
//--------------------------------------------------------------
void ofApp::mouseExited(int x, int y){
}
//--------------------------------------------------------------
void ofApp::windowResized(int w, int h){
}
//--------------------------------------------------------------
void ofApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void ofApp::dragEvent(ofDragInfo dragInfo){
}