Merge branch 'i2c_detect' into dev_environment
This commit is contained in:
commit
d63ff51a42
3 changed files with 20 additions and 5 deletions
|
|
@ -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) ?? []}/>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue