VisualHMI 屏幕旋转:set_lcd_rotate 与多方向 bin

freeFree Technical Resource

This content is free to read, suitable for basic learning and search traffic.

运行期整体旋转 UI(0°/90°/180°/270°),手持器、竖装机柜都适用。一套 Lua 适配すべての姿态,DX 系列专属。

1. Lua 控制旋转

set_lcd_rotate(angle)  -- angle: 0~3 (0=0°,1=90°,2=180°,3=270°)

function on_init()
  local angle = get_uint16(VT_RW, 0x0001)  -- 从Flash读旋转方向
  angle = (angle < 0 or angle > 3) and 0 or angle
  set_lcd_rotate(angle)
  set_uint16(VT_LW, 0x8888, angle)
end

function on_update(slave,vtype,addr)
  if vtype == VT_LW and addr == 0x8888 then
    local val = get_uint16(VT_LW, 0x8888)
    set_uint16(VT_RW, 0x0001, val)  -- 存旋转方向
    set_lcd_rotate(val)
  end
end

VisualHMI 屏幕旋转:set_lcd_rotate 与多方向 binFigure

2. 生成多方向文件

横屏工程(0°/180°)编译两次:0° 保留デフォルト image.bin/project.bin;180° 重命名为 image180.bin/project180.bin 放进 private。竖屏工程(90°/270°)同理生成 image90/image270 放入 private。private 目录最终含 8 个核心文件,启动时デフォルト加载 0°,运行时切方向自动加载对应 bin。

VisualHMI 屏幕旋转:set_lcd_rotate 与多方向 binFigure1

VisualHMI 屏幕旋转:set_lcd_rotate 与多方向 binFigure2

屏幕旋转注意:横屏和竖屏的 Lua 脚本逻辑完全一致,差异のみ编译出的 bin 文件(imageXXX.bin/projectXXX.bin)。開発者たちは只维护一套工程,按方向编译四次命名好丢进 private 即可。DX 系列专属。

整理自 广州大彩科技 VisualHMI 开发ドキュメント(hmi-doc.gz-dc.com)其他技术チュートリアル「屏幕旋转」,著作権は大彩科技すべての。

Put this resource to use in a real project?

Go to the Tool Center for message parsing, CRC verification and device debugging, or submit your requirements for selection and integration advice.

Engineer Membership

Turn this article into actionable debugging resources

After activation, you can use advanced message parsing, resource pack downloads, code examples, engineering cases and priority technical support, suitable for real project delivery.

Unlimited Advanced Tools
Resource & Code Packs
Complete Engineering Case Library
Priority Technical Support

Leave a Reply

Your email address will not be published. Required fields are marked *.