private void btPlay_Click(object sender, EventArgs e) { wclWeDoHub Hub = GetHub(); wclWeDoPiezo Piezo = FRobot.GetPiezoDevice(Hub); if (Piezo != null) { wclWeDoPiezoNote[] Notes = new wclWeDoPiezoNote[] { wclWeDoPiezoNote.pnA, wclWeDoPiezoNote.pnAis, wclWeDoPiezoNote.pnB, wclWeDoPiezoNote.pnC, wclWeDoPiezoNote.pnCis, wclWeDoPiezoNote.pnD, wclWeDoPiezoNote.pnDis, wclWeDoPiezoNote.pnE, wclWeDoPiezoNote.pnF, wclWeDoPiezoNote.pnFis, wclWeDoPiezoNote.pnG, wclWeDoPiezoNote.pnGis }; wclWeDoPiezoNote Note = Notes[cbNote.SelectedIndex]; Int32 Res = Piezo.PlayNote(Note, (Byte)(cbOctave.SelectedIndex + 1), Convert.ToUInt16(edDuration.Text)); if (Res != wclErrors.WCL_E_SUCCESS) { MessageBox.Show("Play failed: 0x" + Res.ToString("X8")); } } }
private void FHub_OnDeviceAttached(Object Sender, wclWeDoIo Device) { if (Device.DeviceType == wclWeDoIoDeviceType.iodPiezo) { FPiezo = (wclWeDoPiezo)Device; EnablePlay(true); } }
private void FHub_OnDeviceDetached(Object Sender, wclWeDoIo Device) { if (Device.DeviceType == wclWeDoIoDeviceType.iodPiezo) { FPiezo = null; EnablePlay(false); } }
private void button1_Click(object sender, EventArgs e) { wclWeDoHub Hub = GetHub(); wclWeDoPiezo Piezo = FRobot.GetPiezoDevice(Hub); if (Piezo != null) { Int32 Res = Piezo.StopPlaying(); if (Res != wclErrors.WCL_E_SUCCESS) { MessageBox.Show("Stop failed: 0x" + Res.ToString("X8")); } } }
private void FmMain_Load(Object Sender, EventArgs e) { cbNote.SelectedIndex = 0; cbOctave.SelectedIndex = 0; FManager = new wclBluetoothManager(); FWatcher = new wclWeDoWatcher(); FWatcher.OnHubFound += FWatcher_OnHubFound; FHub = new wclWeDoHub(); FHub.OnConnected += FHub_OnConnected; FHub.OnDisconnected += FHub_OnDisconnected; FHub.OnDeviceAttached += FHub_OnDeviceAttached; FHub.OnDeviceDetached += FHub_OnDeviceDetached; FPiezo = null; }
private void UpdateTabs() { wclWeDoHub Hub = GetHub(); if (Hub == null) { RemoveTabs(); } else { AddPage(tsHubInfo); UpdateHubInfo(Hub); wclWeDoCurrentSensor Current = FRobot.GetCurrentSensor(Hub); if (Current != null && Current.Attached) { AddPage(tsCurrent); UpdateCurrent(Current); } wclWeDoVoltageSensor Voltage = FRobot.GetVoltageSensor(Hub); if (Voltage != null && Voltage.Attached) { AddPage(tsVoltage); UpdateVoltage(Voltage); } wclWeDoRgbLight Rgb = FRobot.GetRgbDevice(Hub); if (Rgb != null && Rgb.Attached) { AddPage(tsRgb); UpdateRgb(Rgb); } wclWeDoPiezo Piezo = FRobot.GetPiezoDevice(Hub); if (Piezo != null && Piezo.Attached) { AddPage(tsPiezo); UpdatePiezo(Piezo); } wclWeDoMotionSensor Motion = GetMotionSensor(0); if (Motion != null && Motion.Attached) { AddPage(tsMotion1); UpdateMotion(Motion); } Motion = GetMotionSensor(1); if (Motion != null && Motion.Attached) { AddPage(tsMotion2); UpdateMotion(Motion); } wclWeDoTiltSensor Tilt = GetTiltSensor(0); if (Tilt != null && Tilt.Attached) { AddPage(tsTilt1); UpdateTilt(Tilt); } Tilt = GetTiltSensor(1); if (Tilt != null && Tilt.Attached) { AddPage(tsTilt2); UpdateTilt(Tilt); } wclWeDoMotor Motor = GetMotor(0); if (Motor != null && Motor.Attached) { AddPage(tsMotor1); UpdateMotor(Motor); } Motor = GetMotor(1); if (Motor != null && Motor.Attached) { AddPage(tsMotor2); UpdateMotor(Motor); } } }
private void UpdatePiezo(wclWeDoPiezo Sensor) { UpdateDeviceInfo(laPiezoVersion, laPiezoDeviceType, laPiezoConnectionId, Sensor); }