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
2
package-lock.json
generated
2
package-lock.json
generated
|
|
@ -10889,7 +10889,7 @@
|
||||||
},
|
},
|
||||||
"node_modules/protobuf-ts": {
|
"node_modules/protobuf-ts": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#801fdcc314a081c283564e1ac551f8b012c0d59c",
|
"resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#1facaa10a603c0cad59adad9a7ca2283f51adb62",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"protobufjs": "^6.8.8"
|
"protobufjs": "^6.8.8"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -207,7 +207,7 @@ export default function DeviceScannedComponents(props: Props){
|
||||||
</Box>
|
</Box>
|
||||||
{scannedI2C.settings?.foundAddresses && scannedI2C.settings.foundAddresses.length > 0 ? scannedI2C?.settings?.foundAddresses.map((addr, index) => {
|
{scannedI2C.settings?.foundAddresses && scannedI2C.settings.foundAddresses.length > 0 ? scannedI2C?.settings?.foundAddresses.map((addr, index) => {
|
||||||
return (
|
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={{
|
<Box sx={{
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import { quack } from "protobuf-ts/quack";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
decimalAddress: number
|
addressData: quack.AddressData
|
||||||
deviceProduct: pond.DeviceProduct
|
deviceProduct: pond.DeviceProduct
|
||||||
componentSelectionCallback: (component: Component[], checked: boolean) => void
|
componentSelectionCallback: (component: Component[], checked: boolean) => void
|
||||||
availablePositions: DevicePositions
|
availablePositions: DevicePositions
|
||||||
|
|
@ -16,7 +16,7 @@ interface Props {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ScannedI2C(props: 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 [types, setTypes] = useState<quack.ComponentType[]>([])
|
||||||
const [subtypeOptions, setSubtypeOptions] = useState<Array<Subtype>>([])
|
const [subtypeOptions, setSubtypeOptions] = useState<Array<Subtype>>([])
|
||||||
const [selectedPrimaryType, setSelectedPrimaryType] = useState<quack.ComponentType>(quack.ComponentType.COMPONENT_TYPE_INVALID)
|
const [selectedPrimaryType, setSelectedPrimaryType] = useState<quack.ComponentType>(quack.ComponentType.COMPONENT_TYPE_INVALID)
|
||||||
|
|
@ -34,7 +34,7 @@ export default function ScannedI2C(props: Props){
|
||||||
if(i2cMap){
|
if(i2cMap){
|
||||||
i2cMap.forEach((val, key) => {
|
i2cMap.forEach((val, key) => {
|
||||||
let addresses = val as number[] ?? []
|
let addresses = val as number[] ?? []
|
||||||
if(addresses.length > 0 && addresses.includes(decimalAddress)){
|
if(addresses.length > 0 && addresses.includes(addressData.address)){
|
||||||
types.push(key)
|
types.push(key)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -47,7 +47,7 @@ export default function ScannedI2C(props: Props){
|
||||||
checkAddressAvailable(types[0])
|
checkAddressAvailable(types[0])
|
||||||
}
|
}
|
||||||
setTypes(types)
|
setTypes(types)
|
||||||
},[decimalAddress, deviceProduct])
|
},[addressData, deviceProduct])
|
||||||
|
|
||||||
const buildSubtypeOptions = (compType: quack.ComponentType) => {
|
const buildSubtypeOptions = (compType: quack.ComponentType) => {
|
||||||
let subtypes = getSubtypes(compType)
|
let subtypes = getSubtypes(compType)
|
||||||
|
|
@ -69,7 +69,7 @@ export default function ScannedI2C(props: Props){
|
||||||
const checkAddressAvailable = (compType: quack.ComponentType) => {
|
const checkAddressAvailable = (compType: quack.ComponentType) => {
|
||||||
let i2cMap = availablePositions as ComponentAvailabilityMap
|
let i2cMap = availablePositions as ComponentAvailabilityMap
|
||||||
let compAddresses = i2cMap.get(compType) ?? []
|
let compAddresses = i2cMap.get(compType) ?? []
|
||||||
if (!compAddresses.includes(decimalAddress)){
|
if (!compAddresses.includes(addressData.address)){
|
||||||
setAddressInUse(true)
|
setAddressInUse(true)
|
||||||
}else{
|
}else{
|
||||||
setAddressInUse(false)
|
setAddressInUse(false)
|
||||||
|
|
@ -86,7 +86,10 @@ export default function ScannedI2C(props: Props){
|
||||||
primaryComponent.settings.type = selectedPrimaryType
|
primaryComponent.settings.type = selectedPrimaryType
|
||||||
primaryComponent.settings.subtype = selectedPrimarySubtype
|
primaryComponent.settings.subtype = selectedPrimarySubtype
|
||||||
primaryComponent.settings.addressType = quack.AddressType.ADDRESS_TYPE_I2C
|
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)
|
primaryComponent.settings.name = getFriendlyName(selectedPrimaryType, selectedPrimarySubtype)
|
||||||
toAdd.push(primaryComponent)
|
toAdd.push(primaryComponent)
|
||||||
|
|
||||||
|
|
@ -161,9 +164,6 @@ export default function ScannedI2C(props: Props){
|
||||||
|
|
||||||
</Grid2>
|
</Grid2>
|
||||||
</Grid2>
|
</Grid2>
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
:
|
:
|
||||||
<Typography>Sensor Not Supported By Product</Typography>
|
<Typography>Sensor Not Supported By Product</Typography>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue