亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? touch.c

?? 提供了AVR單片機(jī)實(shí)現(xiàn)觸摸屏的功能演示代碼
?? C
字號(hào):
//************************************************************************
// For 4 wire resistive touch screens
// Functions for reading position of touchscreen press
// uses ADC of Mega Prozessor for calculating the position
// Klaus Meinhardt  created 12.01.2008
//************************************************************************
// Declaration of 32 buttons with start point end end point 
// Resolution of point is 2 pixel (for screen with maximal 512x512 pixel)
//************************************************************************


#include <util\delay.h>
#include <inttypes.h>
#include <avr/eeprom.h>
#include "a2d.h"
#include "global.h"
#include "touch.h"
#include "s1D13700.h"

#define TOUCH_MIN 10 // Minimum adc reasult for touch press is recognized
#define MAXBUTTON 32
#define TS_VERSION 110		// version of Settings Data

point_t touch_pos;			// the result of the x and y position of called function read_touch
point_t adc_min; 
ctouch_t touch;							// configuration data se typedef
ctouch_t dummy;

uint8_t ee_version __attribute__ ((section (".eeprom")));
ctouch_t  ee_touch __attribute__ ((section (".eeprom")));  // settingsdata from eeprom

button_t buttons[MAXBUTTON];				// Array of buttoncoordinates 
uint8_t max_button;  // number of declared buttons

int8_t read_touch_settings(void);

// initializes adc and sets parameter for turning on and off acd every adc read
// adc_off = 1 turns on ADC before and off ADC after read the touch position
int8_t touch_init(uint8_t adc_off)
{
	touch.sleep = adc_off;
/*	touch.scale_x = 387;
	touch.scale_y = 407;
	touch.offset_x = 139;
	touch.offset_y = 405; */
	a2dInit();
	if (touch.sleep) a2dOff();
	*(&ADC_PORT -1) |= (1<<TOUCH_X1) | (1 << TOUCH_X2) | (1<< TOUCH_Y1) | (1<< TOUCH_Y2);  // define all for outputs

	return(read_touch_settings());
}

// reads the touch pannels adc inputs in x and y direction
// if touchscreen is configered it calculates it screen position in touch_pos structure
int8_t read_touch(void)
{
	if (touch.sleep) a2dOn();
	int8_t result=0;
	ADC_PORT |= (1<<TOUCH_X1);		// put 5 volt an TOUCH_X1 and 0V on TOUCH_X2
	_delay_us(100);		// delay cause touchpad is like a capacitor
#ifdef AD_ON
	*(&ADC_PORT -1) &=  ~((1<< TOUCH_Y1) | (1<< TOUCH_Y2));  // inputs for measuring wires
	_delay_us(40);		// time delay for signal to settle
	touch_pos.x = a2dConvert10bit(TOUCH_Y2);  // read voltage of X direction
#else
	touch_pos.x = 512;
#endif
	ADC_PORT &= ~(1 <<TOUCH_X1);  // deactivate pullup
	*(&ADC_PORT -1) |= (1<<TOUCH_X1) | (1 << TOUCH_X2) | (1<< TOUCH_Y1) | (1<< TOUCH_Y2);  // define all for outputs
	if (touch_pos.x > touch.offset_x)
	{
		ADC_PORT |= (1<< TOUCH_Y1);		// put 5 volt an TOUCH_Y1 and 0V on TOUCH_Y2
		_delay_us(100);			// delay cause touchpad is like a capacitor
		*(&ADC_PORT -1) &= ~((1<<TOUCH_X1) | (1 << TOUCH_X2)); // put them as input port pins again
#ifdef AD_ON
		_delay_us(40);	// time delay for signal to settle
		touch_pos.y = a2dConvert10bit(TOUCH_X2);  // read voltage of Y direction
#else
		touch_pos.y=512;
#endif
		ADC_PORT &= ~(1 <<TOUCH_Y1);  // deactivate pullup
		*(&ADC_PORT -1) |= (1<<TOUCH_X1) | (1 << TOUCH_X2) | (1<< TOUCH_Y1) | (1<< TOUCH_Y2);  // define all for outputs
		if (touch_pos.y > touch.offset_y)
		{
			result =1;
			// a touch has been recognized -> calculate the display position if possible
			if ((touch.scale_x != 0) && (touch.scale_y != 0)) 
			{
				if (touch_pos.x > touch.offset_x) touch_pos.x -= touch.offset_x;		// remove adc offset for position 0
				else touch_pos.x =0;
				if (touch_pos.y > touch.offset_y) touch_pos.y -= touch.offset_y;
				else touch_pos.y=0;
				touch_pos.x = (unsigned long) touch_pos.x * touch.scale_x /1000;
				touch_pos.y = (unsigned long) touch_pos.y * touch.scale_y /1000;
			} else result = -1;  // calculation not possible
		}
	} 
	if (touch.sleep) a2dOff();
	return(result);
}

//  call function before calibrate touch screen 
void clear_settings(void)
{
	touch.scale_x= touch.scale_y=0;
	touch.offset_x=touch.offset_y=0;
}


// function to capture a touch press for calibration
void capture_point(uint8_t step)
{
	signed char res;
	do
	{
		res=read_touch();
		if (res==-1) 
		{
			for (uint8_t cnt=0;cnt<50;cnt++) _delay_ms(10);  // wait 500ms to stable the signal for accuracy
			res=read_touch();
			if (step==1)
			{
				adc_min.x= touch_pos.x;
				adc_min.y= touch_pos.y;
			}
		}
	}	while (res !=-1);
}


// calculation of Offset and Scale for calculation of givel ADC value to get the display position in pixel
// pixel_min  pointer to structure which hold the ADC values for pressed display position which is in adc_min
// pixel_max  pointer to structure which hold the ADC values for pressed display position which is in adc_max
// adc_max pointer to structure wich holds 
// adc_min
void calc_config( point_t pixel_min, point_t pixel_max)
{
	touch.scale_x = (unsigned long) (pixel_max.x - pixel_min.x) *1000/ (touch_pos.x - adc_min.x);
	touch.scale_y = (unsigned long) (pixel_max.y - pixel_min.y) *1000/ (touch_pos.y - adc_min.y);

	touch.offset_x =  adc_min.x - ((unsigned long) pixel_min.x *1000 / touch.scale_x ) ;
//	touch.offset_x += ((unsigned long) adc_max->x* touch.scale_x / 1000)- pixel_max->x;
//	touch.offset_x /= 2;

	touch.offset_y =  adc_min.y - ((unsigned long) pixel_min.y * 1000/ touch.scale_y );
//	touch.offset_y += ((unsigned long) adc_max->y* touch.scale_y / 1000) - pixel_max->y;
//	touch.offset_y /= 2;
	
}


void save_touch_settings(void)
{
	eeprom_busy_wait();
	eeprom_write_byte(&ee_version,TS_VERSION);
	eeprom_write_block(&touch, &ee_touch, sizeof(ctouch_t));

}

int8_t read_touch_settings(void)
{
	uint8_t version;
	if (eeprom_read_byte(&ee_version) == TS_VERSION) 
	{
		eeprom_read_block(&touch, &ee_touch,  sizeof(ctouch_t));
		return(1);
	} else return(-1);
}

// searches if a given pixel position in pos is defined in button array as Xpixel/2 and Ypixel/2 
// return is number of found button
// return is -1 if no button has been found
int8_t search_areas(void)
{
	uint8_t posx = touch_pos.x/2;
	uint8_t posy = touch_pos.y/2;
	
	uint8_t btn=0;
	do
	{
		if ((posx >= buttons[btn].x1) && (posx <= buttons[btn].x2) && (posy >= buttons[btn].y1) &&(posy <= buttons[btn].y2)) return(btn+1);
		btn++;
	} while (btn < max_button);
	return(-1);
}


// a button with its coordinates start to stop is added to the array
//             start	+------------------------------------+
//								|																			|
//								+------------------------------------+stop
// buttons coordinates must be given in Xpixel and Ypixel
// return is button number if possible to add
// return is -1 if no more button can be added
int8_t add_area(point_t start, point_t stop)
{
	if (max_button < MAXBUTTON)
	{
		buttons[max_button].x1 = start.x/2;
		buttons[max_button].x2 = stop.x/2;
		buttons[max_button].y1 = start.y/2;
		buttons[max_button].y2 = stop.y/2;
		return(max_button++);
	} else return(-1);
}

void clear_areas(void)
{
	max_button=0;
}

int8_t capture_area(void)
{
	int8_t res;
	do
	{
		res = read_touch();
		if (res==1)
		{
			res = search_areas();
			if (res >0) break;
		}
	} while (res <= 0);
	return(res);
}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久99精品免费观看不卡| 国产精品成人免费精品自在线观看| 国产黄色精品网站| 亚洲高清三级视频| 国内外精品视频| 一区二区三区丝袜| 国产色产综合产在线视频| 欧美三区在线观看| 91美女在线视频| 国产乱子轮精品视频| 午夜成人在线视频| 亚洲欧美激情一区二区| 国产性色一区二区| 精品免费日韩av| 欧美高清性hdvideosex| 91久久精品一区二区三区| 国产成人鲁色资源国产91色综| 美女精品自拍一二三四| 天天综合日日夜夜精品| 一区二区欧美精品| 中文字幕日本不卡| 国产精品女上位| 国产校园另类小说区| 久久亚洲私人国产精品va媚药| 91精品国产综合久久久久久久| 日本乱人伦aⅴ精品| 成人免费毛片a| 国产成人久久精品77777最新版本| 久久99精品久久久| 日本视频在线一区| 男女性色大片免费观看一区二区 | 亚洲九九爱视频| 国产精品国产三级国产普通话蜜臀 | www.在线欧美| 大白屁股一区二区视频| 国产美女精品人人做人人爽| 精品亚洲成av人在线观看| 免费久久精品视频| 久久精品国产精品亚洲精品| 青草av.久久免费一区| 欧美a级理论片| 精品中文av资源站在线观看| 久久精品国产99国产精品| 免费成人av在线| 免费观看一级欧美片| 久久精品72免费观看| 另类欧美日韩国产在线| 欧美肥妇毛茸茸| 91精品国产综合久久精品性色| 欧美猛男男办公室激情| 欧美一区二区视频在线观看2020| 91精品国产综合久久精品麻豆 | 欧美性感一类影片在线播放| 欧美日韩视频不卡| 日韩欧美精品在线视频| 欧美精品一区二区精品网| 久久精品亚洲麻豆av一区二区 | 在线观看视频一区| 欧美日韩久久久一区| 欧美一区二区视频观看视频| 2023国产精品自拍| 国产精品欧美综合在线| 亚洲一卡二卡三卡四卡无卡久久| 亚洲高清不卡在线观看| 久草中文综合在线| 不卡一区二区三区四区| 欧美三级一区二区| 精品捆绑美女sm三区| 国产精品二三区| 婷婷久久综合九色国产成人| 精品一二三四区| 色综合网色综合| 日韩视频免费直播| 中文字幕成人av| 五月婷婷久久综合| 韩国视频一区二区| 色婷婷av一区二区三区gif| 337p亚洲精品色噜噜噜| 久久精品在线免费观看| 亚洲成人三级小说| 国产91对白在线观看九色| 欧美午夜精品电影| 久久久91精品国产一区二区精品| 一区二区三区加勒比av| 国产一区二区精品久久99| 色老汉一区二区三区| www一区二区| 亚洲韩国一区二区三区| 国产精品中文欧美| 欧美日本韩国一区| 国产精品久久久99| 日本欧美一区二区三区| 99国内精品久久| 亚洲精品一区二区精华| 亚洲综合清纯丝袜自拍| 国产91精品精华液一区二区三区 | 中文av字幕一区| 日本不卡在线视频| 色av成人天堂桃色av| 久久这里只有精品视频网| 午夜精品视频一区| 色94色欧美sute亚洲线路一ni| 国产视频亚洲色图| 免费人成在线不卡| 欧美日韩久久不卡| 亚洲美女免费在线| 欧美一级欧美一级在线播放| 国产精品初高中害羞小美女文| 九色|91porny| 欧美一区二区三区四区视频| 曰韩精品一区二区| av一区二区不卡| 国产欧美精品区一区二区三区 | 亚洲精品乱码久久久久久黑人| 国产一区二区中文字幕| 日韩一区二区三区高清免费看看| 亚洲综合清纯丝袜自拍| 91在线观看成人| 国产精品久久精品日日| 国产高清无密码一区二区三区| 日韩欧美国产不卡| 婷婷一区二区三区| 欧美美女视频在线观看| 一个色综合av| 91黄视频在线观看| 一区二区免费视频| 在线一区二区视频| 夜夜嗨av一区二区三区 | 精品日韩99亚洲| 免费国产亚洲视频| 欧美一级国产精品| 蜜臀91精品一区二区三区| 9191成人精品久久| 视频一区二区中文字幕| 欧美精品日韩一本| 琪琪久久久久日韩精品| 日韩欧美一区在线观看| 免费在线看一区| 欧美不卡一区二区| 国内精品国产三级国产a久久| 精品久久久久久最新网址| 久久疯狂做爰流白浆xx| 久久老女人爱爱| 丁香激情综合五月| 国产精品卡一卡二卡三| 色综合一区二区三区| 亚洲一区中文日韩| 91精选在线观看| 国产一区二区三区四区五区美女 | 日韩av电影免费观看高清完整版| 欧美精品乱码久久久久久按摩| 日韩电影在线免费观看| 亚洲精品一区二区三区99| 成人污视频在线观看| 亚洲欧洲精品天堂一级| 欧洲在线/亚洲| 日韩国产精品大片| 久久蜜桃av一区二区天堂| 99re8在线精品视频免费播放| 亚洲一区二区三区中文字幕| 欧美一区二区日韩| 国产精品系列在线观看| 亚洲精品免费看| 日韩一区二区三区电影 | 日韩一区二区三区四区| 国产麻豆精品在线观看| 粉嫩av亚洲一区二区图片| 国产精品小仙女| 中文字幕制服丝袜一区二区三区 | 久久成人免费电影| 国产色产综合色产在线视频| 91麻豆swag| 日韩**一区毛片| 国产精品成人免费精品自在线观看| 欧美性三三影院| 国产传媒一区在线| 亚洲超丰满肉感bbw| 国产视频一区不卡| 欧美日韩大陆一区二区| 国产91在线看| 亚洲电影一区二区| 国产日韩欧美一区二区三区综合| 在线观看日韩毛片| 国产在线视频精品一区| 亚洲午夜av在线| 国产欧美一区二区精品忘忧草| 欧美午夜电影一区| 岛国一区二区在线观看| 亚洲成av人影院在线观看网| 国产丝袜在线精品| 欧美一区二区三区电影| 色综合天天综合网国产成人综合天| 老司机精品视频在线| 亚洲情趣在线观看| 国产午夜精品久久久久久久 | 蜜臀久久久久久久| 亚洲摸摸操操av| 欧美激情综合网| 精品少妇一区二区三区在线播放| 在线免费观看日本欧美|