expanded component extensions with secondary components (mainly due to the scd30)
This commit is contained in:
parent
1f733d1d01
commit
98717b7c00
5 changed files with 131 additions and 75 deletions
|
|
@ -164,6 +164,7 @@ export interface ComponentTypeExtension {
|
|||
smoothingAverages?: number,
|
||||
filters?: GraphFilters
|
||||
) => LineChartData;
|
||||
secondaryComponentSettings?: () => pond.ComponentSettings[]
|
||||
}
|
||||
|
||||
export interface Summary {
|
||||
|
|
@ -621,6 +622,11 @@ export function GetComponentIcon(
|
|||
return describer.icon ? describer.icon(theme) : undefined;
|
||||
}
|
||||
|
||||
export function GetSecondaryComponents(type: quack.ComponentType, subtype?: number): pond.ComponentSettings[] {
|
||||
let describer = extension(type, subtype)
|
||||
return describer.secondaryComponentSettings ? describer.secondaryComponentSettings() : []
|
||||
}
|
||||
|
||||
//TODO: deprecated function, new graphs are handled in measurementChart (using reCharts instead of victory)
|
||||
// export function getGraphProps(
|
||||
// componentType: quack.ComponentType,
|
||||
|
|
|
|||
|
|
@ -25,7 +25,18 @@ export function CO2(subtype: number = 0): ComponentTypeExtension {
|
|||
);
|
||||
return {
|
||||
type: quack.ComponentType.COMPONENT_TYPE_CO2,
|
||||
subtypes: [],
|
||||
subtypes: [
|
||||
{
|
||||
key: quack.Co2Subtype.CO2_SUBTYPE_NONE,
|
||||
value: "CO2_SUBTYPE_NONE",
|
||||
friendlyName: "CO2 Only"
|
||||
},
|
||||
{
|
||||
key: quack.Co2Subtype.CO2_SUBTYPE_SCD30,
|
||||
value: "CO2_SUBTYPE_SCD30",
|
||||
friendlyName: "SCD30 (CO2)"
|
||||
},
|
||||
],
|
||||
friendlyName: "CO2",
|
||||
description: "Measures the parts per million of CO2",
|
||||
isController: false,
|
||||
|
|
@ -71,6 +82,24 @@ export function CO2(subtype: number = 0): ComponentTypeExtension {
|
|||
minMeasurementPeriodMs: 5000,
|
||||
icon: (theme?: "light" | "dark"): string | undefined => {
|
||||
return theme === "light" ? Co2SensorDarkIcon : Co2SensorLightIcon;
|
||||
},
|
||||
secondaryComponentSettings: () => {
|
||||
let secondaryComps: pond.ComponentSettings[] = []
|
||||
switch (subtype){ //doesn't have a default because it would just do nothing
|
||||
case quack.Co2Subtype.CO2_SUBTYPE_SCD30:
|
||||
let tempHumComp: pond.ComponentSettings = pond.ComponentSettings.create()
|
||||
//set the defaults for the component
|
||||
tempHumComp.type = quack.ComponentType.COMPONENT_TYPE_DHT
|
||||
tempHumComp.subtype = quack.DHTSubtype.DHT_SUBTYPE_SCD30
|
||||
tempHumComp.addressType = quack.AddressType.ADDRESS_TYPE_I2C
|
||||
tempHumComp.address = 0x40
|
||||
tempHumComp.name = "SCD30 (Temp/Humidity)"
|
||||
//add it to the array to be returned
|
||||
secondaryComps.push(tempHumComp)
|
||||
break
|
||||
}
|
||||
//switch statement here that uses the subtype to determine whaat the secondary component is
|
||||
return secondaryComps
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue