当前位置:网站首页>Kunlun state screen production (serial 3) - based article (button serial port to send)
Kunlun state screen production (serial 3) - based article (button serial port to send)
2022-07-30 07:14:00 【transparent light】
写在开始
After two days of hard work,Finally have a new understanding of this embedded screen.Make an analogy below:
单片机或者ARM:
(1)main函数开始,进行INIT初始化;
(2)while(1)循环;
(3)External or internal interrupt.
The above three points are the conventional hardware programming that we are familiar with
And Kunlun Tong-state screen script programming:

(1)初始化脚本;---对应INIT初始化
(2)采集脚本;---对应while(1)循环
(3)Single-channel scripting;---对应中断
(4)退出脚本.
结论:The two programming are in one-to-one correspondence,It's just that there is an extra exit script when programming the Kunlun state screen script.That is, the program that executes when you exit the screen.
初始化和while(1)There is no difference between the two,It is equivalent to an interrupt in a single-channel script,The change of the channel value is the interrupt that triggers the execution of the single-channel script.This will be described in detail below.
第一节:回顾
上文中https://blog.csdn.net/weixin_45426095/article/details/119410084,《Kunlun on-state screen production(连载2)------基础篇(初试篇)》Details on how to write scripts,How to configure links to scripts and screens,How to make a screen,怎么调试,怎么验证.For those who are not yet clear, you can move to the above link.
There must now be three open windows:
(1)组态软件,也就是屏幕,Feel free to pull modules,Change the display at any time.
(2)脚本软件,Modify the script file at any time,Then connect to the configuration software.
(3)串口助手,方便调试.
注:Use virtual serial port software,Virtual out a pair of serial ports,The configuration software is connected to a serial port,Serial Assistant connects to another serial port,No hardware connection is required,The purpose of serial port debugging is achieved directly through the virtual serial port.
Made a fetch yesterday、Routines for display and serial transmission,Add something new today:按钮发送数据,Slider to enter other displays,Addition and subtraction input display,串口数据显示.
第二节:按钮发送
1. 编写脚本
(1)加入通道:第一个按钮,Device channel direct count,第三个.

(2)编写脚本:In single-channel scripting.
DIM ButtonChannel as INTEGERFirst define a channel number,目的:Which channel to take has changed,That is, which device channel has the interrupt.
ButtonChannel = !GetCurrentChannelNum()执行上述程序,You can get which device channel the value has changed.
IF ButtonChannel = 3 THEN
!Sleep(1000)
nSendByteArr[1] = &H5B
nSendByteArr[2] = &HB5
nSendByteArr[3] = &HFF
nSendByteArr[4] = !BitRShift(gnGetData1, 8)
nSendByteArr[5] = gnGetData1
nSendByteArr[6] = !SvrByteArraySum(nSendByteArr,3,3)'和校验
!DevClearBuff() '清缓冲
!DevWriteAndReadByteArr(nSendByteArr,6,nRecvByteArr,6,通讯延时)
ENDIFBecause the first button is the third channel,That is the third number,So the following explains the code line by line
如果按钮被按下,==3时,执行以下程序;
缓冲1000ms,This is the system time,Does not occupy the interrupt time,So you can rest assured to delay,for the entire interrupt routine andwhile(1)program execution is not affected.
Fill sentbuffer 6个数,
清缓存,发送6个数据,接收6个数据;
(3)保存.
2. Load scripts and screen link drivers
(1)Open the file created yesterday:

(2)点击设备窗口:双击设备窗口,弹出对话框:Because the script file has been rewritten,So it appears that the driver has been modified externally,

双击驱动:更新设备,in the channel connection options,Add the corresponding data object.In this way, the parameters in the script can be recognized by the modules in the screen interface.

(3)保存,退出,Open the user window.
3. Screen interface settings
(1)Place the button module,这个不会的话,It is described in detail in the previous tutorial.

(2)修改参数:双击按钮,打开对话框,in the action properties:

in the value object,choose negation,Select the first button inside the question mark.
注:You must click to negate here,Because the interrupt script is executed every time a key is pressed,That is, single-channel scripting.Select other to execute only once,Or do it multiple times.
(3)保存.
4. 验证
工具,下载配置,工程下载,启动运行:

(1)初始结果:Yesterday's sending program,1s执行一次,报文正确.

(2)Modify the data in the fetch box:The display box follows the changes,The serial port display changes to 0A,报文正确.


(3)点击按钮后,报文正确.

第三节:总结
(1)总的来说,The programming idea is the same as before,But the programming content is close to embedded,Maybe this is why it is called an embedded screen.
(2)After writing the first routine,The following things are more than a gourd painting,一个一个的添加,然后去验证.From mental work to physical work.
(3)Screen entry has a certain threshold,Especially not embeddedARMMCU and other small partners for logic programming,There should be some difficulty.If you are a friend of object-oriented programming,可以看看前面的文章,There is an introduction to the difference between logic-oriented and object-oriented programming.After that, there are small partners who have the basics of oriented logic writing,It is also very difficult to do without a certain routine,If there is a routine,can be changed on this basis,This time it's easier.
第四节:展望
Now write a program for a button,Subsequent tutorials will be issued one after another,After all, programming takes time,Writing articles also takes time,At the same time, there are other tasks to be done while working,请耐心等待,谢谢了!Friends who need to discuss can add WeChat,大家一起进步:

边栏推荐
猜你喜欢

Configure MMdetection environment and train

边境的悍匪—机器学习实战:第一章 机器学习的基础知识

三种内核结构---宏内核、微内核、混合内核

干货:线上下单应知应会,快来了解下
Three working modes of CPU: real mode, protected mode, long mode

Antd简单启动一个企业级项目

边境的悍匪—机器学习实战:第七章 集成学习和随机森林

"R Language + Remote Sensing" Comprehensive Evaluation Method of Water Environment
![[Jiangsu University Self-Chemistry Association stm32F103c8t6] Notes [Entry 32 MCU and GPIO initialization parameter configuration]](/img/96/a98e8b813a2fd9d0a44d3121aaee6a.png)
[Jiangsu University Self-Chemistry Association stm32F103c8t6] Notes [Entry 32 MCU and GPIO initialization parameter configuration]

jvm之逃逸分析
随机推荐
自定义类加载器
边境的悍匪—机器学习实战:第八章 降维
三种内核结构---宏内核、微内核、混合内核
工程师必看:常见的PCB检测方法有哪些?
[Jiangsu University Self-Chemistry Association stm32F103c8t6] Notes [Entry 32 MCU and GPIO initialization parameter configuration]
边境的悍匪—机器学习实战:第一章 机器学习的基础知识
this是什么(你不知道的JS)
Cannnot download sources不能下载源码百分百超详细解决方案
高集成度 MCU 市场增大,如何加速 BLDC 领域落地应用
QT串口和CAN数据动态实时显示最后日志
逻辑右移和算术右移区别
昆仑通态屏幕制作(连载3)---基础篇(按钮串口发送)
clinit方法
使用Dva项目作Antd的Demo
vs编译boost库脚本
Machine Learning, Deep Learning Based on MATLAB 2021b
R language application in the field of ecological environment
JS的值和引用,复制和传递
Diwen serial screen production (serialization 1) ===== preparation work
QT串口动态实时显示大量数据波形曲线(四)========“界面的美化与处理”