How to use the farmbot/dist/resources/api_resources.PinBindingType.special function in farmbot

To help you get started, we’ve selected a few farmbot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github FarmBot / Farmbot-Web-App / webpack / devices / pin_bindings / list_and_label_support.tsx View on Github external
import { t } from "i18next";
import {
  PinBindingType,
  PinBindingSpecialAction
} from "farmbot/dist/resources/api_resources";
import { DropDownItem } from "../../ui";
import { gpio } from "./rpi_gpio_diagram";
import { flattenDeep, isNumber } from "lodash";
import { ShouldDisplay, Feature } from "../interfaces";
import { sysBtnBindings } from "./tagged_pin_binding_init";

export const bindingTypeLabelLookup: { [x: string]: string } = {
  [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"),
github FarmBot / Farmbot-Web-App / frontend / devices / pin_bindings / tagged_pin_binding_init.tsx View on Github external
(bodyInputs: {
    pin_num: number,
    binding_type: PinBindingType,
    sequence_id?: number | undefined,
    special_action?: PinBindingSpecialAction | undefined
  }): PinBinding => {
    const { pin_num, binding_type, special_action, sequence_id } = bodyInputs;
    const body: PinBinding =
      binding_type == PinBindingType.special
        ? {
          pin_num,
          binding_type,
          special_action: special_action
            || PinBindingSpecialAction.emergency_lock,
        }
        : {
          pin_num,
          binding_type,
          sequence_id: sequence_id || 0,
        };
    return body;
  };
github FarmBot / Farmbot-Web-App / frontend / devices / pin_bindings / pin_bindings.tsx View on Github external
const getBindingTarget = (bindingBody: PinBinding): {
  sequence_id: number | undefined,
  special_action: PinBindingSpecialAction | undefined
} => {
  return bindingBody.binding_type == PinBindingType.special
    ? { sequence_id: undefined, special_action: bindingBody.special_action }
    : { sequence_id: bindingBody.sequence_id, special_action: undefined };
};
github FarmBot / Farmbot-Web-App / webpack / devices / pin_bindings / list_and_label_support.tsx View on Github external
.filter(([value, _]) =>
      shouldDisplay(Feature.api_pin_bindings)
      || !(value == PinBindingType.special))
    .map(([value, label]) => ({ label, value }));
github FarmBot / Farmbot-Web-App / webpack / devices / pin_bindings / tagged_pin_binding_init.tsx View on Github external
(bodyInputs: {
    pin_num: number,
    binding_type: PinBindingType,
    sequence_id?: number | undefined,
    special_action?: PinBindingSpecialAction | undefined
  }): PinBinding => {
    const { pin_num, binding_type, special_action, sequence_id } = bodyInputs;
    const body: PinBinding =
      binding_type == PinBindingType.special
        ? {
          pin_num,
          binding_type,
          special_action: special_action
            || PinBindingSpecialAction.emergency_lock,
        }
        : {
          pin_num,
          binding_type,
          sequence_id: sequence_id || 0,
        };
    return body;
  };
github FarmBot / Farmbot-Web-App / frontend / devices / pin_bindings / list_and_label_support.tsx View on Github external
import {
  PinBindingType,
  PinBindingSpecialAction
} from "farmbot/dist/resources/api_resources";
import { DropDownItem } from "../../ui";
import { gpio } from "./rpi_gpio_diagram";
import { flattenDeep, isNumber } from "lodash";
import { sysBtnBindings } from "./tagged_pin_binding_init";
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"),
github FarmBot / Farmbot-Web-App / webpack / devices / pin_bindings / pin_binding_input_group.tsx View on Github external
bindPin = () => {
    const { shouldDisplay, dispatch } = this.props;
    const {
      pinNumberInput, sequenceIdInput, bindingType, specialActionInput
    } = this.state;
    if (isNumber(pinNumberInput)) {
      if (bindingType && (sequenceIdInput || specialActionInput)) {
        if (shouldDisplay(Feature.api_pin_bindings)) {
          bindingType == PinBindingType.special
            ? dispatch(initSave("PinBinding", pinBindingBody({
              pin_num: pinNumberInput,
              special_action: specialActionInput,
              binding_type: bindingType
            })))
            : dispatch(initSave("PinBinding", pinBindingBody({
              pin_num: pinNumberInput,
              sequence_id: sequenceIdInput,
              binding_type: bindingType
            })));
        } else {
          dispatch(registerGpioPin({
            pin_number: pinNumberInput,
            sequence_id: sequenceIdInput || 0
          }));
        }
github FarmBot / Farmbot-Web-App / frontend / devices / pin_bindings / list_and_label_support.tsx View on Github external
.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,
  },
];
github FarmBot / Farmbot-Web-App / webpack / devices / pin_bindings / pin_bindings.tsx View on Github external
const getBindingTarget = (bindingBody: PinBinding): {
  sequence_id: number | undefined,
  special_action: PinBindingSpecialAction | undefined
} => {
  return bindingBody.binding_type == PinBindingType.special
    ? { sequence_id: undefined, special_action: bindingBody.special_action }
    : { sequence_id: bindingBody.sequence_id, special_action: undefined };
};