当前位置:网站首页>零基础学习CANoe Panel(14)——二极管( LED Control )和液晶屏(LCD Control)
零基础学习CANoe Panel(14)——二极管( LED Control )和液晶屏(LCD Control)
2022-07-25 12:25:00 【蚂蚁小兵】
- 我是蚂蚁小兵,专注于车载诊断领域,尤其擅长于对CANoe工具的使用
- 寻找组织 ,答疑解惑,摸鱼聊天,博客源码,点击加入【相亲相爱一家人】
- 零基础学习CANoe Panel设计目录汇总,点击跳转
前言
本节通过一个简易版的电源操作面板,来一起演示下液晶屏(LCD Control)控件和二极管( LED Control )控件
演示软硬件环境
Windows11 x64;CANoe 11 SP2 x64

液晶屏(LCD Control)
- 放置两个LCD Control取来实时显示电源电压电流
- 放置一个 LED Control 用来显示电源连接状态
- 放置两个Input/Out 控件,串口连接的配置

设置数码管数量
- 一个数字就是一个数码管,以小数位为界,可以设置整数位和小数位的显示位数
Decimal Places:整数位设置为2个Number Of Digits:小数位设置2个

数码管配色设置
- 默认配置就是点亮段时红色,背景色和没有被点亮的段时黑色
- 下面我们简单设置下数码管的颜色

电源连接和电压读取模板代码
- 下面代码,可以作为一个标准电源连接和电压读取的模板把,实际使用时,再根据具体情况加工下
/*@!Encoding:936*/
variables
{
msTimer timer_V;
msTimer timer_C;
char tempText[0x500];
int Port;
int BaudRate;
int res;
byte GetCurrentCommand [6] = {
'I','O','U','T',13,10};//13 CR ; 10 LF
byte GetVoltageCommand [6] = {
'I','O','U','T',13,10};//13 CR ; 10 LF
}
on timer timer_V
{
//RS232Send(Port, GetCurrentCommand, elCount(GetCurrentCommand));
//模拟随机值,真实硬件情况下,把RS232Send打开,然后在RS232OnReceive解析返回值
sysSetVariableFloat(sysvar::Panel::LCD_Voltage,random(5)/10.0+random(10));
setTimer(timer_V,1000);
}
on timer timer_C
{
//RS232Send(Port, GetCurrentCommand, elCount(GetCurrentCommand));
//模拟随机值,真实硬件情况下,把RS232Send打开,然后在RS232OnReceive解析返回值
sysSetVariableFloat(sysvar::Panel::LCD_Current,random(5)/10.0);
setTimer(timer_C,600);
}
on sysvar Panel::Port
{
InitPower();
}
on sysvar Panel::BaudRate
{
InitPower();
}
RS232OnReceive(dword port, byte buffer[], dword number)
{
if(buffer[0] =='V')
{
sysSetVariableFloat(sysvar::Panel::LCD_Voltage,random(5)/10+random(10)); //模拟随机值
}
else if(buffer[0] =='C')
{
sysSetVariableFloat(sysvar::Panel::LCD_Current,random(5)/10);//模拟随机值
}
}
int InitPower()
{
Port = sysGetVariableInt(sysvar::Panel::Port);
BaudRate = sysGetVariableInt(sysvar::Panel::BaudRate);
write("Port:%d ;BaudRate:%d ",Port,BaudRate);
res = RS232Open(Port);
if(res!=1)
{
write("Open COM %d Failed!",Port);
return 0;
}
res = RS232Configure(Port,BaudRate,8,1,0);
if(res!=1)
{
write("Configure COM %d Failed! :%d",Port,res);
return 0;
}
res = RS232SetHandshake(Port,0,0,0,0,0);
if(res!=1)
{
write(" Configure handshaking COM %d Failed!",Port);
return 0;
}
//配置成功
setTimer(timer_V,500);
setTimer(timer_C,600);
sysSetVariableInt(sysvar::Panel::LED_1,1);
write("Configure COM %d Ok!",Port);
return 1;
}
on stopMeasurement
{
rs232Close(Port);
}
实际测试结果

液晶屏(LED Control)
- LED Control 作为一个状态显示控件,比较简单

On Off 值和颜色属性设置
- LED Control 只有On和Off两种状态,默认 On 是1 ,OFF是0,颜色也可选

形状属性设置
- panel提供了6种可选形状


总结


- 要有最朴素的生活,最遥远的梦想,即使明天天寒地冻,路遥马亡!
- 如果这篇博客对你有帮助,请 “点赞” “评论”“收藏”一键三连 哦!码字不易,大家的支持就是我坚持下去的动力。
边栏推荐
- 论文解读(MaskGAE)《MaskGAE: Masked Graph Modeling Meets Graph Autoencoders》
- JS convert pseudo array to array
- 【AI4Code】《CodeBERT: A Pre-Trained Model for Programming and Natural Languages》 EMNLP 2020
- 3.2.1 what is machine learning?
- 【Flutter -- 布局】层叠布局(Stack和Positioned)
- More accurate and efficient segmentation of organs-at-risk in radiotherapy with Convolutional Neural
- 艰辛的旅程
- Pytorch project practice - fashionmnist fashion classification
- 【十一】矢量、栅格数据图例制作以及调整
- 【11】 Production and adjustment of vector and grid data Legends
猜你喜欢

Alibaba cloud technology expert Qin long: reliability assurance is a must - how to carry out chaos engineering on the cloud?
![[rust] reference and borrowing, string slice type (& STR) - rust language foundation 12](/img/48/7a1777b735312f29d3a4016a14598c.png)
[rust] reference and borrowing, string slice type (& STR) - rust language foundation 12

Introduction to the scratch crawler framework

Crawler crawls dynamic website

Technical management essay

485 communication (detailed explanation)

Leetcode 0133. clone diagram

clickhouse笔记03-- Grafana 接入ClickHouse

2022.07.24(LC_6126_设计食物评分系统)

2022.07.24 (lc_6124_the first letter that appears twice)
随机推荐
Moving Chinese figure liushenglan
【Flutter -- 实例】案例一:基础组件 & 布局组件综合实例
论文解读(MaskGAE)《MaskGAE: Masked Graph Modeling Meets Graph Autoencoders》
【11】 Production and adjustment of vector and grid data Legends
【9】 Coordinate grid addition and adjustment
Clickhouse notes 03-- grafana accesses Clickhouse
我想问DMS有没有定时备份某一个数据库的功能?
JS 中根据数组内元素的属性进行排序
485 communication (detailed explanation)
2022.07.24(LC_6125_相等行列对)
Excuse me, using data integration to import data from PostgreSQL to MySQL database, emoj appears in some data fields
【6】 Map box settings
Monit installation and use
R language Visual scatter diagram, geom using ggrep package_ text_ The rep function avoids overlapping labels between data points (set the min.segment.length parameter to inf and do not add label segm
Visualize the training process using tensorboard
Use of hystrix
More accurate and efficient segmentation of organs-at-risk in radiotherapy with Convolutional Neural
【九】坐标格网添加以及调整
R language uses LM function to build multiple linear regression model, step function to build forward stepwise regression model to screen the best subset of prediction variables, and scope parameter t
Crawler crawls dynamic website
