Skip to content

Commit

Permalink
Add Raspberry Pi Pico
Browse files Browse the repository at this point in the history
  • Loading branch information
Amanmahe committed Dec 7, 2024
1 parent 9873b03 commit 44422a1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
20 changes: 12 additions & 8 deletions src/components/Canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/components/boards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const BoardsList = Object.freeze([
},
{
name: "Raspberry Pi Pico",
field_pid: "10",
field_pid: "192",
bits: "twelve",
},
]);
7 changes: 6 additions & 1 deletion src/components/filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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).
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 44422a1

Please sign in to comment.