{"id":51512,"date":"2026-08-04T20:26:43","date_gmt":"2026-08-04T12:26:43","guid":{"rendered":"https:\/\/www.modbus.cn\/51512.html"},"modified":"2026-08-04T20:26:43","modified_gmt":"2026-08-04T12:26:43","slug":"visualhmi-%e6%96%87%e5%ad%97%e9%a2%9c%e8%89%b2%e6%8e%a7%e5%88%b6%ef%bc%9aon_wgt_text_color-%e6%89%b9%e9%87%8f%e5%88%87%e6%8d%a2%e4%b8%bb%e9%a2%98","status":"publish","type":"post","link":"http:\/\/www.modbus.cn\/en\/51512.html","title":{"rendered":"VisualHMI \u6587\u5b57\u989c\u8272\u63a7\u5236\uff1aon_wgt_text_color \u6279\u91cf\u5207\u6362\u4e3b\u9898"},"content":{"rendered":"<p>\u5168\u5c40\u6587\u5b57\u989c\u8272\u6279\u91cf\u8bbe\u7f6e\uff1a\u4e00\u4e2a\u56de\u8c03\u51fd\u6570\u540c\u6b65\u6539\u753b\u9762\u6240\u6709\u6587\u672c\u63a7\u4ef6\u7684\u6587\u5b57\u989c\u8272\uff0c\u5b9e\u73b0&#8221;\u4eae\u8272\u6a21\u5f0f \u2194 \u6697\u8272\u6a21\u5f0f&#8221;\u5373\u65f6\u5207\u6362\u3002<strong>\u5b9a\u5236\u56fa\u4ef6\u4e13\u5c5e<\/strong>\u3002<\/p>\n<h2>1. \u524d\u7f6e\u914d\u7f6e\uff08\u4e24\u6b65\uff09<\/h2>\n<ol>\n<li><strong>\u5168\u5c40\u542f\u7528\u63a7\u4ef6\u5206\u7ec4<\/strong>\uff1a\u5de5\u7a0b\u5c5e\u6027 \u2192 \u63a7\u4ef6\u5206\u7ec4 \u2192 \u542f\u7528\u3002\u4e0d\u542f\u7528\u5219\u6240\u6709\u63a7\u4ef6\u5ffd\u7565\u5206\u7ec4\u5c5e\u6027<\/li>\n<li><strong>\u63a7\u4ef6\u5206\u914d\u5206\u7ec4\u6807\u8bc6<\/strong>\uff1a\u63a7\u4ef6\u5c5e\u6027\u9762\u677f \u2192 \u63a7\u4ef6ID\uff0c\u5fc5\u987b \u2260 0\uff080 \u4e3a\u9ed8\u8ba4\u65e0\u6548\u503c\uff0c\u8868\u793a\u672a\u5206\u7ec4\uff09<\/li>\n<\/ol>\n<h2>2. on_wgt_text_color(screen, control)<\/h2>\n<p>\u7cfb\u7edf\u5728\u63a7\u4ef6\u5237\u65b0\u65f6\u8c03\u7528\u6b64\u56de\u8c03\uff0c\u8fd4\u56de\u6307\u5b9a\u63a7\u4ef6\u663e\u793a\u65f6\u7528\u7684\u6587\u5b57\u989c\u8272\uff08RGB565\uff09\uff1a<\/p>\n<pre style=\"background:#f5f5f5;padding:10px;border-radius:4px\">function on_wgt_text_color(screen, control)\n  local mode = get_uint16(VT_LW, 0x1000)   -- 0=\u4eae\u8272\u6a21\u5f0f, 1=\u6697\u8272\u6a21\u5f0f\n  if mode == 0 then\n    return 0x0000    -- \u4eae\u8272\u6a21\u5f0f: \u9ed1\u5b57\n  else\n    return 0xFFFF    -- \u6697\u8272\u6a21\u5f0f: \u767d\u5b57\n  end\nend<\/pre>\n<p>\u652f\u6301\u6279\u91cf\u8bbe\u7f6e\u7684\u63a7\u4ef6\uff1a\u6587\u672c\u3001\u6570\u503c\u3001\u4f4d\u72b6\u6001\u6307\u793a\u706f\uff08\u6587\u5b57\u90e8\u5206\uff09\u7b49\u6587\u672c\u7c7b\u63a7\u4ef6\u3002<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.modbus.cn\/wp-content\/uploads\/2026\/08\/visualhmi\/lu016_2.png\" style=\"max-width:100%;border:1px solid #eee;margin:8px 0\" loading=\"lazy\" title=\"VisualHMI \u6587\u5b57\u989c\u8272\u63a7\u5236\uff1aon_wgt_text_color \u6279\u91cf\u5207\u6362\u4e3b\u9898\u63d2\u56fe\" alt=\"VisualHMI \u6587\u5b57\u989c\u8272\u63a7\u5236\uff1aon_wgt_text_color \u6279\u91cf\u5207\u6362\u4e3b\u9898\u63d2\u56fe\" \/><\/p>\n<div class=\"tip\" style=\"border-left:4px solid #f7941e;padding:10px 14px;background:#fff8ef;margin:14px 0\">\u6ce8\u610f\u4e24\u70b9\uff1a<strong>\u2460\u63a7\u4ef6\u5206\u7ec4\u529f\u80fd\u5fc5\u987b\u5148\u5728\u5de5\u7a0b\u5c5e\u6027\u91cc\u542f\u7528\uff0c\u63a7\u4ef6 ID \u975e 0 \u624d\u53c2\u4e0e\u56de\u8c03\uff1b\u2461\u8fd4\u56de\u7684\u662f RGB565 \u8272\u503c\uff0c0x0000 \u9ed1\u30010xFFFF \u767d\uff0c\u548c set_pen_color \u540c\u4e00\u5957\u8272\u57df<\/strong>\u3002<\/div>\n<p style=\"color:#888;font-size:13px\">\u6574\u7406\u81ea \u5e7f\u5dde\u5927\u5f69\u79d1\u6280 VisualHMI \u5f00\u53d1\u6587\u6863\uff08hmi-doc.gz-dc.com\uff09LUA \u6559\u7a0b\u300c\u6587\u5b57\u989c\u8272\u63a7\u5236\u300d\uff0c\u7248\u6743\u5f52\u5927\u5f69\u79d1\u6280\u6240\u6709\u3002<\/p>\n<span id=\"magicpostMarker\"><\/span>","protected":false},"excerpt":{"rendered":"<p>\u5168\u5c40\u6587\u5b57\u989c\u8272\u6279\u91cf\u8bbe\u7f6e\uff1a\u4e00\u4e2a\u56de\u8c03\u51fd\u6570\u540c\u6b65\u6539\u753b\u9762\u6240\u6709\u6587\u672c\u63a7\u4ef6\u7684\u6587&#8230;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_members_access_role":[],"_members_access_error":""},"categories":[3131,3126],"tags":[3374,3336,3134,3376,3375,3373],"class_list":["post-51512","post","type-post","status-publish","format-standard","hentry","category-hmi-lua","category-hmi-dev","tag-on_wgt_text_color","tag-rgb565","tag-visualhmi","tag-3376","tag-3375","tag-3373"],"_links":{"self":[{"href":"http:\/\/www.modbus.cn\/en\/wp-json\/wp\/v2\/posts\/51512","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.modbus.cn\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.modbus.cn\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.modbus.cn\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.modbus.cn\/en\/wp-json\/wp\/v2\/comments?post=51512"}],"version-history":[{"count":0,"href":"http:\/\/www.modbus.cn\/en\/wp-json\/wp\/v2\/posts\/51512\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.modbus.cn\/en\/wp-json\/wp\/v2\/media?parent=51512"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.modbus.cn\/en\/wp-json\/wp\/v2\/categories?post=51512"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.modbus.cn\/en\/wp-json\/wp\/v2\/tags?post=51512"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}