MCU发指令让屏幕按钮动作能触发屏内LUA的on_control_notify回调吗
使用86屏,用LUA已经写好程序,触摸这个屏上的按钮可以正常理想的工作,但因为还有一个上位机是用指令来控制的,因而想通过单片机串口发指令控制屏上按钮的动作(模拟手在屏幕上的操作),以达到用手操作屏幕的目的,但好像这样不能触发on_control_notify回调函数,有不有其它的变通办法能实现这个想法?如果要再在单片机这边再写程序,那就太累了太慢了。那就相对于屏幕那边的LUA白写了,没用了。(说明开始考虑用LUAl来写就错了?)特请教,谢谢。LUA事件直接调用按钮触发事件函数就可以了,
on_control_notify(0,0,1) xjb1783 发表于 2022-5-29 11:22
LUA事件直接调用按钮触发事件函数就可以了,
on_control_notify(0,0,1)
谢谢关注和回复。LUA事件是直接调用on_control_notify函数,我的意思是用单片机发指令让屏上的按钮按下或者断开模拟手在屏上的触摸从而触发lua回调函数,仔细看了大彩的文档,说是不行的,不知有不有变通的办法? fsy 发表于 2022-5-29 12:07
谢谢关注和回复。LUA事件是直接调用on_control_notify函数,我的意思是用单片机发指令让屏上的按钮按下或 ...
回调函数里面的按钮按下或者弹起后lua脚本要实现的操作,全部用指令来实现 按钮按下或弹起指令后跟一句事件函数不就是你所要了
set_value(0,0,1)
on_control_notify(0,0,1)
set_value(0,0,0)
on_control_notify(0,0,0) xjb1783 发表于 2022-5-30 15:45
按钮按下或弹起指令后跟一句事件函数不就是你所要了
set_value(0,0,1)
on_control_notify(0,0,1)
谢谢朋友的回复,知道了。第一次用lua,很多地方不清楚。好像用lua来写,要根据自己对屏的功能要求来定,有利有弊。
本帖最后由 woutnme 于 2023-7-14 11:01 编辑
Hi, you can try, you can adapt to your protocol of communication
function on_timer( timer_id )
if(timer_id==1)then
local flag_uart_change = get_variant("UART_BITS_BUTTONS")
if(flag_uart_change>0)then --if some button
if( (flag_uart_change&1)>0)then
my_actionbutton(0)
flag_uart_change = flag_uart_change&65534 --mask for down bit
end
--all bits you have
if((flag_uart_change&16384)>0)then --bit 14
my_actionbutton(14)
flag_uart_change = flag_uart_change&49151 --mask for down bit
end
end
set_variant("UART_BITS_BUTTONS",flag_uart_change) --reset bits
end
--body
end
function on_init()
start_timer(1,100,0,0) --check if the variable have ch anger
end
function on_control_notify(screen,control,value)
if(screen == 6) then
if (control == 14 and value == 1) then --my screen button
my_actionbutton(14)
end
end
end
function my_actionbutton(number_button)
-- here its the action make press the button, maybe simple change of state
if(number_button==14) then
--Make something
end
end
页:
[1]