Merge pull request #14 from sam-ward/master
Cleaned up some code formatting
This commit is contained in:
commit
9c93fe2a87
2 changed files with 89 additions and 90 deletions
|
|
@ -1,5 +1,6 @@
|
|||
// Tonokip RepRap firmware rewrite based off of Hydra-mmm firmware.
|
||||
// Licence: GPL
|
||||
#include <WProgram.h>
|
||||
|
||||
void get_command();
|
||||
void process_commands();
|
||||
|
|
|
|||
|
|
@ -61,23 +61,23 @@ bool direction_x, direction_y, direction_z, direction_e;
|
|||
unsigned long previous_micros=0, previous_micros_x=0, previous_micros_y=0, previous_micros_z=0, previous_micros_e=0, previous_millis_heater, previous_millis_bed_heater;
|
||||
unsigned long x_steps_to_take, y_steps_to_take, z_steps_to_take, e_steps_to_take;
|
||||
#ifdef RAMP_ACCELERATION
|
||||
unsigned long max_x_interval = 100000000.0 / (min_units_per_second * x_steps_per_unit);
|
||||
unsigned long max_y_interval = 100000000.0 / (min_units_per_second * y_steps_per_unit);
|
||||
unsigned long max_interval;
|
||||
unsigned long x_steps_per_sqr_second = max_acceleration_units_per_sq_second * x_steps_per_unit;
|
||||
unsigned long y_steps_per_sqr_second = max_acceleration_units_per_sq_second * y_steps_per_unit;
|
||||
unsigned long x_travel_steps_per_sqr_second = max_travel_acceleration_units_per_sq_second * x_steps_per_unit;
|
||||
unsigned long y_travel_steps_per_sqr_second = max_travel_acceleration_units_per_sq_second * y_steps_per_unit;
|
||||
unsigned long steps_per_sqr_second, plateau_steps;
|
||||
unsigned long max_x_interval = 100000000.0 / (min_units_per_second * x_steps_per_unit);
|
||||
unsigned long max_y_interval = 100000000.0 / (min_units_per_second * y_steps_per_unit);
|
||||
unsigned long max_interval;
|
||||
unsigned long x_steps_per_sqr_second = max_acceleration_units_per_sq_second * x_steps_per_unit;
|
||||
unsigned long y_steps_per_sqr_second = max_acceleration_units_per_sq_second * y_steps_per_unit;
|
||||
unsigned long x_travel_steps_per_sqr_second = max_travel_acceleration_units_per_sq_second * x_steps_per_unit;
|
||||
unsigned long y_travel_steps_per_sqr_second = max_travel_acceleration_units_per_sq_second * y_steps_per_unit;
|
||||
unsigned long steps_per_sqr_second, plateau_steps;
|
||||
#endif
|
||||
#ifdef EXP_ACCELERATION
|
||||
unsigned long long_full_velocity_units = full_velocity_units * 100;
|
||||
unsigned long long_travel_move_full_velocity_units = travel_move_full_velocity_units * 100;
|
||||
unsigned long max_x_interval = 100000000.0 / (min_units_per_second * x_steps_per_unit);
|
||||
unsigned long max_y_interval = 100000000.0 / (min_units_per_second * y_steps_per_unit);
|
||||
unsigned long max_interval;
|
||||
unsigned long x_min_constant_speed_steps = min_constant_speed_units * x_steps_per_unit,
|
||||
y_min_constant_speed_steps = min_constant_speed_units * y_steps_per_unit, min_constant_speed_steps;
|
||||
unsigned long long_full_velocity_units = full_velocity_units * 100;
|
||||
unsigned long long_travel_move_full_velocity_units = travel_move_full_velocity_units * 100;
|
||||
unsigned long max_x_interval = 100000000.0 / (min_units_per_second * x_steps_per_unit);
|
||||
unsigned long max_y_interval = 100000000.0 / (min_units_per_second * y_steps_per_unit);
|
||||
unsigned long max_interval;
|
||||
unsigned long x_min_constant_speed_steps = min_constant_speed_units * x_steps_per_unit,
|
||||
y_min_constant_speed_steps = min_constant_speed_units * y_steps_per_unit, min_constant_speed_steps;
|
||||
#endif
|
||||
boolean acceleration_enabled=false ,accelerating=false;
|
||||
unsigned long interval;
|
||||
|
|
@ -91,7 +91,7 @@ bool relative_mode = false; //Determines Absolute or Relative Coordinates
|
|||
bool relative_mode_e = false; //Determines Absolute or Relative E Codes while in Absolute Coordinates mode. E is always relative in Relative Coordinates mode.
|
||||
long timediff=0;
|
||||
#ifdef STEP_DELAY_RATIO
|
||||
long long_step_delay_ratio = STEP_DELAY_RATIO * 100;
|
||||
long long_step_delay_ratio = STEP_DELAY_RATIO * 100;
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -119,25 +119,25 @@ int target_bed_raw = 0;
|
|||
int current_bed_raw=0;
|
||||
float tt=0,bt=0;
|
||||
#ifdef PIDTEMP
|
||||
int temp_iState=0;
|
||||
int temp_dState=0;
|
||||
int pTerm;
|
||||
int iTerm;
|
||||
int dTerm;
|
||||
//int output;
|
||||
int error;
|
||||
int temp_iState_min = 100*-PID_INTEGRAL_DRIVE_MAX/PID_IGAIN;
|
||||
int temp_iState_max = 100*PID_INTEGRAL_DRIVE_MAX/PID_IGAIN;
|
||||
int temp_iState=0;
|
||||
int temp_dState=0;
|
||||
int pTerm;
|
||||
int iTerm;
|
||||
int dTerm;
|
||||
//int output;
|
||||
int error;
|
||||
int temp_iState_min = 100*-PID_INTEGRAL_DRIVE_MAX/PID_IGAIN;
|
||||
int temp_iState_max = 100*PID_INTEGRAL_DRIVE_MAX/PID_IGAIN;
|
||||
#endif
|
||||
#ifdef SMOOTHING
|
||||
uint32_t nma=SMOOTHFACTOR*analogRead(TEMP_0_PIN);
|
||||
uint32_t nma=SMOOTHFACTOR*analogRead(TEMP_0_PIN);
|
||||
#endif
|
||||
#ifdef WATCHPERIOD
|
||||
int watch_raw=-1000;
|
||||
unsigned long watchmillis=0;
|
||||
int watch_raw=-1000;
|
||||
unsigned long watchmillis=0;
|
||||
#endif
|
||||
#ifdef MINTEMP
|
||||
int minttemp=temp2analog(MINTEMP);
|
||||
int minttemp=temp2analog(MINTEMP);
|
||||
#endif
|
||||
|
||||
//Inactivity shutdown variables
|
||||
|
|
@ -146,56 +146,54 @@ unsigned long max_inactive_time = 0;
|
|||
unsigned long stepper_inactive_time = 0;
|
||||
|
||||
#ifdef SDSUPPORT
|
||||
Sd2Card card;
|
||||
SdVolume volume;
|
||||
SdFile root;
|
||||
SdFile file;
|
||||
uint32_t filesize=0;
|
||||
uint32_t sdpos=0;
|
||||
bool sdmode=false;
|
||||
bool sdactive=false;
|
||||
bool savetosd=false;
|
||||
int16_t n;
|
||||
|
||||
void initsd(){
|
||||
sdactive=false;
|
||||
#if SDSS>-1
|
||||
if(root.isOpen())
|
||||
root.close();
|
||||
if (!card.init(SPI_FULL_SPEED,SDSS)){
|
||||
if (!card.init(SPI_HALF_SPEED,SDSS))
|
||||
Serial.println("SD init fail");
|
||||
}
|
||||
else if (!volume.init(&card))
|
||||
Serial.println("volume.init failed");
|
||||
else if (!root.openRoot(&volume))
|
||||
Serial.println("openRoot failed");
|
||||
else
|
||||
sdactive=true;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void write_command(char *buf){
|
||||
char* begin=buf;
|
||||
char* npos=0;
|
||||
char* end=buf+strlen(buf)-1;
|
||||
|
||||
file.writeError = false;
|
||||
if((npos=strchr(buf, 'N')) != NULL){
|
||||
begin = strchr(npos,' ')+1;
|
||||
end =strchr(npos, '*')-1;
|
||||
Sd2Card card;
|
||||
SdVolume volume;
|
||||
SdFile root;
|
||||
SdFile file;
|
||||
uint32_t filesize=0;
|
||||
uint32_t sdpos=0;
|
||||
bool sdmode=false;
|
||||
bool sdactive=false;
|
||||
bool savetosd=false;
|
||||
int16_t n;
|
||||
|
||||
void initsd(){
|
||||
sdactive=false;
|
||||
#if SDSS>-1
|
||||
if(root.isOpen())
|
||||
root.close();
|
||||
if (!card.init(SPI_FULL_SPEED,SDSS)){
|
||||
if (!card.init(SPI_HALF_SPEED,SDSS))
|
||||
Serial.println("SD init fail");
|
||||
}
|
||||
end[1]='\r';
|
||||
end[2]='\n';
|
||||
end[3]='\0';
|
||||
//Serial.println(begin);
|
||||
file.write(begin);
|
||||
if (file.writeError){
|
||||
Serial.println("error writing to file");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
else if (!volume.init(&card))
|
||||
Serial.println("volume.init failed");
|
||||
else if (!root.openRoot(&volume))
|
||||
Serial.println("openRoot failed");
|
||||
else
|
||||
sdactive=true;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void write_command(char *buf){
|
||||
char* begin=buf;
|
||||
char* npos=0;
|
||||
char* end=buf+strlen(buf)-1;
|
||||
|
||||
file.writeError = false;
|
||||
if((npos=strchr(buf, 'N')) != NULL){
|
||||
begin = strchr(npos,' ')+1;
|
||||
end =strchr(npos, '*')-1;
|
||||
}
|
||||
end[1]='\r';
|
||||
end[2]='\n';
|
||||
end[3]='\0';
|
||||
//Serial.println(begin);
|
||||
file.write(begin);
|
||||
if (file.writeError){
|
||||
Serial.println("error writing to file");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -226,12 +224,12 @@ void setup()
|
|||
|
||||
//endstop pullups
|
||||
#ifdef ENDSTOPPULLUPS
|
||||
if(X_MIN_PIN > -1) { pinMode(X_MIN_PIN,INPUT); digitalWrite(X_MIN_PIN,HIGH);}
|
||||
if(Y_MIN_PIN > -1) { pinMode(Y_MIN_PIN,INPUT); digitalWrite(Y_MIN_PIN,HIGH);}
|
||||
if(Z_MIN_PIN > -1) { pinMode(Z_MIN_PIN,INPUT); digitalWrite(Z_MIN_PIN,HIGH);}
|
||||
if(X_MAX_PIN > -1) { pinMode(X_MAX_PIN,INPUT); digitalWrite(X_MAX_PIN,HIGH);}
|
||||
if(Y_MAX_PIN > -1) { pinMode(Y_MAX_PIN,INPUT); digitalWrite(Y_MAX_PIN,HIGH);}
|
||||
if(Z_MAX_PIN > -1) { pinMode(Z_MAX_PIN,INPUT); digitalWrite(Z_MAX_PIN,HIGH);}
|
||||
if(X_MIN_PIN > -1) { pinMode(X_MIN_PIN,INPUT); digitalWrite(X_MIN_PIN,HIGH);}
|
||||
if(Y_MIN_PIN > -1) { pinMode(Y_MIN_PIN,INPUT); digitalWrite(Y_MIN_PIN,HIGH);}
|
||||
if(Z_MIN_PIN > -1) { pinMode(Z_MIN_PIN,INPUT); digitalWrite(Z_MIN_PIN,HIGH);}
|
||||
if(X_MAX_PIN > -1) { pinMode(X_MAX_PIN,INPUT); digitalWrite(X_MAX_PIN,HIGH);}
|
||||
if(Y_MAX_PIN > -1) { pinMode(Y_MAX_PIN,INPUT); digitalWrite(Y_MAX_PIN,HIGH);}
|
||||
if(Z_MAX_PIN > -1) { pinMode(Z_MAX_PIN,INPUT); digitalWrite(Z_MAX_PIN,HIGH);}
|
||||
#endif
|
||||
//Initialize Enable Pins
|
||||
if(X_ENABLE_PIN > -1) pinMode(X_ENABLE_PIN,OUTPUT);
|
||||
|
|
@ -258,12 +256,12 @@ void setup()
|
|||
|
||||
#ifdef SDSUPPORT
|
||||
|
||||
//power to SD reader
|
||||
#if SDPOWER > -1
|
||||
pinMode(SDPOWER,OUTPUT);
|
||||
digitalWrite(SDPOWER,HIGH);
|
||||
#endif
|
||||
initsd();
|
||||
//power to SD reader
|
||||
#if SDPOWER > -1
|
||||
pinMode(SDPOWER,OUTPUT);
|
||||
digitalWrite(SDPOWER,HIGH);
|
||||
#endif
|
||||
initsd();
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue