【安富莱二代示波器教程】第8章 示波器设计—测量功能

第8章        示波器设计—测量功能

    二代示波器测量功能实现比较简单,使用2D函数绘制即可。不过也专门开辟一个章节,为大家做一个简单的说明,方便理解。

8.1    水平测量功能

8.2     垂直测量功能

8.3     总结

 

 

8.1  水平测量功能

水平测量方式的效果如下:

 

水平测量功能的数据显示不要以窗口的形式呈现,因为将窗口显示在波形显示区上会造成波形刷新慢。当前的方案是在绘制完毕波形后,直接2D函数绘制测量窗口,这种方式的实际效果好很多。对应的代码如下:

/***********************************************************************************************************    函 数 名: DSO_DrawCursorH*    功能说明: 绘制示波器的水平测量游标,用于测量幅值。*    形    参: 无          *    返 回 值: 无**********************************************************************************************************/void DSO_DrawCursorH(void){char buf[60];/* 第1步:绘制用于测量的两个游标线********************************************************/GUI_SetColor(0x0040f0);/* 绘制横线A */GUI_DrawHLine(g_Cursors->sCursorHA, DSOSCREEN_STARTX, DSOSCREEN_ENDX);GUI_DrawHLine(g_Cursors->sCursorHA+1, DSOSCREEN_STARTX, DSOSCREEN_ENDX); GUI_FillRoundedRect(50, g_Cursors->sCursorHA+3, 61, g_Cursors->sCursorHA+18, 3);/* 绘制横线B */GUI_DrawHLine(g_Cursors->sCursorHB, DSOSCREEN_STARTX, DSOSCREEN_ENDX);GUI_DrawHLine(g_Cursors->sCursorHB-1, DSOSCREEN_STARTX, DSOSCREEN_ENDX); GUI_FillRoundedRect(50, g_Cursors->sCursorHB-18, 61, g_Cursors->sCursorHB-3, 3);/* 在横线A和横线B旁边的小圆圈中显示字母a和字母b */GUI_SetColor(GUI_BLACK);GUI_SetFont(&GUI_Font20_ASCII);GUI_SetTextMode(GUI_TEXTMODE_TRANS);                   GUI_DispCharAt('a', 51, g_Cursors->sCursorHA);GUI_DispCharAt('b', 51, g_Cursors->sCursorHB-19);/* 第2步:绘制游标数据显示窗口********************************************************/GUI_SetColor(GUI_BLACK);GUI_FillRoundedRect(500, 55, 635, 135, 4);GUI_SetColor(GUI_WHITE);GUI_DrawRoundedRect( 499, 54, 636, 136, 4);GUI_SetColor(0x0040f0);GUI_FillRoundedRect(75 + 433 , 47 + 15, 86 + 433, 62 + 15, 3);                GUI_FillRoundedRect(75 + 433 , 45 + 45, 86 + 433, 60 + 45, 3);GUI_SetColor(GUI_BLACK);GUI_SetFont(&GUI_Font20_1);GUI_SetTextMode(GUI_TEXTMODE_TRANS);                   GUI_DispCharAt('a', 509, 59);GUI_DispCharAt('b', 509, 88);GUI_SetColor(GUI_YELLOW);GUI_SetFont(&GUI_Font16_1);GUI_DispCharAt('#', 511, 115);/* 第3步:计算竖线线A的数值***********************************************************/g_Cursors->WaveCursorA = (float)((g_Cursors->sCursorVA - 340) * g_CursorUintTable[TimeBaseId][0])/1000;if(g_CursorUintTable[TimeBaseId][1] == 1){sprintf(buf, "%5.1fus", g_Cursors->WaveCursorA);}else if(g_CursorUintTable[TimeBaseId][1] == 2){sprintf(buf, "%5.3fms", g_Cursors->WaveCursorA);}else if(g_CursorUintTable[TimeBaseId][1] == 3){sprintf(buf, "%5.2fms", g_Cursors->WaveCursorA);}else if(g_CursorUintTable[TimeBaseId][1] == 4){sprintf(buf, "%5.1fms", g_Cursors->WaveCursorA);}else if(g_CursorUintTable[TimeBaseId][1] == 5){sprintf(buf, "%5.3fs", g_Cursors->WaveCursorA);}else if(g_CursorUintTable[TimeBaseId][1] == 6){sprintf(buf, "%5.2fs", g_Cursors->WaveCursorA);}else if(g_CursorUintTable[TimeBaseId][1] == 7){sprintf(buf, "%5.1fs", g_Cursors->WaveCursorA);}GUI_DispStringAt(buf, 523, 63);/* 第3步:计算竖线线B的数值***********************************************************/g_Cursors->WaveCursorB = (float)((g_Cursors->sCursorVB - 340) * g_CursorUintTable[TimeBaseId][0])/1000;if(g_CursorUintTable[TimeBaseId][1] == 1){sprintf(buf, "%5.1fus", g_Cursors->WaveCursorB);}else if(g_CursorUintTable[TimeBaseId][1] == 2){sprintf(buf, "%5.3fms", g_Cursors->WaveCursorB);}else if(g_CursorUintTable[TimeBaseId][1] == 3){sprintf(buf, "%5.2fms", g_Cursors->WaveCursorB);}else if(g_CursorUintTable[TimeBaseId][1] == 4){sprintf(buf, "%5.1fms", g_Cursors->WaveCursorB);}else if(g_CursorUintTable[TimeBaseId][1] == 5){sprintf(buf, "%5.3fs", g_Cursors->WaveCursorB);}else if(g_CursorUintTable[TimeBaseId][1] == 6){sprintf(buf, "%5.2fs", g_Cursors->WaveCursorB);}else if(g_CursorUintTable[TimeBaseId][1] == 7){sprintf(buf, "%5.1fs", g_Cursors->WaveCursorB);}GUI_DispStringAt(buf, 523, 91);/* 第5步:计算竖线A竖线B的差值***********************************************************/if(g_CursorUintTable[TimeBaseId][1] == 1){sprintf(buf, "%5.1fus", (g_Cursors->WaveCursorB - g_Cursors->WaveCursorA));}else if(g_CursorUintTable[TimeBaseId][1] == 2){sprintf(buf, "%5.3fms", (g_Cursors->WaveCursorB - g_Cursors->WaveCursorA));}else if(g_CursorUintTable[TimeBaseId][1] == 3){sprintf(buf, "%5.2fms", (g_Cursors->WaveCursorB - g_Cursors->WaveCursorA));}else if(g_CursorUintTable[TimeBaseId][1] == 4){sprintf(buf, "%5.1fms", (g_Cursors->WaveCursorB - g_Cursors->WaveCursorA));}else if(g_CursorUintTable[TimeBaseId][1] == 5){sprintf(buf, "%5.3fs", (g_Cursors->WaveCursorB - g_Cursors->WaveCursorA));}else if(g_CursorUintTable[TimeBaseId][1] == 6){sprintf(buf, "%5.2fs", (g_Cursors->WaveCursorB - g_Cursors->WaveCursorA));}else if(g_CursorUintTable[TimeBaseId][1] == 7){sprintf(buf, "%5.1fs",(g_Cursors->WaveCursorB - g_Cursors->WaveCursorA));}GUI_DispStringAt(buf, 523, 115);/* 第6步:显示水平线的计算数值***********************************************************/GUI_DispCharAt('#', 509+72, 115);g_Cursors->WaveCursorA = (float)((240 - g_Cursors->sCursorHA) * g_AttTable[Ch1AmpId][1]) / 50000;sprintf(buf, "%5.3fV", g_Cursors->WaveCursorA);GUI_DispStringAt(buf, 518+72, 63);g_Cursors->WaveCursorB = (float)((240 - g_Cursors->sCursorHB) * g_AttTable[Ch1AmpId][1]) / 50000;sprintf(buf, "%5.3fV", g_Cursors->WaveCursorB);   GUI_DispStringAt(buf, 518+70, 91);sprintf(buf, "%5.3fV", g_Cursors->WaveCursorA - g_Cursors->WaveCursorB);GUI_DispStringAt(buf, 520+70, 115);}

水平测量的实现比较简单,就是2D函数调用和字符显示。如果大家要自己实现,按照代码中注释的步骤制作即可。测量功能的调节是通过开发板上面的摇杆实现的。

8.2   垂直测量功能

垂直测量方式的效果如下:

 

垂直测量功能的数据显示不要以窗口的形式呈现,因为将窗口显示在波形显示区上会造成波形刷新慢。当前的方案是在绘制完毕波形后,直接2D函数绘制测量窗口,这种方式的实际效果好很多。对应的代码如下:

/***********************************************************************************************************    函 数 名: DSO_DrawCursorV*    功能说明: 绘制示波器的垂直测量游标,用于测量的时间。*    形    参: 无          *    返 回 值: 无**********************************************************************************************************/void DSO_DrawCursorV(void){char buf[60];/* 第1步:绘制用于测量的两个游标线********************************************************/GUI_SetColor(0x0040f0);/* 绘制竖线A */GUI_DrawVLine(g_Cursors->sCursorVA, DSOSCREEN_STARTY, DSOSCREEN_ENDY);GUI_DrawVLine(g_Cursors->sCursorVA+1, DSOSCREEN_STARTY, DSOSCREEN_ENDY); GUI_FillRoundedRect(g_Cursors->sCursorVA+5, 47, g_Cursors->sCursorVA+16, 62, 3);/* 绘制竖线B */GUI_DrawVLine(g_Cursors->sCursorVB, DSOSCREEN_STARTY, DSOSCREEN_ENDY);GUI_DrawVLine(g_Cursors->sCursorVB-1, DSOSCREEN_STARTY, DSOSCREEN_ENDY);GUI_FillRoundedRect(g_Cursors->sCursorVB-16, 47, g_Cursors->sCursorVB-5, 62, 3);/* 在竖线A和竖线B旁边的小圆圈中显示字母a和字母b */GUI_SetColor(GUI_BLACK);GUI_SetFont(&GUI_Font20_ASCII);GUI_SetTextMode(GUI_TEXTMODE_TRANS);                   GUI_DispCharAt('a', g_Cursors->sCursorVA+6, 44);GUI_DispCharAt('b', g_Cursors->sCursorVB-15, 45);/* 第2步:绘制游标数据显示窗口********************************************************/GUI_SetColor(GUI_BLACK);GUI_FillRoundedRect(500, 55, 635, 135, 4);GUI_SetColor(GUI_WHITE);GUI_DrawRoundedRect( 499, 54, 636, 136, 4);GUI_SetColor(0x0040f0);GUI_FillRoundedRect(75 + 433 , 47 + 15, 86 + 433, 62 + 15, 3);                GUI_FillRoundedRect(75 + 433 , 45 + 45, 86 + 433, 60 + 45, 3);GUI_SetColor(GUI_BLACK);GUI_SetFont(&GUI_Font20_1);GUI_SetTextMode(GUI_TEXTMODE_TRANS);                   GUI_DispCharAt('a', 509, 59);GUI_DispCharAt('b', 509, 88);GUI_SetColor(GUI_YELLOW);GUI_SetFont(&GUI_Font16_1);GUI_DispCharAt('#', 513, 115);/* 第3步:计算竖线A的数值***********************************************************/g_Cursors->WaveCursorA = (float)((g_Cursors->sCursorVA - 340) * g_CursorUintTable[TimeBaseId][0])/1000;if(g_CursorUintTable[TimeBaseId][1] == 1){sprintf(buf, "%5.1fus", g_Cursors->WaveCursorA);}else if(g_CursorUintTable[TimeBaseId][1] == 2){sprintf(buf, "%5.3fms", g_Cursors->WaveCursorA);}else if(g_CursorUintTable[TimeBaseId][1] == 3){sprintf(buf, "%5.2fms", g_Cursors->WaveCursorA);}else if(g_CursorUintTable[TimeBaseId][1] == 4){sprintf(buf, "%5.1fms", g_Cursors->WaveCursorA);}else if(g_CursorUintTable[TimeBaseId][1] == 5){sprintf(buf, "%5.3fs", g_Cursors->WaveCursorA);}else if(g_CursorUintTable[TimeBaseId][1] == 6){sprintf(buf, "%5.2fs",g_Cursors->WaveCursorA);}else if(g_CursorUintTable[TimeBaseId][1] == 7){sprintf(buf, "%5.1fs", g_Cursors->WaveCursorA);}/* 显示竖线A数值 */GUI_DispStringAt(buf, 523, 63);/* 第4步:计算竖线B的数值***********************************************************/g_Cursors->WaveCursorB = (float)((g_Cursors->sCursorVB - 340) * g_CursorUintTable[TimeBaseId][0])/1000;if(g_CursorUintTable[TimeBaseId][1] == 1){sprintf(buf, "%5.1fus", g_Cursors->WaveCursorB);}else if(g_CursorUintTable[TimeBaseId][1] == 2){sprintf(buf, "%5.3fms", g_Cursors->WaveCursorB);}else if(g_CursorUintTable[TimeBaseId][1] == 3){sprintf(buf, "%5.2fms", g_Cursors->WaveCursorB);}else if(g_CursorUintTable[TimeBaseId][1] == 4){sprintf(buf, "%5.1fms", g_Cursors->WaveCursorB);}else if(g_CursorUintTable[TimeBaseId][1] == 5){sprintf(buf, "%5.3fs", g_Cursors->WaveCursorB);}else if(g_CursorUintTable[TimeBaseId][1] == 6){sprintf(buf, "%5.2fs", g_Cursors->WaveCursorB);}else if(g_CursorUintTable[TimeBaseId][1] == 7){sprintf(buf, "%5.1fs", g_Cursors->WaveCursorB);}/* 显示竖线B数值 */GUI_DispStringAt(buf, 523, 91);/* 第5步:计算竖线A竖线B的差值***********************************************************/if(g_CursorUintTable[TimeBaseId][1] == 1){sprintf(buf, "%5.1fus", (g_Cursors->WaveCursorB - g_Cursors->WaveCursorA));}else if(g_CursorUintTable[TimeBaseId][1] == 2){sprintf(buf, "%5.3fms", (g_Cursors->WaveCursorB - g_Cursors->WaveCursorA));}else if(g_CursorUintTable[TimeBaseId][1] == 3){sprintf(buf, "%5.2fms", (g_Cursors->WaveCursorB - g_Cursors->WaveCursorA));}else if(g_CursorUintTable[TimeBaseId][1] == 4){sprintf(buf, "%5.1fms", (g_Cursors->WaveCursorB - g_Cursors->WaveCursorA));}else if(g_CursorUintTable[TimeBaseId][1] == 5){sprintf(buf, "%5.3fs", (g_Cursors->WaveCursorB - g_Cursors->WaveCursorA));}else if(g_CursorUintTable[TimeBaseId][1] == 6){sprintf(buf, "%5.2fs", (g_Cursors->WaveCursorB - g_Cursors->WaveCursorA));}else if(g_CursorUintTable[TimeBaseId][1] == 7){sprintf(buf, "%5.1fs",(g_Cursors->WaveCursorB - g_Cursors->WaveCursorA));}/* 显示竖线A和竖线B的差值 */GUI_DispStringAt(buf, 523, 115);/* 第6步:显示水平线的计算数值***********************************************************/GUI_DispCharAt('#', 509+72, 115);g_Cursors->WaveCursorA = (float)((240 - g_Cursors->sCursorHA) * g_AttTable[Ch1AmpId][1]) / 50000;sprintf(buf, "%5.3fV", g_Cursors->WaveCursorA);GUI_DispStringAt(buf, 518+72, 63);g_Cursors->WaveCursorB = (float)((240 - g_Cursors->sCursorHB) * g_AttTable[Ch1AmpId][1]) / 50000;sprintf(buf, "%5.3fV", g_Cursors->WaveCursorB);   GUI_DispStringAt(buf, 518+70, 91);sprintf(buf, "%5.3fV", g_Cursors->WaveCursorA - g_Cursors->WaveCursorB);GUI_DispStringAt(buf, 520+70, 115);}

垂直测量的实现比较简单,就是2D函数调用和字符显示。如果大家要自己实现,按照代码中注释的步骤制作即可。测量功能的调节是通过开发板上面的摇杆实现的。

8.3   总结

由于测量功能的实现比较简单,所以我们这里只是简单的进行了说明。如果大家要自己制作的话,建议实际操作下。

 

转载于:https://www.cnblogs.com/armfly/p/9253918.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/389305.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

深度学习数据更换背景_开始学习数据科学的最佳方法是了解其背景

深度学习数据更换背景数据科学教育 (DATA SCIENCE EDUCATION) 目录 (Table of Contents) The Importance of Context Knowledge 情境知识的重要性 (Optional) Research Supporting Context-Based Learning (可选)研究支持基于上下文的学习 The Context of Data Science 数据科学…

熊猫数据集_用熊猫掌握数据聚合

熊猫数据集Data aggregation is the process of gathering data and expressing it in a summary form. This typically corresponds to summary statistics for numerical and categorical variables in a data set. In this post we will discuss how to aggregate data usin…

IOS CALayer的属性和使用

一、CALayer的常用属性 1、propertyCGPoint position; 图层中心点的位置,类似与UIView的center;用来设置CALayer在父层中的位置;以父层的左上角为原点(0,0); 2、 property CGPoint anchorPoint…

QZEZ第一届“饭吉圆”杯程序设计竞赛

终于到了饭吉圆杯的开赛,这是EZ我参与的历史上第一场ACM赛制的题目然而没有罚时 不过题目很好,举办地也很成功,为法老点赞!!! 这次和翰爷,吴骏达 dalao,陈乐扬dalao组的队&#xff0…

谈谈数据分析 caoz_让我们谈谈开放数据…

谈谈数据分析 caozAccording to the International Open Data Charter(1), it defines open data as those digital data that are made available with the technical and legal characteristics necessary so that they can be freely used, reused and redistributed by any…

数据创造价值_展示数据并创造价值

数据创造价值To create the maximum value, urgency, and leverage in a data partnership, you must present the data available for sale or partnership in a clear and comprehensive way. Partnerships are based upon the concept that you are offering value for valu…

卷积神经网络——各种网络的简洁介绍和实现

各种网络模型:来源《动手学深度学习》 一,卷积神经网络(LeNet) LeNet分为卷积层块和全连接层块两个部分。下面我们分别介绍这两个模块。 卷积层块里的基本单位是卷积层后接最大池化层:卷积层用来识别图像里的空间模…

数据中台是下一代大数据_全栈数据科学:下一代数据科学家群体

数据中台是下一代大数据重点 (Top highlight)Data science has been an eye-catching field for many years now to young individuals having formal education with a bachelors, masters or Ph.D. in computer science, statistics, business analytics, engineering manage…

pwn学习之四

本来以为应该能出一两道ctf的pwn了,结果又被sctf打击了一波。 bufoverflow_a 做这题时libc和堆地址都泄露完成了,卡在了unsorted bin attack上,由于delete会清0变量导致无法写,一直没构造出unsorted bin attack,后面根…

北方工业大学gpa计算_北方大学联盟仓库的探索性分析

北方工业大学gpa计算This is my firts publication here and i will start simple.这是我的第一篇出版物,这里我将简单介绍 。 I want to make an exploratory data analysis of UFRN’s warehouse and answer some questions about the data using Python and Pow…

泰坦尼克数据集预测分析_探索性数据分析-泰坦尼克号数据集案例研究(第二部分)

泰坦尼克数据集预测分析Data is simply useless until you don’t know what it’s trying to tell you.除非您不知道数据在试图告诉您什么,否则数据将毫无用处。 With this quote we’ll continue on our quest to find the hidden secrets of the Titanic. ‘The …

关于我

我是谁? Who am I?这是个哲学问题。。 简单来说,我是Light,一个靠前端吃饭,又不想单单靠前端吃饭的Coder。 用以下几点稍微给自己打下标签: 工作了两三年,对,我是16年毕业的90后一直…

基于PyTorch搭建CNN实现视频动作分类任务代码详解

数据及具体讲解来源: 基于PyTorch搭建CNN实现视频动作分类任务 import torch import torch.nn as nn import torchvision.transforms as T import scipy.io from torch.utils.data import DataLoader,Dataset import os from PIL import Image from torch.autograd…

missforest_missforest最佳丢失数据插补算法

missforestMissing data often plagues real-world datasets, and hence there is tremendous value in imputing, or filling in, the missing values. Unfortunately, standard ‘lazy’ imputation methods like simply using the column median or average don’t work wel…

华硕猛禽1080ti_F-22猛禽动力回路的视频分析

华硕猛禽1080tiThe F-22 Raptor has vectored thrust. This means that the engines don’t just push towards the front of the aircraft. Instead, the thrust can be directed upward or downward (from the rear of the jet). With this vectored thrust, the Raptor can …

Memory-Associated Differential Learning论文及代码解读

Memory-Associated Differential Learning论文及代码解读 论文来源: 论文PDF: Memory-Associated Differential Learning论文 论文代码: Memory-Associated Differential Learning代码 论文解读: 1.Abstract Conventional…

大数据技术 学习之旅_如何开始您的数据科学之旅?

大数据技术 学习之旅Machine Learning seems to be fascinating to a lot of beginners but they often get lost into the pool of information available across different resources. This is true that we have a lot of different algorithms and steps to learn but star…

数据可视化工具_数据可视化

数据可视化工具Visualizations are a great way to show the story that data wants to tell. However, not all visualizations are built the same. My rule of thumb is stick to simple, easy to understand, and well labeled graphs. Line graphs, bar charts, and histo…

Android Studio调试时遇见Install Repository and sync project的问题

我们可以看到,报的错是“Failed to resolve: com.android.support:appcompat-v7:16.”,也就是我们在build.gradle中最后一段中的compile项内容。 AS自动生成的“com.android.support:appcompat-v7:16.”实际上是根据我们的最低版本16来选择16.x.x及以上编…

VGAE(Variational graph auto-encoders)论文及代码解读

一,论文来源 论文pdf Variational graph auto-encoders 论文代码 github代码 二,论文解读 理论部分参考: Variational Graph Auto-Encoders(VGAE)理论参考和源码解析 VGAE(Variational graph auto-en…