implemented the epansion line stuff

made adjustments to to the grain cable by adding i2c as an option as long as you set and expander line,
also ajusted DeviceAvailability so that an i2c address will not be claimed if the component has an expansion line set, updated the device wizard to removed pin options if the i2c port was selected and vice versa for pins since we now have a components that supports both types, updated the components setting to set the default address type based on the restriction passed in that is set by the wizard, and fall back to what is was before if one is not passed in
This commit is contained in:
csawatzky 2025-07-11 13:56:17 -06:00
parent 54a826bc2d
commit 3325c9d75b
11 changed files with 113 additions and 36 deletions

View file

@ -11,6 +11,11 @@ export type DevicePositions = number[] | ComponentAvailabilityMap | Configurable
export type DeviceAvailabilityMap = Map<quack.AddressType, DevicePositions>;
export type OffsetAvailabilityMap = Map<quack.AddressType, number[][]>;
//component types that can be connected to an expander in the I2C port
const ExpansionComponentTypes: quack.ComponentType[] = [
quack.ComponentType.COMPONENT_TYPE_GRAIN_CABLE
]
const DefaultPinArray: ConfigurablePin[] = [
{ address: 1, label: "1" },
{ address: 2, label: "2" },
@ -60,7 +65,8 @@ const DefaultAvailability: DeviceAvailabilityMap = new Map<quack.AddressType, De
[quack.ComponentType.COMPONENT_TYPE_CAPACITANCE, [0x50]],
[quack.ComponentType.COMPONENT_TYPE_CAPACITOR_CABLE, [0x50]],
[quack.ComponentType.COMPONENT_TYPE_SEN5X, [0x69]],
[quack.ComponentType.COMPONENT_TYPE_AIRFLOW, [0x2a]]
[quack.ComponentType.COMPONENT_TYPE_AIRFLOW, [0x2a]],
[quack.ComponentType.COMPONENT_TYPE_GRAIN_CABLE, [0x71]] // the address cables will use when they are plugged into the expander with V2 device only
])
],
[quack.AddressType.ADDRESS_TYPE_DAC, [0, 1]],
@ -103,7 +109,8 @@ export class DeviceAvailability {
ClaimAddress(
addressType: quack.AddressType,
componentType: quack.ComponentType,
address: number
address: number,
expansionLine?: number
) {
let offset = addressType - 8;
if (offset > 0) addressType = addressType - (7 + offset);
@ -127,6 +134,9 @@ export class DeviceAvailability {
break;
case quack.AddressType.ADDRESS_TYPE_I2C:
case quack.AddressType.ADDRESS_TYPE_SPI:
if(expansionLine){
break;
}
let addressTypePositions = cloneDeep(
this.availability.get(addressType) as ComponentAvailabilityMap
);
@ -171,7 +181,8 @@ export function FindAvailablePositions(
available.ClaimAddress(
component.settings.addressType,
component.settings.type,
or(component.settings.address, 0)
or(component.settings.address, 0),
component.settings.expansionLine
);
}
});