diff --git a/src/device/autoDetect/DeviceScannedComponents.tsx b/src/device/autoDetect/DeviceScannedComponents.tsx index e07dd94..52a66e4 100644 --- a/src/device/autoDetect/DeviceScannedComponents.tsx +++ b/src/device/autoDetect/DeviceScannedComponents.tsx @@ -37,6 +37,14 @@ export default function DeviceScannedComponents(props: Props){ useEffect(()=>{ if (scannedComponents.i2c) setScannedI2C(scannedComponents.i2c) + //makes the array empty for testing + // if (scannedComponents.i2c) { + // let clone = cloneDeep(scannedComponents.i2c) + // if (clone.settings){ + // clone.settings.foundAddresses = [] + // } + // setScannedI2C(clone) + // } },[scannedComponents]) useEffect(() => { @@ -101,57 +109,56 @@ export default function DeviceScannedComponents(props: Props){ }} /> - - - - - - - {currentStep !== 0 && ( - - )} - {currentStep !== steps.length - 1 && ( - - - - )} - - - - + + + + + + + {currentStep !== 0 && ( + + )} + {currentStep !== steps.length - 1 && ( + + + + )} + + + + ); }; @@ -182,14 +189,24 @@ export default function DeviceScannedComponents(props: Props){ - I2C Components Found + I2C Sensors - {scannedI2C?.settings?.foundAddresses.map((addr, index) => { + {scannedI2C.settings?.foundAddresses && scannedI2C.settings.foundAddresses.length > 0 ? scannedI2C?.settings?.foundAddresses.map((addr, index) => { return ( - + ) - })} + }) : + + + No Sensors Found + + + } } diff --git a/src/device/autoDetect/ScannedI2C.tsx b/src/device/autoDetect/ScannedI2C.tsx index 5b83d44..db5954a 100644 --- a/src/device/autoDetect/ScannedI2C.tsx +++ b/src/device/autoDetect/ScannedI2C.tsx @@ -1,4 +1,4 @@ -import { Box, Button, Checkbox, FormControlLabel, Grid2, MenuItem, Radio, RadioGroup, TextField, Tooltip } from "@mui/material"; +import { Box, Button, Checkbox, FormControlLabel, Grid2, MenuItem, Radio, RadioGroup, TextField, Tooltip, Typography } from "@mui/material"; import { Component } from "models"; import { getAddressTypes, getFriendlyName, getSubtypes, Subtype } from "pbHelpers/ComponentType"; import { ComponentAvailabilityMap, DevicePositions } from "pbHelpers/DeviceAvailability"; @@ -12,10 +12,11 @@ interface Props { deviceProduct: pond.DeviceProduct componentSelectionCallback: (component: Component, checked: boolean) => void availablePositions: DevicePositions + sensorNum?: number } export default function ScannedI2C(props: Props){ - const {decimalAddress, deviceProduct, componentSelectionCallback, availablePositions} = props + const {decimalAddress, deviceProduct, componentSelectionCallback, availablePositions, sensorNum} = props const [types, setTypes] = useState([]) const [subtypeOptions, setSubtypeOptions] = useState>([]) const [selectedType, setSelectedType] = useState(quack.ComponentType.COMPONENT_TYPE_INVALID) @@ -90,8 +91,8 @@ export default function ScannedI2C(props: Props){ return ( - - Sensor 1 + + {sensorNum && Sensor {sensorNum}}