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{
58 DecimalPosition target_position_2;
59 float32_t num_averaging_samples = 20;
92 void set_ratio(
float input_units,
float channel_units = 1.0);
161 void enroll(
RPC *rpc,
const String& instance_name);
168 const uint32_t ACCUMULATOR_THRESHOLD = 1000000;
169 const uint32_t PULSE_MAX_RATE = 1000000 / CORE_FRAME_PERIOD_US;
174 uint8_t output_signal = SIGNAL_X;
175 uint8_t output_inverted = 0;
178 volatile float accumulator;
179 volatile float accumulator_velocity;
180 volatile int last_direction;
181 DecimalPosition upper_limit;
182 DecimalPosition lower_limit;
183 bool upper_limit_enabled =
false;
184 bool lower_limit_enabled =
false;
188 void initialize_state();
189 void register_channel();
190 void pulse(int8_t direction);
BlockPorts provide a unified interface for mapping inputs and outputs of different StepDance componen...
Definition core.hpp:148
void disable_limits()
Disables the channel.
Definition channels.hpp:117
void disable_lower_limit()
Disables the lower position limit.
bool filtering_on
Flag indicating whether filtering is enabled for the channel.
Definition channels.hpp:52
void begin()
Initialize the Channel with no output port. Not for normal use.
DecimalPosition current_position
Current position of the channel in pulses. Current position is where the channel is currently at.
Definition channels.hpp:44
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.
DecimalPosition target_position
Target position of the channel in pulses. Target positon is what the channel is driving toward.
Definition channels.hpp:40
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.
DecimalPosition filtered_target_position
Filtered target position of the channel in pulses. This is used when the enableFiltering() method is ...
Definition channels.hpp:48
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