【拓普微智能显示屏测评】2.2 SGTools图形编辑软件之键盘、曲线、二维码应用
<div class='showpostmsg'><p style="text-indent:21.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">项目中用到了界面输入密码功能,需要在输入框中键入相应的密码,键入完毕后通过串口发送至下位机,</font><font face="Calibri">SGTools</font><font face="宋体">正好提供了强大的键盘功能,在工具栏中</font></span></span></span></span> <span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">,三种不同形式的键盘,只需将此控件拖入屏幕页面,即可在页面生成键盘界面,</font></span></span></span></span> <span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">,如果想要采用</font></span></span><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="Calibri">SGToolS</font><font face="宋体">官方的按键背景,则选择“是”即可。</font></span></span></span></span></p><p style="text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">生成的键盘界面如下:</font></span></span></span></span></p>
<p style="text-align:left"> </p>
<p style="text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">这里的数字及字母按键默认所对应的</font></span></span><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="Calibri">VP</font><font face="宋体">变量为:</font><font face="Calibri">0x000000-BUF</font></span></span></span></span></p>
<p style="text-align:left"> </p>
<p style="text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">即按键按下后产生的对应字符都会在</font><font face="Calibri">VP</font><font face="宋体">:</font><font face="Calibri">0x000000-BUF</font><font face="宋体">中,那么我们创建一个字符串控件用来显示</font><font face="Calibri">VP</font><font face="宋体">:</font><font face="Calibri">0x000000-BUF</font><font face="宋体">中的内容即可,需要注意字符串所对应的</font><font face="Calibri">VP</font><font face="宋体">设置为</font><font face="Calibri">VP</font><font face="宋体">:</font><font face="Calibri">0x000000-BUF</font><font face="宋体">即可。</font></span></span></span></span> </p>
<p style="text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">实际在屏幕运行效果图如下:</font></span></span></span></span></p>
<p style="text-align:left"> </p>
<p style="text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">通过屏幕按键键入</font>“</span></span><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="Calibri">123456</font></span></span><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">”,然后点击“</font></span></span><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="Calibri">OK</font></span></span><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">”后,可以看到屏幕串口输出:</font></span></span></span></span></p>
<p style="text-align:left"> </p>
<p style="text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">这样,下位机即可通过串口接收到的数据中解析出密码,并进行判断即可。</font></span></span></span></span></p>
<p style="text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"> <font face="宋体">如果下位机检测到密码正确,那么通过向屏幕发送切换指定页面指令即可切换到下一级界面:发送指令如:</font><font face="Calibri">aa 70 00 01 cc 33 c3 3c </font><font face="宋体">(切换到显示界面</font><font face="Calibri">1</font><font face="宋体">)</font></span></span></span></span></p>
<p style="text-align:left"> </p>
<p style="text-align:left"> </p>
<p style="text-indent:21.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">项目要实现</font><font face="Calibri">PH</font><font face="宋体">、</font><font face="Calibri">ORP</font><font face="宋体">等参数的历史数据显示曲线功能,这就要用到</font><font face="Calibri">SGTools</font><font face="宋体">工具的曲线显示控件</font></span></span></span></span> <span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">,使用起来也相对简单,直接拖拽到要显示的区域,然后需要给曲线添加变量</font></span></span><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="Calibri">VP</font><font face="宋体">,那么这里需要是专用的曲线显示变量</font><font face="Calibri">VP</font><font face="宋体">,</font></span></span></span></span> </p>
<p style="text-indent:21.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">新建的数字变量中的长度是自定义的,其实就是数组的长度,这需要根据自身实际显示曲线的范围来设置,比如我这里设置的长度是</font><font face="Calibri">770</font><font face="宋体">,也就是曲线显示的横坐标的长度。然后在曲线的属性中设置</font><font face="Calibri">VP</font><font face="宋体">为</font><font face="Calibri">0x060000 </font><font face="宋体">即可。</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:left"> <span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">其中的最大值和最小值设置即曲线纵坐标的最大值和最小值。配置完成以后看一下实际效果,</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">通过串口向屏幕发送曲线数据指令:</font><font face="Calibri">AA 4D 00 06 00 00 00 02 00 32 00 33 CC 33 C3 3C</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">注意这条指令是向曲线发送了两条数据,分别为</font></span></span><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="Calibri">00 32 </font><font face="宋体">和</font><font face="Calibri">00 33 </font><font face="宋体">,这种指令的效果就是发送几个数据,就代表几个坐标,就只显示这几个坐标的数据,当然坐标是从最左边开始算。效果如下:(仅仅在前两个坐标显示了曲线像素)</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"> </span></span> </p>
<p style="text-indent:21.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">如果想要显示整个坐标范围的曲线就必须一次性向屏幕发送整个坐标范围数量的数据,那么指令将相当长。</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">那么我们采用发送:</font><font face="Calibri">AA 4E 00 06 00 00 00 f2 00 93 CC 33 C3 3C</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">这条指令运用了左推进写曲线数据:</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:left"> </p>
<p style="text-indent:21.0000pt; text-align:left"> </p>
<p style="text-indent:21.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">也就是可以指定一个参考坐标,然后之后发送的数据都会以这个坐标为显示点,这个坐标原来显示的曲线将会向左移动一个坐标,如果在发送一个数据,那么就再次移动一个坐标,这样就实现了随着时间的推移,显示的曲线也在将旧的曲线退出,新的曲线从右面进来。</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">实际的显示效果如下:(这里曲线显示采用填充式)</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:left"> </p>
<p style="text-indent:21.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">曲线显示的功能注意下数组变量的宽度和曲线</font></span></span><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="Calibri">VP</font><font face="宋体">的最大值和最小值即可。</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">项目还采用了二维码显示的功能,用于给用户绑定设备提供交互方式,这里采用二维码包含</font>“<font face="Calibri">http://www.baidu.com</font><font face="宋体">” 字符串网址的例子来说明下二维码的使用。</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">直接将工具栏中二维码控件</font></span></span></span></span> <span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">拖入要显示的界面区域,并在属性中为其添加指定的</font></span></span><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="Calibri">VP</font><font face="宋体">地址,这里我们需要在二维码中包含字符串,所以选择</font><font face="Calibri">VP=0x000080</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:left"> </p>
<p style="text-indent:21.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">属性中可以看到</font><font face="Calibri">VP</font><font face="宋体">变量可以包含的内容最大长度为</font><font face="Calibri">154</font><font face="宋体">字节,这已经足以满足我们的要求,当然如果不够用还可以选择包含更多的大小格式。</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">配置完毕后,通过发送串口指令给屏幕进行测试,由于是向普通的字符串变量</font><font face="Calibri">VP</font><font face="宋体">写指令,那么直接按照写指令发送即可:</font></span></span><span style="font-size:10.5000pt"><span style="font-family:Calibri">AA 42 00 00 00 80 68 74 74 70 3a 2f 2f 77 77 77 2e 62 61 69 64 75 2e 63 6f 6d 00 CC 33 C3 3C</span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">指令中的</font></span></span><span style="font-size:10.5000pt"><span style="font-family:Calibri">68 74 74 70 3a 2f 2f 77 77 77 2e 62 61 69 64 75 2e 63 6f 6d</span></span><span style="font-size:10.5000pt"><span style="font-family:宋体"> <font face="宋体">对应字符串:</font></span></span><a href="http://www.baidu.com"><u><span class="15" style="font-family:宋体"><span style="color:#0000ff"><span style="text-decoration:underline"><span style="text-underline:single"><font face="Calibri">http://www.baidu.com</font></span></span></span></span></u></a></span></span></p>
<p style="text-indent:21.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">实际生成二维码效果如下图:</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:left"> </p>
</div><script> var loginstr = '<div class="locked">查看本帖全部内容,请<a href="javascript:;" style="color:#e60000" class="loginf">登录</a>或者<a href="https://bbs.eeworld.com.cn/member.php?mod=register_eeworld.php&action=wechat" style="color:#e60000" target="_blank">注册</a></div>';
if(parseInt(discuz_uid)==0){
(function($){
var postHeight = getTextHeight(400);
$(".showpostmsg").html($(".showpostmsg").html());
$(".showpostmsg").after(loginstr);
$(".showpostmsg").css({height:postHeight,overflow:"hidden"});
})(jQuery);
} </script><script type="text/javascript">(function(d,c){var a=d.createElement("script"),m=d.getElementsByTagName("script"),eewurl="//counter.eeworld.com.cn/pv/count/";a.src=eewurl+c;m.parentNode.insertBefore(a,m)})(document,523)</script> <p>谢谢分享:)</p>
页:
[1]