How to use the farmbot/dist/resources/api_resources.PinBindingType.standard 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 / frontend / __test_support__ / fake_state / resources.ts View on Github external
export function fakePinBinding(): TaggedPinBinding {
  return fakeResource("PinBinding", {
    id: idCounter++,
    pin_num: 10,
    sequence_id: idCounter++,
    binding_type: PinBindingType.standard,
  });
}
github FarmBot / Farmbot-Web-App / webpack / devices / pin_bindings / pin_binding_input_group.tsx View on Github external
bindingTypeList
} from "./list_and_label_support";
import { SequenceSelectBox } from "../../sequences/sequence_select_box";
import { ResourceIndex } from "../../resources/interfaces";
import {
  PinBindingType, PinBindingSpecialAction
} from "farmbot/dist/resources/api_resources";

export class PinBindingInputGroup
  extends React.Component {
  state = {
    isEditing: false,
    pinNumberInput: undefined,
    sequenceIdInput: undefined,
    specialActionInput: undefined,
    bindingType: PinBindingType.standard,
  };

  /** Validate and provide warnings about a selected pin number. */
  setSelectedPin = (pin: number | undefined) => {
    if (!includes(this.boundPins, pin)) {
      if (includes(validGpioPins, pin)) {
        this.setState({ pinNumberInput: pin });
        if (includes(reservedPiGPIO, pin)) {
          warning(t("Reserved Raspberry Pi pin may not work as expected."));
        }
      } else {
        error(t("Invalid Raspberry Pi GPIO pin number."));
      }
    } else {
      error(t("Raspberry Pi GPIO pin already bound."));
    }
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"),
github FarmBot / Farmbot-Web-App / webpack / devices / pin_bindings / pin_binding_input_group.tsx View on Github external
: dispatch(initSave("PinBinding", pinBindingBody({
              pin_num: pinNumberInput,
              sequence_id: sequenceIdInput,
              binding_type: bindingType
            })));
        } else {
          dispatch(registerGpioPin({
            pin_number: pinNumberInput,
            sequence_id: sequenceIdInput || 0
          }));
        }
        this.setState({
          pinNumberInput: undefined,
          sequenceIdInput: undefined,
          specialActionInput: undefined,
          bindingType: PinBindingType.standard,
        });
      } else {
        error(t("Please select a sequence or action."));
      }
    } else {
      error(t("Pin number cannot be blank."));
    }
  }
github FarmBot / Farmbot-Web-App / frontend / devices / pin_bindings / pin_binding_input_group.tsx View on Github external
} from "./list_and_label_support";
import { SequenceSelectBox } from "../../sequences/sequence_select_box";
import { ResourceIndex } from "../../resources/interfaces";
import {
  PinBindingType, PinBindingSpecialAction
} from "farmbot/dist/resources/api_resources";
import { t } from "../../i18next_wrapper";

export class PinBindingInputGroup
  extends React.Component {
  state: PinBindingInputGroupState = {
    isEditing: false,
    pinNumberInput: undefined,
    sequenceIdInput: undefined,
    specialActionInput: undefined,
    bindingType: PinBindingType.standard,
  };

  /** Validate and provide warnings about a selected pin number. */
  setSelectedPin = (pin: number | undefined) => {
    if (!includes(this.boundPins, pin)) {
      if (includes(validGpioPins, pin)) {
        this.setState({ pinNumberInput: pin });
        if (includes(reservedPiGPIO, pin)) {
          warning(t("Reserved Raspberry Pi pin may not work as expected."));
        }
      } else {
        error(t("Invalid Raspberry Pi GPIO pin number."));
      }
    } else {
      error(t("Raspberry Pi GPIO pin already bound or in use."));
    }
github FarmBot / Farmbot-Web-App / frontend / devices / pin_bindings / pin_binding_input_group.tsx View on Github external
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
          })));
        this.setState({
          pinNumberInput: undefined,
          sequenceIdInput: undefined,
          specialActionInput: undefined,
          bindingType: PinBindingType.standard,
        });
      } else {
        error(t("Please select a sequence or action."));
      }
    } else {
      error(t("Pin number cannot be blank."));
    }
  }
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"),