Merge branch 'i2c_detect' into staging_environment

This commit is contained in:
csawatzky 2025-10-30 16:50:11 -06:00
commit 8fd63e249d
8 changed files with 69 additions and 21 deletions

View file

@ -36,6 +36,7 @@ import {
} from "pbHelpers/AddressType";
import {
extension,
FilterSubtypeI2C,
getAddressTypes,
GetComponentTypeOptions,
getFriendlyName,
@ -240,7 +241,8 @@ export default function ComponentSettings(props: Props) {
const getAvailablePositions = (
addressType: quack.AddressType,
componentType: quack.ComponentType
componentType: quack.ComponentType,
subtype: number
): number[] => {
let positions = availablePositions.get(addressType);
if (!positions) return [];
@ -249,7 +251,8 @@ export default function ComponentSettings(props: Props) {
case quack.AddressType.ADDRESS_TYPE_SPI:
let componentPositions;
if (positions) {
componentPositions = (positions as ComponentAvailabilityMap).get(componentType);
componentPositions = (positions as ComponentAvailabilityMap).get(componentType); //gets the addresses that are not claimed yet
componentPositions = FilterSubtypeI2C(componentType, subtype, componentPositions as number[]) //filters the I2C addresses for valid ones for the subtype
}
return componentPositions ? (componentPositions as number[]) : [];
case quack.AddressType.ADDRESS_TYPE_CONFIGURABLE_PIN_ARRAY:
@ -264,7 +267,8 @@ export default function ComponentSettings(props: Props) {
if (mode === "add") {
let positions = getAvailablePositions(
component.settings.addressType,
component.settings.type
component.settings.type,
component.settings.subtype
);
availablePosition = positions ? positions.length > 0 : false;
}
@ -285,7 +289,7 @@ export default function ComponentSettings(props: Props) {
component.settings.subtype
);
for (let i = 0; i < addressTypes.length; i++) {
if (getAvailablePositions(addressTypes[i], component.settings.type).length > 0) {
if (getAvailablePositions(addressTypes[i], component.settings.type, component.settings.subtype).length > 0) {
return true;
}
}
@ -383,7 +387,7 @@ export default function ComponentSettings(props: Props) {
formComponent.settings.subtype
)[0]);
formComponent.settings.address = or(
getAvailablePositions(formComponent.settings.addressType, formComponent.settings.type)[0],
getAvailablePositions(formComponent.settings.addressType, formComponent.settings.type, formComponent.settings.subtype)[0],
Component.create().settings.address
);
formComponent.settings.name = option.label;
@ -426,7 +430,7 @@ export default function ComponentSettings(props: Props) {
let availableMenuItemPositions = [];
for (let i = 0; i < addressTypes.length; i++) {
let addressType = addressTypes[i];
let availablePositions = getAvailablePositions(addressType, type);
let availablePositions = getAvailablePositions(addressType, type, subtype);
availableMenuItemPositions.push(
<MenuItem key={addressType} divider disabled>