FreeDATA/gui/src/js/waterfallHandler.js

44 lines
1.2 KiB
JavaScript
Raw Normal View History

2023-10-22 08:12:00 +00:00
import { Spectrum } from "../assets/waterfall/spectrum.js";
2023-10-09 14:11:01 +00:00
import { setActivePinia } from "pinia";
import pinia from "../store/index";
setActivePinia(pinia);
2023-11-18 16:12:05 +00:00
import { settingsStore as settings } from "../store/settingsStore.js";
2023-10-22 08:12:00 +00:00
var spectrum = new Object();
var spectrums = [];
2023-12-04 03:43:48 +00:00
export function initWaterfall(id) {
2023-12-04 03:49:02 +00:00
spectrum = new Spectrum(id, {
2023-10-22 08:12:00 +00:00
spectrumPercent: 0,
2023-12-04 03:43:48 +00:00
wf_rows: 1024, //Assuming 1 row = 1 pixe1, 192 is the height of the spectrum container
wf_size: 1024,
2023-10-22 08:12:00 +00:00
});
2023-12-04 03:43:48 +00:00
spectrum.setColorMap(settings.local.wf_theme);
spectrums.push(spectrum);
2023-12-04 03:43:48 +00:00
return spectrum;
2023-10-09 14:11:01 +00:00
}
2023-10-22 08:12:00 +00:00
export function addDataToWaterfall(data) {
2023-11-09 16:15:12 +00:00
data = JSON.parse(data);
2023-12-16 16:12:03 +00:00
if (data.constructor !== Array) return;
2023-12-10 20:58:12 +00:00
spectrums.forEach((element) => {
//console.log(element);
element.addData(data);
});
//window.dispatchEvent(new CustomEvent("wf-data-avail", {bubbles:true, detail: data }));
2023-12-04 03:49:02 +00:00
}
2023-11-04 18:56:25 +00:00
/**
* Setwaterfall colormap array by index
* @param {number} index colormap index to use
2023-11-09 16:15:12 +00:00
*/
export function setColormap() {
let index = settings.local.wf_theme;
2023-11-09 16:15:12 +00:00
if (isNaN(index)) index = 0;
2023-12-10 20:58:12 +00:00
console.log("Setting waterfall colormap to " + index);
spectrums.forEach((element) => {
//console.log(element);
element.setColorMap(index);
});
2023-12-04 03:49:02 +00:00
}