2#include <sys/_stdint.h>
3#include "output_ports.hpp"
18#define MAX_NUM_CHANNELS 10
20void run_all_registered_channels();
21void activate_channels();
34class Channel :
public Plugin{
51 DecimalPosition target_position;
52 DecimalPosition target_position_2;
53 DecimalPosition current_position;
54 DecimalPosition filtered_target_position;
55 float32_t num_averaging_samples = 20;
87 void set_ratio(
float input_units,
float channel_units = 1.0);
156 void enroll(
RPC *rpc,
const String& instance_name);
159 DecimalPosition read_deep(
BlockPort& in_blockport)
override;
165 const uint32_t ACCUMULATOR_THRESHOLD = 1000000;
166 const uint32_t PULSE_MAX_RATE = 1000000 / CORE_FRAME_PERIOD_US;
171 uint8_t output_signal = SIGNAL_X;
172 uint8_t output_inverted = 0;
175 volatile float accumulator;
176 volatile float accumulator_velocity;
177 volatile int last_direction;
178 DecimalPosition upper_limit;
179 DecimalPosition lower_limit;
180 bool upper_limit_enabled =
false;
181 bool lower_limit_enabled =
false;
185 void initialize_state();
186 void register_channel();
187 void pulse(int8_t direction);
BlockPorts provide a unified interface for mapping inputs and outputs of different StepDance componen...
Definition core.hpp:152
void disable_limits()
Disables the channel.
Definition channels.hpp:112
void disable_lower_limit()
Disables the lower position limit.
bool filtering_on
Flag indicating whether filtering is enabled for the channel.
Definition channels.hpp:45
void begin()
Initialize the Channel with no output port. Not for normal use.
BlockPort input_target_position
Blockport managing the target position of the channel in pulses. Target positon is what the channel i...
Definition channels.hpp:40
void enable()
Enables the channel.
void enable_filtering(uint16_t num_samples=20)
Enables a moving average filter with a specified sample window. The bigger the window,...
void disable()
Disables the channel.
int8_t is_outside_limits()
Checks if the current channel position is outside the set limits.
void disable_upper_limit()
Disables the upper position limit.
void begin(OutputPort *target_output_port, uint8_t output_signal)
Initialize the Channel with a target OutputPort and output signal.
void set_upper_limit(DecimalPosition upper_limit_input_units)
Sets the upper position limit for the channel. Useful if you want the channel to stop transmitting mo...
void invert_output(bool invert)
Inverts the channel output direction. Useful for reversing motor direction without changing wiring.
void invert_output()
Inverts the channel output direction.
void set_max_pulse_rate(float max_pulses_per_sec)
Sets the maxium allowable pulse rate for the channel.
void set_ratio(float input_units, float channel_units=1.0)
Sets the transmission ratio for all target transmissions.
void set_lower_limit(DecimalPosition lower_limit_input_units)
Sets the lower position limit for the channel. Useful if you want the channel to stop transmitting mo...
void disable_filtering()
Disables the moving average filter.
OutputPorts are modules that convert internal step commands into a frame of pulse signals on the phys...
Definition output_ports.hpp:108
RPC class for handling remote procedure calls over serial streams.
Definition rpc.hpp:35