From: Joel Holdsworth Date: Sat, 25 Jan 2014 09:51:11 +0000 (+0000) Subject: Add an extra sample to the logic edges so that the end sample is visible X-Git-Tag: pulseview-0.2.0~114 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=175d6573de78a10cc4ff461147d26c99ab3847b4;p=pulseview.git Add an extra sample to the logic edges so that the end sample is visible --- diff --git a/pv/data/logicsnapshot.cpp b/pv/data/logicsnapshot.cpp index 177c6627..f203e8b6 100644 --- a/pv/data/logicsnapshot.cpp +++ b/pv/data/logicsnapshot.cpp @@ -366,8 +366,10 @@ void LogicSnapshot::get_subsampled_edges( } // Add the final state - edges.push_back(pair(end, - get_sample(end) & sig_mask)); + const bool end_sample = get_sample(end) & sig_mask; + if (last_sample != end_sample) + edges.push_back(pair(end, end_sample)); + edges.push_back(pair(end + 1, end_sample)); } uint64_t LogicSnapshot::get_subsample(int level, uint64_t offset) const diff --git a/pv/view/logicsignal.cpp b/pv/view/logicsignal.cpp index cf75bc28..65ecae53 100644 --- a/pv/view/logicsignal.cpp +++ b/pv/view/logicsignal.cpp @@ -167,7 +167,7 @@ void LogicSignal::paint_mid(QPainter &p, int left, int right) delete[] edge_lines; // Paint the caps - const unsigned int max_cap_line_count = (edges.size() - 1); + const unsigned int max_cap_line_count = edges.size(); QLineF *const cap_lines = new QLineF[max_cap_line_count]; p.setPen(HighColour); diff --git a/test/data/logicsnapshot.cpp b/test/data/logicsnapshot.cpp index ba89c607..5fc17213 100644 --- a/test/data/logicsnapshot.cpp +++ b/test/data/logicsnapshot.cpp @@ -140,7 +140,7 @@ BOOST_AUTO_TEST_CASE(Basic) BOOST_CHECK_EQUAL(edges[0].first, 0); BOOST_CHECK_EQUAL(edges[1].first, 8); BOOST_CHECK_EQUAL(edges[2].first, 16); - BOOST_CHECK_EQUAL(edges[3].first, 255); + BOOST_CHECK_EQUAL(edges[3].first, 256); // Test a subset at high zoom edges.clear(); @@ -150,7 +150,7 @@ BOOST_AUTO_TEST_CASE(Basic) BOOST_CHECK_EQUAL(edges[0].first, 6); BOOST_CHECK_EQUAL(edges[1].first, 8); BOOST_CHECK_EQUAL(edges[2].first, 16); - BOOST_CHECK_EQUAL(edges[3].first, 17); + BOOST_CHECK_EQUAL(edges[3].first, 18); } BOOST_AUTO_TEST_CASE(LargeData) @@ -263,7 +263,7 @@ BOOST_AUTO_TEST_CASE(LargeData) BOOST_CHECK_EQUAL(edges[i].second, i & 1); } - BOOST_CHECK_EQUAL(edges[31].first, 999999); + BOOST_CHECK_EQUAL(edges[31].first, 1000000); // Check in very low zoom case edges.clear(); @@ -401,7 +401,7 @@ BOOST_AUTO_TEST_CASE(LongPulses) BOOST_CHECK_EQUAL(edges[i*2+1].second, false); } - BOOST_CHECK_EQUAL(edges.back().first, Length-1); + BOOST_CHECK_EQUAL(edges.back().first, Length); BOOST_CHECK_EQUAL(edges.back().second, false); //----- Test get_subsampled_edges at a simplified scale -----// @@ -418,7 +418,7 @@ BOOST_AUTO_TEST_CASE(LongPulses) BOOST_CHECK_EQUAL(edges[i+1].second, false); } - BOOST_CHECK_EQUAL(edges.back().first, Length-1); + BOOST_CHECK_EQUAL(edges.back().first, Length); BOOST_CHECK_EQUAL(edges.back().second, false); }