]> sigrok.org Git - pulseview.git/commitdiff
AnalogSignal: Split up divs during autoranging if needed
authorSoeren Apel <redacted>
Mon, 13 Feb 2017 23:12:54 +0000 (00:12 +0100)
committerUwe Hermann <redacted>
Wed, 15 Feb 2017 11:12:52 +0000 (12:12 +0100)
pv/view/analogsignal.cpp

index d9ac2f60afcf853d1b225a18c139854ec94ed824..2715a386bdf83a37d64e194063b86b23e8c552d8 100644 (file)
@@ -389,6 +389,12 @@ void AnalogSignal::perform_autoranging(bool force_update)
                neg_vdivs_ = 0;
        }
 
+       // Split up the divs if there are negative values but no negative divs
+       if ((min < 0) && (neg_vdivs_ == 0)) {
+               neg_vdivs_ = pos_vdivs_ / 2;
+               pos_vdivs_ -= neg_vdivs_;
+       }
+
        double min_value_per_div;
        if ((pos_vdivs_ > 0) && (neg_vdivs_ >  0))
                min_value_per_div = std::max(max / pos_vdivs_, -min / neg_vdivs_);