Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ set(pulseview_HEADERS
pv/data/analogsegment.hpp
pv/data/logic.hpp
pv/data/logicsegment.hpp
pv/data/mathsignalbase.hpp
pv/data/mathsignal.hpp
pv/data/signalbase.hpp
pv/dialogs/connect.hpp
Expand Down
191 changes: 191 additions & 0 deletions icons/add-math-logic-signal.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions pulseview.qrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<RCC>
<qresource prefix="/">
<file>icons/add-decoder.svg</file>
<file>icons/add-math-logic-signal.svg</file>
<file>icons/add-math-signal.svg</file>
<file>icons/application-exit.png</file>
<file>icons/channels.svg</file>
Expand Down
16 changes: 16 additions & 0 deletions pv/data/analog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,22 @@ using std::vector;
namespace pv {
namespace data {

const QColor Analog::SignalColors[8] =
{
QColor(0xC4, 0xA0, 0x00), // Yellow HSV: 49 / 100 / 77
QColor(0x87, 0x20, 0x7A), // Magenta HSV: 308 / 70 / 53
QColor(0x20, 0x4A, 0x87), // Blue HSV: 216 / 76 / 53
QColor(0x4E, 0x9A, 0x06), // Green HSV: 91 / 96 / 60
QColor(0xBF, 0x6E, 0x00), // Orange HSV: 35 / 100 / 75
QColor(0x5E, 0x20, 0x80), // Purple HSV: 280 / 75 / 50
QColor(0x20, 0x80, 0x7A), // Turqoise HSV: 177 / 75 / 50
QColor(0x80, 0x20, 0x24) // Red HSV: 358 / 75 / 50
};

const char *Analog::InvalidSignal = "\"%1\" isn't a valid analog signal";

//const SignalBase::ChannelType math_channel_type = SignalBase::AnalogMathChannel;

Analog::Analog() :
SignalData(),
samplerate_(1) // Default is 1 Hz to prevent division-by-zero errors
Expand Down
17 changes: 17 additions & 0 deletions pv/data/analog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
#include <memory>

#include <QObject>
#include <QColor>
#include "pv/data/segment.hpp"
#include "pv/data/signalbase.hpp"

using std::deque;
using std::shared_ptr;
Expand All @@ -41,13 +43,28 @@ class Analog : public SignalData
{
Q_OBJECT

public:
/**
* Types and statics used with templates
*/
typedef AnalogSegment segment_t;
typedef float sample_t;
static const QColor SignalColors[8];
static const char *InvalidSignal;
static const SignalBase::ChannelType math_channel_type = SignalBase::AnalogMathChannel;

public:
Analog();

void push_segment(shared_ptr<AnalogSegment> &segment);

const deque< shared_ptr<AnalogSegment> >& analog_segments() const;

inline const deque< shared_ptr<AnalogSegment> >& typed_segments() const
{
return analog_segments();
}

vector< shared_ptr<Segment> > segments() const;

uint32_t get_segment_count() const;
Expand Down
4 changes: 3 additions & 1 deletion pv/data/analogsegment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,13 @@ void AnalogSegment::append_interleaved_samples(const float *data,
prev_sample_count + 1, prev_sample_count + 1);
}

float AnalogSegment::get_sample(int64_t sample_num) const
float AnalogSegment::get_sample(int64_t sample_num, unsigned int index) const
{
assert(sample_num >= 0);
assert(sample_num <= (int64_t)sample_count_);

Q_UNUSED(index);

lock_guard<recursive_mutex> lock(mutex_); // Because of free_unused_memory()

return *((const float*)get_raw_sample(sample_num));
Expand Down
2 changes: 1 addition & 1 deletion pv/data/analogsegment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class AnalogSegment : public Segment, public enable_shared_from_this<Segment>
void append_interleaved_samples(const float *data,
size_t sample_count, size_t stride);

float get_sample(int64_t sample_num) const;
float get_sample(int64_t sample_num, unsigned int index) const;
void get_samples(int64_t start_sample, int64_t end_sample, float* dest) const;

const pair<float, float> get_min_max() const;
Expand Down
18 changes: 18 additions & 0 deletions pv/data/logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,24 @@ using std::vector;
namespace pv {
namespace data {

const QColor Logic::SignalColors[10] =
{
QColor(0x16, 0x19, 0x1A), // Black
QColor(0x8F, 0x52, 0x02), // Brown
QColor(0xCC, 0x00, 0x00), // Red
QColor(0xF5, 0x79, 0x00), // Orange
QColor(0xED, 0xD4, 0x00), // Yellow
QColor(0x73, 0xD2, 0x16), // Green
QColor(0x34, 0x65, 0xA4), // Blue
QColor(0x75, 0x50, 0x7B), // Violet
QColor(0x88, 0x8A, 0x85), // Grey
QColor(0xEE, 0xEE, 0xEC), // White
};

const char *Logic::InvalidSignal = "\"%1\" isn't a valid logic signal";

// const SignalBase::ChannelType math_channel_type = SignalBase::LogicMathChannel;

Logic::Logic(unsigned int num_channels) :
SignalData(),
samplerate_(1), // Default is 1 Hz to prevent division-by-zero errors
Expand Down
19 changes: 18 additions & 1 deletion pv/data/logic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@

#include "signaldata.hpp"
#include "segment.hpp"
#include "signalbase.hpp"

#include <deque>

#include <QObject>
#include <QColor>

using std::deque;
using std::shared_ptr;
Expand All @@ -41,7 +43,17 @@ class Logic : public SignalData
Q_OBJECT

public:
Logic(unsigned int num_channels);
/**
* Types and statics used with templates
*/
typedef LogicSegment segment_t;
typedef uint8_t sample_t;
static const QColor SignalColors[10];
static const char *InvalidSignal;
static const SignalBase::ChannelType math_channel_type = SignalBase::LogicMathChannel;

public:
Logic(unsigned int num_channels = 1);

unsigned int num_channels() const;

Expand All @@ -50,6 +62,11 @@ class Logic : public SignalData
const deque< shared_ptr<LogicSegment> >& logic_segments() const;
deque< shared_ptr<LogicSegment> >& logic_segments();

inline const deque< shared_ptr<LogicSegment> >& typed_segments() const
{
return logic_segments();
}

vector< shared_ptr<Segment> > segments() const;

uint32_t get_segment_count() const;
Expand Down
Loading