allow frequency display precision to be set via configuration
This commit is contained in:
@ -11,6 +11,8 @@ function DemodulatorPanel(el) {
|
||||
self.getDemodulator().set_offset_frequency(freq - self.center_freq);
|
||||
});
|
||||
|
||||
this.mouseFrequencyDisplay = el.find('.webrx-mouse-freq').frequencyDisplay();
|
||||
|
||||
Modes.registerModePanel(this);
|
||||
el.on('click', '.openwebrx-demodulator-button', function() {
|
||||
var modulation = $(this).data('modulation');
|
||||
@ -332,6 +334,15 @@ DemodulatorPanel.prototype.getSquelchMargin = function() {
|
||||
return this.squelchMargin;
|
||||
};
|
||||
|
||||
DemodulatorPanel.prototype.setMouseFrequency = function(freq) {
|
||||
this.mouseFrequencyDisplay.setFrequency(freq);
|
||||
};
|
||||
|
||||
DemodulatorPanel.prototype.setFrequencyPrecision = function(precision) {
|
||||
this.tuneableFrequencyDisplay.setFrequencyPrecision(precision);
|
||||
this.mouseFrequencyDisplay.setFrequencyPrecision(precision);
|
||||
};
|
||||
|
||||
$.fn.demodulatorPanel = function(){
|
||||
if (!this.data('panel')) {
|
||||
this.data('panel', new DemodulatorPanel(this));
|
||||
|
@ -1,6 +1,7 @@
|
||||
function FrequencyDisplay(element) {
|
||||
this.element = $(element);
|
||||
this.digits = [];
|
||||
this.precision = 4;
|
||||
this.setupElements();
|
||||
this.setFrequency(0);
|
||||
}
|
||||
@ -14,7 +15,10 @@ FrequencyDisplay.prototype.setupElements = function() {
|
||||
|
||||
FrequencyDisplay.prototype.setFrequency = function(freq) {
|
||||
this.frequency = freq;
|
||||
var formatted = (freq / 1e6).toLocaleString(undefined, {maximumFractionDigits: 4, minimumFractionDigits: 4});
|
||||
var formatted = (freq / 1e6).toLocaleString(
|
||||
undefined,
|
||||
{maximumFractionDigits: this.precision, minimumFractionDigits: this.precision}
|
||||
);
|
||||
var children = this.digitContainer.children();
|
||||
for (var i = 0; i < formatted.length; i++) {
|
||||
if (!this.digits[i]) {
|
||||
@ -34,6 +38,12 @@ FrequencyDisplay.prototype.setFrequency = function(freq) {
|
||||
}
|
||||
};
|
||||
|
||||
FrequencyDisplay.prototype.setFrequencyPrecision = function(precision) {
|
||||
if (!precision) return;
|
||||
this.precision = precision;
|
||||
this.setFrequency(this.frequency);
|
||||
};
|
||||
|
||||
function TuneableFrequencyDisplay(element) {
|
||||
FrequencyDisplay.call(this, element);
|
||||
this.setupEvents();
|
||||
|
Reference in New Issue
Block a user