summaryrefslogtreecommitdiff
path: root/ofxHelios/src/ofxHelios.h
blob: e55e99d1b2e92f1a7de7c5bae6944515cb97318e (plain)
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
//
//  ofxHelios.h
// 
//
//  Created by Tim Redfern Nov 2017
// 
// it would be good if ofxHelios could inherit the current transform   
//                      

#ifndef ofxHelios_h
#define ofxHelios_h
#define OFXHELIOS_VERSION 0.1
#define OFXHELIOS_NODEVICE -1
#include "ofMain.h"
#include "colourPolyline.h"

#define SUBDIVIDE 20
#define BLANK_NUM 4
#define MAX_ANGLE 15.0f

#include <HeliosDac.h>

class ofxHelios : public ofThread
{
public:
    
    ofxHelios(int _pps=20000,int _device = 0)
    {
        int numdevices=dac.OpenDevices();
        for (int i=0;i<numdevices;i++){
            ofLogNotice() << "ofxHelios v "<<OFXHELIOS_VERSION<<": found laser DAC: firmware v "<<dac.GetFirmwareVersion(i);
        }
        if (!numdevices){
            ofLogNotice() << "ofxHelios v "<<OFXHELIOS_VERSION<<": no devices found";

        }
        if (_device>=numdevices){
            ofLogNotice() << "ofxHelios v "<<OFXHELIOS_VERSION<<": could not open device "<<_device;
            device=OFXHELIOS_NODEVICE;
        }
        else {
            device=_device;
            pps=_pps;
            //dac.SetShutter(device,true);
        }
        prev_point=ofPoint(0x7ff,0x7ff);
    }
    
    ~ofxHelios()
    {
        //stopThread();
    }

    void set_pts(int n){
        pps=n;
        ofLogNotice() << "ofxHelios v "<<OFXHELIOS_VERSION<<": set point output to "<<pps;
    }
    void set_intensity(int i){
        laserintensity=i;
        ofLogNotice() << "ofxHelios v "<<OFXHELIOS_VERSION<<": set intensity to "<<laserintensity;
    }
    int get_pts(){
        return pps;
    }
    int draw(colourPolyline &line, int intensity=255);
    int draw(ofPolyline &line,ofColor colour=ofColor(255,255,255),int intensity=255);
    int draw(vector <ofPolyline> &lines,ofColor colour=ofColor(255,255,255),int intensity=255);
    int draw(vector <colourPolyline> &lines, int intensity=255);

    void threadedFunction();

    //isReady()
    
    private:

        int device;
        HeliosDac dac;
        int pps;
        int laserintensity;

        ofPoint prev_point;
        ofColor prev_colour;
    
};

#endif