-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a8c45cc
commit 16427fd
Showing
4 changed files
with
101 additions
and
3 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
src/components/PageComponents/ModuleConfig/AmbientLighting.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { useDevice } from "@app/core/stores/deviceStore.js"; | ||
import type { AmbientLightingValidation } from "@app/validation/moduleConfig/ambientLighting.js"; | ||
import { DynamicForm } from "@components/Form/DynamicForm.js"; | ||
import { Protobuf } from "@meshtastic/meshtasticjs"; | ||
|
||
export const AmbientLighting = (): JSX.Element => { | ||
const { moduleConfig, setWorkingModuleConfig } = useDevice(); | ||
|
||
const onSubmit = (data: AmbientLightingValidation) => { | ||
setWorkingModuleConfig( | ||
new Protobuf.ModuleConfig({ | ||
payloadVariant: { | ||
case: "ambientLighting", | ||
value: data, | ||
}, | ||
}), | ||
); | ||
}; | ||
|
||
return ( | ||
<DynamicForm<AmbientLightingValidation> | ||
onSubmit={onSubmit} | ||
defaultValues={moduleConfig.ambientLighting} | ||
fieldGroups={[ | ||
{ | ||
label: "Ambient Lighting Settings", | ||
description: "Settings for the Ambient Lighting module", | ||
fields: [ | ||
{ | ||
type: "toggle", | ||
name: "ledState", | ||
label: "LED State", | ||
description: "Sets LED to on or off", | ||
}, | ||
{ | ||
type: "number", | ||
name: "current", | ||
label: "Current", | ||
description: "Sets the current for the LED output. Default is 10", | ||
}, | ||
{ | ||
type: "number", | ||
name: "red", | ||
label: "Red", | ||
description: "Sets the red LED level. Values are 0-255", | ||
}, | ||
{ | ||
type: "number", | ||
name: "green", | ||
label: "Green", | ||
description: "Sets the green LED level. Values are 0-255", | ||
}, | ||
{ | ||
type: "number", | ||
name: "blue", | ||
label: "Blue", | ||
description: "Sets the blue LED level. Values are 0-255", | ||
}, | ||
], | ||
}, | ||
]} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { IsBoolean, IsInt } from "class-validator"; | ||
|
||
import type { Protobuf } from "@meshtastic/meshtasticjs"; | ||
|
||
export class AmbientLightingValidation | ||
implements | ||
Omit< | ||
Protobuf.ModuleConfig_AmbientLightingConfig, | ||
keyof Protobuf.native.Message | ||
> | ||
{ | ||
@IsBoolean() | ||
ledState: boolean; | ||
|
||
@IsInt() | ||
current: number; | ||
|
||
@IsInt() | ||
red: number; | ||
|
||
@IsInt() | ||
green: number; | ||
|
||
@IsInt() | ||
blue: number; | ||
} |