X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fdecodetrace.cpp;h=9cc07d3377e5646c6191635714aa9dbc1420afc9;hp=74d0dd6511b623a4c41aba5b66bd6cf13194f830;hb=407c9ebeb13200fb7f28a33cab00e996c018f8dc;hpb=7ba8dbe5272f1d16a620c61ac86492a3de7aa747
diff --git a/pv/view/decodetrace.cpp b/pv/view/decodetrace.cpp
index 74d0dd65..9cc07d33 100644
--- a/pv/view/decodetrace.cpp
+++ b/pv/view/decodetrace.cpp
@@ -812,14 +812,24 @@ void DecodeTrace::create_decoder_form(int index,
for (l = decoder->channels; l; l = l->next) {
const struct srd_channel *const pdch =
(struct srd_channel *)l->data;
+
QComboBox *const combo = create_channel_selector(parent, dec, pdch);
+ QComboBox *const combo_initial_pin = create_channel_selector_initial_pin(parent, dec, pdch);
+
connect(combo, SIGNAL(currentIndexChanged(int)),
this, SLOT(on_channel_selected(int)));
+ connect(combo_initial_pin, SIGNAL(currentIndexChanged(int)),
+ this, SLOT(on_initial_pin_selected(int)));
+
+ QHBoxLayout *const hlayout = new QHBoxLayout;
+ hlayout->addWidget(combo);
+ hlayout->addWidget(combo_initial_pin);
+
decoder_form->addRow(tr("%1 (%2) *")
.arg(QString::fromUtf8(pdch->name),
- QString::fromUtf8(pdch->desc)), combo);
+ QString::fromUtf8(pdch->desc)), hlayout);
- const ChannelSelector s = {combo, dec, pdch};
+ const ChannelSelector s = {combo, combo_initial_pin, dec, pdch};
channel_selectors_.push_back(s);
}
@@ -827,14 +837,24 @@ void DecodeTrace::create_decoder_form(int index,
for (l = decoder->opt_channels; l; l = l->next) {
const struct srd_channel *const pdch =
(struct srd_channel *)l->data;
+
QComboBox *const combo = create_channel_selector(parent, dec, pdch);
+ QComboBox *const combo_initial_pin = create_channel_selector_initial_pin(parent, dec, pdch);
+
connect(combo, SIGNAL(currentIndexChanged(int)),
this, SLOT(on_channel_selected(int)));
+ connect(combo_initial_pin, SIGNAL(currentIndexChanged(int)),
+ this, SLOT(on_initial_pin_selected(int)));
+
+ QHBoxLayout *const hlayout = new QHBoxLayout;
+ hlayout->addWidget(combo);
+ hlayout->addWidget(combo_initial_pin);
+
decoder_form->addRow(tr("%1 (%2)")
.arg(QString::fromUtf8(pdch->name),
- QString::fromUtf8(pdch->desc)), combo);
+ QString::fromUtf8(pdch->desc)), hlayout);
- const ChannelSelector s = {combo, dec, pdch};
+ const ChannelSelector s = {combo, combo_initial_pin, dec, pdch};
channel_selectors_.push_back(s);
}
@@ -891,6 +911,24 @@ QComboBox* DecodeTrace::create_channel_selector(
return selector;
}
+QComboBox* DecodeTrace::create_channel_selector_initial_pin(QWidget *parent,
+ const shared_ptr &dec, const srd_channel *const pdch)
+{
+ QComboBox *selector = new QComboBox(parent);
+
+ selector->addItem("0", qVariantFromValue((int)SRD_INITIAL_PIN_LOW));
+ selector->addItem("1", qVariantFromValue((int)SRD_INITIAL_PIN_HIGH));
+ selector->addItem("?", qVariantFromValue((int)SRD_INITIAL_PIN_SAME_AS_SAMPLE0));
+
+ // Default to index 2 (SRD_INITIAL_PIN_SAME_AS_SAMPLE0).
+ const int idx = (!dec->initial_pins()) ? 2 : dec->initial_pins()->data[pdch->order];
+ selector->setCurrentIndex(idx);
+
+ selector->setToolTip("Initial (assumed) pin value before the first sample");
+
+ return selector;
+}
+
void DecodeTrace::commit_decoder_channels(shared_ptr &dec)
{
assert(dec);
@@ -900,6 +938,10 @@ void DecodeTrace::commit_decoder_channels(shared_ptr &dec
const unordered_set< shared_ptr >
sigs(session_.signalbases());
+ GArray *const initial_pins = g_array_sized_new(FALSE, TRUE,
+ sizeof(uint8_t), channel_selectors_.size());
+ g_array_set_size(initial_pins, channel_selectors_.size());
+
for (const ChannelSelector &s : channel_selectors_) {
if (s.decoder_ != dec)
break;
@@ -913,9 +955,15 @@ void DecodeTrace::commit_decoder_channels(shared_ptr &dec
channel_map[s.pdch_] = sig;
break;
}
+
+ int selection_initial_pin = s.combo_initial_pin_->itemData(
+ s.combo_initial_pin_->currentIndex()).value();
+
+ initial_pins->data[s.pdch_->order] = selection_initial_pin;
}
dec->set_channels(channel_map);
+ dec->set_initial_pins(initial_pins);
}
void DecodeTrace::commit_channels()
@@ -950,6 +998,11 @@ void DecodeTrace::on_channel_selected(int)
commit_channels();
}
+void DecodeTrace::on_initial_pin_selected(int)
+{
+ commit_channels();
+}
+
void DecodeTrace::on_stack_decoder(srd_decoder *decoder)
{
shared_ptr decoder_stack = base_->decoder_stack();