1. Color指令
a) CMD_FGCOLOR -设定前景颜色
+0 | CMD_FGCOLOR(0xffffff0a) |
+4 | Color |
Color是24bit RGB的数值。例如设置前景色为红色:
ftWrDispCmd(CMD_FGCOLOR);
ftWrDispCmd(0xff0000);
该命令能作用在CMD_BUTTON、CMD_KEYS、CMD_SCROLLBAR、CMD_TOGGLE、CMD_SLIDER等(应用于前景能移动的控件上)
b) CMD_BGCOLOR -设定背景颜色
+0 | CMD_BGCOLOR(0xffffff09) |
+4 | Color |
同前景色的方式一样
ftWrDispCmd(CMD_BGCOLOR);
ftWrDispCmd(0xff0000);
该命令能作用在CMD_SCROLLBAR、CMD_GAUGE、CMD_PROCESS、CMD_SLIDER等控件(应用于背景不能移动的控件上)
c) CMD_GRADCOLOR -设定3D按键上强调显示的颜色
+0 | CMD_GRADCOLOR(0xffffff34) |
+4 | Color |
同前景色
ftWrDispCmd(CMD_GRADCOLOR);
ftWrDispCmd(0xff0000);
该命令只能作用在CMD_BUTTON、CMD_KEYS上,改变的是按键上的渐变色。
控件颜色设定表
Widget | CMD_FGCOLOR | CMD_BGCOLOR | COLOR_RGB |
CMD_TEXT | NO | NO | YES |
CMD_BUTTON | YES | NO | YES(标签) |
CMD_GAUGE | NO | YES | YES(针与标识) |
CMD_KEYS | YES | NO | YES(文字) |
CMD_PROGRESS | NO | YES | YES |
CMD_SCROLLBAR | YES(内部条) | YES(外部条) | NO |
CMD_SLIDER | YES(旋钮) | YES(旋钮右边条) | YES(旋钮左边条) |
CMD_DIAL | YES(旋钮) | NO | YES(标识) |
CMD_TOGGLE | YES(旋钮) | YES(条) | YES(文字) |
CMD_NUMBER | NO | NO | YES |
CMD_CALIBRATE | YES(动画点) | YES(外部点) | NO |
CMD_SPINNER | NO | NO | YES |
注:如果需要复位颜色设置,可写入命令CMD_COLDSTART复位CoProcessor。
2. Button
CMD_BUTTON –绘制一个按钮
+0 | CMD_BUTTON(0xffffff0d) |
+4 | X |
+6 | Y |
+8 | W |
+10 | H |
+12 | Font |
+14 | Option |
+16 | String |
… | … |
+n | 0 |
用宏定义写入CMD_BUTTON:
#define ftCoCmdButton(x, y, w, h, font, options, s) \
{\
uint16_t len = strlen((char *)s) + 1; \
ftWrDispCmd(CMD_BUTTON);\
ftWrDispCmd(((uint32_t)(y) << 16) | ((x) & 0xffff));\
ftWrDispCmd(((uint32_t)(h) << 16) | (w));\
ftWrDispCmd(((uint32_t)(options) << 16) | (font));\
ftWrDispBuf(s, len); \
}
参数x, y, w, h分别表示按钮的左顶点x, y坐标和长宽。font是按钮上显示字符串的handle值,option有效值为0(3D 效果)或者OPT_FLAT(扁平效果)。最后是按钮上的字符串,以0为结束。
ftCoCmdButton((LCD_WIDTH / 2 - 150), (LCD_HEIGHT / 2 - 110), 140, 100, 31, 0, "Press!");
ftCoCmdButton((LCD_WIDTH / 2 + 10), (LCD_HEIGHT / 2 - 110), 140, 100, 31, OPT_FLAT, "Press!");
ftCoCmdButton((LCD_WIDTH / 2 - 100), (LCD_HEIGHT / 2 + 10), 50, 25, 26, 0, "One");
ftCoCmdButton((LCD_WIDTH / 2 - 100), (LCD_HEIGHT / 2 + 40), 50, 25, 26, 0, "Two");
ftCoCmdButton((LCD_WIDTH / 2 - 100), (LCD_HEIGHT / 2 + 70), 50, 25, 26, 0, "Three");
ftWrDispCmd(CMD_FGCOLOR);
ftWrDispCmd(0xb9b900);
ftCoCmdButton((LCD_WIDTH / 2 + 50), (LCD_HEIGHT / 2 + 10), 50, 25, 26, 0, "One");
ftWrDispCmd(CMD_FGCOLOR);
ftWrDispCmd(0xb97300);
ftCoCmdButton((LCD_WIDTH / 2 + 50), (LCD_HEIGHT / 2 + 40), 50, 25, 26, 0, "Two");
ftWrDispCmd(CMD_FGCOLOR);
ftWrDispCmd(0xb90007);
ftCoCmdButton((LCD_WIDTH / 2 + 50), (LCD_HEIGHT / 2 + 70), 50, 25, 26, 0, "Three"
3. Clock
CMD_CLOCK – 绘制一个针式台钟
#define ftCoCmdClock(x, y, r, options, h, m, s, ms)\
{\
ftWrDispCmd(CMD_CLOCK);\
ftWrDispCmd(((uint32_t)(y) << 16) | ((x) & 0xffff));\
ftWrDispCmd(((uint32_t)(options) << 16) | ((r) & 0xffff));\
ftWrDispCmd(((uint32_t)(m) << 16) | ((h) & 0xffff));\
ftWrDispCmd(((uint32_t)(ms) << 16) | ((s) & 0xffff));\
}
参数x, y分别表示时钟中心的x, y坐标,r表示时钟的半径。options有效值为0(3D),OPT_FLAT(扁平),OPT_NOBACK(没有背景),OPT_NOTICKS(没有12小时的刻点),OPT_NOSECS(没有秒针),OPT_NOHANDS(没有指针),OPT_NOHM(不画小时针及分针),多个option可用或的方式设置,比如同时没有背景和秒针options = OPT_NOBACK| OPT_NOSECS。参数h, m, s, ms分别为小时,分,秒,毫秒的值。
例程1s tmp加一,显示8种不同风格的时钟:
ms = 0;
s = (tmp % 60);
tmp = tmp / 60;
m = (tmp % 60);
tmp = tmp / 60;
h = (tmp % 12);
ftWrDispCmd(CMD_BGCOLOR);
ftWrDispCmd(0xb9b900);
ftCoCmdClock((LCD_WIDTH / 2 - 120), (LCD_HEIGHT / 2 - 60), 40, 0, h, m, s, ms);
ftCoCmdClock((LCD_WIDTH / 2 - 10), (LCD_HEIGHT / 2 - 60), 40, OPT_FLAT, h, m, s, ms);
ftCoCmdClock((LCD_WIDTH / 2 + 80), (LCD_HEIGHT / 2 - 60), 40, OPT_NOBACK, h, m, s, ms);
ftCoCmdClock((LCD_WIDTH / 2 + 180), (LCD_HEIGHT / 2 - 60), 40, OPT_NOTICKS, h, m, s, ms);
ftWrDispCmd(CMD_BGCOLOR);
ftWrDispCmd(0xb97300);
ftWrDispCmd(COLOR_RGB(0, 0, 255));
ftCoCmdClock((LCD_WIDTH / 2 - 120), (LCD_HEIGHT / 2 + 60), 40, OPT_NOSECS, h, m, s, ms);
ftCoCmdClock((LCD_WIDTH / 2 - 10), (LCD_HEIGHT / 2 + 60), 40, OPT_NOHANDS, h, m, s, ms);
ftCoCmdClock((LCD_WIDTH / 2 + 80), (LCD_HEIGHT / 2 + 60), 40, OPT_NOHM, h, m, s, ms);
ftCoCmdClock((LCD_WIDTH / 2 + 180), (LCD_HEIGHT / 2 + 60), 40, OPT_NOBACK | OPT_NOSECS, h, m, s, ms);
4. Gauge(仪表盘)
CMD_GAUGE –绘制一个仪表
#define ftCoCmdGauge(x, y, r, options, major, minor, val, range)\
{\
ftWrDispCmd(CMD_GAUGE);\
ftWrDispCmd(((uint32_t)(y) << 16) | ((x) & 0xffff));\
ftWrDispCmd(((uint32_t)(options) << 16) | ((r) & 0xffff));\
ftWrDispCmd(((uint32_t)(minor) << 16) | ((major) & 0xffff));\
ftWrDispCmd(((uint32_t)(range) << 16) | ((val) & 0xffff));\
}
参数x, y是仪表盘的中心坐标,r是半径。options为0是默认的3D效果,OPT_FLAT(扁平效果),OPT_NOBACK (没有背景),OPT_NOTICKS(没有刻度),OPT_NOPOINTER(没有指针)。major是仪表盘上大刻度区间数量,范围1-10。minor是仪表盘上小刻度区间数量,范围1-10。val是仪表盘指示的值,介于0到range值之间,包含range值。range表示最大值。
ftWrDispCmd(CMD_BGCOLOR);
ftWrDispCmd(0xb9b900);
ftCoCmdGauge((LCD_WIDTH / 2 - 120), (LCD_HEIGHT / 2 - 60), 40, 0, major, mijor, value, range);
ftCoCmdGauge((LCD_WIDTH / 2 - 10), (LCD_HEIGHT / 2 - 60), 40, OPT_FLAT, major, mijor, value, range);
ftCoCmdGauge((LCD_WIDTH / 2 + 80), (LCD_HEIGHT / 2 - 60), 40, OPT_NOBACK, major, mijor, value, range);
ftCoCmdGauge((LCD_WIDTH / 2 + 180), (LCD_HEIGHT / 2 - 60), 40, OPT_NOTICKS, major, mijor, value, range);
ftWrDispCmd(CMD_BGCOLOR);
ftWrDispCmd(0xb97300);
ftWrDispCmd(COLOR_RGB(0, 0, 255));
ftCoCmdGauge((LCD_WIDTH / 2 - 10), (LCD_HEIGHT / 2 + 60), 40, OPT_NOPOINTER, major, mijor, value, range);
ftCoCmdGauge((LCD_WIDTH / 2 + 180), (LCD_HEIGHT / 2 + 60), 40, OPT_NOBACK | OPT_FLAT, major, mijor, value, range);