Touchgfx(交互系统和创建无触发交互)

(一)目的是让Touchgfx给我们自动生成一些函数

(1)Screen1View.cpp

cpp 复制代码
#include <gui/screen1_screen/Screen1View.hpp>
#include <touchgfx/Unicode.hpp>
Screen1View::Screen1View()
{
		num = 0;
}
void Screen1View::setupScreen()
{
    Screen1ViewBase::setupScreen();
}
void Screen1View::tearDownScreen()
{
    Screen1ViewBase::tearDownScreen();
}
void Screen1View::addButtonClickHandler()
{
		num++;
		Unicode::snprintf(textArea1Buffer,TEXTAREA1_SIZE,"%d",num);
		textArea1.invalidate();
		newTrigger();
		if(num==5)
			application().gotoScreen2ScreenSlideTransitionWest();
}
void Screen1View::newAction(int32_t val)
{
	touchgfx_printf("执行了newAction,参数值为:%d",val);
}

(2)Screen1View.hpp

cpp 复制代码
#ifndef SCREEN1VIEW_HPP
#define SCREEN1VIEW_HPP
#include <gui_generated/screen1_screen/Screen1ViewBase.hpp>
#include <gui/screen1_screen/Screen1Presenter.hpp>
class Screen1View : public Screen1ViewBase
{
public:
    Screen1View();
    virtual ~Screen1View() {}
    virtual void setupScreen();
    virtual void tearDownScreen();
	virtual	void addButtonClickHandler();
	virtual	void newAction(int32_t val);	
protected:
		int num;
};

#endif // SCREEN1VIEW_HPP

(3)Screen1ViewBase.cpp

cpp 复制代码
/*********************************************************************************/
/********** THIS FILE IS GENERATED BY TOUCHGFX DESIGNER, DO NOT MODIFY ***********/
/*********************************************************************************/
#include <gui_generated/screen1_screen/Screen1ViewBase.hpp>
#include <touchgfx/Color.hpp>
#include <texts/TextKeysAndLanguages.hpp>
#include <images/BitmapDatabase.hpp>

Screen1ViewBase::Screen1ViewBase() :
    buttonCallback(this, &Screen1ViewBase::buttonCallbackHandler),
    interaction1Counter(0)
{
    __background.setPosition(0, 0, 1024, 600);
    __background.setColor(touchgfx::Color::getColorFromRGB(0, 0, 0));
    add(__background);

    bgBox.setPosition(0, 0, 1024, 600);
    bgBox.setColor(touchgfx::Color::getColorFromRGB(255, 255, 255));
    add(bgBox);

    box1.setPosition(96, 40, 50, 50);
    box1.setColor(touchgfx::Color::getColorFromRGB(255, 0, 0));
    add(box1);

    textArea1.setPosition(48, 161, 146, 30);
    textArea1.setColor(touchgfx::Color::getColorFromRGB(0, 0, 0));
    textArea1.setLinespacing(0);
    Unicode::snprintf(textArea1Buffer, TEXTAREA1_SIZE, "%s", touchgfx::TypedText(T___SINGLEUSE_N7BF).getText());
    textArea1.setWildcard(textArea1Buffer);
    textArea1.setTypedText(touchgfx::TypedText(T___SINGLEUSE_UOL8));
    add(textArea1);

    addButton.setXY(36, 223);
    addButton.setBitmaps(touchgfx::Bitmap(BITMAP_BLUE_BUTTONS_ROUND_EDGE_SMALL_ID), touchgfx::Bitmap(BITMAP_BLUE_BUTTONS_ROUND_EDGE_SMALL_PRESSED_ID));
    addButton.setLabelText(touchgfx::TypedText(T___SINGLEUSE_7J1W));
    addButton.setLabelColor(touchgfx::Color::getColorFromRGB(255, 255, 255));
    addButton.setLabelColorPressed(touchgfx::Color::getColorFromRGB(255, 255, 255));
    addButton.setAction(buttonCallback);
    add(addButton);
}
Screen1ViewBase::~Screen1ViewBase()
{

}
void Screen1ViewBase::setupScreen()
{

}
void Screen1ViewBase::buttonCallbackHandler(const touchgfx::AbstractButton& src)
{
    if (&src == &addButton)
    {
        //Interaction4
        //When addButton clicked call virtual function
        //Call addButtonClickHandler
        addButtonClickHandler();

        //Interaction5
        //When addButton clicked call newAction on Screen1
        //Call newAction
        newAction(126);
    }
}

void Screen1ViewBase::afterTransition()
{
    //Interaction1
    //When screen transition ends delay
    //Delay for 3000 ms (180 Ticks)
    interaction1Counter = INTERACTION1_DURATION;
}
void Screen1ViewBase::handleTickEvent()
{
    if (interaction1Counter > 0)
    {
        interaction1Counter--;
        if (interaction1Counter == 0)
        {
            //Interaction2
            //When Interaction1 completed change color of box1
            //Set RGB color R:0, G:255, B:0 on box1
            box1.setColor(touchgfx::Color::getColorFromRGB(0, 255, 0));
            box1.invalidate();
        }
    }

}
void Screen1ViewBase::newTrigger()
{
    //Interaction6
    //When newTrigger is called change color of box1
    //Set RGB color R:0, G:0, B:255 on box1
    box1.setColor(touchgfx::Color::getColorFromRGB(0, 0, 255));
    box1.invalidate();
}

(4)Screen1ViewBase.hpp

cpp 复制代码
/*********************************************************************************/
/********** THIS FILE IS GENERATED BY TOUCHGFX DESIGNER, DO NOT MODIFY ***********/
/*********************************************************************************/
#ifndef SCREEN1VIEWBASE_HPP
#define SCREEN1VIEWBASE_HPP

#include <gui/common/FrontendApplication.hpp>
#include <mvp/View.hpp>
#include <gui/screen1_screen/Screen1Presenter.hpp>
#include <touchgfx/widgets/Box.hpp>
#include <touchgfx/widgets/TextAreaWithWildcard.hpp>
#include <touchgfx/widgets/ButtonWithLabel.hpp>

class Screen1ViewBase : public touchgfx::View<Screen1Presenter>
{
public:
    Screen1ViewBase();
    virtual ~Screen1ViewBase();
    virtual void setupScreen();
    virtual void afterTransition();
    virtual void handleTickEvent();

    /*
     * Custom Actions
     */
    virtual void newAction(int32_t value)
    {
        // Override and implement this function in Screen1
    }
    virtual void newTrigger();
    /*
     * Virtual Action Handlers
     */
    virtual void addButtonClickHandler()
    {
        // Override and implement this function in Screen1
    }
protected:
    FrontendApplication& application() {
        return *static_cast<FrontendApplication*>(touchgfx::Application::getInstance());
    }
    touchgfx::Box __background;
    touchgfx::Box bgBox;
    touchgfx::Box box1;
    touchgfx::TextAreaWithOneWildcard textArea1;
    touchgfx::ButtonWithLabel addButton;
    static const uint16_t TEXTAREA1_SIZE = 10;
    touchgfx::Unicode::UnicodeChar textArea1Buffer[TEXTAREA1_SIZE];
private:
    touchgfx::Callback<Screen1ViewBase, const touchgfx::AbstractButton&> buttonCallback;
    void buttonCallbackHandler(const touchgfx::AbstractButton& src);
    static const uint16_t INTERACTION1_DURATION = 180;
    uint16_t interaction1Counter;

};

#endif // SCREEN1VIEWBASE_HPP
相关推荐
XINVRY-FPGA3 小时前
XC3S1000-4FGG320I Xilinx AMD Spartan-3 SRAM-based FPGA
嵌入式硬件·机器学习·计算机视觉·fpga开发·硬件工程·dsp开发·fpga
0***86334 小时前
SQL Server2019安装步骤+使用+解决部分报错+卸载(超详细 附下载链接)
javascript·数据库·ui
猫猫的小茶馆5 小时前
【ARM】ARM的介绍
c语言·开发语言·arm开发·stm32·单片机·嵌入式硬件·物联网
猫猫的小茶馆5 小时前
【PCB工艺】数模电及射频电路基础
驱动开发·stm32·单片机·嵌入式硬件·mcu·物联网·pcb工艺
点灯小铭5 小时前
基于单片机的智能药物盒设计与实现
数据库·单片机·嵌入式硬件·毕业设计·课程设计·期末大作业
梓德原6 小时前
【基础】详细分析带隙型稳压电路的工作原理
单片机·嵌入式硬件·物联网
国科安芯7 小时前
航天医疗领域AS32S601芯片的性能分析与适配性探讨
大数据·网络·人工智能·单片机·嵌入式硬件·fpga开发·性能优化
小李做物联网7 小时前
【物联网毕业设计】60.1基于单片机物联网嵌入式项目程序开发之图像厨房监测系统
stm32·单片机·嵌入式硬件·物联网
贝塔实验室8 小时前
新手如何使用Altium Designer创建第一张原理图(三)
arm开发·单片机·嵌入式硬件·fpga开发·射频工程·基带工程·嵌入式实时数据库
@good_good_study8 小时前
STM32 ADC多通道采样实验
stm32·单片机·嵌入式硬件