zoukankan      html  css  js  c++  java
  • 触摸屏移植Emwin

    1.时间配置程序GUI_X.c中包含触摸屏程序touch.h头文件

    2.添加以下程序:

    //准备 X 轴测量-----------里面不需要加东西,只要存在就会自动进行测量
    void GUI_TOUCH_X_ActivateX(void)
    {
    }
    //准备 Y 轴测量
    void GUI_TOUCH_X_ActivateY(void)
    {
    }
    //返回 A/D 转换器的 X 轴测量结果
    int GUI_TOUCH_X_MeasureX(void)
    {
    Touch_GetLCDXY();
    return touch.xpos;
    }
    //返回 A/D 转换器的 Y 轴测量结果
    int GUI_TOUCH_X_MeasureY(void)
    {
    Touch_GetLCDXY();
    return touch.ypos;
    }

    3.触摸屏touch.c中写入一个函数,返回坐标值

    //触摸屏坐标值转换成LCD屏坐标值
    void Touch_GetLCDXY(void)
    {
    if(T_PEN == 0)//如果按键触摸按下
    {
    if(TP_ADGet())//获取触摸屏坐标值
    {
    //转化成LCD屏坐标值
    touch.xpos = (u16)((double)touch.A/touch.K*touch.ad_xvalue + (double)touch.B/touch.K*touch.ad_yvalue+(double)touch.C/touch.K+0.5f);
    touch.ypos = (u16)((double)touch.D/touch.K*touch.ad_xvalue + (double)touch.E/touch.K*touch.ad_yvalue+(double)touch.F/touch.K+0.5f);
    return;
    }
    }
    touch.xpos = 0xffff; //失败
    touch.ypos = 0xffff;
    }

    4.在

     5.使用时间片实现校准(主函数while里)

    if(touchrun[0]>touchrun[1])
    {
    GUI_TOUCH_Exec();
    GUI_TOUCH_Exec();
    touchrun[0] =0;
    }

    6.刷新窗口
    if(guiupdata[0] >guiupdata[1])
    {
    GUI_Exec();//刷新窗口
    guiupdata[0] =0;
    }

    7.检测触摸是否可用,可以进行光标显示 GUI_CURSOR_Show();

  • 相关阅读:
    203. Remove Linked List Elements
    python练习小程序
    五十音练习小软件
    CocosCreator生命游戏
    一个swift下载程序
    用excel做一幅像素画
    翻译一篇SpiderMonkey GC的文章
    unity-3d拼图游戏
    NDK编译Python2.7.5
    git命令简图
  • 原文地址:https://www.cnblogs.com/juan-4-14/p/12927190.html
Copyright © 2011-2022 走看看