|
楼主 |
发表于 2021-8-24 10:08:05
|
显示全部楼层
本帖最后由 lihui163 于 2021-8-24 10:18 编辑
这是迪文主界面
串口接收中断函数
- void USART1_IRQHandler(void)
- {
-
- if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)
- {
- RecDateBuffer[RecLen]=USART_ReceiveData(USART1);
- RecLen++;
-
-
- if(RecLen==RecBufferLen)
- {
- RecDate=RecDateBuffer[3];
- RecLen=0;
- if(RecDate==0x0004)//氧气
- {
- flag0=5;
- }
- else if(RecDate==0x0003)//一氧化碳低浓度
- {
- flag0=4;
- }
- else if(RecDate==0x0002)//一氧化碳高浓度
- {
- flag0=3;
- }
- else if(RecDate==0x0001)//甲烷低浓度
- {
- flag0=2;
- }
- else if(RecDate==0x0000)//甲烷高浓度
- {
- flag0=1;
- }
- else if(RecDate==0x0015)
- {
- GPIO_SetBits(GPIOE,GPIO_Pin_3);
- }
- else if(RecDate==0x0014)
- {
- GPIO_ResetBits(GPIOE,GPIO_Pin_3);
- }
- else
- {
- flag0=0;
- // RecDate=0xff;
- }
-
- }
- }
- USART_ITConfig(USART1, USART_IT_TXE, DISABLE);
- }
复制代码 每个图标对应一个变量地址频率和浓度上传
- quzhi=caiji;//测量频率
- nongdu=(quzhi/100)/8-25;
- //===============================================================================
- /*波形频率*/
- uint8_t TxBuffer1[] = {
- 0xAA,
- 0x55, //字体
- 0x02,0x20, //X轴坐标
- 0x00,0xF0, //Y轴坐标
- (0x30+(quzhi/10000)),
- (0x30+(quzhi/1000%10)),
- (0x30+(quzhi/100%10)),
- 0x2E, //小数点
- (0x30 + (quzhi/10%10)),
- (0x30 + (quzhi%10)),
- 72,
- 90,
- 0xCC,0x33,0xC3,0x3C
- };
- /*波形频率*/
- uint8_t TxBuffer11[] = {
- 0xAA,
- 0x55, //字体
- 0x02,0x20, //X轴坐标
- 0x00,0xF0, //Y轴坐标
- (0x30),
- (0x30),
- (0x30),
- 0x2E, //小数点
- (0x30 ),
- (0x30),
- 72,
- 90,
- 0xCC,0x33,0xC3,0x3C
- };
-
-
-
- //=========================甲烷高=========================================
- /*波形频率串口发送*/
- if(flag0==1){
-
- /*气体浓度*/
- uint8_t TxBuffer2[] = {
- 0xAA,
- 0x55, //字体
- 0x02,0x30, //X轴坐标
- 0x01,0x30, //Y轴坐标
- (0x30+(nongdu/100)),
- (0x30+(nongdu/10%10)),
- (0x30+(nongdu%10)),
- 37,
- 0xCC,0x33,0xC3,0x3C
- };
- /*气体浓度*/
- uint8_t TxBuffer22[] = {
- 0xAA,
- 0x55, //字体
- 0x02,0x30, //X轴坐标
- 0x01,0x30, //Y轴坐标
- (0x30),
- (0x30),
- (0x30),
- 37,
- 0xCC,0x33,0xC3,0x3C
- };
-
-
- if(quzhi >= 100000 || quzhi <=20000)
- {
- for(j=0;j<=13;j++)
- {
-
- USART_SendData(USART1,TxBuffer22[j]);
- while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
- }
- j=0;
-
-
- for(i=0;i<=17;i++)
- {
-
- USART_SendData(USART1,TxBuffer11[i]);
-
-
- while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
- }
- i=0;
- }
-
- else
- {
-
- for(i=0;i<=17;i++)
- {
-
- USART_SendData(USART1,TxBuffer1[i]);
- while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
- }
- i=0;
-
-
-
- /*气体浓度串口发送*/
-
- for(j=0;j<=13;j++)
- {
-
- USART_SendData(USART1,TxBuffer2[j]);
- while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
- }
- j=0;
-
-
- }
-
- }
复制代码
迪文部分工程
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
x
|