Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import * as React from "react";
import { McuParams, Encoder, McuParamName } from "farmbot/dist";
import { FBSelect, DropDownItem } from "../../../ui/index";
import { t } from "../../../i18next_wrapper";
export interface EncoderTypeProps {
hardware: McuParams;
onChange(key: McuParamName, value: Encoder): void;
}
export const LOOKUP: { [name: string]: DropDownItem } = {
[Encoder.differential]: { label: "Differential", value: Encoder.differential },
[Encoder.quadrature]: { label: "Single-Ended", value: Encoder.quadrature },
DEFAULT: { label: "---", value: Encoder.unknown }
};
const OPTIONS = [LOOKUP[Encoder.differential], LOOKUP[Encoder.quadrature]];
const KEYS: McuParamName[] = [
"encoder_type_x",
"encoder_type_y",
"encoder_type_z"
];
export function isEncoderValue(x: unknown): x is Encoder {
return !!Encoder[parseInt("" + x)];
}
export function findByType(input: number | string | undefined) {
return LOOKUP[input || "DEFAULT"] || LOOKUP.DEFAULT;
import * as React from "react";
import { McuParams, Encoder, McuParamName } from "farmbot/dist";
import { t } from "i18next";
import { FBSelect, DropDownItem } from "../../../ui/index";
export interface EncoderTypeProps {
hardware: McuParams;
onChange(key: McuParamName, value: Encoder): void;
}
export const LOOKUP: { [name: string]: DropDownItem } = {
[Encoder.differential]: { label: "Differential", value: Encoder.differential },
[Encoder.quadrature]: { label: "Single-Ended", value: Encoder.quadrature },
DEFAULT: { label: "---", value: Encoder.unknown }
};
const OPTIONS = [LOOKUP[Encoder.differential], LOOKUP[Encoder.quadrature]];
const KEYS: McuParamName[] = [
"encoder_type_x",
"encoder_type_y",
"encoder_type_z"
];
export function isEncoderValue(x: unknown): x is Encoder {
return !!Encoder[parseInt("" + x)];
}
export function findByType(input: number | string | undefined) {
return LOOKUP[input || "DEFAULT"] || LOOKUP.DEFAULT;