int EtherDream::send(Frame frame) { int r = 0; //if the laser is ready for another frame if(etherdream_is_ready(dac) == 1) { buffer.resize(frame.size()); for(size_t i = 0; i < frame.size(); i++) { //convert LZR point into etherdream point Point& p = frame[i]; struct etherdream_point ep; ep.x = (int16_t) (CLAMP(p.x) * 32767); ep.y = (int16_t) (CLAMP(p.y) * 32767); ep.r = (uint16_t) (p.r * 255); ep.g = (uint16_t) (p.g * 255); ep.b = (uint16_t) (p.b * 255); ep.i = (uint16_t) (p.i * 255); buffer[i] = ep; } r = etherdream_write(dac, buffer.data(), buffer.size(), internal->pps, -1); } //else, dump the frame, an old one is still being drawn //TODO: ^ is this really a good idea? Could create a stutterring animation return r; }
//-------------------------------------------------------------- void ofxEtherdream::send() { // if(!stateIsFound() || points.empty()) return; if((points.empty()) || (device==NULL) || (device->state == ST_DISCONNECTED) || (device->state == ST_BROKEN) || (device->state == ST_SHUTDOWN)) return; //cout << "ETHERDREAM SENDING POINTS " << points.size() << endl; if(bWaitBeforeSend) etherdream_wait_for_ready(device); else if(!etherdream_is_ready(device)) return; /* dataBuffer.clear(); // fill the buffer with something important for(int i = 0; i<points.size(); i++) { ofxIlda::Point& p = points[i]; dataBuffer.append(ofToString(p.x)+ " " ); dataBuffer.append(ofToString(p.y)+ " " ); dataBuffer.append(ofToString(p.r)+ " " ); dataBuffer.append(ofToString(p.g)+ " " ); dataBuffer.append(ofToString(p.b)+ " " ); dataBuffer.append(ofToString(p.a)+ " " ); dataBuffer.append(ofToString(p.u1)+ " " ); dataBuffer.append(ofToString(p.u2)+ "\n" ); }*/ //bool fileWritten = ofBufferToFile("etherdream.txt", dataBuffer); // // DODGY HACK: casting ofxIlda::Point* to etherdream_point* int res = etherdream_write(device, (etherdream_point*)points.data(), points.size(), pps, -1); if (res != 0) { ofLogVerbose() << "ofxEtherdream::write " << res; } points.clear(); }