@@ -99,7 +99,7 @@ const Connection: React.FC<ConnectionProps> = ({
9999
100100 // States and Refs for Connection & Recording
101101 const [ isDeviceConnected , setIsDeviceConnected ] = useState < boolean > ( false ) ; // Track if the device is connected
102- const [ isserial , setIsserial ] = useState < boolean > ( false ) ; // Track if the device is connected
102+ const [ isserial , setIsserial ] = useState ( false ) ; // Track if the device is connected
103103
104104 const [ FFTDeviceConnected , setFFTDeviceConnected ] = useState < boolean > ( false ) ; // Track if the device is connected
105105 const isDeviceConnectedRef = useRef < boolean > ( false ) ; // Ref to track if the device is connected
@@ -128,7 +128,7 @@ const Connection: React.FC<ConnectionProps> = ({
128128 const sampingrateref = useRef < number > ( 0 ) ;
129129 const [ open , setOpen ] = useState ( false ) ;
130130 const [ openfft , setOpenfft ] = useState ( false ) ;
131- const [ isPauseSate , setIsPauseState ] = useState ( false ) ;
131+ const [ isPauseState , setIsPauseState ] = useState ( false ) ;
132132
133133 // UI Themes & Modes
134134 const { theme } = useTheme ( ) ; // Current theme of the app
@@ -379,8 +379,13 @@ const Connection: React.FC<ConnectionProps> = ({
379379 } ) ;
380380
381381 } ;
382- setSelectedChannelsInWorker ( selectedChannels )
383-
382+ if ( FFTDeviceConnected ) {
383+ // If FFT device is connected, send only the selected channel
384+ setSelectedChannelsInWorker ( [ selectedChannel ] ) ;
385+ } else {
386+ // Otherwise, send all selected channels
387+ setSelectedChannelsInWorker ( selectedChannels ) ;
388+ }
384389 const processBuffer = async ( bufferIndex : number , canvasCount : number , selectChannel : number [ ] ) => {
385390 if ( ! workerRef . current ) {
386391 initializeWorker ( ) ;
@@ -1001,7 +1006,7 @@ const Connection: React.FC<ConnectionProps> = ({
10011006 let prevSampleCounter : number | null = null ;
10021007 const samplesReceivedRef = useRef ( 0 ) ;
10031008 let channelData : number [ ] = [ ] ;
1004- const SINGLE_SAMPLE_LEN = 7 ; // Each sample is 10 bytes
1009+ const SINGLE_SAMPLE_LEN = 7 ; // Each sample is 7 bytes: 1 counter + 3 × 2-byte channels
10051010 const BLOCK_COUNT = 10 ; // 10 samples batched per notification
10061011 const NEW_PACKET_LEN = SINGLE_SAMPLE_LEN * BLOCK_COUNT ; // 100 bytes
10071012 interface BluetoothRemoteGATTCharacteristicExtended extends EventTarget {
@@ -1572,7 +1577,7 @@ const Connection: React.FC<ConnectionProps> = ({
15721577 < PopoverTrigger asChild >
15731578 < Button
15741579 className = "flex items-center gap-1 py-2 px-4 rounded-xl font-semibold"
1575- disabled = { isfftLoading || isPauseSate }
1580+ disabled = { isfftLoading || isPauseState }
15761581 >
15771582 { isfftLoading ? (
15781583 < >
@@ -1685,7 +1690,7 @@ const Connection: React.FC<ConnectionProps> = ({
16851690 < Button
16861691 className = "rounded-xl"
16871692 onClick = { handleRecord }
1688- disabled = { isPauseSate }
1693+ disabled = { isPauseState }
16891694 >
16901695 { isRecordingRef . current ? (
16911696 < CircleStop />
@@ -1782,7 +1787,7 @@ const Connection: React.FC<ConnectionProps> = ({
17821787 < PopoverTrigger asChild >
17831788 < Button
17841789 className = "flex items-center justify-center px-3 py-2 select-none min-w-12 whitespace-nowrap rounded-xl"
1785- disabled = { isPauseSate }
1790+ disabled = { isPauseState }
17861791 >
17871792 Filter
17881793 </ Button >
@@ -2183,7 +2188,7 @@ const Connection: React.FC<ConnectionProps> = ({
21832188 < PopoverTrigger asChild >
21842189 < Button
21852190 className = "flex items-center gap-1 py-2 px-4 rounded-xl font-semibold"
2186- disabled = { isfftLoading || isPauseSate }
2191+ disabled = { isfftLoading || isPauseState }
21872192 >
21882193 Channels
21892194 </ Button >
0 commit comments