From 073c59c50adfff83404cecbd7797693b24121181 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 29 Jan 2015 18:52:21 -0800 Subject: [PATCH] Clean up some formatting - Also partial cleanup of Marlin_main.cpp with a smidgen of Doxygen. --- Marlin/Marlin_main.cpp | 156 +++++++++--------- Marlin/boards.h | 2 +- Marlin/language.h | 2 - .../ultralcd_implementation_hitachi_HD44780.h | 10 +- 4 files changed, 83 insertions(+), 87 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 16030c795..25902d339 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -49,16 +49,16 @@ #include "math.h" #ifdef BLINKM -#include "BlinkM.h" -#include "Wire.h" + #include "BlinkM.h" + #include "Wire.h" #endif #if NUM_SERVOS > 0 -#include "Servo.h" + #include "Servo.h" #endif #if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1 -#include + #include #endif // look here for descriptions of G-codes: http://linuxcnc.org/handbook/gcode/g-code.html @@ -138,17 +138,17 @@ // M203 - Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in mm/sec // M204 - Set default acceleration: S normal moves T filament only moves (M204 S3000 T7000) in mm/sec^2 also sets minimum segment time in ms (B20000) to prevent buffer under-runs and M20 minimum feedrate // M205 - advanced settings: minimum travel speed S=while printing T=travel only, B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk, E=maximum E jerk -// M206 - set additional homing offset -// M207 - set retract length S[positive mm] F[feedrate mm/min] Z[additional zlift/hop], stays in mm regardless of M200 setting -// M208 - set recover=unretract length S[positive mm surplus to the M207 S*] F[feedrate mm/sec] +// M206 - Set additional homing offset +// M207 - Set retract length S[positive mm] F[feedrate mm/min] Z[additional zlift/hop], stays in mm regardless of M200 setting +// M208 - Set recover=unretract length S[positive mm surplus to the M207 S*] F[feedrate mm/sec] // M209 - S<1=true/0=false> enable automatic retract detect if the slicer did not support G10/11: every normal extrude-only move will be classified as retract depending on the direction. -// M218 - set hotend offset (in mm): T X Y +// M218 - Set hotend offset (in mm): T X Y // M220 S- set speed factor override percentage // M221 S- set extrude factor override percentage // M226 P S- Wait until the specified pin reaches the state required // M240 - Trigger a camera to take a photograph // M250 - Set LCD contrast C (value 0..63) -// M280 - set servo position absolute. P: servo index, S: angle or microseconds +// M280 - Set servo position absolute. P: servo index, S: angle or microseconds // M300 - Play beep sound S P // M301 - Set PID parameters P I and D // M302 - Allow cold extrudes, or set the minimum extrude S. @@ -161,14 +161,14 @@ // M405 - Turn on Filament Sensor extrusion control. Optional D to set delay in centimeters between sensor and extruder // M406 - Turn off Filament Sensor extrusion control // M407 - Displays measured filament diameter -// M500 - stores parameters in EEPROM -// M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily). -// M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to. -// M503 - print the current settings (from memory not from EEPROM). Use S0 to leave off headings. +// M500 - Store parameters in EEPROM +// M501 - Read parameters from EEPROM (if you need reset them after you changed them temporarily). +// M502 - Revert to the default "factory settings". You still need to store them in EEPROM afterwards if you want to. +// M503 - Print the current settings (from memory not from EEPROM). Use S0 to leave off headings. // M540 - Use S[0|1] to enable or disable the stop SD card print on endstop hit (requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) // M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal] -// M665 - set delta configurations -// M666 - set delta endstop adjustment +// M665 - Set delta configurations +// M666 - Set delta endstop adjustment // M605 - Set dual x-carriage movement mode: S [ X R ] // M907 - Set digital trimpot motor current using axis codes. // M908 - Control digital trimpot directly. @@ -187,25 +187,16 @@ // M928 - Start SD logging (M928 filename.g) - ended by M29 // M999 - Restart after being stopped by error -//Stepper Movement Variables - -//=========================================================================== -//=============================imported variables============================ -//=========================================================================== - - -//=========================================================================== -//=============================public variables============================= -//=========================================================================== #ifdef SDSUPPORT -CardReader card; + CardReader card; #endif + float homing_feedrate[] = HOMING_FEEDRATE; bool axis_relative_modes[] = AXIS_RELATIVE_MODES; -int feedmultiply=100; //100->1 200->2 +int feedmultiply = 100; //100->1 200->2 int saved_feedmultiply; -int extrudemultiply=100; //100->1 200->2 -int extruder_multiply[EXTRUDERS] = {100 +int extrudemultiply = 100; //100->1 200->2 +int extruder_multiply[EXTRUDERS] = { 100 #if EXTRUDERS > 1 , 100 #if EXTRUDERS > 2 @@ -240,14 +231,14 @@ float volumetric_multiplier[EXTRUDERS] = {1.0 #endif }; float current_position[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0 }; -float add_homing[3]={0,0,0}; +float add_homing[3] = { 0, 0, 0 }; #ifdef DELTA -float endstop_adj[3]={0,0,0}; + float endstop_adj[3] = { 0, 0, 0 }; #endif float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS }; float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS }; -bool axis_known_position[3] = {false, false, false}; +bool axis_known_position[3] = { false, false, false }; float zprobe_zoffset; // Extruder offset @@ -258,25 +249,36 @@ float zprobe_zoffset; #define NUM_EXTRUDER_OFFSETS 3 // supports offsets in XYZ plane #endif float extruder_offset[NUM_EXTRUDER_OFFSETS][EXTRUDERS] = { -#if defined(EXTRUDER_OFFSET_X) && defined(EXTRUDER_OFFSET_Y) - EXTRUDER_OFFSET_X, EXTRUDER_OFFSET_Y -#endif + #if defined(EXTRUDER_OFFSET_X) + EXTRUDER_OFFSET_X + #else + 0 + #endif + #if defined(EXTRUDER_OFFSET_Y) + EXTRUDER_OFFSET_Y + #else + 0 + #endif }; #endif + uint8_t active_extruder = 0; -int fanSpeed=0; +int fanSpeed = 0; + #ifdef SERVO_ENDSTOPS int servo_endstops[] = SERVO_ENDSTOPS; int servo_endstop_angles[] = SERVO_ENDSTOP_ANGLES; #endif + #ifdef BARICUDA -int ValvePressure=0; -int EtoPPressure=0; + int ValvePressure = 0; + int EtoPPressure = 0; #endif #ifdef FWRETRACT - bool autoretract_enabled=false; - bool retracted[EXTRUDERS]={false + + bool autoretract_enabled = false; + bool retracted[EXTRUDERS] = { false #if EXTRUDERS > 1 , false #if EXTRUDERS > 2 @@ -287,7 +289,7 @@ int EtoPPressure=0; #endif #endif }; - bool retracted_swap[EXTRUDERS]={false + bool retracted_swap[EXTRUDERS] = { false #if EXTRUDERS > 1 , false #if EXTRUDERS > 2 @@ -306,38 +308,41 @@ int EtoPPressure=0; float retract_recover_length = RETRACT_RECOVER_LENGTH; float retract_recover_length_swap = RETRACT_RECOVER_LENGTH_SWAP; float retract_recover_feedrate = RETRACT_RECOVER_FEEDRATE; + #endif // FWRETRACT #ifdef ULTIPANEL - #ifdef PS_DEFAULT_OFF - bool powersupply = false; - #else - bool powersupply = true; - #endif + bool powersupply = + #ifdef PS_DEFAULT_OFF + false + #else + true + #endif + ; #endif #ifdef DELTA - float delta[3] = {0.0, 0.0, 0.0}; + float delta[3] = { 0, 0, 0 }; #define SIN_60 0.8660254037844386 #define COS_60 0.5 // these are the default values, can be overriden with M665 - float delta_radius= DELTA_RADIUS; - float delta_tower1_x= -SIN_60*delta_radius; // front left tower - float delta_tower1_y= -COS_60*delta_radius; - float delta_tower2_x= SIN_60*delta_radius; // front right tower - float delta_tower2_y= -COS_60*delta_radius; - float delta_tower3_x= 0.0; // back middle tower - float delta_tower3_y= delta_radius; - float delta_diagonal_rod= DELTA_DIAGONAL_ROD; - float delta_diagonal_rod_2= sq(delta_diagonal_rod); - float delta_segments_per_second= DELTA_SEGMENTS_PER_SECOND; + float delta_radius = DELTA_RADIUS; + float delta_tower1_x = -SIN_60 * delta_radius; // front left tower + float delta_tower1_y = -COS_60 * delta_radius; + float delta_tower2_x = SIN_60 * delta_radius; // front right tower + float delta_tower2_y = -COS_60 * delta_radius; + float delta_tower3_x = 0; // back middle tower + float delta_tower3_y = delta_radius; + float delta_diagonal_rod = DELTA_DIAGONAL_ROD; + float delta_diagonal_rod_2 = sq(delta_diagonal_rod); + float delta_segments_per_second = DELTA_SEGMENTS_PER_SECOND; #endif -#ifdef SCARA // Build size scaling -float axis_scaling[3]={1,1,1}; // Build size scaling, default to 1 +#ifdef SCARA + float axis_scaling[3] = { 1, 1, 1 }; // Build size scaling, default to 1 #endif -bool cancel_heatup = false ; +bool cancel_heatup = false; #ifdef FILAMENT_SENSOR //Variables for Filament Sensor input @@ -354,17 +359,14 @@ bool cancel_heatup = false ; const char errormagic[] PROGMEM = "Error:"; const char echomagic[] PROGMEM = "echo:"; -//=========================================================================== -//=============================Private Variables============================= -//=========================================================================== const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'}; -static float destination[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0}; +static float destination[NUM_AXIS] = { 0, 0, 0, 0 }; #ifndef DELTA -static float delta[3] = {0.0, 0.0, 0.0}; + static float delta[3] = { 0, 0, 0 }; #endif -static float offset[3] = {0.0, 0.0, 0.0}; +static float offset[3] = { 0, 0, 0 }; static bool home_all_axis = true; static float feedrate = 1500.0, next_feedrate, saved_feedrate; static long gcode_N, gcode_LastN, Stopped_gcode_LastN = 0; @@ -376,29 +378,26 @@ static bool fromsd[BUFSIZE]; static int bufindr = 0; static int bufindw = 0; static int buflen = 0; -//static int i = 0; + static char serial_char; static int serial_count = 0; static boolean comment_mode = false; -static char *strchr_pointer; // just a pointer to find chars in the command string like X, Y, Z, E, etc - -const int sensitive_pins[] = SENSITIVE_PINS; // Sensitive pin list for M42 +static char *strchr_pointer; ///< A pointer to find chars in the command string (X, Y, Z, E, etc.) -//static float tt = 0; -//static float bt = 0; +const int sensitive_pins[] = SENSITIVE_PINS; ///< Sensitive pin list for M42 -//Inactivity shutdown variables +// Inactivity shutdown static unsigned long previous_millis_cmd = 0; static unsigned long max_inactive_time = 0; static unsigned long stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME*1000l; -unsigned long starttime=0; -unsigned long stoptime=0; +unsigned long starttime = 0; ///< Print job start time +unsigned long stoptime = 0; ///< Print job stop time static uint8_t tmp_extruder; -bool Stopped=false; +bool Stopped = false; #if NUM_SERVOS > 0 Servo servos[NUM_SERVOS]; @@ -407,10 +406,9 @@ bool Stopped=false; bool CooldownNoWait = true; bool target_direction; -//Insert variables if CHDK is defined #ifdef CHDK -unsigned long chdkHigh = 0; -boolean chdkActive = false; + unsigned long chdkHigh = 0; + boolean chdkActive = false; #endif //=========================================================================== diff --git a/Marlin/boards.h b/Marlin/boards.h index 18b7132dc..1a5acaa15 100644 --- a/Marlin/boards.h +++ b/Marlin/boards.h @@ -48,7 +48,7 @@ #define BOARD_ELEFU_3 21 // Elefu Ra Board (v3) #define BOARD_5DPRINT 88 // 5DPrint D8 Driver Board #define BOARD_LEAPFROG 999 // Leapfrog -#define BOARD_WITBOX 41 // bq WITBOX +#define BOARD_WITBOX 41 // bq WITBOX #define BOARD_99 99 // This is in pins.h but...? diff --git a/Marlin/language.h b/Marlin/language.h index 68630c4fc..67fc1b372 100644 --- a/Marlin/language.h +++ b/Marlin/language.h @@ -160,8 +160,6 @@ #define MSG_ERR_EEPROM_WRITE "Error writing to EEPROM!" -// LCD Menu Messages - #include LANGUAGE_INCLUDE #endif //__LANGUAGE_H diff --git a/Marlin/ultralcd_implementation_hitachi_HD44780.h b/Marlin/ultralcd_implementation_hitachi_HD44780.h index fe0953e56..9eeee1e15 100644 --- a/Marlin/ultralcd_implementation_hitachi_HD44780.h +++ b/Marlin/ultralcd_implementation_hitachi_HD44780.h @@ -1,5 +1,5 @@ -#ifndef ULTRA_LCD_IMPLEMENTATION_HITACHI_HD44780_H -#define ULTRA_LCD_IMPLEMENTATION_HITACHI_HD44780_H +#ifndef ULTRALCD_IMPLEMENTATION_HITACHI_HD44780_H +#define ULTRALCD_IMPLEMENTATION_HITACHI_HD44780_H /** * Implementation of the LCD display routines for a Hitachi HD44780 display. These are common LCD character displays. @@ -7,9 +7,9 @@ **/ #ifndef REPRAPWORLD_KEYPAD -extern volatile uint8_t buttons; //the last checked buttons in a bit array. + extern volatile uint8_t buttons; //the last checked buttons in a bit array. #else -extern volatile uint16_t buttons; //an extended version of the last checked buttons in a bit array. + extern volatile uint16_t buttons; //an extended version of the last checked buttons in a bit array. #endif //////////////////////////////////// @@ -903,4 +903,4 @@ static uint8_t lcd_implementation_read_slow_buttons() } #endif -#endif//ULTRA_LCD_IMPLEMENTATION_HITACHI_HD44780_H +#endif //__ULTRALCD_IMPLEMENTATION_HITACHI_HD44780_H