Commit 75bd86161b1d6176f061722d36c14e83816e9175

Authored by Calvin Bulla
1 parent 00f12265
Exists in master and in 1 other branch dev

Minor Changes to Connection

app/src/inoChannel.cpp
... ... @@ -26,9 +26,7 @@ void inoChannel::startStream() {
26 26 void inoChannel::stopStream() {
27 27 }
28 28  
29   -void inoChannel::threadedFunction() {
30   - serial.setup(device, 115200);
31   - serial.flush();
  29 +void inoChannel::checkSystem() {
32 30 while(isThreadRunning() && !(serial.available() >= 4));
33 31 if(serial.available() >= 4) {
34 32 char buf[4];
... ... @@ -43,9 +41,19 @@ void inoChannel::threadedFunction() {
43 41 string status("Connected");
44 42 ofNotifyEvent(statusChange, status, this);
45 43 }
  44 +}
  45 +
  46 +void inoChannel::threadedFunction() {
  47 + serial.setup(device, 115200);
  48 + serial.flush();
  49 + checkSystem();
46 50 while(isThreadRunning()) {
  51 + // Read from Arduino (frame)
  52 + // Check commands / Send
  53 + // serial.writeBytes(buffer, length);
  54 + // serial.writeBytes(command.c_str(), command.size());
47 55 }
48   - string status("Idle");
  56 + string status("Closed");
49 57 ofNotifyEvent(statusChange, status, this);
50 58 serial.close();
51 59 }
... ...
app/src/inoControl.h
... ... @@ -16,9 +16,9 @@ private:
16 16 string filePath;
17 17 string device;
18 18 ofxGuiGroup gui;
19   - ofxGuiGroup settings;
20 19 ofxToggle connect;
21 20 ofxLabel status;
  21 + ofxGuiGroup settings;
22 22 ofxColorSlider color;
23 23 inoChannel channel;
24 24 };
... ...
app/src/ofApp.cpp
... ... @@ -24,14 +24,16 @@ void ofApp::update() {
24 24 }
25 25  
26 26 void ofApp::draw() {
27   - ofSetPolyMode(OF_POLY_WINDING_ODD);
28   - ofNoFill();
29   - ofSetLineWidth(1.5);
30   - ofBeginShape();
31   - for(int i = 0; i <= 100; i++) {
32   - ofVertex((float)i/100 * 800, (float)i/100 * 600);
33   - }
34   - ofEndShape(false);
  27 + /*
  28 + ofSetPolyMode(OF_POLY_WINDING_ODD);
  29 + ofNoFill();
  30 + ofSetLineWidth(1.5);
  31 + ofBeginShape();
  32 + for(int i = 0; i <= 100; i++) {
  33 + ofVertex((float)i/100 * 800, (float)i/100 * 600);
  34 + }
  35 + ofEndShape(false);
  36 + */
35 37 if(showGui) {
36 38 gui.draw();
37 39 }
... ... @@ -43,27 +45,22 @@ void ofApp::keyPressed(int key) {
43 45 }
44 46 }
45 47  
46   -void ofApp::keyReleased(int key) { }
47   -void ofApp::mouseMoved(int x, int y ) { }
48   -void ofApp::mouseDragged(int x, int y, int button) { }
49   -void ofApp::mousePressed(int x, int y, int button) { }
50   -void ofApp::mouseReleased(int x, int y, int button) { }
51   -void ofApp::windowResized(int w, int h) { }
52   -void ofApp::gotMessage(ofMessage msg) { }
53   -void ofApp::dragEvent(ofDragInfo dragInfo) { }
54   -
55 48 void ofApp::discoverArduinos() {
56 49 vector<string> devs = getArduinoDevices();
  50 + // Current Devices
57 51 for(auto ctrl = controls.begin(); ctrl != controls.end();) {
  52 + // Check if still connected
58 53 auto it = find(devs.begin(), devs.end(), ctrl->first);
  54 + // Not connected anymore
59 55 if(it == devs.end()) {
60 56 delete ctrl->second;
61 57 controls.erase(ctrl++);
62   - } else {
  58 + } else { // Still connected
63 59 devs.erase(it);
64 60 ++ctrl;
65 61 }
66 62 }
  63 + // New Devices
67 64 for(string dev : devs) {
68 65 inoControl *ctrl = new inoControl(dev);
69 66 controls.insert({dev, ctrl});
... ... @@ -78,3 +75,12 @@ void ofApp::rebuildGui() {
78 75 gui.add(ctrl.second->getGui());
79 76 }
80 77 }
  78 +
  79 +void ofApp::keyReleased(int key) { }
  80 +void ofApp::mouseMoved(int x, int y ) { }
  81 +void ofApp::mouseDragged(int x, int y, int button) { }
  82 +void ofApp::mousePressed(int x, int y, int button) { }
  83 +void ofApp::mouseReleased(int x, int y, int button) { }
  84 +void ofApp::windowResized(int w, int h) { }
  85 +void ofApp::gotMessage(ofMessage msg) { }
  86 +void ofApp::dragEvent(ofDragInfo dragInfo) { }
... ...