kylemcdonald / ofxDmx

DMX Pro wrapper for openFrameworks
Other
83 stars 30 forks source link

suggested change on how to connect to device #12

Open stephanschulz opened 5 years ago

stephanschulz commented 5 years ago

Hey Kyle.

Sometimes I don't want to connected to a specific indexed device, nor know the exact name. So, I changed the code a bit to look for a partial name match.

dmx.connect("serial-EN", 512 );

maybe you think it makes sense to include it.

bool ofxDmx::connect(std::string device, unsigned int channels) {
     vector<ofSerialDeviceInfo> serialDevices = serial.getDeviceList();

     string deviceLine;
     for(int i=0; i<serialDevices.size();i++){
         deviceLine = serialDevices[i].getDeviceName().c_str();

         if(ofIsStringInString(deviceLine, device)){
             connected = serial.setup(deviceLine.c_str(), 57600);
             setChannels(channels);
             return connected;
         }
     }

}