Пример #1
0
static void report_abs(void)
{
	int i;
	s8 xyz[3]; 
	s16 x, y, z;

	{
		for(i=0; i<3; i++)
			mma7660_read_xyz(i, &xyz[i]);

		/* convert signed 8bits to signed 16bits */
		//x = (short)(xyz[0] << 6) >> 6;
		//y = (short)(xyz[1] << 6) >> 6;
		//z = (short)(xyz[2] << 6) >> 6;

		x = (((short)xyz[0]) << 8) >> 8;
		y = (((short)xyz[1]) << 8) >> 8;
		z = (((short)xyz[2]) << 8) >> 8;

		x=-x; //jacky
		y=-y; //end
		//z=-z;



		input_report_abs(mma7660_idev->input, ABS_X,x);
		input_report_abs(mma7660_idev->input, ABS_Y, y);
		input_report_abs(mma7660_idev->input, ABS_Z, z);
		//printk(" %d, %d, %d : 123445556676\n" , x,y,z );
		//printk(KERN_INFO "XYZ Output:,x = %d, y = %d, z = %d\n", x, y, z);	
		input_sync(mma7660_idev->input);
	}
}
Пример #2
0
ssize_t	show_axis_force(struct device *dev, struct attribute *attr, char *buf)
{
	s8 force;
	int n = to_sensor_dev_attr(attr)->index;

	mma7660_read_xyz(n, &force);
	return sprintf(buf, "%d\n", force);	
}
Пример #3
0
ssize_t show_xyz_force(struct device *dev, struct attribute *attr, char *buf)
{
	int i;
	s8 xyz[3]; 
	for(i=0; i<3; i++)
		mma7660_read_xyz(i, &xyz[i]);
	return sprintf(buf, "(%d,%d,%d)\n", xyz[0], xyz[1], xyz[2]);	
}
Пример #4
0
static ssize_t mma7660_value_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{
	int i;
	s8 xyz[3]; 
	s16 x, y, z;

	for(i=0; i<3; i++)
		mma7660_read_xyz(i, &xyz[i]);

	/* convert signed 8bits to signed 16bits */
	x = (((short)xyz[0]) << 8) >> 8;
	y = (((short)xyz[1]) << 8) >> 8;
	z = (((short)xyz[2]) << 8) >> 8;

	return sprintf(buf, "x= %d y= %d z= %d\n", x, y, z);

}
Пример #5
0
static void report_abs(void)
{
	int i;
	s8 xyz[3]; 
	s16 x, y, z;

	for(i=0; i<3; i++)
		mma7660_read_xyz(i, &xyz[i]);

	/* convert signed 8bits to signed 16bits */
	x = (((short)xyz[0]) << 8) >> 8;
	y = (((short)xyz[1]) << 8) >> 8;
	z = (((short)xyz[2]) << 8) >> 8;

	input_report_abs(mma7660_idev->input, ABS_X, x);
	input_report_abs(mma7660_idev->input, ABS_Y, y);
	input_report_abs(mma7660_idev->input, ABS_Z, z);

	input_sync(mma7660_idev->input);
}