Skip to content

Commit 9b115bb

Browse files
authored
Merge pull request #68 from Ritika8081/board-support
Arduino Nano support is added and maximum channel limit dynamically adjustable
2 parents e902228 + f356cde commit 9b115bb

File tree

11 files changed

+2834
-1944
lines changed

11 files changed

+2834
-1944
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ Chords is an application based on Web Serial connection, you can connect [Compat
7575

7676
Thank you for contributing to our project! Your support is invaluable in creating & enhancing Chords-Web and making it even better. 😊
7777

78-
7978
<center>
8079
<a href="https://github.com/upsidedownlabs/Chords-Web/graphs/contributors">
8180
<img src="https://contrib.rocks/image?repo=upsidedownlabs/Chords-Web" />

next.config.mjs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// next.config.mjs
2-
export default {
1+
/** @type {import('next').NextConfig} */
2+
const nextConfig = {
33
reactStrictMode: true,
4-
output: 'export',
4+
output: 'export', // This is key for static export
55
images: {
66
unoptimized: true,
77
remotePatterns: [
@@ -11,14 +11,6 @@ export default {
1111
},
1212
],
1313
},
14-
webpack(config, { isServer }) {
15-
// If this is the server-side bundle, we don’t need to process worker files
16-
if (!isServer) {
17-
config.module.rules.push({
18-
test: /\.worker\.(js|ts)$/,
19-
use: { loader: 'worker-loader' },
20-
});
21-
}
22-
return config;
23-
},
2414
};
15+
/* module.exports = nextConfig*/
16+
export default nextConfig;

package-lock.json

Lines changed: 2560 additions & 1720 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"name": "chords",
3-
"version": "2.3.3a",
3+
"version": "2.3.4a",
44
"private": true,
5-
"type": "module",
65
"scripts": {
76
"dev": "next dev",
87
"build": "next build",
@@ -50,6 +49,7 @@
5049
"tailwind-merge": "^2.3.0",
5150
"tailwindcss-animate": "^1.0.7",
5251
"tailwindcss-textshadow": "^2.1.3",
52+
"uuid": "^11.0.3",
5353
"webgl-plot": "^0.7.1"
5454
},
5555
"devDependencies": {
@@ -58,6 +58,7 @@
5858
"@types/node": "^20",
5959
"@types/react": "^18",
6060
"@types/react-dom": "^18",
61+
"@types/uuid": "^10.0.0",
6162
"eslint": "^8",
6263
"eslint-config-next": "14.2.3",
6364
"postcss": "^8",

src/components/Canvas.tsx

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ interface CanvasProps {
1515
selectedBits: BitSelection;
1616
isDisplay: boolean;
1717
canvasCount?: number;
18-
currentValue?:number;
18+
timeBase?: number;
19+
currentSamplingRate:number;
1920
Zoom: number;
2021
currentSnapshot: number;
2122
snapShotRef: React.MutableRefObject<boolean[]>;
@@ -28,7 +29,8 @@ const Canvas = forwardRef(
2829
selectedBits,
2930
isDisplay,
3031
canvasCount = 6, // default value in case not provided
31-
currentValue=4,
32+
timeBase = 4,
33+
currentSamplingRate,
3234
Zoom,
3335
currentSnapshot,
3436
snapShotRef,
@@ -41,10 +43,10 @@ const Canvas = forwardRef(
4143
const [numChannels, setNumChannels] = useState<number>(canvasCount);
4244
const numXRef = useRef<number>(2000); // To track the calculated value
4345
const [canvases, setCanvases] = useState<HTMLCanvasElement[]>([]);
44-
const [samplingRate,setSamplingRate]=useState<number>(500);
4546
const [wglPlots, setWglPlots] = useState<WebglPlot[]>([]);
4647
const [lines, setLines] = useState<WebglLine[]>([]);
4748
const linesRef = useRef<WebglLine[]>([]);
49+
const [samplingRate, setSamplingRate] = useState<number>(500);
4850
const sweepPositions = useRef<number[]>(new Array(6).fill(0)); // Array for sweep positions
4951
const currentSweepPos = useRef<number[]>(new Array(6).fill(0)); // Array for sweep positions
5052
const array3DRef = useRef<number[][][]>(
@@ -68,12 +70,12 @@ const Canvas = forwardRef(
6870
return 500; // Default fallback
6971
}
7072
}, []);
73+
7174

75+
useEffect(() => {
76+
numXRef.current = (currentSamplingRate * timeBase);
7277

73-
useEffect(() => {
74-
numXRef.current= (getpoints(selectedBits) * currentValue);
75-
76-
}, [ currentValue]);
78+
}, [timeBase]);
7779

7880
const prevCanvasCountRef = useRef<number>(canvasCount);
7981

@@ -116,11 +118,11 @@ const Canvas = forwardRef(
116118

117119

118120
useEffect(() => {
119-
// Reset when currentValue changes
121+
// Reset when timeBase changes
120122
currentSweepPos.current = new Array(numChannels).fill(0);
121123
sweepPositions.current = new Array(numChannels).fill(0);
122-
}, [currentValue]);
123-
124+
}, [timeBase]);
125+
124126

125127
useImperativeHandle(
126128
ref,
@@ -131,7 +133,7 @@ const Canvas = forwardRef(
131133
currentSweepPos.current = new Array(numChannels).fill(0);
132134
sweepPositions.current = new Array(numChannels).fill(0);
133135
}
134-
136+
135137
if (pauseRef.current) {
136138
processIncomingData(data);
137139
updatePlots(data, Zoom);
@@ -149,7 +151,7 @@ const Canvas = forwardRef(
149151
previousCounter = data[0]; // Update the previous counter with the current counter
150152
},
151153
}),
152-
[Zoom, numChannels,currentValue]
154+
[Zoom, numChannels, timeBase]
153155
);
154156

155157
const createCanvases = () => {
@@ -186,7 +188,7 @@ const Canvas = forwardRef(
186188
const opacityLightMajor = "0.4"; // Opacity for every 5th line in light theme
187189
const opacityLightMinor = "0.1"; // Opacity for other lines in light theme
188190
const distanceminor = samplingRate * 0.04;
189-
const numGridLines = getpoints(selectedBits)*4 / distanceminor;
191+
const numGridLines = getpoints(selectedBits) * 4 / distanceminor;
190192
for (let j = 1; j < numGridLines; j++) {
191193
const gridLineX = document.createElement("div");
192194
gridLineX.className = "absolute bg-[rgb(128,128,128)]";
@@ -317,12 +319,12 @@ const Canvas = forwardRef(
317319
sweepPositions.current[i] = (currentSweepPos.current[i] + 1) % line.numPoints;
318320
});
319321
},
320-
[lines, wglPlots, numChannels, theme,currentValue]
322+
[lines, wglPlots, numChannels, theme, timeBase]
321323
);
322324

323325
useEffect(() => {
324326
createCanvases();
325-
}, [numChannels, theme,currentValue]);
327+
}, [numChannels, theme, timeBase]);
326328

327329

328330
const animate = useCallback(() => {

0 commit comments

Comments
 (0)