This may use slightly more memory in the long run (std::vector vs std::array), but it doesn't need the huge chunk to allocate
which may fails as the heap is too fragmented after config
add_module( this->slow_ticker = new SlowTicker());
this->step_ticker = new StepTicker();
- this->adc = new(AHB0) Adc();
+ this->adc = new Adc();
// TODO : These should go into platform-specific files
// LPC17xx-specific
this->add_module( this->conveyor = new Conveyor() );
this->add_module( this->simpleshell = new SimpleShell() );
- this->planner = new(AHB0) Planner();
- this->configurator = new Configurator();
+ this->planner = new Planner();
+ this->configurator = new Configurator();
}
// return a GRBL-like query string for serial ?
#include "ConfigValue.h"
#include "StepTicker.h"
#include "SlowTicker.h"
+#include "Robot.h"
// #include "libs/ChaNFSSD/SDFileSystem.h"
#include "libs/nuts_bolts.h"
}
#endif
-
// Create and add main modules
kernel->add_module( new(AHB0) Player() );
}
// start the timers and interrupts
- THEKERNEL->conveyor->start();
+ THEKERNEL->conveyor->start(THEROBOT->get_number_registered_motors());
THEKERNEL->step_ticker->start();
THEKERNEL->slow_ticker->start();
}
#define STEP_TICKER_FREQUENCY THEKERNEL->step_ticker->get_frequency()
#define STEP_TICKER_FREQUENCY_2 (STEP_TICKER_FREQUENCY*STEP_TICKER_FREQUENCY)
+uint8_t Block::n_actuators= 0;
+
// A block represents a movement, it's length for each stepper motor, and the corresponding acceleration curves.
// It's stacked on a queue, and that queue is then executed in order, to move the motors.
// Most of the accel math is also done in this class
void Block::clear()
{
- //commands.clear();
- //travel_distances.clear();
- //gcodes.clear();
- //std::vector<Gcode>().swap(gcodes); // this resizes the vector releasing its memory
-
this->steps.fill(0);
steps_event_count = 0;
acceleration_per_tick= 0;
deceleration_per_tick= 0;
total_move_ticks= 0;
+ if(tick_info.size() != n_actuators) {
+ tick_info.resize(n_actuators);
+ }
for(auto &i : tick_info) {
i.steps_per_tick= 0;
i.counter= 0;
void Block::debug() const
{
THEKERNEL->streams->printf("%p: steps-X:%04lu Y:%04lu Z:%04lu ", this, this->steps[0], this->steps[1], this->steps[2]);
- for (size_t i = E_AXIS; i < k_max_actuators; ++i) {
+ for (size_t i = E_AXIS; i < n_actuators; ++i) {
THEKERNEL->streams->printf("E%d:%04lu ", i-E_AXIS, this->steps[i]);
}
THEKERNEL->streams->printf("(max:%4lu) nominal:r%1.4f/s%1.4f mm:%1.4f acc:%1.2f accu:%5lu decu:%5lu rates:%10.4f entry/max: %10.4f/%10.4f ready:%d locked:%d ticking:%d recalc:%d nomlen:%d time:%f\r\n",
}
// prepare block for the step ticker, called everytime the block changes
-// this is done during planning so does not delay tick generation and step ticker can simplh grab the next block during the interrupt
+// this is done during planning so does not delay tick generation and step ticker can simply grab the next block during the interrupt
void Block::prepare()
{
float inv = 1.0F / this->steps_event_count;
- for (uint8_t m = 0; m < k_max_actuators; m++) {
+ for (uint8_t m = 0; m < n_actuators; m++) {
uint32_t steps = this->steps[m];
this->tick_info[m].steps_to_move = steps;
if(steps == 0) continue;
You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef BLOCK_H
-#define BLOCK_H
+#pragma once
#include <vector>
#include <bitset>
#include "ActuatorCoordinates.h"
-class Gcode;
-
class Block {
public:
Block();
};
// need info for each active motor
- std::array<tickinfo_t, k_max_actuators> tick_info;
+ //std::array<tickinfo_t, k_max_actuators> tick_info;
+ std::vector<tickinfo_t> tick_info;
+ static uint8_t n_actuators;
struct {
bool recalculate_flag:1; // Planner flag to recalculate trapezoids on entry junction
volatile bool locked:1; // set to true when the critical data is being updated, stepticker will have to skip if this is set
};
};
-
-
-#endif
}
// we allocate the queue here after config is completed so we do not run out of memory during config
-void Conveyor::start()
+void Conveyor::start(uint8_t n)
{
+ Block::n_actuators= n; // set the number of motors which determines how big the tick info vector is
queue.resize(queue_size);
running = true;
}
{
public:
Conveyor();
- void start();
+ void start(uint8_t n_actuators);
void on_module_loaded(void);
void on_idle(void *);
void set_last_probe_position(std::tuple<float, float, float, uint8_t> p) { last_probe_position = p; }
bool solo_move(const float target[], float rate_mm_s, uint8_t naxis);
uint8_t register_motor(StepperMotor*);
+ uint8_t get_number_registered_motors() const {return n_motors; }
BaseSolution* arm_solution; // Selected Arm solution ( millimeters to step calculation )
uint8_t selected_extruder;
uint8_t n_motors; //count of the motors/axis registered
- // Used by Stepper, Planner
+ // Used by Planner
friend class Planner;
- friend class Stepper;
};
#include "BaseSolution.h"
#include "StepperMotor.h"
#include "Configurator.h"
+#include "Block.h"
#include "TemperatureControlPublicAccess.h"
#include "EndstopsPublicAccess.h"
AHB0.debug(stream);
AHB1.debug(stream);
}
+
+ stream->printf("Block size: %u bytes\n", sizeof(Block));
}
static uint32_t getDeviceType()