硬汉嵌入式论坛

 找回密码
 立即注册
查看: 2790|回复: 1
收起左侧

stm32f429bit6出厂程序中转屏

[复制链接]

2

主题

0

回帖

2

积分

新手上路

积分
2
发表于 2016-12-15 10:46:20 | 显示全部楼层 |阅读模式
新手,想知道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个方向
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
115653
QQ
发表于 2016-12-15 20:08:36 | 显示全部楼层
在bsp_tft_429.c文件里面,你简单看个打点函数应该就明白了。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2025-5-10 07:16 , Processed in 0.353398 second(s), 30 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表