• touchGFX综合学习八、touchGFX在其他线程直接更新控件(不使用邮箱、队列、信号量等IPC)


    一、touchGFX工程搭建

    放置一个box为背景,放置一个textArea控件,开启通配符,在其他任务中更新textArea控件计数值
    在这里插入图片描述

    二、touchGFX源码修改

    1、在Screen1Presenter.hpp文件中声明一个变量和方法

    在这里插入图片描述

    2、在Screen1Presenter.cpp文件中实现方法

    在方法中实现自增num值,并将值赋值给textArea控件显示
    在这里插入图片描述

    3、定义一个Screen1View 变量,在启动和停止函数中赋值

    在这里插入图片描述

    4、定义一个全局函数调用成员add_num函数,使用C语言编译器进行编译

    在这里插入图片描述

    5、其任务操作方法

    extern void update_control_text()while(1)
    {
    	update_control_text();
    	delay(100);
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    三、源码

    Screen1View.hpp

    #ifndef SCREEN1VIEW_HPP
    #define SCREEN1VIEW_HPP
    
    #include 
    #include 
    
    class Screen1View : public Screen1ViewBase
    {
    public:
        Screen1View();
        virtual ~Screen1View() {}
        virtual void setupScreen();
        virtual void tearDownScreen();
        void add_num();
    protected:
    
        uint16_t num;
    };
    
    #endif // SCREEN1VIEW_HPP
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21

    Screen1View.cpp

    #include 
    #include 
    
    extern "C" void update_control_text();
    
    Screen1View *screen1;
    
    Screen1View::Screen1View():
    	num(0)
    {
    
    }
    
    void Screen1View::setupScreen()
    {
        Screen1ViewBase::setupScreen();
        screen1 = this;
    }
    
    void Screen1View::tearDownScreen()
    {
        screen1 = NULL;
        Screen1ViewBase::tearDownScreen();
    }
    void Screen1View::add_num()
    {
        this->num++;
        Unicode::snprintf(this->textArea1Buffer, this->TEXTAREA1_SIZE,"%d" ,this->num);
        textArea1.resizeToCurrentText();
        textArea1.invalidate();
    
       // getRootContainer().invalidate();//解决屏幕乱跳
    }
    extern "C" void update_control_text()
    {
        if(screen1)
        {
            screen1->add_num();
        }
    }
    
    
    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
  • 相关阅读:
    Sulfo-CY7 NHS ester的荧光波长特性1603861-95-5星戈瑞
    web前端开发网页设计课堂作业/html练习《课程表》
    linux写文件如何保证落盘?
    Android 动画和过渡
    移动端适配单位vw和px的转换
    学习笔记25--多传感器前融合技术
    RCP系列-第一章 环境安装
    Java 8之后的那些新特性(四):网络请求 Java Http Client
    项目中集成高德地图
    Kaggle 专利匹配比赛赛后总结
  • 原文地址:https://blog.csdn.net/qq_15181569/article/details/127380943