Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { t } from "../../i18next_wrapper";
export const bindingTypeLabelLookup: { [x: string]: string } = {
[PinBindingType.standard]: t("Sequence"),
[PinBindingType.special]: t("Action"),
"": t("Sequence"),
};
export const bindingTypeList = (): DropDownItem[] =>
Object.entries(bindingTypeLabelLookup)
.filter(([value, _]) => !(value == ""))
.map(([value, label]) => ({ label, value }));
export const specialActionLabelLookup: { [x: string]: string } = {
[PinBindingSpecialAction.emergency_lock]: t("E-STOP"),
[PinBindingSpecialAction.emergency_unlock]: t("UNLOCK"),
[PinBindingSpecialAction.power_off]: t("Shutdown"),
[PinBindingSpecialAction.reboot]: t("Reboot"),
[PinBindingSpecialAction.sync]: t("Sync"),
[PinBindingSpecialAction.dump_info]: t("Diagnostic Report"),
[PinBindingSpecialAction.read_status]: t("Read Status"),
[PinBindingSpecialAction.take_photo]: t("Take Photo"),
"": t("None")
};
export const specialActionList: DropDownItem[] =
Object.values(PinBindingSpecialAction)
.map((action: PinBindingSpecialAction) =>
({ label: specialActionLabelLookup[action], value: action }));
/** Pin numbers for standard buttons. */
export enum ButtonPin {
.filter(n => !sysBindings.includes(n))
.filter(n => !taken.includes(n))
.filter(n => !reservedPiGPIO.includes(n))
.sort(sortByNameAndPin)
.map(n => ({ label: generatePinLabel(n), value: n }));
/** FarmBot OS default pin binding data used by Pin Bindings widget. */
export const stockPinBindings = [
{
pin_num: ButtonPin.estop,
special_action: PinBindingSpecialAction.emergency_lock,
binding_type: PinBindingType.special,
},
{
pin_num: ButtonPin.unlock,
special_action: PinBindingSpecialAction.emergency_unlock,
binding_type: PinBindingType.special,
},
];
.filter(n => !sysBindings.includes(n))
.filter(n => !taken.includes(n))
.filter(n => !reservedPiGPIO.includes(n))
.sort(sortByNameAndPin)
.map(n => ({ label: generatePinLabel(n), value: n }));
/** FarmBot OS default pin binding data used by Pin Bindings widget. */
export const stockPinBindings = [
{
pin_num: ButtonPin.estop,
special_action: PinBindingSpecialAction.emergency_lock,
binding_type: PinBindingType.special,
},
{
pin_num: ButtonPin.unlock,
special_action: PinBindingSpecialAction.emergency_unlock,
binding_type: PinBindingType.special,
},
];
[PinBindingType.standard]: t("Sequence"),
[PinBindingType.special]: t("Action"),
"": t("Sequence"),
};
export const bindingTypeList = (shouldDisplay: ShouldDisplay): DropDownItem[] =>
Object.entries(bindingTypeLabelLookup)
.filter(([value, _]) => !(value == ""))
.filter(([value, _]) =>
shouldDisplay(Feature.api_pin_bindings)
|| !(value == PinBindingType.special))
.map(([value, label]) => ({ label, value }));
export const specialActionLabelLookup: { [x: string]: string } = {
[PinBindingSpecialAction.emergency_lock]: t("E-STOP"),
[PinBindingSpecialAction.emergency_unlock]: t("UNLOCK"),
[PinBindingSpecialAction.power_off]: t("Shutdown"),
[PinBindingSpecialAction.reboot]: t("Reboot"),
[PinBindingSpecialAction.sync]: t("Sync"),
[PinBindingSpecialAction.dump_info]: t("Diagnostic Report"),
[PinBindingSpecialAction.read_status]: t("Read Status"),
[PinBindingSpecialAction.take_photo]: t("Take Photo"),
"": t("None")
};
export const specialActionList: DropDownItem[] =
Object.values(PinBindingSpecialAction)
.map((action: PinBindingSpecialAction) =>
({ label: specialActionLabelLookup[action], value: action }));
/** Pin numbers for standard buttons. */
export enum ButtonPin {