During the runtime, the UI can be rotated in full (0°/90°/180°/270°), applicable to both handheld devices and vertical cabinets. One set of Lua scripts adapts to all orientations, exclusive to the DX series.
1. Lua controls rotation
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
2. Generates multi-orientation files
Compile landscape projects (0°/180°) twice: 0° retains the default image.bin/project.bin; 180° is renamed to image180.bin/project180.bin and placed in private. Similarly, for portrait projects (90°/270°), generate image90/image270 and place them in private. The private directory ultimately contains 8 core files, with 0° loaded by default at startup, and the corresponding bin automatically loaded during runtime when changing orientation.


Compiled from VisualHMI development documentation of Guangzhou Dacai Technology (hmi-doc.gz-dc.com) and other technical tutorials on "screen rotation", copyright belongs to Dacai Technology.
Leave a Reply