本文整理汇总了C++中Joystick::Update方法的典型用法代码示例。如果您正苦于以下问题:C++ Joystick::Update方法的具体用法?C++ Joystick::Update怎么用?C++ Joystick::Update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Joystick
的用法示例。
在下文中一共展示了Joystick::Update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loop
// the loop routine runs over and over again forever:
void loop() {
if(enabled)
{
S1overflow = 0.0;
S2overflow = 0.0;
Stick.Update();
driveSpeed = Stick.GetX();
rotSpeed = Stick.GetY();
S1 = driveSpeed + rotSpeed;
S2 = driveSpeed + (-rotSpeed);
if(S1 > 1) { //calculate S1 overflow
S1overflow = S1 - 1.00;
S1 = 1.00;
}
else{
if(S1 < -1.00) {
S1overflow = S1 + 1.00;
S1 = -1.00;
}
}
if(S2 > 1) { //calculate S2 overflow
S2overflow = S2 - 1.00;
S2 = 1.00;
}
else{
if(S2 < -1.00) {
S2overflow = S2 + 1.00;
S2 = -1.00;
}
}
S1 = S1 + (-S2overflow);
S2 = S2 + (-S1overflow);
if(reverseS1) {
S1 = (-S1);
}
if(reverseS2) {
S2 = (-S2);
}
talon1s = (S1 + 1.00) * 90;
talon2s = (S2 + 1.00) * 90;
//Talon1.write(talon1s);
// Talon2.write(talon2s);
}
}