kopia lustrzana https://gitlab.com/Teuniz/DSRemote
Work in progress.
rodzic
b0bdf06520
commit
143f18efb3
|
@ -58,6 +58,8 @@ HEADERS += read_settings_thread.h
|
|||
HEADERS += save_data_thread.h
|
||||
HEADERS += decode_dialog.h
|
||||
HEADERS += tdial.h
|
||||
HEADERS += wave_dialog.h
|
||||
HEADERS += wave_view.h
|
||||
|
||||
HEADERS += third_party/kiss_fft/kiss_fft.h
|
||||
HEADERS += third_party/kiss_fft/_kiss_fft_guts.h
|
||||
|
@ -85,6 +87,8 @@ SOURCES += read_settings_thread.cpp
|
|||
SOURCES += save_data_thread.cpp
|
||||
SOURCES += decode_dialog.cpp
|
||||
SOURCES += tdial.cpp
|
||||
SOURCES += wave_dialog.cpp
|
||||
SOURCES += wave_view.cpp
|
||||
|
||||
SOURCES += third_party/kiss_fft/kiss_fft.c
|
||||
SOURCES += third_party/kiss_fft/kiss_fftr.c
|
||||
|
|
8
global.h
8
global.h
|
@ -35,7 +35,7 @@
|
|||
|
||||
|
||||
#define PROGRAM_NAME "DSRemote"
|
||||
#define PROGRAM_VERSION "0.33_1612261016"
|
||||
#define PROGRAM_VERSION "0.33_1612281147"
|
||||
|
||||
#define MAX_PATHLEN 4096
|
||||
|
||||
|
@ -92,7 +92,7 @@
|
|||
#define DECODE_MODE_SPI 2
|
||||
#define DECODE_MODE_I2C 3
|
||||
|
||||
#define DECODE_MAX_CHARS 256
|
||||
#define DECODE_MAX_CHARS 512
|
||||
|
||||
|
||||
|
||||
|
@ -173,7 +173,7 @@ struct device_settings
|
|||
int acquiretype; // 0=normal, 1=average, 2=peak, 3=highres
|
||||
int acquireaverages; // 2, 4, 8, 16, 32, 64, etc. to 8192
|
||||
int acquirememdepth; // Number of waveform points that the oscilloscope can
|
||||
//store in a single trigger sample. 0=AUTO
|
||||
// store in a single trigger sample. 0=AUTO
|
||||
|
||||
int countersrc; // 0=off, 1=ch1, 2=ch2, 3=ch3, 4=ch4
|
||||
double counterfreq; // Value of frequency counter
|
||||
|
@ -273,6 +273,8 @@ struct device_settings
|
|||
int current_screen_sf;
|
||||
|
||||
int show_fps;
|
||||
|
||||
int wave_mem_view_sample_start;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1486,15 +1486,28 @@ void UI_Mainwindow::saveButtonClicked()
|
|||
{
|
||||
QMenu menu;
|
||||
|
||||
menu.addAction("Save screen waveform", this, SLOT(save_screen_waveform()));
|
||||
menu.addAction("Save memory waveform", this, SLOT(save_memory_waveform()));
|
||||
menu.addAction("Save screenshot", this, SLOT(save_screenshot()));
|
||||
menu.addAction("Factory", this, SLOT(set_to_factory()));
|
||||
menu.addAction("Save screen waveform", this, SLOT(save_screen_waveform()));
|
||||
menu.addAction("Save memory waveform", this, SLOT(save_mem_wav()));
|
||||
menu.addAction("Analyze memory waveform", this, SLOT(analyze_mem_wav()));
|
||||
menu.addAction("Save screenshot", this, SLOT(save_screenshot()));
|
||||
menu.addAction("Factory", this, SLOT(set_to_factory()));
|
||||
|
||||
menu.exec(saveButton->mapToGlobal(QPoint(0,0)));
|
||||
}
|
||||
|
||||
|
||||
void UI_Mainwindow::save_mem_wav()
|
||||
{
|
||||
save_memory_waveform(1);
|
||||
}
|
||||
|
||||
|
||||
void UI_Mainwindow::analyze_mem_wav()
|
||||
{
|
||||
save_memory_waveform(0);
|
||||
}
|
||||
|
||||
|
||||
void UI_Mainwindow::dispButtonClicked()
|
||||
{
|
||||
QMenu menu,
|
||||
|
|
|
@ -90,6 +90,7 @@
|
|||
#include "save_data_thread.h"
|
||||
#include "decode_dialog.h"
|
||||
#include "tdial.h"
|
||||
#include "wave_dialog.h"
|
||||
|
||||
#include "third_party/kiss_fft/kiss_fftr.h"
|
||||
|
||||
|
@ -239,6 +240,7 @@ private:
|
|||
void serial_decoder(void);
|
||||
inline unsigned char reverse_bitorder_8(unsigned char);
|
||||
inline unsigned int reverse_bitorder_32(unsigned int);
|
||||
void save_memory_waveform(int);
|
||||
|
||||
private slots:
|
||||
|
||||
|
@ -260,7 +262,8 @@ private slots:
|
|||
void open_settings_dialog();
|
||||
int get_device_settings();
|
||||
void save_screen_waveform();
|
||||
void save_memory_waveform();
|
||||
void save_mem_wav();
|
||||
void analyze_mem_wav();
|
||||
void save_screenshot();
|
||||
|
||||
void adjDialChanged(int);
|
||||
|
|
|
@ -179,7 +179,7 @@ OUT_ERROR:
|
|||
}
|
||||
|
||||
|
||||
void UI_Mainwindow::save_memory_waveform()
|
||||
void UI_Mainwindow::save_memory_waveform(int job)
|
||||
{
|
||||
int i, j, k,
|
||||
n=0,
|
||||
|
@ -269,7 +269,7 @@ void UI_Mainwindow::save_memory_waveform()
|
|||
|
||||
rec_len = (EDFLIB_TIME_DIMENSION * (long long)mempnts) / devparms.samplerate;
|
||||
|
||||
if(rec_len < 100)
|
||||
if((job == 1) && (rec_len < 100))
|
||||
{
|
||||
strcpy(str, "Can not save waveforms shorter than 10 uSec.\n"
|
||||
"Set the horizontal timebase to 1 uSec or higher.");
|
||||
|
@ -406,6 +406,12 @@ void UI_Mainwindow::save_memory_waveform()
|
|||
goto OUT_ERROR;
|
||||
}
|
||||
|
||||
if(n == 0)
|
||||
{
|
||||
sprintf(str, "No waveform data available.");
|
||||
goto OUT_ERROR;
|
||||
}
|
||||
|
||||
printf("received %i bytes, total %i bytes\n", n, n + bytes_rcvd);
|
||||
|
||||
if(n > SAV_MEM_BSZ)
|
||||
|
@ -426,14 +432,29 @@ void UI_Mainwindow::save_memory_waveform()
|
|||
empty_buf = 0;
|
||||
}
|
||||
|
||||
for(k=0; k<n; k++)
|
||||
if(job == 1)
|
||||
{
|
||||
if((bytes_rcvd + k) >= mempnts)
|
||||
for(k=0; k<n; k++)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if((bytes_rcvd + k) >= mempnts)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
wavbuf[chn][bytes_rcvd + k] = ((int)(((unsigned char *)device->buf)[k]) - yref[chn] - yor[chn]) << 5;
|
||||
wavbuf[chn][bytes_rcvd + k] = ((int)(((unsigned char *)device->buf)[k]) - yref[chn] - yor[chn]) << 5;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(k=0; k<n; k++)
|
||||
{
|
||||
if((bytes_rcvd + k) >= mempnts)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
wavbuf[chn][bytes_rcvd + k] = (int)(((unsigned char *)device->buf)[k]) - yref[chn] - yor[chn];
|
||||
}
|
||||
}
|
||||
|
||||
bytes_rcvd += n;
|
||||
|
@ -502,6 +523,13 @@ void UI_Mainwindow::save_memory_waveform()
|
|||
statusLabel->setText("Downloading finished");
|
||||
}
|
||||
|
||||
if(job == 0)
|
||||
{
|
||||
new UI_wave_window(&devparms, wavbuf, this);
|
||||
|
||||
goto OUT_NORMAL;
|
||||
}
|
||||
|
||||
opath[0] = 0;
|
||||
if(recent_savedir[0]!=0)
|
||||
{
|
||||
|
@ -597,15 +625,18 @@ OUT_NORMAL:
|
|||
disconnect(&get_data_thrd, 0, 0, 0);
|
||||
disconnect(&sav_data_thrd, 0, 0, 0);
|
||||
|
||||
if(hdl >= 0)
|
||||
if(job == 1)
|
||||
{
|
||||
edfclose_file(hdl);
|
||||
}
|
||||
if(hdl >= 0)
|
||||
{
|
||||
edfclose_file(hdl);
|
||||
}
|
||||
|
||||
for(chn=0; chn<MAX_CHNS; chn++)
|
||||
{
|
||||
free(wavbuf[chn]);
|
||||
wavbuf[chn] = NULL;
|
||||
for(chn=0; chn<MAX_CHNS; chn++)
|
||||
{
|
||||
free(wavbuf[chn]);
|
||||
wavbuf[chn] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
scrn_timer->start(devparms.screentimerival);
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
|
||||
|
||||
|
||||
#ifndef SELECT_DEVICE_FORM1_H
|
||||
#define SELECT_DEVICE_FORM1_H
|
||||
#ifndef SETTINGS_DIALOG_H
|
||||
#define SETTINGS_DIALOG_H
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
***************************************************************************
|
||||
*
|
||||
* Author: Teunis van Beelen
|
||||
*
|
||||
* Copyright (C) 2016 Teunis van Beelen
|
||||
*
|
||||
* Email: teuniz@gmail.com
|
||||
*
|
||||
***************************************************************************
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "wave_dialog.h"
|
||||
|
||||
|
||||
|
||||
UI_wave_window::UI_wave_window(struct device_settings *p_devparms, short *wbuf[MAX_CHNS], QWidget *parnt)
|
||||
{
|
||||
int i, samples_per_div;
|
||||
|
||||
mainwindow = (UI_Mainwindow *)parnt;
|
||||
|
||||
setMinimumSize(840, 635);
|
||||
setWindowTitle("Wave Memory");
|
||||
|
||||
devparms = (struct device_settings *)calloc(1, sizeof(struct device_settings));
|
||||
if(devparms == NULL)
|
||||
{
|
||||
printf("Malloc error! file: %s line: %i", __FILE__, __LINE__);
|
||||
}
|
||||
else
|
||||
{
|
||||
*devparms = *p_devparms;
|
||||
}
|
||||
|
||||
for(i=0; i<MAX_CHNS; i++)
|
||||
{
|
||||
devparms->wavebuf[i] = wbuf[i];
|
||||
}
|
||||
|
||||
devparms->wavebufsz = devparms->acquirememdepth;
|
||||
|
||||
if(devparms->timebasedelayenable)
|
||||
{
|
||||
samples_per_div = devparms->samplerate * devparms->timebasedelayscale;
|
||||
}
|
||||
else
|
||||
{
|
||||
samples_per_div = devparms->samplerate * devparms->timebasescale;
|
||||
}
|
||||
|
||||
devparms->timebasedelayenable = 0;
|
||||
|
||||
wavcurve = new WaveCurve;
|
||||
wavcurve->setBackgroundColor(Qt::black);
|
||||
wavcurve->setSignalColor1(Qt::yellow);
|
||||
wavcurve->setSignalColor2(Qt::cyan);
|
||||
wavcurve->setSignalColor3(Qt::magenta);
|
||||
wavcurve->setSignalColor4(QColor(0, 128, 255));
|
||||
wavcurve->setRasterColor(Qt::darkGray);
|
||||
wavcurve->setBorderSize(40);
|
||||
wavcurve->setDeviceParameters(devparms);
|
||||
|
||||
wavslider = new QSlider;
|
||||
wavslider->setOrientation(Qt::Horizontal);
|
||||
wavslider->setRange(0, devparms->wavebufsz - (devparms->hordivisions * samples_per_div));
|
||||
wavslider->setValue((devparms->wavebufsz - (devparms->hordivisions * samples_per_div)) / 2);
|
||||
|
||||
devparms->wave_mem_view_sample_start = wavslider->value();
|
||||
|
||||
g_layout = new QGridLayout(this);
|
||||
g_layout->addWidget(wavcurve, 0, 0);
|
||||
g_layout->addWidget(wavslider, 1, 0);
|
||||
|
||||
connect(wavslider, SIGNAL(sliderMoved(int)), this, SLOT(wavslider_value_changed(int)));
|
||||
|
||||
show();
|
||||
}
|
||||
|
||||
|
||||
UI_wave_window::~UI_wave_window()
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0; i<MAX_CHNS; i++)
|
||||
{
|
||||
free(devparms->wavebuf[i]);
|
||||
}
|
||||
|
||||
free(devparms);
|
||||
}
|
||||
|
||||
|
||||
void UI_wave_window::wavslider_value_changed(int val)
|
||||
{
|
||||
devparms->wave_mem_view_sample_start = val;
|
||||
|
||||
wavcurve->update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
***************************************************************************
|
||||
*
|
||||
* Author: Teunis van Beelen
|
||||
*
|
||||
* Copyright (C) 2016 Teunis van Beelen
|
||||
*
|
||||
* Email: teuniz@gmail.com
|
||||
*
|
||||
***************************************************************************
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef WAVE_DIALOG_H
|
||||
#define WAVE_DIALOG_H
|
||||
|
||||
|
||||
|
||||
#include <QApplication>
|
||||
#include <QObject>
|
||||
#include <QDialog>
|
||||
#include <QGridLayout>
|
||||
#include <QSlider>
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "global.h"
|
||||
#include "wave_view.h"
|
||||
|
||||
|
||||
class UI_Mainwindow;
|
||||
|
||||
class WaveCurve;
|
||||
|
||||
|
||||
class UI_wave_window : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
UI_wave_window(struct device_settings *, short *wbuf[MAX_CHNS], QWidget *parent=0);
|
||||
~UI_wave_window();
|
||||
|
||||
private:
|
||||
|
||||
struct device_settings *devparms;
|
||||
|
||||
UI_Mainwindow *mainwindow;
|
||||
|
||||
QGridLayout *g_layout;
|
||||
|
||||
WaveCurve *wavcurve;
|
||||
|
||||
QSlider *wavslider;
|
||||
|
||||
private slots:
|
||||
|
||||
void wavslider_value_changed(int);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
Plik diff jest za duży
Load Diff
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
***************************************************************************
|
||||
*
|
||||
* Author: Teunis van Beelen
|
||||
*
|
||||
* Copyright (C) 2016 Teunis van Beelen
|
||||
*
|
||||
* Email: teuniz@gmail.com
|
||||
*
|
||||
***************************************************************************
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef WAVECURVE_H
|
||||
#define WAVECURVE_H
|
||||
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QWidget>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
#include <QPushButton>
|
||||
#include <QPen>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QFont>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "utils.h"
|
||||
#include "wave_dialog.h"
|
||||
|
||||
|
||||
class UI_wave_window;
|
||||
|
||||
|
||||
class WaveCurve: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
WaveCurve(QWidget *parent=0);
|
||||
|
||||
QSize sizeHint() const {return minimumSizeHint(); }
|
||||
QSize minimumSizeHint() const {return QSize(30,10); }
|
||||
|
||||
void setSignalColor1(QColor);
|
||||
void setSignalColor2(QColor);
|
||||
void setSignalColor3(QColor);
|
||||
void setSignalColor4(QColor);
|
||||
void setTraceWidth(int);
|
||||
void setBackgroundColor(QColor);
|
||||
void setRasterColor(QColor);
|
||||
void setTextColor(QColor);
|
||||
void setBorderSize(int);
|
||||
void setDeviceParameters(struct device_settings *);
|
||||
|
||||
|
||||
private slots:
|
||||
|
||||
private:
|
||||
|
||||
QColor SignalColor[MAX_CHNS],
|
||||
BackgroundColor,
|
||||
RasterColor,
|
||||
TextColor;
|
||||
|
||||
QFont smallfont;
|
||||
|
||||
double v_sense;
|
||||
|
||||
int bufsize,
|
||||
bordersize,
|
||||
tracewidth,
|
||||
w,
|
||||
h,
|
||||
old_w,
|
||||
chan_arrow_pos[MAX_CHNS],
|
||||
trig_level_arrow_pos,
|
||||
trig_pos_arrow_pos,
|
||||
trig_pos_arrow_moving,
|
||||
use_move_events,
|
||||
mouse_x,
|
||||
mouse_y,
|
||||
mouse_old_x,
|
||||
mouse_old_y;
|
||||
|
||||
void drawArrow(QPainter *, int, int, int, QColor, char);
|
||||
void drawSmallTriggerArrow(QPainter *, int, int, int, QColor);
|
||||
void drawTrigCenterArrow(QPainter *, int, int);
|
||||
void drawTopLabels(QPainter *);
|
||||
void paintLabel(QPainter *, int, int, int, int, const char *, QColor);
|
||||
void draw_decoder(QPainter *, int, int);
|
||||
int ascii_decode_control_char(char, char *);
|
||||
|
||||
struct device_settings *devparms;
|
||||
|
||||
UI_wave_window *wavedialog;
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *);
|
||||
void mousePressEvent(QMouseEvent *);
|
||||
void mouseReleaseEvent(QMouseEvent *);
|
||||
void mouseMoveEvent(QMouseEvent *);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
Ładowanie…
Reference in New Issue