1. Spinner
CMD_SPINNER – 开始一个动态转盘
#define ftCoCmdSpinner(x, y, style, scale)\
{\
ftWrDispCmd(CMD_SPINNER);\
ftWrDispCmd(((uint32_t)(y) << 16) | ((x) & 0xffff));\
ftWrDispCmd(((uint32_t)(scale) << 16) | (style));\
}
参数style是Spinner的类型,有效值为0 - 3。scale是Spinner的放大倍数,0表示原始大小。如果需要退出,可写入CMD_STOP或新的显示列表。
switch (spinnerType)
{
case 0:
ftCoCmdText((PANEL_WIDTH / 2), (PANEL_HEIGHT / 2 - 50), 27, OPT_CENTER, "0) Circle");
ftCoCmdSpinner((PANEL_WIDTH / 2), (PANEL_HEIGHT / 2), 0, 0);
break;
case 1:
ftCoCmdText((PANEL_WIDTH / 2), (PANEL_HEIGHT / 2 - 50), 27, OPT_CENTER, "1) Line");
ftCoCmdSpinner((PANEL_WIDTH / 2), (PANEL_HEIGHT / 2), 1, 0);
break;
case 2:
ftCoCmdText((PANEL_WIDTH / 2), (PANEL_HEIGHT / 2 - 50), 27, OPT_CENTER, "2) Clock");
ftCoCmdSpinner((PANEL_WIDTH / 2), (PANEL_HEIGHT / 2), 2, 0);
break;
case 3:
ftCoCmdText((PANEL_WIDTH / 2), (PANEL_HEIGHT / 2 - 50), 27, OPT_CENTER, "3) Dots");
ftCoCmdSpinner((PANEL_WIDTH / 2), (PANEL_HEIGHT / 2), 3, 0);
break;
case 4:
ftCoCmdText((PANEL_WIDTH / 2), (PANEL_HEIGHT / 2 - 80), 27, OPT_CENTER, "0) Circle X2");
ftCoCmdSpinner((PANEL_WIDTH / 2), (PANEL_HEIGHT / 2), 0, 1);
break;
}
测试程序只写一次显示指令,而屏幕会显示动态的图案,每点击一次图案切换一种显示模式。
2. 屏保
CMD_SCREENSAVER - 开始一个动态屏幕保护程序
生成一个动态屏保(只能一张图像显示动态变化),FT8xx会自动改变图像的坐标,无需MCU写入更新。该命令必须和MACRO(0)配合使用,FT8xx自动将新坐标写入到REG_MACRO_0里面以实现动态显示。
ftWrDispCmd(BITMAP_HANDLE(HANDLE_HOME));
ftWrDispCmd(BITMAP_SOURCE(0));
ftWrDispCmd(BITMAP_LAYOUT(L4, 30, 60));
ftWrDispCmd(BITMAP_LAYOUT_H(0, 0));
ftWrDispCmd(BITMAP_SIZE(NEAREST, BORDER, BORDER, 60, 60));
ftWrDispCmd(BITMAP_SIZE_H(0, 0));
ftWrDispCmd(BEGIN(BITMAPS));
ftWrDispCmd(MACRO(0));
ftWrDispCmd(END());
ftWrDispCmd(CMD_SCREENSAVER);
ftEnDisp(FALSE);
需要显示的图片不用写入VERTEX2F命令设置初始坐标,用MACRO(0)命令替代即可。如果需要退出,可写入CMD_STOP或新的显示列表。
3. 手写
CMD_SKETCH -开始一个手写界面
#define ftCoCmdSketch(x, y, w, h, ptr, format)\
{\
ftWrDispCmd(CMD_SKETCH);\
ftWrDispCmd(((uint32_t)(y) << 16) | ((x) & 0xffff));\
ftWrDispCmd(((uint32_t)(h) << 16) | (w));\
ftWrDispCmd(ptr);\
ftWrDispCmd(format);\
}
参数x, y,w,h是手写界面的坐标和大小。ptr是手写后图片保存在RAMG中位置。format是指图片的格式,仅支持L1和L8格式。
ftWrDispCmd(CMD_MEMZERO);
ftWrDispCmd(RAM_G + 60 * 60 / 2);
if (sketchFormat == L1)
ftWrDispCmd(((uint32_t)SKETCH_W * SKETCH_H + 7) / 8);
else//L8
ftWrDispCmd((uint32_t)SKETCH_W * SKETCH_H);
ftCoCmdSketch(SKETCH_X, SKETCH_Y, SKETCH_W, SKETCH_H, RAM_G + 60 * 60 / 2, sketchFormat);
ftUpdateBufToCmd();
ftStartDisp();
menuShowBackground();
menuShowHomeIcon();
ftWrDispCmd(BEGIN(RECTS));
ftWrDispCmd(LINE_WIDTH(1 * 16));
ftWrDispCmd(VERTEX2F(SKETCH_X * 16, SKETCH_Y * 16));
ftWrDispCmd(VERTEX2F((SKETCH_X + SKETCH_W) * 16, (SKETCH_Y + SKETCH_H) * 16));
ftWrDispCmd(COLOR_RGB(0, 0, 0));
ftWrDispCmd(BEGIN(BITMAPS));
ftWrDispCmd(BITMAP_HANDLE(2));
ftWrDispCmd(BITMAP_SOURCE(RAM_G + 60 * 60 / 2));
if (sketchFormat == L1)
{
ftWrDispCmd(BITMAP_LAYOUT(L1, (SKETCH_W + 7) / 8, SKETCH_H));
ftWrDispCmd(BITMAP_LAYOUT_H((SKETCH_W + 7) / 8, SKETCH_H));
}
else
{
ftWrDispCmd(BITMAP_LAYOUT(L8, SKETCH_W, SKETCH_H));
ftWrDispCmd(BITMAP_LAYOUT_H(SKETCH_W, SKETCH_H));
}
ftWrDispCmd(BITMAP_SIZE(NEAREST, BORDER, BORDER, SKETCH_W, SKETCH_H));
ftWrDispCmd(BITMAP_SIZE_H(SKETCH_W, SKETCH_H));
ftWrDispCmd(VERTEX2F(SKETCH_X * 16, SKETCH_Y * 16));
ftWrDispCmd(COLOR_RGB(0xff, 0xff, 0xff));
ftWrDispCmd(TAG_MASK(1));
ftWrDispCmd(TAG(2));
if (sketchFormat == L1)
{
ftCoCmdButton(10, 80, 60, 40, 22, 0, "L1");
}
else
{
ftCoCmdButton(10, 80, 60, 40, 22, 0, "L8");
}
ftEnDisp(FALSE);
CMD_MEMZERO是将RAMG中的数据清零。CMD_SKETCH命令也需要在ftStartDisp()前写入。BEGIN(BITMAPS)是显示手写的图片。
4. 截屏
CMD_SNAPSHOT -对目前的屏幕截图
#define ftCoCmdSnapshot(ptr)\
{\
ftWrDispCmd(CMD_SNAPSHOT);\
ftWrDispCmd(ptr);\
}
FT80x只能从地址0,0开始截图,截图会以ARGB4的格式保存在RAMG指定地址中,该RAMG段不能被当前显示的内容使用。截图大小由寄存器REG_HSIZE及REG_VSIZE决定。在截图前必须REG_PCLK设置为0,即关闭显示。如果需要更强的功能,可以选择FT81x,CMD_SNAPSHOT2功能可以实现任意位置的截图。
void menuSnapshotShow(void)
{
ftStartDisp();
menuShowBackground();
menuShowHomeIcon();
ftCoCmdNumber(PANEL_WIDTH / 2, SNAPSHOT_H / 2, 24, OPT_CENTER, snapshotNum);
ftWrDispCmd(BEGIN(BITMAPS));
ftWrDispCmd(BITMAP_HANDLE(2));
ftWrDispCmd(BITMAP_SOURCE(RAM_G + 60 * 60 / 2));
ftWrDispCmd(BITMAP_LAYOUT(ARGB4, SNAPSHOT_W * 2, SNAPSHOT_H));
ftWrDispCmd(BITMAP_LAYOUT_H(SNAPSHOT_W * 2, SNAPSHOT_H));
ftWrDispCmd(BITMAP_SIZE(NEAREST, BORDER, BORDER, SNAPSHOT_W, SNAPSHOT_H));
ftWrDispCmd(BITMAP_SIZE_H(SNAPSHOT_W, SNAPSHOT_H));
ftWrDispCmd(VERTEX2F(0 * 16, (PANEL_HEIGHT - SNAPSHOT_H) * 16));
ftWrDispCmd(TAG_MASK(1));
ftWrDispCmd(TAG(2));
ftCoCmdButton(PANEL_WIDTH / 2 - 60, 80, 120, 30, 21, 0, "Random Num");
ftWrDispCmd(TAG(3));
ftCoCmdButton(PANEL_WIDTH / 2 - 60, 120, 120, 30, 21, 0, "Snapshot");
ftEnDisp(FALSE);
}
snapshotNum是一个随机数,点击按钮“Random Num”会生成一个随机数,点击按钮“Snapshot”会将(0,0)开始,屏宽+70高的区域截图,并显示在屏幕下方。
截屏命令:
eveBLControl(0);
ft8xxWrMem8(REG_PCLK, 0);
ft8xxWrMem16(REG_HSIZE, SNAPSHOT_W);
ft8xxWrMem16(REG_VSIZE, SNAPSHOT_H);
ftCoCmdSnapshot(RAM_G + 60 * 60 / 2);
ftUpdateBufToCmd();
while(ft8xxRdMem16(REG_CMD_READ) != ft8xxRdMem16(REG_CMD_WRITE));
delayms(400);
ft8xxWrMem8(REG_PCLK, REG_PCLK_VALUE);
ft8xxWrMem16(REG_HSIZE, LCD_WIDTH);
ft8xxWrMem16(REG_VSIZE, LCD_HEIGHT);
menuSnapshotShow();
eveBLControl(0x80);