Example #1
0
File: main.c Project: awersatos/AD
void main (void)
{
    // Connect to our drivers for the TFT, touch sensor.
    tft_touch = touchscreen_open(TOUCHSCREEN_1);
    ptr = pointer_open(POINTER_1);
    display = graphics_open(GRAPHICS_1);
    canvas = graphics_get_visible_canvas(display);
    leds = led_open(DRV_LED_1);
    led_turn_all_off(leds);

    // Clear screen
    graphics_fill_canvas(canvas, BLACK);
    graphics_set_visible_canvas(display, canvas);

    // Update display and turn off LEDs
    while(!graphics_visible_canvas_is_set(display));

    // Set up and calibrate touch screen.
    touchscreen_set_callback(tft_touch, draw_mark, canvas);
    while(!touchscreen_calibrate(tft_touch, 320, 240))
    {
        set_all_leds(0xFF0000); // If Touchscreen can't calibrate RED ALERT!
    }
    led_turn_all_off(leds);

    // Put colormap on TFT
    graphics_draw_bitmap(canvas, bmp, 0, 0, 320, 240, 0);
    graphics_set_visible_canvas(display, canvas);

    // Start picking colors!
    while(1)
    {
        if (pointer_update(ptr, pointer_state))
        {
            set_all_leds(graphics_get_pixel(canvas, pointer_state->x, pointer_state->y));
        }
    }
}
Example #2
0
static int pixcir_i2c_ts_probe(struct i2c_client *client,
			  const struct i2c_device_id *id)
{
#ifdef DEBUG	
	printk("pixcir_i2c_ts_probe\n");
#endif

	struct pixcir_i2c_ts_data *tsdata;
	struct input_dev *input;
	int error;
	tsdata=kzalloc(sizeof(*tsdata),GFP_KERNEL);
	if(!tsdata){
		dev_err(&client->dev,"failed to allocate driver data!\n");
		error = -ENOMEM;
		dev_set_drvdata(&client->dev, NULL);
		return error;
	}
	m_ts = tsdata;

	dev_set_drvdata(&client->dev, tsdata);

	input = input_allocate_device();
	if(!input){
		dev_err(&client->dev,"failed to allocate input device!\n");
		error = -ENOMEM;
		input_free_device(input);
		kfree(tsdata);
	}

	set_bit(EV_SYN, input->evbit);
	set_bit(EV_KEY, input->evbit);
	set_bit(EV_ABS, input->evbit);
	set_bit(BTN_TOUCH, input->keybit);
	set_bit(BTN_2, input->keybit);
	input_set_abs_params(input, ABS_X, TOUCHSCREEN_MINX, TOUCHSCREEN_MAXX, 0, 0);
	input_set_abs_params(input, ABS_Y, TOUCHSCREEN_MINY, TOUCHSCREEN_MAXY, 0, 0);
	input_set_abs_params(input, ABS_HAT0X, TOUCHSCREEN_MINX, TOUCHSCREEN_MAXX, 0, 0);
	input_set_abs_params(input, ABS_HAT0Y, TOUCHSCREEN_MINY, TOUCHSCREEN_MAXY, 0, 0);
	input_set_abs_params(input, ABS_MT_POSITION_X, TOUCHSCREEN_MINX, TOUCHSCREEN_MAXX, 0, 0);
	input_set_abs_params(input, ABS_MT_POSITION_Y, TOUCHSCREEN_MINY, TOUCHSCREEN_MAXY, 0, 0);
	input_set_abs_params(input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
	input_set_abs_params(input, ABS_MT_WIDTH_MAJOR, 0, 25, 0, 0);

	input->name = client->name;
	input->id.bustype = BUS_I2C;
	input->dev.parent = &client->dev;

	input->open = pixcir_ts_open;
	input->close = pixcir_ts_close;

	input_set_drvdata(input, tsdata);

	tsdata->client = client;
	tsdata->input = input;

	if(input_register_device(input)){
		input_free_device(input);
 		kfree(tsdata);
	}

#ifdef CONFIG_MACH_EMEV
	emxx_ts_connect();
#endif

	tsdata->reset_wq = create_singlethread_workqueue("pixcir_reset");
	if(!tsdata->reset_wq)
		dev_err(&client->dev, "Unable to create workqueue,\
				touchscreen may not work after resume\n");

	INIT_WORK(&tsdata->reset_work, resume_reset);

	INIT_WORK(&tsdata->work.work,pixcir_ts_poscheck);
	//INIT_DELAYED_WORK(&tsdata->work, pixcir_ts_poscheck);

	tsdata->irq = client->irq;
#ifdef DEBUG
	printk("irq number is %d\n", tsdata->irq);
#endif
	if(request_irq(tsdata->irq,pixcir_ts_isr,IRQF_TRIGGER_FALLING,client->name,tsdata)){
		dev_err(&client->dev, "Unable to request touchscreen IRQ.\n");
		input_unregister_device(input);
		input=NULL;
	}

	device_init_wakeup(&client->dev, 0);

	dev_err(&tsdata->client->dev,"insmod successfully!\n");
#if 0
	//hengai 2011-03-29 Press VolumeUp+Power
	if( (gpio_get_value(GPIO_P13)==0) && (gpio_get_value(GPIO_P13)==0) ) {
		printk("touchpanel calibrate ....\n");
		touchscreen_calibrate();
	}
#endif
	return 0;
}