- // Convert as many sample blocks as we can
- while ((end_sample - i) > block_size) {
- const float* asamples = asegment->get_samples(i, i + block_size);
- for (uint32_t j = 0; j < block_size; j++)
- lsamples.push_back(convert_a2l_threshold(threshold, asamples[j]));
- lsegment->append_payload(lsamples.data(), lsamples.size());
- i += block_size;
- lsamples.clear();
+ asegment->get_samples(i, end_sample, asamples);
+ shared_ptr<sigrok::Logic> logic =
+ analog->get_logic_via_threshold(threshold, lsamples);
+ lsegment->append_payload(logic->data_pointer(), logic->data_length());
+ samples_added(lsegment, i, end_sample);
+ }
+
+ if (conversion_type_ == A2LConversionBySchmittTrigger) {
+ const vector<double> thresholds = get_conversion_thresholds();
+ const double lo_thr = thresholds[0];
+ const double hi_thr = thresholds[1];
+
+ uint8_t state = 0; // TODO Use value of logic sample n-1 instead of 0
+
+ // Convert as many sample blocks as we can
+ while ((end_sample - i) > ConversionBlockSize) {
+ asegment->get_samples(i, i + ConversionBlockSize, asamples);
+
+ shared_ptr<sigrok::Logic> logic =
+ analog->get_logic_via_schmitt_trigger(lo_thr, hi_thr,
+ &state, lsamples);
+
+ lsegment->append_payload(logic->data_pointer(), logic->data_length());
+
+ samples_added(lsegment, i, i + ConversionBlockSize);
+ i += ConversionBlockSize;
+ }
+
+ // Re-create sigrok::Analog and convert remaining samples
+ packet = Session::sr_context->create_analog_packet(channels,
+ asamples, end_sample - i, mq, unit, mq_flags);
+
+ analog = dynamic_pointer_cast<sigrok::Analog>(packet->payload());
+
+ asegment->get_samples(i, end_sample, asamples);
+ shared_ptr<sigrok::Logic> logic =
+ analog->get_logic_via_schmitt_trigger(lo_thr, hi_thr,
+ &state, lsamples);
+ lsegment->append_payload(logic->data_pointer(), logic->data_length());
+ samples_added(lsegment, i, end_sample);
+ }
+
+ // If acquisition is ongoing, start-/endsample may have changed
+ end_sample = asegment->get_sample_count();
+
+ delete[] lsamples;