private void SetServoAdjAngle() { UpdateInfo(); if (activeServo > 0) { byte id = (byte)activeServo; int n = (int)sliderAdjValue.Value; if (n < 0) { n += 65536; } UInt16 adjValue = (UInt16)n; if (!UBT.V2_SetAdjAngle(id, adjValue)) { UpdateInfo("Fail setting servo adjustment", UTIL.InfoType.error); return; } if ((txtAdjPreview.Text == null) || (txtAdjPreview.Text.Trim() == "")) { return; } byte angle = (byte)Convert.ToInt32(txtAdjPreview.Text, 10); UBT.V2_MoveServo(id, angle, 50); } }
private void btnAutoFixAngle_Click(object sender, RoutedEventArgs e) { int angle = 0; try { angle = int.Parse(txtFixAngle.Text.Trim()); if ((angle < 0) || (angle > 180)) { UpdateInfo("輸入角度不正確", MyUtil.UTIL.InfoType.error); return; } } catch (Exception) { UpdateInfo("輸入角度不正確", MyUtil.UTIL.InfoType.error); return; } byte id = (byte)activeServo; if (UBT.V2_SetAngle(id, (byte)angle, 0)) { UBT.V2_MoveServo(id, (byte)angle, 50); } UBT.LockServo(id, true); UpdateActiveServo(); }