farmbot_os/farmbot_core/lib/firmware/handler.ex

87 lines
2.3 KiB
Elixir
Raw Normal View History

defmodule Farmbot.Firmware.Handler do
@moduledoc """
Any module that implements this behaviour should be a GenStage.
The implementng stage should communicate with the various Farmbot
hardware such as motors and encoders. The `Farmbot.Firmware` module
will subscribe_to: the implementing handler. Events should be
Gcodes as parsed by `Farmbot.Firmware.Gcode.Parser`.
"""
2017-11-04 22:04:00 -06:00
@typedoc "Pid of a firmware implementation."
@type handler :: pid
@doc "Start a firmware handler."
@callback start_link :: {:ok, handler}
@typedoc false
@type fw_ret_val :: :ok | {:error, term}
@typedoc false
@type vec3 :: Farmbot.Firmware.Vec3.t
@typedoc false
@type axis :: Farmbot.Firmware.Vec3.axis
@typedoc false
@type fw_param :: Farmbot.Firmware.Gcode.Param.t
2017-11-05 03:07:30 -07:00
@typedoc "Speed of a command."
@type speed :: number
@typedoc "Pin"
@type pin :: number
@typedoc "Mode of a pin."
@type pin_mode :: :digital | :analog
@doc "Move to a position."
@callback move_absolute(handler, vec3, speed, speed, speed) :: fw_ret_val
@doc "Calibrate an axis."
@callback calibrate(handler, axis) :: fw_ret_val
2017-10-24 07:21:23 -06:00
@doc "Find home on an axis."
@callback find_home(handler, axis) :: fw_ret_val
2017-10-24 07:21:23 -06:00
@doc "Manually set an axis's current position to zero."
2017-11-08 13:55:16 -07:00
@callback zero(handler, axis) :: fw_ret_val
2017-11-05 03:07:30 -07:00
@doc "Home an axis."
@callback home(handler, axis) :: fw_ret_val
@doc "Home every axis."
@callback home_all(handler) :: fw_ret_val
2017-10-24 07:21:23 -06:00
@doc "Update a paramater."
@callback update_param(handler, fw_param, number) :: fw_ret_val
@doc "Read a paramater."
2017-11-08 17:55:16 -07:00
@callback read_param(handler, fw_param) :: fw_ret_val
@doc "Read all params"
@callback read_all_params(handler) :: fw_ret_val
@doc "Lock the firmware."
@callback emergency_lock(handler) :: fw_ret_val
@doc "Unlock the firmware."
@callback emergency_unlock(handler) :: fw_ret_val
@doc "Read a pin."
@callback read_pin(handler, pin, pin_mode) :: fw_ret_val
@doc "Write a pin."
@callback write_pin(handler, pin, pin_mode, number) :: fw_ret_val
2017-11-08 17:55:16 -07:00
2017-11-09 18:38:44 -07:00
@doc "Set a pin mode (input/output)"
2018-04-19 09:19:41 -06:00
@callback set_pin_mode(handler, pin, :input | :input_pullup | :output) :: fw_ret_val
2017-11-09 18:34:06 -07:00
2017-11-09 18:10:47 -07:00
@doc "Request firmware version."
@callback request_software_version(handler) :: fw_ret_val
@doc "Set angle on a servo pin."
@callback set_servo_angle(handler, pin, number) :: fw_ret_val
end