#include "geometry.h"
#include "font.h"

int lcd_respage(void)
{
	unsigned int fb_base;
	int xres, yres, bpp;
	int x, y,pressure;
	int x1, y1;
	unsigned char *p0;
	unsigned short *p;
	unsigned int *p2;
	int i,j,temp1,temp2;
	
	res_eint_init();

	/* 获得LCD的参数: fb_base, xres, yres, bpp */
	get_lcd_params(&fb_base, &xres, &yres, &bpp);

	clear_screen(0x80FFFF);

	/* 画圆 */

	draw_circle(xres-60, yres-60 , 40, 0x800000);
	fb_print_string(xres-60-24, yres-60-8, "Return", 0xA0);

	fb_print_string(20, 20, "rphotoresistor dark.......", 0xA0);
	
	//测试一段时间
	for(x1= 4000;x1>0;x1--)
	{
		photoresistor_test();
		mdelay(1);
	}
	
	/*Return 圆圈变色*/

	draw_circle(xres-60, yres-60 , 40, 0x808000);

	unregister_timer("touchscreen");
	touchscreen_init();
	
	while (1)
	{
		if (ts_read(&x, &y, &pressure) == 0)
		{

			if (pressure)
			{
				do {
					ts_read_raw(&x1, &y1, &pressure); 
				} while (pressure);
			
				temp1 = x - (xres-60);
				temp2 = y - (yres-60);
				if( (temp1 * temp1 + temp2 * temp2) - 40*40 < 0 )
				{
					res_eint_uninstall();
					return 0;
				}

			}
		}
	}

	

}


