Ejemplo n.º 1
0
 private void Connect_OnClick(object sender, RoutedEventArgs e)
 {
     if (ComPorts.SelectedValue == null)
     {
         throw new InvalidOperationException("Please select port");
     }
     _swingDispatch    = new SwingDispatch(new [] { 0, 1, 2, 3, 4, 5 }, new NoteMapper(0, new PlayingDevice()));
     _arduinoConnector = new ArduinoConnector(ComPorts.SelectedValue.ToString(), _swingDispatch);
 }
Ejemplo n.º 2
0
 public ArduinoConnector(string commPort, SwingDispatch dispatch)
 {
     _dispatch = dispatch;
     _port     = new SerialPort(commPort, 9600)
     {
         Parity    = Parity.None,
         DataBits  = 8,
         StopBits  = StopBits.One,
         Handshake = Handshake.None,
         RtsEnable = true,
         DtrEnable = true
     };
     _port.DataReceived += PortOnDataReceived;
     _port.Open();
 }