Merge branch 'i2c_detect' into dev_environment

This commit is contained in:
csawatzky 2025-07-28 15:25:44 -06:00
commit d63ff51a42
3 changed files with 20 additions and 5 deletions

2
package-lock.json generated
View file

@ -10911,7 +10911,7 @@
},
"node_modules/protobuf-ts": {
"version": "1.0.0",
"resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#615043c402800121752f0bbe2620f7760c972110",
"resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#46df972192510aa2aec201100382063607535a66",
"dependencies": {
"protobufjs": "^6.8.8"
}

View file

@ -18,17 +18,20 @@ interface Props {
availableOffsets: OffsetAvailabilityMap
refreshCallback: () => void
}
interface CompStep {
label: string;
completed?: boolean;
}
let i2cBlacklistAddresses: number[] = [0x70]
export default function DeviceScannedComponents(props: Props){
const {scannedComponents, device, availablePositions, availableOffsets, refreshCallback} = props
const compAPI = useComponentAPI();
const deviceAPI = useDeviceAPI()
const [scannedI2C, setScannedI2C] = useState<pond.DetectI2C>()
const [scannedI2C, setScannedI2C] = useState<pond.DetectI2C>() //the unmodified scan of addresses
const [validCompAddresses, setValidComponentAddresses] = useState<quack.AddressData[]>([]) //the filtered array of address data
const [components, setComponents] = useState<Component[]>([])
const [steps, setSteps] = useState<CompStep[]>([]);
const { error, success } = useSnackbar();
@ -59,6 +62,18 @@ export default function DeviceScannedComponents(props: Props){
setSteps(steps)
},[components])
useEffect(()=>{
let valid: quack.AddressData[] = []
//filter the address data
scannedI2C?.settings?.foundAddresses.forEach(addrData => {
if(!i2cBlacklistAddresses.includes(addrData.address)){
valid.push(addrData)
}
})
console.log(valid)
setValidComponentAddresses(valid)
},[scannedI2C])
const stepper = () => {
return (
<Stepper nonLinear activeStep={currentStep} style={{ width: "100%" }}>
@ -205,7 +220,7 @@ export default function DeviceScannedComponents(props: Props){
</Typography>
<Button variant="contained" color="primary" onClick={()=>{removeScan(scannedI2C.key)}}>Clear Scan</Button>
</Box>
{scannedI2C.settings?.foundAddresses && scannedI2C.settings.foundAddresses.length > 0 ? scannedI2C?.settings?.foundAddresses.map((addr, index) => {
{validCompAddresses.length > 0 ? validCompAddresses.map((addr, index) => {
return (
<ScannedI2C key={index} sensorNum={index+1} addressData={addr} deviceProduct={device.settings.product} componentSelectionCallback={componentSelection} availablePositions={availablePositions.get(quack.AddressType.ADDRESS_TYPE_I2C) ?? []}/>
)

View file

@ -261,7 +261,7 @@ function unitConversion(
newVals.forEach((val, i) => {
val.values.forEach((v, j) => {
//convert m/s to ft/m by multiplying by 196.9
newVals[i].values[j] = v * 196.9
newVals[i].values[j] = Math.round(v * 196.9)
});
});
}