DebugPrinter是再我们进行调试程序的时候经常用到的功能,比如显示运行日志等,下面介绍一下它的应用方法:
(一)修改FrontendApplication.cpp文件
#include <gui/common/FrontendApplication.hpp>
//增加下面的头文件
#include <platform/driver/lcd/LCD16bpp.hpp>
static LCD16DebugPrinter dp;//定义对象
FrontendApplication::FrontendApplication(Model& m, FrontendHeap& heap)
: FrontendApplicationBase(m, heap)
{
dp.setPosition(5,5,1024,60);
dp.setScale(4);//设置放大倍数
dp.setColor(0x0000);//黑色
setDebugPrinter(&dp);//注册定义过的对象
}
(二)修改Screen1View.cpp文件
#include <gui/screen1_screen/Screen1View.hpp>
//增加下面的头文件
#include <platform/driver/lcd/LCD16bpp.hpp>
DebugPrinter * dp;//定义指针
Screen1View::Screen1View()
{
}
void Screen1View::setupScreen()
{
Screen1ViewBase::setupScreen();
//屏幕打印方式
dp = Application::getDebugPrinter();
dp->setString("This is DebugPrinter!");
Application::invalidateDebugRegion();//更新屏幕,刷新显示区域
//模拟器打印方式
touchgfx_printf("this is simulator:%d\r\n",123456);
}
void Screen1View::tearDownScreen()
{
Screen1ViewBase::tearDownScreen();
}