static int run_enable_sequence()
{
	/*disable the master enable */
	enable_enable(0);
	dmp_event_control();
	enable_gyro(1);
	enable_accel(1);
	if (has_compass)
		enable_compass(1);
	enable_quaternion(1);
	enable_accel_output(1);
	write_dmp_event(0);
	write_dmp_output_rate(10);
	enable_motion(0);
	/*enable the master enable */
	enable_enable(1);
	if (enable_random_delay)
		random_delay();
	else {
		printf("sleep %ds\n", enable_delay);
		sleep(enable_delay);
	}

	return 0;
}
static int run_disable_sequence() {
	enable_enable(0);

	enable_gyro(0);
	enable_accel(1);
	enable_quaternion(0);
	enable_accel_output(0);
	write_dmp_event(1);
	enable_motion(enable_motion_on);

	enable_enable(1);
	if (enable_random_delay)
		random_delay();
	else {
		printf("sleep %ds\n", disable_delay);
		sleep(disable_delay);
	}

	return 0;
}
Beispiel #3
0
static int run_dmp_off() {
	bool g, a, out;

	counter++;
	g = rand()%2;
	a = rand()%2;
	if (!g && !a)
		a = true;

	g = true;
	a = true;
//	a = false;
//	g = false;
	/*disable the master enable */
	enable_enable(0);
	if(g) {
		enable_gyro(1);
		if (rand()%2) {
			enable_gyro_output(!out);
		} else {
			enable_gyro_output(1);
		}
		enable_gyro_output(1);

	} else {
		enable_gyro(0);
		enable_gyro_output(0);
	}
	if(a) {
		enable_accel(1);
		enable_accel_output(1);
//		enable_accel_output(0);
	} else {
		enable_accel(0);
		enable_accel_output(0);
	}
	if (has_compass) {
		if(rand()%2)
			enable_compass(1);
		else
			enable_compass(0);
		enable_compass(counter%2);
		enable_compass(1);
	}
	if (has_pressure) {
		if(rand()%2)
			enable_pressure(1);
		else
			enable_pressure(0);
		enable_pressure(counter%3);
		enable_pressure(1);
	}

	write_sysfs_int_and_verify("sampling_frequency", dev_dir_name,100);
	first_flag = 1;
	/*enable the master enable */
	enable_enable(1);	
	sleep(2);

	return 0;
}	
Beispiel #4
0
static int run_enable_sequence()
{
	bool g, a, out;

	counter++;
	g = rand()%2;
	a = rand()%2;
	if (!g && !a)
		a = true;

	//g = true;
	//a = true;
	/*disable the master enable */
	enable_enable(0);
	if(g) {
		enable_gyro(1);
		if (rand()%2) {
			out = rand()%2;
			enable_quaternion(out);
			enable_gyro_output(!out);
		} else {
			enable_quaternion(1);
			enable_gyro_output(1);
		}
	//	enable_quaternion(0);
	//	enable_gyro_output(0);

	} else {
		enable_gyro(0);
		enable_gyro_output(0);
		enable_quaternion(0);
	}
	if(a) {
		enable_accel(1);
		enable_accel_output(1);
	} else {
		enable_accel(0);
		enable_accel_output(0);
	}
	if (has_compass) {
		if(rand()%2)
			enable_compass(1);
		else
			enable_compass(0);
		enable_compass(counter%2);
		//enable_compass(0);
	}
	if (has_pressure) {
		if(rand()%2)
			enable_pressure(1);
		else
			enable_pressure(0);
		enable_pressure(counter%3);
		//enable_pressure(0);
	}
	enable_step_detector(1);
	enable_step_indicator(1);
	//enable_step_detector(0);
	//enable_step_indicator(0);

	write_dmp_event(0);

	enable_motion(0);
	if (accel_engine_is_on)
		dmp_event_control(1);
	else
		dmp_event_control(0);
	first_flag = 1;
	/*enable the master enable */
	enable_enable(1);
	//write_sysfs_string_and_verify("wake_unlock", "/sys/power/", "hack");
	if (enable_random_delay)
		random_delay();
	else {
		printf("sleep %ds\n", enable_delay);
		sleep(enable_delay);
	}

	return 0;
}