From 72ace55e6ae964a5984a13e09492d1d92295f098 Mon Sep 17 00:00:00 2001 From: Bernhard Kubicek Date: Sun, 6 Nov 2011 23:34:40 +0100 Subject: [PATCH] better visibility of public/private/imported variables --- Marlin/planner.cpp | 15 ++++++++--- Marlin/stepper.cpp | 56 ++++++++++++++++++++++++++++-------------- Marlin/temperature.cpp | 41 +++++++++++++++++++++---------- Marlin/ultralcd.pde | 36 +++++++++++++++++++++------ Marlin/watchdog.pde | 41 ++++++++++++++++++++----------- 5 files changed, 132 insertions(+), 57 deletions(-) diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index 888fe45c8..34e29ff53 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -65,7 +65,10 @@ #include "temperature.h" #include "ultralcd.h" -//public variables +//=========================================================================== +//=============================public variables ============================ +//=========================================================================== + unsigned long minsegmenttime; float max_feedrate[4]; // set the max speeds float axis_steps_per_unit[4]; @@ -77,17 +80,23 @@ float max_xy_jerk; //speed than can be stopped at once, if i understand correctl float max_z_jerk; float mintravelfeedrate; unsigned long axis_steps_per_sqr_second[NUM_AXIS]; + +// The current position of the tool in absolute steps long position[4]; //rescaled from extern when axis_steps_per_unit are changed by gcode -//private variables +//=========================================================================== +//=============================private variables ============================ +//=========================================================================== static block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instfructions static volatile unsigned char block_buffer_head; // Index of the next block to be pushed static volatile unsigned char block_buffer_tail; // Index of the block to process now -// The current position of the tool in absolute steps +//=========================================================================== +//=============================functions ============================ +//=========================================================================== #define ONE_MINUTE_OF_MICROSECONDS 60000000.0 // Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index 2607eef60..7d94d8063 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -32,6 +32,38 @@ #include "speed_lookuptable.h" + +//=========================================================================== +//=============================public variables ============================ +//=========================================================================== +block_t *current_block; // A pointer to the block currently being traced + + +//=========================================================================== +//=============================private variables ============================ +//=========================================================================== +//static makes it inpossible to be called from outside of this file by extern.! + +// Variables used by The Stepper Driver Interrupt +static unsigned char out_bits; // The next stepping-bits to be output +static long counter_x, // Counter variables for the bresenham line tracer + counter_y, + counter_z, + counter_e; +static unsigned long step_events_completed; // The number of step events executed in the current block +#ifdef ADVANCE + static long advance_rate, advance, final_advance = 0; + static short old_advance = 0; + static short e_steps; +#endif +static unsigned char busy = false; // TRUE when SIG_OUTPUT_COMPARE1A is being serviced. Used to avoid retriggering that handler. +static long acceleration_time, deceleration_time; +//static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate; +static unsigned short acc_step_rate; // needed for deccelaration start point +static char step_loops; + + + // if DEBUG_STEPS is enabled, M114 can be used to compare two methods of determining the X,Y,Z position of the printer. // for debugging purposes only, should be disabled by default #ifdef DEBUG_STEPS @@ -39,6 +71,10 @@ volatile int count_direction[NUM_AXIS] = { 1, 1, 1, 1}; #endif +//=========================================================================== +//=============================functions ============================ +//=========================================================================== + // intRes = intIn1 * intIn2 >> 16 // uses: @@ -115,27 +151,9 @@ asm volatile ( \ #define ENABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 |= (1< LiquidCrystal lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7 static unsigned long previous_millis_lcd=0; static long previous_millis_buttons=0; -inline int intround(const float &x){return int(0.5+x);} -volatile char buttons=0; //the last checked buttons in a bit array. -int encoderpos=0; -short lastenc=0; #ifdef NEWPANEL static long blocking=0; #else static long blocking[8]={0,0,0,0,0,0,0,0}; #endif -MainMenu menu; + +static MainMenu menu; + + +//=========================================================================== +//=============================functions ============================ +//=========================================================================== + +inline int intround(const float &x){return int(0.5+x);} void lcd_status(const char* message) { @@ -1106,7 +1127,7 @@ void MainMenu::showControl() } } -#include "SdFat.h" + @@ -1437,8 +1458,7 @@ void MainMenu::update() -//return for string conversion routines -static char conv[8]; + // convert float to string with +123.4 format char *ftostr3(const float &x) diff --git a/Marlin/watchdog.pde b/Marlin/watchdog.pde index 71868cec5..167bc633d 100644 --- a/Marlin/watchdog.pde +++ b/Marlin/watchdog.pde @@ -3,10 +3,37 @@ #include #include +//=========================================================================== +//=============================private variables ============================ +//=========================================================================== + static volatile uint8_t timeout_seconds=0; void(* ctrlaltdelete) (void) = 0; //does not work on my atmega2560 +//=========================================================================== +//=============================functinos ============================ +//=========================================================================== + + +/// intialise watch dog with a 1 sec interrupt time +void wd_init() +{ + WDTCSR = (1<1sec ISR(WDT_vect) { @@ -31,18 +58,4 @@ ISR(WDT_vect) } } -/// intialise watch dog with a 1 sec interrupt time -void wd_init() -{ - WDTCSR = (1<