迪文智能屏
直播中

donatello1996

7年用户 687经验值
擅长:处理器/DSP 控制/MCU RF/无线
私信 关注

【迪文COF结构智能屏试用体验】基于迪文屏和QT上位机的图表远程监控界面

本帖最后由 donatello1996 于 2022-4-11 10:02 编辑

项目说明:使用迪文COF结构智能屏及其串口通信接口,结合电脑端QT上位机进行基于串口通信的上位机的图表远程监控界面,图案完全由QT上位机DIY定制,省去造轮子,可以使用QT上位机的高级GUI控件如渐变图层或OpenGL,具体显示效果由迪文COF结构智能屏的显示材质所表现。QT上位机端可开发各种基于QLabel控件所显示的图案或图表,如仪表盘,折线图,AD采集曲线图,电子罗盘等,这里为了方便就只做了仪表盘和折线图,并且QT描绘的矢量图占用空间过大,导致刷屏速率和分辨率都很低,只能做两张200*200的矢量图,如果迪文厂家在后续扩充flash空间,则可配置更多类型的QT上位机图案或图表。


使用到的串口通信指令:
  1. 显示命令
  2. 5A A5 07 82 7F FE 5A A5 80 00
  3. 5A A5 07 82 BF FE 5A A5 C0 00

  4. 更改坐标
  5. 5A A5 07 82 1011 0064 0064

  6. 5A A5 07 82 1011 0064 0064


  7. 数据帧
  8. 5A A5 F3 82 80 00 。。。


6.JPG 5.JPG
在DGUS软件中添加两个显示控件,两个控件的起始坐标重叠,描述指针分别为0x1010和0x2020,内存地址分别为0x7FFE和0xBFFE,使用两个控件更改坐标交替显示图案和图表可以实现双缓冲效果。


使用到的QT上位机图案:
仪表盘:
1.jpg

仪表盘支持OpenGL加速,渐变图层显示。

折线图:
2.jpg

折线图为矢量图表,可以任意描绘坐标点。

本来我是打算做AD采集的波浪曲线图的,但是无奈矢量曲线图占用空间真的大,采集一帧600*400曲线图的JPG文件都达到了100K以上,只能用这种显示内容简单的折线图。

仪表盘和折线图内容均取自QT上位机,可以在上面做基于XML或QTWidget套件操作,因为懒得造轮子,又想显示的内容够精美,只能出此上策!
3.JPG

原计划是打算显示AD采集曲线的,但是这个矢量图的占用空间是真的大,没写一点点进去就已经刷满GRAM了:
4.JPG

QT代码中抓取单个LABEL标签为JPG文件,并将JPG文件分片通过串口上传到GRAM:
  1. void MainWindow::on_PB_GRAB_clicked()
  2. {
  3.     int res = 0;
  4.     unsigned char recvbuf[6] ={0};
  5.     unsigned char commbuf[246] =
  6.     {0x5a , 0xa5 , 0xf3 , 0x82};

  7.     unsigned short word_offset = 0x8000;

  8. 。。。

  9.     if(fileName.isEmpty())
  10.     {
  11.         QMessageBox mesg;
  12.         mesg.warning(this,"警告","打开图片失败!");
  13.         return;
  14.     }
  15.     else
  16.     {
  17.         QFile file(fileName);
  18.         QImage img(fileName);
  19.         file.open(QIODevice::ReadOnly);

  20.         while(1)
  21.         {
  22.             memset(commbuf , 0 , 246);
  23.             commbuf[0] = 0x5a;
  24.             commbuf[1] = 0xa5;
  25.             commbuf[2] = 0xf3;
  26.             commbuf[3] = 0x82;
  27.             commbuf[4] = ( word_offset & 0xff00 ) >> 8;
  28.             commbuf[5] =   word_offset & 0xff;

  29.             res = file.read((char*)commbuf + 6 , 240);
  30.             if(res < 240)
  31.             {
  32.                 qDebug("res = %d eof" , res);
  33.                 break;
  34.             }
  35.             else
  36.             {
  37.                 word_offset += 0x78;
  38.             }

  39.             QString qscommbuf;
  40.             for(int n = 0 ; n < sizeof(commbuf); n++)
  41.             {
  42.                 qscommbuf += QString().sprintf("%02x", (unsigned char)commbuf[n]);
  43.             }
  44.             qDebug()<<"res =" << res << qscommbuf;

  45.             res = commt->sendMyComm(commbuf , 246);
  46.             qDebug()<<"ressend =" << res;
  47.         }
  48.         file.close();
  49.     }
  50. }
  1. void MainWindow::on_PB_GRAB_2_clicked()
  2. {
  3.     int res = 0;
  4.     unsigned char recvbuf[6] ={0};
  5.     unsigned char commbuf[246] =
  6.     {0x5a , 0xa5 , 0xf3 , 0x82};

  7.     unsigned short word_offset = 0xC000;

  8. 。。。

  9.     if(fileName.isEmpty())
  10.     {
  11.         QMessageBox mesg;
  12.         mesg.warning(this,"警告","打开图片失败!");
  13.         return;
  14.     }
  15.     else
  16.     {
  17.         QFile file(fileName);
  18.         QImage img(fileName);
  19.         file.open(QIODevice::ReadOnly);

  20.         while(1)
  21.         {
  22.             memset(commbuf , 0 , 246);
  23.             commbuf[0] = 0x5a;
  24.             commbuf[1] = 0xa5;
  25.             commbuf[2] = 0xf3;
  26.             commbuf[3] = 0x82;
  27.             commbuf[4] = ( word_offset & 0xff00 ) >> 8;
  28.             commbuf[5] =   word_offset & 0xff;

  29.             res = file.read((char*)commbuf + 6 , 240);
  30.             if(res < 240)
  31.             {
  32.                 qDebug("res = %d eof" , res);
  33.                 break;
  34.             }
  35.             else
  36.             {
  37.                 word_offset += 0x78;
  38.             }

  39.             QString qscommbuf;
  40.             for(int n = 0 ; n < sizeof(commbuf); n++)
  41.             {
  42.                 qscommbuf += QString().sprintf("%02x", (unsigned char)commbuf[n]);
  43.             }
  44.             qDebug()<<"res =" << res << qscommbuf;

  45.             res = commt->sendMyComm(commbuf , 246);
  46.             qDebug()<<"ressend =" << res;
  47.         }
  48.         file.close();
  49.     }
  50. }

更改显示坐标,实际上就是切换隐藏或显示图案:
  1. void MainWindow::on_PB_MOVE_11_clicked()
  2. {
  3.     unsigned char commbuf[246] =
  4.     {0x5A , 0xA5 , 0x07 , 0x82 , 0x10 , 0x11 , 0x00 , 0x00 , 0x00 , 0x00};
  5.     int res = commt->sendMyComm(commbuf , 10);
  6.     qDebug()<<"ressendshow =" << res;
  7. }
  1. void MainWindow::on_PB_MOVE_12_clicked()
  2. {
  3.     unsigned char commbuf[246] =
  4.     {0x5A , 0xA5 , 0x07 , 0x82 , 0x10 , 0x11 , 0x02 , 0xd0 , 0x02 , 0xd0};
  5.     int res = commt->sendMyComm(commbuf , 10);
  6.     qDebug()<<"ressendshow =" << res;
  7. }
  1. void MainWindow::on_PB_MOVE_21_clicked()
  2. {
  3.     unsigned char commbuf[246] =
  4.     {0x5A , 0xA5 , 0x07 , 0x82 , 0x20 , 0x21 , 0x00 , 0x00 , 0x00 , 0x00};
  5.     int res = commt->sendMyComm(commbuf , 10);
  6.     qDebug()<<"ressendshow =" << res;
  7. }
  1. void MainWindow::on_PB_MOVE_22_clicked()
  2. {
  3.     unsigned char commbuf[246] =
  4.     {0x5A , 0xA5 , 0x07 , 0x82 , 0x20 , 0x21 , 0x02 , 0xd0 , 0x02 , 0xd0};
  5.     int res = commt->sendMyComm(commbuf , 10);
  6.     qDebug()<<"ressendshow =" << res;
  7. }

循环显示:
  1. void MainWindow::on_PB_GRAB_3_clicked()
  2. {
  3.         on_PB_MOVE_22_clicked();
  4.         on_PB_MOVE_12_clicked();

  5.         while(1)
  6.         {
  7.             on_PB_GRAB_clicked();
  8.             on_PB_MOVE_11_clicked();
  9.             on_PB_GRAB_2_clicked();
  10.             on_PB_MOVE_21_clicked();
  11.             Sleep(2000);
  12.             on_PB_MOVE_22_clicked();
  13.         }
  14. }



回帖(1)

donatello1996

2022-4-11 14:42:02
[media]https://www.bilibili.com/video/BV1tY4y1i7hK/[/media]
举报

更多回帖

发帖
×
20
完善资料,
赚取积分