FreeDATA/gui/src/js/waterfallHandler.js

34 lines
944 B
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();
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);
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-04 03:49:02 +00:00
window.dispatchEvent(new CustomEvent("wf-data-avail", { detail: data }));
}
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(index) {
if (isNaN(index)) index = 0;
2023-11-04 18:56:25 +00:00
//console.log("Setting waterfall colormap to " + index)
2023-11-04 02:12:06 +00:00
spectrum.setColorMap(index);
2023-12-04 03:49:02 +00:00
}