Reduce memory use
* Command definition now uses char * instead of String * registered_commands is now an array of pointers to Commands, previously this was an array of Command and was allocated to MAX_COMMANDS entries which were then overwritten with the module provided Commands, so every Command used twice as much memory. This saves ~200bytes * Several (u)ints are now (u)int8_t On the nano with all modules included this reduces global RAM use from 1676 bytes to 1237 bytes (from 81.8% to 60.4%).
This commit is contained in:
parent
2dab1008dc
commit
1c8e725282
4 changed files with 36 additions and 30 deletions
|
|
@ -11,12 +11,12 @@
|
|||
unsigned long retreat_steps = 5000;
|
||||
unsigned long home_move_steps = 100000;
|
||||
unsigned long axis_max[STAGE_N_MOTORS];
|
||||
const int axis_max_eeprom = sizeof(long)*(STAGE_N_MOTORS+2);
|
||||
const uint8_t axis_max_eeprom = sizeof(long)*(STAGE_N_MOTORS+2);
|
||||
#ifdef ENDSTOPS_MIN
|
||||
const int endstops_min_pins[] = WIRING_ENDSTOPS_MIN;
|
||||
const uint8_t endstops_min_pins[] = WIRING_ENDSTOPS_MIN;
|
||||
#endif
|
||||
#ifdef ENDSTOPS_MAX
|
||||
const int endstops_max_pins[] = WIRING_ENDSTOPS_MAX;
|
||||
const uint8_t endstops_max_pins[] = WIRING_ENDSTOPS_MAX;
|
||||
#endif
|
||||
bool endstops_enabled = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -10,13 +10,13 @@
|
|||
#include "main.h"
|
||||
|
||||
// The array below has 3 stepper objects, for X,Y,Z respectively
|
||||
const int n_motors = 3;
|
||||
const uint8_t n_motors = 3;
|
||||
long min_step_delay;
|
||||
const int min_step_delay_eeprom = sizeof(long) * n_motors;
|
||||
const uint8_t min_step_delay_eeprom = sizeof(long) * n_motors;
|
||||
long ramp_time;
|
||||
const int ramp_time_eeprom = sizeof(long) * (n_motors + 1);
|
||||
const int axis_max_eeprom = sizeof(long) * (n_motors + 2);
|
||||
const int non_blocking_moves_eeprom = sizeof(long) * (n_motors + 3);
|
||||
const uint8_t ramp_time_eeprom = sizeof(long) * (n_motors + 1);
|
||||
const uint8_t axis_max_eeprom = sizeof(long) * (n_motors + 2);
|
||||
const uint8_t non_blocking_moves_eeprom = sizeof(long) * (n_motors + 3);
|
||||
Stepper *motors[n_motors];
|
||||
signed long current_pos[n_motors];
|
||||
long steps_remaining[n_motors];
|
||||
|
|
@ -93,7 +93,7 @@ void start_move(long displ[n_motors])
|
|||
{
|
||||
// move all the axes in a nice move
|
||||
// split displacements into magnitude and direction, and find max. travel
|
||||
unsigned long max_steps = 0;
|
||||
long max_steps = 0;
|
||||
EACH_MOTOR
|
||||
{
|
||||
move_directions[i] = displ[i] > 0 ? 1 : -1;
|
||||
|
|
@ -103,14 +103,16 @@ void start_move(long displ[n_motors])
|
|||
}
|
||||
// scale the step delays so the move goes in a straight line, with >=1 motor
|
||||
// running at max. speed.
|
||||
EACH_MOTOR {if (displacement[i] > 0)
|
||||
EACH_MOTOR
|
||||
{
|
||||
step_delay[i] = float(max_steps) / float(displacement[i]) * float(min_step_delay);
|
||||
}
|
||||
else
|
||||
{
|
||||
step_delay[i] = 9999999999;
|
||||
}
|
||||
if (displacement[i] > 0)
|
||||
{
|
||||
step_delay[i] = float(max_steps) / float(displacement[i]) * float(min_step_delay);
|
||||
}
|
||||
else
|
||||
{
|
||||
step_delay[i] = 9999999999;
|
||||
}
|
||||
}
|
||||
EACH_MOTOR distance_moved[i] = 0;
|
||||
move_start_time = micros();
|
||||
|
|
@ -165,7 +167,7 @@ void stage_loop()
|
|||
stage_moving = false;
|
||||
EACH_MOTOR
|
||||
{
|
||||
if ((long) distance_moved[i] < displacement[i])
|
||||
if ((long)distance_moved[i] < displacement[i])
|
||||
{
|
||||
stage_moving = true; //only if all axes are done are we truly finished.
|
||||
|
||||
|
|
@ -186,7 +188,7 @@ void stage_loop()
|
|||
|
||||
void stage_move_single_axis(uint8_t axis, String command)
|
||||
{
|
||||
char * args[1];
|
||||
char *args[1];
|
||||
parse_arguments(args, command, 1);
|
||||
int move = atoi(args[0]);
|
||||
EACH_MOTOR displacement[i] = 0;
|
||||
|
|
@ -211,7 +213,7 @@ void stage_mrz(String command)
|
|||
|
||||
void stage_mr(String command)
|
||||
{
|
||||
char * args[3];
|
||||
char *args[3];
|
||||
parse_arguments(args, command, 3);
|
||||
EACH_MOTOR
|
||||
{
|
||||
|
|
@ -238,7 +240,7 @@ void stage_p(String command)
|
|||
|
||||
void stage_min_step_delay(String command)
|
||||
{
|
||||
char * args[1];
|
||||
char *args[1];
|
||||
parse_arguments(args, command, 1);
|
||||
if (args[0][0] == '?')
|
||||
{
|
||||
|
|
@ -256,7 +258,7 @@ void stage_min_step_delay(String command)
|
|||
|
||||
void stage_ramp_time(String command)
|
||||
{
|
||||
char * args[1];
|
||||
char *args[1];
|
||||
parse_arguments(args, command, 1);
|
||||
if (args[0][0] == '?')
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue