Merge branch 'i2c_detect' into dev_environment
This commit is contained in:
commit
d63ff51a42
3 changed files with 20 additions and 5 deletions
2
package-lock.json
generated
2
package-lock.json
generated
|
|
@ -10911,7 +10911,7 @@
|
||||||
},
|
},
|
||||||
"node_modules/protobuf-ts": {
|
"node_modules/protobuf-ts": {
|
||||||
"version": "1.0.0",
|
"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": {
|
"dependencies": {
|
||||||
"protobufjs": "^6.8.8"
|
"protobufjs": "^6.8.8"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,17 +18,20 @@ interface Props {
|
||||||
availableOffsets: OffsetAvailabilityMap
|
availableOffsets: OffsetAvailabilityMap
|
||||||
refreshCallback: () => void
|
refreshCallback: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CompStep {
|
interface CompStep {
|
||||||
label: string;
|
label: string;
|
||||||
completed?: boolean;
|
completed?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let i2cBlacklistAddresses: number[] = [0x70]
|
||||||
|
|
||||||
export default function DeviceScannedComponents(props: Props){
|
export default function DeviceScannedComponents(props: Props){
|
||||||
const {scannedComponents, device, availablePositions, availableOffsets, refreshCallback} = props
|
const {scannedComponents, device, availablePositions, availableOffsets, refreshCallback} = props
|
||||||
const compAPI = useComponentAPI();
|
const compAPI = useComponentAPI();
|
||||||
const deviceAPI = useDeviceAPI()
|
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 [components, setComponents] = useState<Component[]>([])
|
||||||
const [steps, setSteps] = useState<CompStep[]>([]);
|
const [steps, setSteps] = useState<CompStep[]>([]);
|
||||||
const { error, success } = useSnackbar();
|
const { error, success } = useSnackbar();
|
||||||
|
|
@ -59,6 +62,18 @@ export default function DeviceScannedComponents(props: Props){
|
||||||
setSteps(steps)
|
setSteps(steps)
|
||||||
},[components])
|
},[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 = () => {
|
const stepper = () => {
|
||||||
return (
|
return (
|
||||||
<Stepper nonLinear activeStep={currentStep} style={{ width: "100%" }}>
|
<Stepper nonLinear activeStep={currentStep} style={{ width: "100%" }}>
|
||||||
|
|
@ -205,7 +220,7 @@ export default function DeviceScannedComponents(props: Props){
|
||||||
</Typography>
|
</Typography>
|
||||||
<Button variant="contained" color="primary" onClick={()=>{removeScan(scannedI2C.key)}}>Clear Scan</Button>
|
<Button variant="contained" color="primary" onClick={()=>{removeScan(scannedI2C.key)}}>Clear Scan</Button>
|
||||||
</Box>
|
</Box>
|
||||||
{scannedI2C.settings?.foundAddresses && scannedI2C.settings.foundAddresses.length > 0 ? scannedI2C?.settings?.foundAddresses.map((addr, index) => {
|
{validCompAddresses.length > 0 ? validCompAddresses.map((addr, index) => {
|
||||||
return (
|
return (
|
||||||
<ScannedI2C key={index} sensorNum={index+1} addressData={addr} deviceProduct={device.settings.product} componentSelectionCallback={componentSelection} availablePositions={availablePositions.get(quack.AddressType.ADDRESS_TYPE_I2C) ?? []}/>
|
<ScannedI2C key={index} sensorNum={index+1} addressData={addr} deviceProduct={device.settings.product} componentSelectionCallback={componentSelection} availablePositions={availablePositions.get(quack.AddressType.ADDRESS_TYPE_I2C) ?? []}/>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -261,7 +261,7 @@ function unitConversion(
|
||||||
newVals.forEach((val, i) => {
|
newVals.forEach((val, i) => {
|
||||||
val.values.forEach((v, j) => {
|
val.values.forEach((v, j) => {
|
||||||
//convert m/s to ft/m by multiplying by 196.9
|
//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)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue