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
105
106
107
108
|
//
// ofxHelios.cpp
//
//
// Created by Tim Redfern Nov 2017
//
//
#include "ofxHelios.h"
/*
draw a colourpolyline
put in mid points
draw a vector of lines
put in dwell points
*/
int ofxHelios::draw(vector <ofPolyline> &lines,ofColor colour,int intensity){
return 0;
}
int ofxHelios::draw(ofPolyline &line,ofColor colour,int intensity){
colourPolyline col=colourPolyline(line,colour);
return draw(col,intensity);
}
int ofxHelios::draw(colourPolyline &line, int intensity){
vector <colourPolyline> lines;
lines.push_back(line);
return draw(lines,intensity);
}
int ofxHelios::draw(vector <colourPolyline> &lines, int intensity){
//todo: move to a thread
//todo: add a transform
//POC
int xoffs=0x800-(ofGetWidth()/2);
int yoffs=0x800-(ofGetHeight()/2);
if (device!=OFXHELIOS_NODEVICE){
while (!dac.GetStatus(device)); //timeout for this?
//assemble data
vector <HeliosPoint> points;
ofPoint prev_point=lines[0][0];
for (auto& line:lines){
float joindist=prev_point.distance(line[0]);
if (joindist>SUBDIVIDE){
//printf("ofxHelios: creating %i join points\n",(int)joindist/SUBDIVIDE);
}
for (float j=0;j<joindist;j+=SUBDIVIDE){
float amt=j/joindist;
points.push_back(HeliosPoint(
(uint16_t)((prev_point.x*(1.0-amt))+(line[0].x*amt)+xoffs),
(uint16_t)((prev_point.y*(1.0-amt))+(line[0].y*amt)+xoffs),
0,0,0,0)); //blank point
}
int i;
for (i=0;i<line.size();i++){
points.push_back(HeliosPoint(
(uint16_t)(line[i].x+xoffs),
(uint16_t)(line[i].y+yoffs),
(uint8_t)(((line.getColourAt(i).r)*laserintensity)>>8),
(uint8_t)(((line.getColourAt(i).g)*laserintensity)>>8),
(uint8_t)(((line.getColourAt(i).b)*laserintensity)>>8),
(uint8_t)intensity
));
}
for (int k=0;k<BLANK_NUM;k++){
points.push_back(HeliosPoint(
(uint16_t)(line[line.size()-1].x+xoffs),
(uint16_t)(line[line.size()-1].y+yoffs),
0,0,0,0)); //blank point
}
}
if (HELIOS_ERROR==dac.WriteFrame(device, pps, HELIOS_FLAGS_DEFAULT, &points[0], points.size())){
printf("ofxHelios: write error (%i,%i,%i,%i)\n",device, pps, HELIOS_FLAGS_DEFAULT, (int)points.size());
return -1;
}
return points.size();
}
return -2;
}
void ofxHelios::threadedFunction(){
while(isThreadRunning()) {
}
}
|