You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

101 lines
3.2 KiB

import type { CannedMessageValidation } from "@app/validation/moduleConfig/cannedMessage.js";
import { useDevice } from "@core/stores/deviceStore.js";
import { Protobuf } from "@meshtastic/meshtasticjs";
import { DynamicForm } from "@app/components/DynamicForm.js";
export const CannedMessage = (): JSX.Element => {
const { moduleConfig, setWorkingModuleConfig } = useDevice();
const onSubmit = (data: CannedMessageValidation) => {
setWorkingModuleConfig(
new Protobuf.ModuleConfig({
payloadVariant: {
case: "cannedMessage",
value: data
}
})
);
};
return (
<DynamicForm<CannedMessageValidation>
onSubmit={onSubmit}
defaultValues={moduleConfig.mqtt}
fieldGroups={[
{
label: "Canned Message Settings",
description: "Settings for the Canned Message module",
fields: [
{
type: "toggle",
name: "rotary1Enabled",
label: "Rotary Encoder #1 Enabled",
description: "Enable the rotary encoder"
},
{
type: "number",
name: "inputbrokerPinA",
label: "Encoder Pin A",
description: "GPIO Pin Value (1-39) For encoder port A"
},
{
type: "number",
name: "inputbrokerPinB",
label: "Encoder Pin B",
description: "GPIO Pin Value (1-39) For encoder port B"
},
{
type: "number",
name: "inputbrokerPinPress",
label: "Encoder Pin Press",
description: "GPIO Pin Value (1-39) For encoder Press"
},
{
type: "select",
name: "inputbrokerEventCw",
label: "Clockwise event",
description: "Select input event.",
enumValue:
Protobuf.ModuleConfig_CannedMessageConfig_InputEventChar
},
{
type: "select",
name: "inputbrokerEventCcw",
label: "Counter Clockwise event",
description: "Select input event.",
enumValue:
Protobuf.ModuleConfig_CannedMessageConfig_InputEventChar
},
{
type: "select",
name: "inputbrokerEventPress",
label: "Press event",
description: "Select input event",
enumValue:
Protobuf.ModuleConfig_CannedMessageConfig_InputEventChar
},
{
type: "toggle",
name: "updown1Enabled",
label: "Up Down enabled",
description: "Enable the up / down encoder"
},
{
type: "text",
name: "allowInputSource",
label: "Allow Input Source",
description:
"Select from: '_any', 'rotEnc1', 'upDownEnc1', 'cardkb'"
},
{
type: "toggle",
name: "sendBell",
label: "Send Bell",
description: "Sends a bell character with each message"
}
]
}
]}
/>
);
};