Here's a bug-fix on the patch (*blush*); I had an off-by-one that
caused the 1-2-5 loop to skip the final value in the range. Now it
goes up to 200 MHz for the Openbench analyzer, just as the device
reports.
Regards,
/Emil
diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp
index b32aa6a..57b4c6f 100644
--- a/gui/mainwindow.cpp
+++ b/gui/mainwindow.cpp
@@ -261,12 +261,32 @@ void MainWindow::on_actionScan_triggered()
/* Populate the combobox with supported samplerates. */
ui->comboBoxSampleRate->clear();
- /* TODO: Samplerate steps support. */
- for (int i = 0; samplerates->list[i]; ++i) {
- /* TODO: Free return value of sigrok_samplerate_string(). */
- s = QString(sigrok_samplerate_string(samplerates->list[i]));
- ui->comboBoxSampleRate->addItem(s,
- QVariant::fromValue(samplerates->list[i]));
+ if (samplerates->list != NULL)
+ {
+ for (int i = 0; samplerates->list[i]; ++i) {
+ char *str = sigrok_samplerate_string(samplerates->list[i]);
+ s = QString(str);
+ free(str);
+ ui->comboBoxSampleRate->addItem(s,
+ QVariant::fromValue(samplerates->list[i]));
+ }
+ }
+ else
+ {
+ const static float mult[] = { 2.f, 2.5f, 2.f };
+ int pos = 0;
+
+ for (uint64_t r = samplerates->low; r <= samplerates->high; ) {
+ char *str = sigrok_samplerate_string(r);
+ s = QString(str);
+ free(str);
+ ui->comboBoxSampleRate->addItem(s,
+ QVariant::fromValue(r));
+ r *= mult[pos];
+ pos++;
+ if (pos > 2)
+ pos = 0;
+ }
}
/* FIXME */
diff --git a/libsigrok/output/common.c b/libsigrok/output/common.c
index 69338f0..cebddc0 100644
--- a/libsigrok/output/common.c
+++ b/libsigrok/output/common.c
@@ -26,7 +26,7 @@
/**
* Convert a numeric samplerate value to its "natural" string representation.
*
- * E.g. a value of 3000000 would be converted to "3 MHz", 20000 to "20 KHz".
+ * E.g. a value of 3000000 would be converted to "3 MHz", 20000 to "20 kHz".
*
* @param samplerate The samplerate in Hz.
* @return A malloc()ed string representation of the samplerate value,
@@ -46,7 +46,7 @@ char *sigrok_samplerate_string(uint64_t samplerate)
else if (samplerate >= MHZ(1))
r = snprintf(o, 30, "%" PRIu64 " MHz", samplerate / 1000000);
else if (samplerate >= KHZ(1))
- r = snprintf(o, 30, "%" PRIu64 " KHz", samplerate / 1000);
+ r = snprintf(o, 30, "%" PRIu64 " kHz", samplerate / 1000);
else
r = snprintf(o, 30, "%" PRIu64 " Hz", samplerate);
@@ -58,3 +58,4 @@ char *sigrok_samplerate_string(uint64_t samplerate)
return o;
}
+
------------------------------------------------------------------------------
_______________________________________________
sigrok-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sigrok-devel