Par19_控件数据同步演示
<p>[TOC]</p>
<h1>功能描述</h1>
<p>数据关联,用不同形式来呈现同一个控件数据。</p>
<h4>接线方法</h4>
<p>与Arduino控制器进行连接,RX-TX,GND-GND(用到了RX和TX串口)。</p>
<h4>实现功能</h4>
<p>将不同界面里不同控件的数据进行关联同步,只需给相关的控件中的其中一个设置数据便可同步更新数据显示。</p>
<h4>操作示例</h4>
<p>本例将在part13的基础上进行修改
1.打开part13的资源配置文件。
2.进入界面0,将四个数值控件复制到界面1,复制后的id号分别是107,108,109,110
3.打开控件107的配置对话框,在最下方点击选择数据关联控件id号。与100控件关联,108与101关联。109与102关联,110与同界面的109关联。
关联操作如图:
<img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=343620d57afee51f2227cfea88a1cd67&amp;file=file.png" alt="" /></p>
<h1>使用代码</h1>
<pre><code class="language-c">#include &quot;CnStringDefine.c&quot;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
delay(2000);
}
unsigned long m_BackCounter_mils=0;
unsigned char m_NowDisGUI=0;
unsigned long m_BackCounterAdd_mils=0;
int m_DisIntDat=0;
float m_DisFloatDat=0.0;
unsigned char m_GUI1Status1=0;
unsigned char m_GUI1Status2=0;
void loop() {
// put your main code here, to run repeatedly:
unsigned long n_TempCounter_mils=millis();
if((n_TempCounter_mils-m_BackCounter_mils)&gt;=5000)
{
m_BackCounter_mils = n_TempCounter_mils;
m_NowDisGUI++;
if(m_NowDisGUI&gt;=2) m_NowDisGUI = 0;
Serial.print(&quot;@GUIS &quot;);
Serial.println(m_NowDisGUI);
}
n_TempCounter_mils=millis();
if((n_TempCounter_mils-m_BackCounterAdd_mils)&gt;=1000)
{
m_BackCounterAdd_mils = n_TempCounter_mils;
m_DisIntDat+=1;
m_DisFloatDat+= 0.123;
if(m_GUI1Status1) m_GUI1Status1=0;
else m_GUI1Status1=1;
m_GUI1Status2++;
if(m_GUI1Status2&gt;=4) m_GUI1Status2=0;
Serial.print(&quot;@SET 100,&quot;);
Serial.println(m_DisIntDat);
Serial.print(&quot;@SET 101,&quot;);
Serial.println(m_DisIntDat);
Serial.print(&quot;@SET 102,&quot;);
Serial.println(m_DisFloatDat,3);
Serial.print(&quot;@SET 103,&quot;);
Serial.println(m_DisFloatDat,3);
Serial.print(&quot;@SET 104,&quot;);
if(m_GUI1Status1) Serial.println(m_String1);
else Serial.println(m_String2);
Serial.print(&quot;@SET 106,&quot;);
Serial.println(m_GUI1Status2);
Serial.print(&quot;@SET 105,&quot;);
Serial.println(m_GUI1Status1);
}
}</code></pre>
<p>CnStringDefine.c</p>
<pre><code class="language-c">const char m_String1[]=&quot;当前状态:停止Stop&quot;;
const char m_String2[]=&quot;当前状态:运行Run&quot;;</code></pre>
<h1>资源文件</h1>
<p><a href="https://pan.baidu.com/e/180jia4w4NUHlrs09aDaFog?pwd=ATFC">高级篇part19_资源文件</a></p>
<h1>视频教程</h1>
<p><a href="https://www.bilibili.com/video/BV1bF411376k/?spm_id_from=333.999.0.0&amp;vd_source=8adc070117854dc6967b17bf3379321b">【高级篇】Part19_二维码显示控件演示</a></p>