changed up the scan dispaly to show expanders properly rather than just as another sensor with no expansion line, and added the lines to the port info in the component cards

This commit is contained in:
csawatzky 2026-05-14 13:32:53 -06:00
parent 6565b854b6
commit 0910dc44cf
4 changed files with 86 additions and 22 deletions

View file

@ -190,6 +190,17 @@ export default function ComponentCard(props: Props) {
cableID = "Cable: " + (component.settings.addressType - 8);
}
return port + " " + cableID;
} else if (component.settings.addressType === quack.AddressType.ADDRESS_TYPE_I2C) {
let description = ""
let type = getFriendlyAddressTypeName(component.settings.addressType);
description = type
if(component.settings.expansionLine){
description = description + ": Exp Line " + component.settings.expansionLine
}
if(component.settings.muxLine){
description = description + " ,Mux Line " + component.settings.muxLine
}
return description
}else{
return getFriendlyAddressTypeName(component.settings.addressType);
}

View file

@ -12,6 +12,7 @@ import ResponsiveDialog from "common/ResponsiveDialog";
import { useComponentAPI, useDeviceAPI, useSnackbar } from "hooks";
import { ConfigurablePin } from "pbHelpers/AddressTypes";
import ScannedOneWirePort from "./OneWire/ScannedOneWirePort";
import I2CExpander from "./I2CExpander";
interface Props {
scannedComponents: pond.ComponentAddressMap
@ -27,6 +28,7 @@ interface CompStep {
}
let i2cBlacklistAddresses: number[] = [0x70]
let i2cExpanderAddresses: number[] = [0x71]
export default function DeviceScannedComponents(props: Props){
const {scannedComponents, device, availablePositions, availableOffsets, refreshCallback} = props
@ -35,6 +37,7 @@ export default function DeviceScannedComponents(props: Props){
const [scannedI2C, setScannedI2C] = useState<pond.DetectI2C>() //the unmodified scan of addresses
const [scannedOneWire, setScannedOneWire] = useState<pond.DetectOneWire[]>([])
const [validI2CCompAddresses, setValidI2CComponentAddresses] = useState<quack.AddressData[]>([]) //the filtered array of address data
const [expanderAddresses, setExpanderAddresses] = useState<quack.AddressData[]>([])
const [components, setComponents] = useState<Component[]>([])
const [steps, setSteps] = useState<CompStep[]>([]);
const { error, success } = useSnackbar();
@ -69,17 +72,23 @@ export default function DeviceScannedComponents(props: Props){
useEffect(()=>{
let valid: quack.AddressData[] = []
let expanders: quack.AddressData[] = []
//filter the address data
let addr = scannedI2C?.settings?.foundAddresses
console.log(addr)
if(addr){
addr.forEach(addrData => {
if(!i2cBlacklistAddresses.includes(addrData.address)){
if(!(addrData.address === 0x71 && addrData.expansionLine === undefined)){
if(i2cExpanderAddresses.includes(addrData.address) && addrData.expansionLine === 0){
expanders.push(addrData)
}else{
valid.push(addrData)
}
}
})
}
console.log(valid)
setExpanderAddresses(expanders)
setValidI2CComponentAddresses(valid)
},[scannedI2C])
@ -256,16 +265,32 @@ export default function DeviceScannedComponents(props: Props){
{scannedI2C !== undefined &&
<Box marginBottom={5}>
<Box justifyContent="space-between" display="flex">
<Typography sx={{fontWeight: 650}}>
I2C Sensors
<Typography sx={{fontWeight: 650, fontSize: 20}}>
I2C Scan
</Typography>
<Button variant="contained" color="primary" onClick={()=>{removeScan(scannedI2C.key, pond.ObjectType.OBJECT_TYPE_DETECT_I2C)}}>Clear Scan</Button>
</Box>
{validI2CCompAddresses.length > 0 ? validI2CCompAddresses.map((addr, index) => {
{expanderAddresses.length > 0 &&
<Box marginBottom={3}>
<Typography fontWeight={650}>Detected Expanders</Typography>
{expanderAddresses.map((expAddr, index) => {
return (
<I2CExpander key={index} address={expAddr}/>
)
})}
</Box>
}
{validI2CCompAddresses.length > 0 ?
<Box>
<Typography fontWeight={650}>Detected Sensors</Typography>
{validI2CCompAddresses.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) ?? new Map<quack.ComponentType, number[]>()}/>
)
}) :
})}
</Box>
:
<Box sx={{
margin: 1,
display: "flex",
@ -282,7 +307,7 @@ export default function DeviceScannedComponents(props: Props){
<Box>
<Box justifyContent="space-between" display="flex">
<Typography sx={{fontWeight: 650}}>
Pin Port Sensors
Pin Port Scan
</Typography>
</Box>
{scannedOneWire.map((scan,i) => {

View file

@ -0,0 +1,27 @@
import { Box, Typography } from "@mui/material"
import { quack } from "protobuf-ts/quack"
interface Props {
address: quack.AddressData
}
export default function I2CExpander(props: Props) {
const {address} = props
const expanderType = () => {
switch(address.address){
case 0x71:
return "Grain Cable Expander"
default:
return "Unknown Expander"
}
}
return (
<Box sx={{marginY: 1}}>
<Typography>{expanderType()} {address.muxLine ? "Mux Line: " + address.muxLine : ""}</Typography>
</Box>
)
}

View file

@ -108,6 +108,7 @@ export default function ScannedI2C(props: Props){
<Box sx={{marginY: 1}}>
{sensorNum && <Typography>Sensor {sensorNum}</Typography>}
<Typography variant="caption">{addressData.expansionLine !== 0 && "Expansion Line: " + addressData.expansionLine}</Typography>
{/* may also want to specify the mux line, not sure if the sensors will have a mux line though */}
{types.length > 0 ?
<React.Fragment>
<Grid2 container direction="row" alignItems="center" justifyContent="space-between">