Browse Source

update

master
zhaohe 1 year ago
parent
commit
878ee15bf7
  1. 13
      libzqt/widgetplot2d.cpp
  2. 9
      mainwindow.cpp

13
libzqt/widgetplot2d.cpp

@ -110,12 +110,12 @@ void WidgetPlot2D::initGraphName(QStringList name) {
}
/* 添加数据 */
void WidgetPlot2D::addData(QString name, double value, int abs) {
void WidgetPlot2D::addData(QString name, double value, int offms) {
// 如果点击了“暂停”按钮,则不绘制图形
if (ui->pausePBtn->text() == "开始") return;
// 系统当前时间 = 系统运行初始时间 + 系统运行时间
static double start = 0;
double key = abs;
static double start = time.hour() * 60 * 60 + time.minute() * 60 + time.second() + time.msec() / 1000.0;
double key = start + time.elapsed() / 1000.0 + offms / 1000;
// double start = 0;
// static int key = 0;
// key++;
@ -129,7 +129,7 @@ void WidgetPlot2D::addData(QString name, double value, int abs) {
ui->customPlot->rescaleAxes();
}
// 设置时间轴
int timeAxis = ui->customPlot->xAxis->range().size();
int timeAxis = ui->timeAxisSpin->value();
ui->customPlot->xAxis->setRange(key, timeAxis, Qt::AlignRight);
// x轴和y轴全程显示
if (ui->fullShowCheck->isChecked()) {
@ -152,7 +152,7 @@ void WidgetPlot2D::addData(QString name, double value, int abs) {
static int frameCount = 0;
frameCount++;
// 每2秒显示一次帧率
if (key - lastFpsKey > 50) {
if (key - lastFpsKey > 0.5) {
uint64_t sum = 0;
for (int i = 0; i < ui->customPlot->plottableCount(); i++) {
sum += uint64_t(ui->customPlot->graph(i)->data()->size());
@ -440,8 +440,7 @@ void WidgetPlot2D::savePlotPng() {
void WidgetPlot2D::horzScrollBarChanged(int value) {
// 若全程显示,则不移动绘图坐标
if (ui->fullShowCheck->isChecked()) return;
// int timeAxis = ui->timeAxisSpin->value();
int timeAxis = ui->customPlot->xAxis->range().size();
int timeAxis = ui->timeAxisSpin->value();
ui->customPlot->xAxis->setRange(value, timeAxis, Qt::AlignRight);
ui->customPlot->replot();
}

9
mainwindow.cpp

@ -285,13 +285,16 @@ void MainWindow::constructUI() {
lostpacket++;
}
lastpacket_index = heartrate_report->sample_data_index;
reportPreviewShow("[preview data ] lost:%d index %d %d", lostpacket, heartrate_report->sample_data_index, packetlen);
uint32_t timestamp = *(uint32_t*)(&heartrate_report->data[50*4]);
reportPreviewShow("[preview data ] timestamp:%10d lost:%d index %d packetlen %d", timestamp,lostpacket, heartrate_report->sample_data_index, packetlen);
int32_t *frame = (int32_t *)heartrate_report->data;
for (int i = 0; i < 50; i++) {
int32_t data = frame[i];
int32_t data = frame[i];
int32_t frameIndex = heartrate_report->sample_data_index + i;
emit doinui_signal(QFunction([this, data, frameIndex]() { wp2d->addData("心电", data, frameIndex); }));
emit doinui_signal(QFunction([this, data, i]() { wp2d->addData("心电", data, i * 2); }));
}
}
}

Loading…
Cancel
Save