Stepdance Software Library
Loading...
Searching...
No Matches
InputPort Class Reference

InputPort components receive motion streams on physical Stepdance input ports, and map these signals to downstream components. More...

#include <input_ports.hpp>

Inheritance diagram for InputPort:

Public Member Functions

 InputPort ()
 Default constructor for InputPort.
void begin (uint8_t port_number)
 Initialize the InputPort with a port number corresponding to the target physical port on the Stepdance Board.
void enable_all_signals ()
 Enables all input signals (SIGNAL_X, SIGNAL_Y, SIGNAL_Z, SIGNAL_E, SIGNAL_R, SIGNAL_T). Signals are enabled by default.
void disable_all_signals ()
 Disables all input signals (SIGNAL_X, SIGNAL_Y, SIGNAL_Z, SIGNAL_E, SIGNAL_R, SIGNAL_T).
void enable_signal (uint8_t signal_index)
 Enables a specific input signal.
void disable_signal (uint8_t signal_index)
 Disables a specific input signal.
void set_ratio (float output_units, float input_units=1.0)
 Sets the ratio between input units and output units for all input signals. Default is 1:1.

Public Attributes

BlockPort output_x
 BlockPort that acts as output for the SIGNAL_X input.
BlockPort output_y
 BlockPort that acts as output for the SIGNAL_Y input.
BlockPort output_r
 BlockPort that acts as output for the SIGNAL_R input.
BlockPort output_t
 BlockPort that acts as output for the SIGNAL_T input.
BlockPort output_z
 BlockPort that acts as output for the SIGNAL_Z input.
BlockPort output_e
 BlockPort that acts as output for the SIGNAL_E input.

Detailed Description

InputPort components receive motion streams on physical Stepdance input ports, and map these signals to downstream components.

Receiving and decoding of input streams occurs asynchronously. Here's an example of how to instantiate and configure an InputPort and map it to an OutputPort:

#define module_driver
#include "stepdance.hpp"
InputPort input_a;
Channel channel_z;
KinematicsCoreXY axidraw_kinematics;
void setup() {
// -- Configure and start the input port --
input_a.begin(INPUT_A); // "INPUT_A" specifies the physical port on the PCB for the input.
// -- Map InputPort x, y, and z Output BlockPorts to kinematics object BlockPorts --
input_a.output_x.set_ratio(0.01, 1); //for this mapping, 1 step is 0.01mm
input_a.output_x.map(&axidraw_kinematics.input_x);
input_a.output_y.set_ratio(0.01, 1); //1 step is 0.01mm
input_a.output_y.map(&axidraw_kinematics.input_y);
input_a.output_z.set_ratio(0.01, 1); //1 step is 0.01mm
input_a.output_z.map(&channel_z.input_target_position);
}
void loop(){
dance_loop();
}

Constructor & Destructor Documentation

◆ InputPort()

InputPort::InputPort ( )

Default constructor for InputPort.

Initializes an InputPort instance with default, unconfigured state. This does not configure hardware or register the port; call begin() to initialize hardware-specific settings and register the port with the system.

Member Function Documentation

◆ begin()

void InputPort::begin ( uint8_t port_number)

Initialize the InputPort with a port number corresponding to the target physical port on the Stepdance Board.

Parameters
port_numberIndex of the physical input port (INPUT_A for all Basic Modules and INPUT_A through INPUT_D for Machine Controllers).

◆ disable_signal()

void InputPort::disable_signal ( uint8_t signal_index)

Disables a specific input signal.

Parameters
signal_indexIndex of the signal to disable (SIGNAL_X, SIGNAL_Y, SIGNAL_Z, SIGNAL_E, SIGNAL_R, SIGNAL_T).

◆ enable_signal()

void InputPort::enable_signal ( uint8_t signal_index)

Enables a specific input signal.

Parameters
signal_indexIndex of the signal to enable (SIGNAL_X, SIGNAL_Y, SIGNAL_Z, SIGNAL_E, SIGNAL_R, SIGNAL_T).

◆ set_ratio()

void InputPort::set_ratio ( float output_units,
float input_units = 1.0 )

Sets the ratio between input units and output units for all input signals. Default is 1:1.

Parameters
output_unitsNumber of world units per input unit.
input_unitsNumber of input units. Default is 1.

Member Data Documentation

◆ output_x

BlockPort InputPort::output_x

BlockPort that acts as output for the SIGNAL_X input.

InputPort inputA;
inputA.begin(INPUT_A); // Initialize InputPort A
inputA.output_x.map(channelX.input_target_position); // Map SIGNAL_X to Channel X's input target position
void map(BlockPort *map_target, uint8_t mode)
Maps this BlockPort to a target BlockPort with a specified mode (INCREMENTAL or ABSOLUTE).
BlockPort output_x
BlockPort that acts as output for the SIGNAL_X input.
Definition input_ports.hpp:123
void begin(uint8_t port_number)
Initialize the InputPort with a port number corresponding to the target physical port on the Stepdanc...
InputPort()
Default constructor for InputPort.

The documentation for this class was generated from the following file: