#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "global.h"
#include "CH341DLL.H"
int iEvent =USB_IIC_DEV_UNKNOW;
void CALLBACK CH341_NOTIFY_ROUTINE(ULONG iEventStatus) // IIC设备事件通知回调程序
{
iEvent = static_cast<int>(iEventStatus);
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
IIC_mIndex=0;
setWindowFlags(Qt::FramelessWindowHint);
QFile file(":/res/mySheetStyle.qss");
file.open(QFile::ReadOnly);
QTextStream filetext(&file);
QString stylesheet = filetext.readAll();
this->setStyleSheet(stylesheet);
file.close();
CH341SetDeviceNotify(IIC_mIndex, reinterpret_cast<char*>(NULL), CH341_NOTIFY_ROUTINE); //IIC注册监视通知
if (CH341OpenDevice(IIC_mIndex) == INVALID_HANDLE_VALUE)
{
ui->USB_STA->setText(S_IIC_OUT);
ui->USB_STA->setStyleSheet("background-color:gray");
}
else
{
ui->USB_STA->setText(S_IIC_INTO);
ui->USB_STA->setStyleSheet("background-color:green");
}
timer_USB_Bru = new QTimer();
connect(timer_USB_Bru,&QTimer::timeout,this, &MainWindow::timer_USB_STA_Bru_TimeOut); // 刷新IIC 状态
timer_USB_Bru->setInterval(200);
timer_USB_Bru->start();
// //** 其他USB设备监控 检测TTL电平
// m_usb_listener = new usb_listener;
// qApp->installNativeEventFilter(m_usb_listener);
// connect(m_usb_listener, &usb_listener::DevicePlugIn, [=](){
// //do something...
// ui->USB_STA->setText("其他USB已连接");
// });
// connect(m_usb_listener, &usb_listener::DevicePlugOut, [=](){
// //do something...
// ui->USB_STA->setText("USB退出");
// });
// connect(&IIC_thread, &ch341Thread::response, this, &MainWindow::showResponse);
// connect(&IIC_thread, &ch341Thread::error, this, &MainWindow::processError);
// connect(&IIC_thread, &ch341Thread::timeout, this, &MainWindow::processTimeout);
// connect(&IIC_thread, &ch341Thread::IIC_Sta, this, &MainWindow::IIC_Sta);
}
MainWindow::~MainWindow()
{
timer_USB_Bru->stop();
delete ui;
}
void MainWindow::paintEvent(QPaintEvent *)
{
// QPainter painter(this);
// painter.drawPixmap(m_pixmapBg.rect(), m_pixmapBg);
}
void MainWindow::mouseMoveEvent(QMouseEvent *e)
{
this->move(e->globalPos() - m_pointStart);
}
void MainWindow::mousePressEvent(QMouseEvent *e)
{
m_pointPress = e->globalPos();
m_pointStart = m_pointPress - this->pos();
}
void MainWindow::setNomalStyle()
{
QFile styleSheet(":/res/qss/style_360.qss");
if (!styleSheet.open(QIODevice::ReadOnly))
{
qWarning("Can't open the style sheet file.");
return;
}
qApp->setStyleSheet(styleSheet.readAll());
}
void MainWindow::initData()
{
}
void MainWindow::timer_USB_STA_Bru_TimeOut()
{
if(iEvent==USB_IIC_DEV_INTO)
{
ui->USB_STA->setText(S_IIC_INTO);
ui->USB_STA->setStyleSheet("background-color:green");
}
else if(iEvent==USB_IIC_DEV_OUT)
{
ui->USB_STA->setText(S_IIC_OUT);
ui->USB_STA->setStyleSheet("background-color:gray");
}
}
void MainWindow::showResponse(const QString &s)
{
ui->USB_STA->setText(s);
}
void MainWindow::processError(const QString &s)
{
}
void MainWindow::processTimeout(const QString &s)
{
}
void MainWindow::IIC_Sta(const QString &s)
{
ui->USB_STA->setText(s);
}
void MainWindow::on_btn_IIC_Start_clicked()
{
if(ui->btn_IIC_Start->text()=="start")
{
ui->btn_IIC_Start->setText("stop");
if(!m_workthread.isRunning())
m_workthread.start();
}
else
{ if(m_workthread.isRunning())
m_workthread.stop();
ui->btn_IIC_Start->setText("start");
}
}
void MainWindow::on_btn_Brush_clicked()
{
QString siEventStatus = QString::number(iEvent,10);
ui->USB_STA->setText(siEventStatus);
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
_USB_.zip (71个子文件)
usb_listener.h 502B
mainwindow.ui 8KB
workthread.cpp 1KB
_USB_.pro 1KB
mainwindow.cpp 4KB
CH341DLL.LIB 57KB
usb_listener.cpp 818B
res
mySheetStyle.qss 4KB
image
08.png 19KB
4.png 81KB
03.png 12KB
20.png 21KB
22.png 93KB
title.ico 17KB
12.png 18KB
3.png 88KB
33.png 90KB
66.png 86KB
cai2.png 71KB
02.png 30KB
e.ico 167KB
close.png 70KB
99.png 89KB
16.png 18KB
7.png 80KB
15.png 15KB
5.png 77KB
1.png 81KB
77.png 82KB
2.png 90KB
19.png 22KB
max2.png 70KB
55.png 80KB
04.png 21KB
17.png 20KB
min2.png 70KB
11.png 84KB
max.png 70KB
frame.jpg 119KB
09.png 20KB
06.png 20KB
21.png 17KB
close2.png 71KB
frame.png 1.21MB
44.png 84KB
6.png 83KB
8.png 82KB
9.png 86KB
cai.png 70KB
10.png 17KB
frame1.png 1.09MB
88.png 85KB
01.png 32KB
05.png 19KB
360logo.png 67KB
07.png 17KB
13.png 22KB
screen.png 4KB
min.png 70KB
18.png 19KB
14.png 22KB
CH341DLL.DLL 30KB
main.cpp 719B
workthread.h 1KB
chart.scxml 2KB
myss.qrc 2KB
mainwindow.h 1KB
_USB_.pro.user 23KB
global.h 227B
CH341DLL.H 29KB
res.qrc 1KB
共 71 条
- 1
Marco629
- 粉丝: 8
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0