|
新手,想知道5方向摇杆切换屏幕方向的函数在哪
/*
*********************************************************************************************************
* oˉ êy Ãû: TOUCH_PutKey
* 1|ÄüËμÃ÷: ½«1¸ö′¥Ãtμã×ø±êÖμÑ1èë′¥ÃtFIFO»o3åÇø¡£óÃóúμç×è′¥ÃtÆá¡£
* DÎ 2Î: _usX, _usY ×ø±êÖμ
* ·μ »Ø Öμ: ÎT
*********************************************************************************************************
*/
void TOUCH_PutKey(uint8_t _ucEvent, uint16_t _usX, uint16_t _usY)
{
uint16_t xx, yy;
uint16_t x = 0, y = 0;
g_tTP.Event[g_tTP.Write] = _ucEvent;
if (g_GT811.Enable == 1) /* μçèYÆá (ÎTDèD£×¼) */
{
xx = _usX;
yy = _usY;
}
else if (g_tFT5X06.Enable == 1)
{
xx = _usX;
yy = _usY;
}
else /* μç×èÆá */
{
xx = TOUCH_TransX(_usX, _usY);
yy = TOUCH_TransY(_usX, _usY);
}
/* oáÆáoíêúÆá·½Ïòê¶±e */
switch (g_tParam.TouchDirection)
{
case 0: /* D£×¼′¥Ãtê±£¬ÆáÄ»·½ÏòÎa0 */
if (g_LcdDirection == 0) /* oáÆá */
{
x = xx;
y = yy;
}
else if (g_LcdDirection == 1) /* oáÆá180¡ã*/
{
x = g_LcdWidth - xx - 1;
y = g_LcdHeight - yy - 1;
}
else if (g_LcdDirection == 2) /* êúÆá */
{
y = xx;
x = g_LcdWidth - yy - 1;
}
else if (g_LcdDirection == 3) /* êúÆá180¡ã */
{
y = g_LcdHeight - xx - 1;
x = yy;
}
break;
case 1: /* D£×¼′¥Ãtê±£¬ÆáÄ»·½ÏòÎa1 */
if (g_LcdDirection == 0) /* oáÆá */
{
x = g_LcdWidth - xx - 1;
y = g_LcdHeight - yy - 1;
}
else if (g_LcdDirection == 1) /* oáÆá180¡ã*/
{
x = xx;
y = yy;
}
else if (g_LcdDirection == 2) /* êúÆá */
{
y = g_LcdHeight - xx - 1;
x = yy;
}
else if (g_LcdDirection == 3) /* êúÆá180¡ã */
{
y = xx;
x = g_LcdWidth - yy - 1;
}
break;
case 2: /* D£×¼′¥Ãtê±£¬ÆáÄ»·½ÏòÎa2 */
if (g_LcdDirection == 0) /* oáÆá */
{
y = xx;
x = g_LcdWidth - yy - 1;
}
else if (g_LcdDirection == 1) /* oáÆá180¡ã*/
{
y = g_LcdHeight - xx - 1;
x = yy;
}
else if (g_LcdDirection == 2) /* êúÆá */
{
x = xx;
y = yy;
}
else if (g_LcdDirection == 3) /* êúÆá180¡ã */
{
x = g_LcdWidth - xx - 1;
y = g_LcdHeight - yy - 1;
}
break;
case 3: /* D£×¼′¥Ãtê±£¬ÆáÄ»·½ÏòÎa3 */
if (g_LcdDirection == 0) /* oáÆá */
{
y = xx;
x = g_LcdWidth - yy - 1;
}
else if (g_LcdDirection == 1) /* oáÆá180¡ã*/
{
y = g_LcdHeight - xx - 1;
x = yy;
}
else if (g_LcdDirection == 2) /* êúÆá */
{
x = g_LcdWidth - xx - 1;
y = g_LcdHeight - yy - 1;
}
else if (g_LcdDirection == 3) /* êúÆá180¡ã */
{
x = xx;
y = yy;
}
break;
default:
g_tParam.TouchDirection = 0; /* ·½Ïò2ÎêyÎTD§ê±£¬¾àÕyÎaè±ê¡μÄoáÆá */
break;
}
g_tTP.XBuf[g_tTP.Write] = x;
g_tTP.YBuf[g_tTP.Write] = y;
if (++g_tTP.Write >= TOUCH_FIFO_SIZE)
{
g_tTP.Write = 0;
}
/* μ÷êÔóï¾ä£¬′òó¡adcoí×ø±ê */
touch_printf("%d - (%d, %d) adcX=%d,adcY=%d\r\n", _ucEvent, x, y, g_tTP.usAdcNowX, g_tTP.usAdcNowY);
}
这个函数说是转屏,但是屏蔽其中一个方向的时候,依然可以切换4个方向 |
|