diff --git a/src/components/Canvas.tsx b/src/components/Canvas.tsx index 032b475..c9fcbc6 100644 --- a/src/components/Canvas.tsx +++ b/src/components/Canvas.tsx @@ -57,6 +57,8 @@ const Canvas = forwardRef( switch (bits) { case "ten": return samplingRate * 2; + case "twelve": + return samplingRate * 2; case "fourteen": return samplingRate * 4; default: @@ -86,6 +88,8 @@ const Canvas = forwardRef( array3DRef.current[activebuffer.current][i] = []; } } + + if (array3DRef.current[activebuffer.current][0].length >= numX) { snapShotRef.current[activebuffer.current] = true; activebuffer.current = (activebuffer.current + 1) % 6; @@ -110,8 +114,8 @@ const Canvas = forwardRef( currentSweepPos.current = new Array(numChannels).fill(0); sweepPositions.current = new Array(numChannels).fill(0); } - processIncomingData(data); if (pauseRef.current) { + processIncomingData(data); updatePlots(data, Zoom); } if (previousCounter !== null) { @@ -339,17 +343,17 @@ const Canvas = forwardRef( ) { const yArray = new Float32Array(array3DRef.current[indicesRef.current[currentSnapshot]][i]); // Check if the line exists - const line = linesRef.current[i]; - if (line) { - line.shiftAdd(yArray); // Efficiently add new points - } else { - console.error(`Line at index ${i} is undefined or null.`); - } + const line = linesRef.current[i]; + if (line) { + line.shiftAdd(yArray); // Efficiently add new points + } else { + console.error(`Line at index ${i} is undefined or null.`); + } } else { console.warn("One of the references is undefined or invalid"); } - + } wglPlots.forEach((wglp) => wglp.update()); // Redraw the plots diff --git a/src/components/boards.ts b/src/components/boards.ts index a53f95c..75c0c44 100644 --- a/src/components/boards.ts +++ b/src/components/boards.ts @@ -36,7 +36,7 @@ export const BoardsList = Object.freeze([ }, { name: "Raspberry Pi Pico", - field_pid: "10", + field_pid: "192", bits: "twelve", }, ]); diff --git a/src/components/filters.tsx b/src/components/filters.tsx index f64e40a..d00b0d9 100644 --- a/src/components/filters.tsx +++ b/src/components/filters.tsx @@ -46,7 +46,10 @@ export class EXGFilter { // function to apply the setSample(sample: string): void { this.sample = sample; - this.bitsPoints = Math.pow(2, sample=="fourteen"?14:10); // Adjust according to your ADC resolution + this.bitsPoints = Math.pow(2, + sample === "fourteen" ? 14 : + sample === "twelve" ? 12 : 10 + ); // Adjust according to your ADC resolution this.yScale = 2 / this.bitsPoints; } @@ -57,6 +60,7 @@ export class EXGFilter { switch (this.sample) { //samplerate 500Hz case "fourteen": + case "twelve": // 500Hz switch (type) { case 1: - this.bitsPoints / 2// ECG Sampling rate: 500.0 Hz, frequency: 30.0 Hz. // Filter is order 2, implemented as second-order sections (biquads). @@ -175,6 +179,7 @@ export class Notch { let output = input; switch (this.sample) { case "fourteen": // 500Hz + case "twelve": // 500Hz switch (type) { case 1: // Notch Sampling rate: 500.0 Hz, frequency: [48.0, 52.0] Hz. this.x_1 = output - (-1.56858163 * this.z1_1) - (0.96424138 * this.z2_1);