Merge branch 'i2c_detect' into dev_environment and a proto update
This commit is contained in:
commit
90ab920f01
3 changed files with 11 additions and 11 deletions
|
|
@ -207,7 +207,7 @@ export default function DeviceScannedComponents(props: Props){
|
|||
</Box>
|
||||
{scannedI2C.settings?.foundAddresses && scannedI2C.settings.foundAddresses.length > 0 ? scannedI2C?.settings?.foundAddresses.map((addr, index) => {
|
||||
return (
|
||||
<ScannedI2C key={index} sensorNum={index+1} decimalAddress={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) ?? []}/>
|
||||
)
|
||||
}) :
|
||||
<Box sx={{
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import { quack } from "protobuf-ts/quack";
|
|||
import React, { useEffect, useState } from "react";
|
||||
|
||||
interface Props {
|
||||
decimalAddress: number
|
||||
addressData: quack.AddressData
|
||||
deviceProduct: pond.DeviceProduct
|
||||
componentSelectionCallback: (component: Component[], checked: boolean) => void
|
||||
availablePositions: DevicePositions
|
||||
|
|
@ -16,7 +16,7 @@ interface Props {
|
|||
}
|
||||
|
||||
export default function ScannedI2C(props: Props){
|
||||
const {decimalAddress, deviceProduct, componentSelectionCallback, availablePositions, sensorNum} = props
|
||||
const {addressData, deviceProduct, componentSelectionCallback, availablePositions, sensorNum} = props
|
||||
const [types, setTypes] = useState<quack.ComponentType[]>([])
|
||||
const [subtypeOptions, setSubtypeOptions] = useState<Array<Subtype>>([])
|
||||
const [selectedPrimaryType, setSelectedPrimaryType] = useState<quack.ComponentType>(quack.ComponentType.COMPONENT_TYPE_INVALID)
|
||||
|
|
@ -34,7 +34,7 @@ export default function ScannedI2C(props: Props){
|
|||
if(i2cMap){
|
||||
i2cMap.forEach((val, key) => {
|
||||
let addresses = val as number[] ?? []
|
||||
if(addresses.length > 0 && addresses.includes(decimalAddress)){
|
||||
if(addresses.length > 0 && addresses.includes(addressData.address)){
|
||||
types.push(key)
|
||||
}
|
||||
})
|
||||
|
|
@ -47,7 +47,7 @@ export default function ScannedI2C(props: Props){
|
|||
checkAddressAvailable(types[0])
|
||||
}
|
||||
setTypes(types)
|
||||
},[decimalAddress, deviceProduct])
|
||||
},[addressData, deviceProduct])
|
||||
|
||||
const buildSubtypeOptions = (compType: quack.ComponentType) => {
|
||||
let subtypes = getSubtypes(compType)
|
||||
|
|
@ -69,7 +69,7 @@ export default function ScannedI2C(props: Props){
|
|||
const checkAddressAvailable = (compType: quack.ComponentType) => {
|
||||
let i2cMap = availablePositions as ComponentAvailabilityMap
|
||||
let compAddresses = i2cMap.get(compType) ?? []
|
||||
if (!compAddresses.includes(decimalAddress)){
|
||||
if (!compAddresses.includes(addressData.address)){
|
||||
setAddressInUse(true)
|
||||
}else{
|
||||
setAddressInUse(false)
|
||||
|
|
@ -86,7 +86,10 @@ export default function ScannedI2C(props: Props){
|
|||
primaryComponent.settings.type = selectedPrimaryType
|
||||
primaryComponent.settings.subtype = selectedPrimarySubtype
|
||||
primaryComponent.settings.addressType = quack.AddressType.ADDRESS_TYPE_I2C
|
||||
primaryComponent.settings.address = decimalAddress
|
||||
primaryComponent.settings.address = addressData.address
|
||||
primaryComponent.settings.expansionLine = addressData.expansionLine
|
||||
primaryComponent.settings.muxLine = addressData.muxLine
|
||||
|
||||
primaryComponent.settings.name = getFriendlyName(selectedPrimaryType, selectedPrimarySubtype)
|
||||
toAdd.push(primaryComponent)
|
||||
|
||||
|
|
@ -161,9 +164,6 @@ export default function ScannedI2C(props: Props){
|
|||
|
||||
</Grid2>
|
||||
</Grid2>
|
||||
{
|
||||
|
||||
}
|
||||
</React.Fragment>
|
||||
:
|
||||
<Typography>Sensor Not Supported By Product</Typography>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue