コード例 #1
0
ファイル: controls.c プロジェクト: jordonwu/ICSim
// Checks throttle to see if we should accelerate or decelerate the vehicle
void checkAccel() {
	float rate = MAX_SPEED / (ACCEL_RATE * 100);
	// Updated every 10 ms
	if(currentTime > lastAccel + 10) {
		if(throttle < 0) {
			current_speed -= rate;
			if(current_speed < 1) current_speed = 0;
		} else if(throttle > 0) {
			current_speed += rate;
			if(current_speed > MAX_SPEED) { // Limiter
				current_speed = MAX_SPEED;
				if(gHaptic != NULL) {SDL_HapticRumblePlay( gHaptic, 0.5, 1000); printf("DEBUG HAPTIC\n"); }
			}
		}
		send_speed();
		lastAccel = currentTime;
	}
}
コード例 #2
0
ファイル: mike.cpp プロジェクト: dimitry-ishenko/phone2
void mike::clear_led()
{
    speed.speed = 0;
    send_speed();
}
コード例 #3
0
ファイル: mike.cpp プロジェクト: dimitry-ishenko/phone2
void mike::set_led(speech::led led, speech::speed speed)
{
    this->speed.speed &= ~(static_cast<unsigned>(speech::speed::mask) << static_cast<unsigned>(led));
    this->speed.speed |= static_cast<unsigned>(speed) << static_cast<unsigned>(led);
    send_speed();
}