@@ -48,7 +48,7 @@ interface ConnectionProps {
4848 onPauseChange : ( pause : boolean ) => void ; // Callback to pass pause state to parent
4949 datastream : ( data : number [ ] ) => void ;
5050 Connection : ( isConnected : boolean ) => void ;
51- selectedBits : BitSelection ;
51+ selectedBits ? : BitSelection ; // Add `?` if it's optional
5252 setSelectedBits : React . Dispatch < React . SetStateAction < BitSelection > > ;
5353 isDisplay : boolean ;
5454 setIsDisplay : React . Dispatch < React . SetStateAction < boolean > > ;
@@ -90,7 +90,7 @@ const Connection: React.FC<ConnectionProps> = ({
9090 const isRecordingRef = useRef < boolean > ( false ) ; // Ref to track if the device is recording
9191 const [ isEndTimePopoverOpen , setIsEndTimePopoverOpen ] = useState ( false ) ;
9292 const [ detectedBits , setDetectedBits ] = useState < BitSelection | null > ( null ) ; // State to store the detected bits
93- const detectedBitsRef = React . useRef < BitSelection > ( "ten" ) ;
93+ const detectedBitsRef = React . useRef < BitSelection > ( 10 ) ;
9494 const [ datasets , setDatasets ] = useState < any [ ] > ( [ ] ) ;
9595 const currentFilenameRef = useRef < string > ( "" ) ;
9696 const [ isRecordButtonDisabled , setIsRecordButtonDisabled ] = useState ( false ) ;
@@ -101,7 +101,7 @@ const Connection: React.FC<ConnectionProps> = ({
101101 const endTimeRef = useRef < number | null > ( null ) ; // Ref to store the end time of the recording
102102 const [ popoverVisible , setPopoverVisible ] = useState ( false ) ;
103103 const portRef = useRef < SerialPort | null > ( null ) ; // Ref to store the serial port
104- const [ ifBits , setifBits ] = useState < BitSelection > ( "auto" ) ;
104+ const [ ifBits , setifBits ] = useState < BitSelection > ( 10 ) ;
105105 const [ showAllChannels , setShowAllChannels ] = useState ( false ) ;
106106 const [ FullZoom , setFullZoom ] = useState ( false ) ;
107107 const canvasnumbersRef = useRef < number > ( 1 ) ;
@@ -350,19 +350,18 @@ const Connection: React.FC<ConnectionProps> = ({
350350 const board = BoardsList . find (
351351 ( b ) =>
352352 b . chords_id . toLowerCase ( ) === deviceName . toLowerCase ( ) &&
353- ( ! fieldPid || parseInt ( b . field_pid , 10 ) === fieldPid ) // Match field_pid if provided
353+ ( ! fieldPid || ( b . field_pid ) === fieldPid ) // Match field_pid if provided
354354 ) ;
355355
356356 if ( board ) {
357357 setifBits ( board . adc_resolution as BitSelection ) ;
358358 setSelectedBits ( board . adc_resolution as BitSelection ) ;
359359 detectedBitsRef . current = board . adc_resolution as BitSelection ;
360360
361- const channel = board . channel_count ? parseInt ( board . channel_count , 10 ) : 0 ;
361+ const channel = board . channel_count ? ( board . channel_count ) : 0 ;
362362 maxCanvasCountRef . current = channel ;
363-
364363 if ( board . sampling_rate ) {
365- setCurrentSamplingRate ( parseInt ( board . sampling_rate , 10 ) ) ;
364+ setCurrentSamplingRate ( board . sampling_rate ) ;
366365 }
367366
368367 return {
@@ -373,8 +372,8 @@ const Connection: React.FC<ConnectionProps> = ({
373372 ) ,
374373 adcResolution : board . adc_resolution ,
375374 channelCount : board . channel_count ,
376- baudRate : parseInt ( board . baud_Rate , 10 ) , // Return baudRate
377- serialTimeout : parseInt ( board . serial_timeout , 10 ) , // Return serialTimeout
375+ baudRate : ( board . baud_Rate ) , // Return baudRate
376+ serialTimeout : ( board . serial_timeout ) , // Return serialTimeout
378377 } ;
379378 }
380379
@@ -405,6 +404,7 @@ const Connection: React.FC<ConnectionProps> = ({
405404 await disconnectDevice ( ) ;
406405 }
407406
407+
408408 const savedPorts = JSON . parse ( localStorage . getItem ( 'savedDevices' ) || '[]' ) ;
409409 let port = null ;
410410
@@ -422,8 +422,6 @@ const Connection: React.FC<ConnectionProps> = ({
422422 ) ;
423423 } ) || null ;
424424 }
425- // Request a new port if no saved port matches
426- // port = await navigator.serial.requestPort();
427425
428426 let baudRate ;
429427 let serialTimeout
@@ -437,11 +435,11 @@ const Connection: React.FC<ConnectionProps> = ({
437435
438436 // Match the board from BoardsList
439437 const board = BoardsList . find (
440- ( b ) => parseInt ( b . field_pid , 10 ) === usbProductId
438+ ( b ) => ( b . field_pid ) === usbProductId
441439 ) ;
442440
443- baudRate = board ? parseInt ( board . baud_Rate , 10 ) : 0 ;
444- serialTimeout = board ? parseInt ( board . serial_timeout , 10 ) : 0 ;
441+ baudRate = board ? ( board . baud_Rate ) : 0 ;
442+ serialTimeout = board ? ( board . serial_timeout ) : 0 ;
445443
446444 const usbVendorId = newPortInfo . usbVendorId ?? 0 ;
447445 // const usbProductId = newPortInfo.usbProductId ?? 0;
@@ -706,10 +704,10 @@ const Connection: React.FC<ConnectionProps> = ({
706704 const notchFilters = Array . from ( { length : maxCanvasCountRef . current } , ( ) => new Notch ( ) ) ;
707705 const EXGFilters = Array . from ( { length : maxCanvasCountRef . current } , ( ) => new EXGFilter ( ) ) ;
708706 notchFilters . forEach ( ( filter ) => {
709- filter . setbits ( detectedBitsRef . current ) ; // Set the bits value for all instances
707+ filter . setbits ( detectedBitsRef . current . toString ( ) ) ; // Set the bits value for all instances
710708 } ) ;
711709 EXGFilters . forEach ( ( filter ) => {
712- filter . setbits ( detectedBitsRef . current ) ; // Set the bits value for all instances
710+ filter . setbits ( detectedBitsRef . current . toString ( ) ) ; // Set the bits value for all instances
713711 } ) ;
714712 try {
715713 while ( isConnectedRef . current ) {
0 commit comments