chiark / gitweb /
better visibility of public/private/imported variables
authorBernhard Kubicek <kubicek@gmx.at>
Sun, 6 Nov 2011 22:34:40 +0000 (23:34 +0100)
committerBernhard Kubicek <kubicek@gmx.at>
Sun, 6 Nov 2011 22:34:40 +0000 (23:34 +0100)
Marlin/planner.cpp
Marlin/stepper.cpp
Marlin/temperature.cpp
Marlin/ultralcd.pde
Marlin/watchdog.pde

index 888fe45c8fd066efe919041b0c9e92bd53ed00b5..34e29ff53561c41ff4fbb0477fb7378ec8e93f68 100644 (file)
 #include "temperature.h"\r
 #include "ultralcd.h"\r
 \r
-//public variables\r
+//===========================================================================\r
+//=============================public variables ============================\r
+//===========================================================================\r
+\r
 unsigned long minsegmenttime;\r
 float max_feedrate[4]; // set the max speeds\r
 float axis_steps_per_unit[4];\r
@@ -77,17 +80,23 @@ float max_xy_jerk; //speed than can be stopped at once, if i understand correctl
 float max_z_jerk;\r
 float mintravelfeedrate;\r
 unsigned long axis_steps_per_sqr_second[NUM_AXIS];\r
+\r
+// The current position of the tool in absolute steps\r
 long position[4];   //rescaled from extern when axis_steps_per_unit are changed by gcode\r
 \r
 \r
-//private variables\r
+//===========================================================================\r
+//=============================private variables ============================\r
+//===========================================================================\r
 static block_t block_buffer[BLOCK_BUFFER_SIZE];            // A ring buffer for motion instfructions\r
 static volatile unsigned char block_buffer_head;           // Index of the next block to be pushed\r
 static volatile unsigned char block_buffer_tail;           // Index of the block to process now\r
 \r
-// The current position of the tool in absolute steps\r
 \r
 \r
+//===========================================================================\r
+//=============================functions         ============================\r
+//===========================================================================\r
 #define ONE_MINUTE_OF_MICROSECONDS 60000000.0\r
 \r
 // Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the \r
index 2607eef60b9d0e424ddb19067357254c61e2cdef..7d94d8063d1fbe8f49898342fa6a60e814acf4ab 100644 (file)
 \r
 #include "speed_lookuptable.h"\r
 \r
+\r
+//===========================================================================\r
+//=============================public variables  ============================\r
+//===========================================================================\r
+block_t *current_block;  // A pointer to the block currently being traced\r
+\r
+\r
+//===========================================================================\r
+//=============================private variables ============================\r
+//===========================================================================\r
+//static makes it inpossible to be called from outside of this file by extern.!\r
+\r
+// Variables used by The Stepper Driver Interrupt\r
+static unsigned char out_bits;        // The next stepping-bits to be output\r
+static long counter_x,       // Counter variables for the bresenham line tracer\r
+            counter_y, \r
+            counter_z,       \r
+            counter_e;\r
+static unsigned long step_events_completed; // The number of step events executed in the current block\r
+#ifdef ADVANCE\r
+  static long advance_rate, advance, final_advance = 0;\r
+  static short old_advance = 0;\r
+  static short e_steps;\r
+#endif\r
+static unsigned char busy = false; // TRUE when SIG_OUTPUT_COMPARE1A is being serviced. Used to avoid retriggering that handler.\r
+static long acceleration_time, deceleration_time;\r
+//static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate;\r
+static unsigned short acc_step_rate; // needed for deccelaration start point\r
+static char step_loops;\r
+\r
+\r
+\r
 // if DEBUG_STEPS is enabled, M114 can be used to compare two methods of determining the X,Y,Z position of the printer.\r
 // for debugging purposes only, should be disabled by default\r
 #ifdef DEBUG_STEPS\r
   volatile int count_direction[NUM_AXIS] = { 1, 1, 1, 1};\r
 #endif\r
 \r
+//===========================================================================\r
+//=============================functions         ============================\r
+//===========================================================================\r
+  \r
 \r
 // intRes = intIn1 * intIn2 >> 16\r
 // uses:\r
@@ -115,27 +151,9 @@ asm volatile ( \
 #define ENABLE_STEPPER_DRIVER_INTERRUPT()  TIMSK1 |= (1<<OCIE1A)\r
 #define DISABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 &= ~(1<<OCIE1A)\r
 \r
-block_t *current_block;  // A pointer to the block currently being traced\r
 \r
-//static makes it inpossible to be called from outside of this file by extern.!\r
 \r
-// Variables used by The Stepper Driver Interrupt\r
-static unsigned char out_bits;        // The next stepping-bits to be output\r
-static long counter_x,       // Counter variables for the bresenham line tracer\r
-            counter_y, \r
-            counter_z,       \r
-            counter_e;\r
-static unsigned long step_events_completed; // The number of step events executed in the current block\r
-#ifdef ADVANCE\r
-  static long advance_rate, advance, final_advance = 0;\r
-  static short old_advance = 0;\r
-  static short e_steps;\r
-#endif\r
-static unsigned char busy = false; // TRUE when SIG_OUTPUT_COMPARE1A is being serviced. Used to avoid retriggering that handler.\r
-static long acceleration_time, deceleration_time;\r
-//static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate;\r
-static unsigned short acc_step_rate; // needed for deccelaration start point\r
-static char step_loops;\r
+\r
 \r
 \r
 //         __________________________\r
index d47e07024fc036b5b8b9c7186c9db00acbdbd110..6d81a9811da86b8b62b9d91a0f91b35599699d12 100644 (file)
 #include "temperature.h"\r
 #include "watchdog.h"\r
 \r
-\r
+//===========================================================================\r
+//=============================public variables============================\r
+//===========================================================================\r
 int target_raw[3] = {0, 0, 0};\r
 int current_raw[3] = {0, 0, 0};\r
 \r
+#ifdef PIDTEMP\r
+  \r
+  // probably used external\r
+  float HeaterPower;\r
+  float pid_setpoint = 0.0;\r
+\r
+  \r
+  float Kp=DEFAULT_Kp;\r
+  float Ki=DEFAULT_Ki;\r
+  float Kd=DEFAULT_Kd;\r
+  float Kc=DEFAULT_Kc;\r
+#endif //PIDTEMP\r
+  \r
+  \r
+//===========================================================================\r
+//=============================private variables============================\r
+//===========================================================================\r
 static bool temp_meas_ready = false;\r
 \r
 static unsigned long previous_millis_heater, previous_millis_bed_heater;\r
@@ -53,23 +72,14 @@ static unsigned long previous_millis_heater, previous_millis_bed_heater;
   static float pTerm;\r
   static float iTerm;\r
   static float dTerm;\r
-      //int output;\r
+  //int output;\r
   static float pid_error;\r
   static float temp_iState_min;\r
   static float temp_iState_max;\r
   static float pid_input;\r
   static float pid_output;\r
   static bool pid_reset;\r
-  \r
-  // probably used external\r
-  float HeaterPower;\r
-  float pid_setpoint = 0.0;\r
-\r
-  \r
-  float Kp=DEFAULT_Kp;\r
-  float Ki=DEFAULT_Ki;\r
-  float Kd=DEFAULT_Kd;\r
-  float Kc=DEFAULT_Kc;\r
\r
 #endif //PIDTEMP\r
   \r
 #ifdef WATCHPERIOD\r
@@ -98,6 +108,10 @@ static unsigned long previous_millis_heater, previous_millis_bed_heater;
   static int bed_maxttemp = temp2analog(BED_MAXTEMP);\r
 #endif //BED_MAXTEMP\r
 \r
+//===========================================================================\r
+//=============================functions         ============================\r
+//===========================================================================\r
+  \r
 void manage_heater()\r
 {\r
   #ifdef USE_WATCHDOG\r
@@ -544,4 +558,5 @@ ISR(TIMER0_COMPB_vect)
   #endif\r
   }\r
 }\r
-\r\r
+\r
+\r
index d437cf3a663ed657460d0ccc3569b1a5aef99fd6..981aa8147034e5edf4776cbd3fe47dea12aa9461 100644 (file)
@@ -1,6 +1,9 @@
 #include "ultralcd.h"\r
 #ifdef ULTRA_LCD\r
 \r
+//===========================================================================\r
+//=============================imported variables============================\r
+//===========================================================================\r
 \r
 extern volatile int feedmultiply;\r
 extern volatile bool feedmultiplychanged;\r
@@ -8,25 +11,43 @@ extern volatile bool feedmultiplychanged;
 extern long position[4];   \r
 extern CardReader card;\r
 \r
+//===========================================================================\r
+//=============================public variables============================\r
+//===========================================================================\r
+volatile char buttons=0;  //the last checked buttons in a bit array.\r
+int encoderpos=0;\r
+short lastenc=0;\r
+\r
+\r
+//===========================================================================\r
+//=============================private  variables============================\r
+//===========================================================================\r
 static char messagetext[LCD_WIDTH]="";\r
 \r
+//return for string conversion routines\r
+static char conv[8];\r
+\r
 #include <LiquidCrystal.h>\r
 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 \r
 \r
 static unsigned long previous_millis_lcd=0;\r
 static long previous_millis_buttons=0;\r
 \r
-inline int intround(const float &x){return int(0.5+x);}\r
 \r
-volatile char buttons=0;  //the last checked buttons in a bit array.\r
-int encoderpos=0;\r
-short lastenc=0;\r
 #ifdef NEWPANEL\r
  static long blocking=0;\r
 #else\r
  static long blocking[8]={0,0,0,0,0,0,0,0};\r
 #endif\r
-MainMenu menu;\r
\r
+static MainMenu menu;\r
+\r
+\r
+//===========================================================================\r
+//=============================functions         ============================\r
+//===========================================================================\r
+\r
+inline int intround(const float &x){return int(0.5+x);}\r
 \r
 void lcd_status(const char* message)\r
 {\r
@@ -1106,7 +1127,7 @@ void MainMenu::showControl()
   } \r
 }\r
 \r
-#include "SdFat.h"\r
+\r
 \r
 \r
 \r
@@ -1437,8 +1458,7 @@ void MainMenu::update()
 \r
 \r
 \r
-//return for string conversion routines\r
-static char conv[8];\r
+\r
 \r
 //  convert float to string with +123.4 format\r
 char *ftostr3(const float &x)\r
index 71868cec5ba50f0d4e01c267449b729a8072c56c..167bc633d31e46c9c609196d6f1d0a9e3fa3df59 100644 (file)
@@ -3,10 +3,37 @@
 #include  <avr/wdt.h>
 #include  <avr/interrupt.h>
 
+//===========================================================================
+//=============================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<<WDCE )|(1<<WDE ); //allow changes
+  WDTCSR = (1<<WDIF)|(1<<WDIE)| (1<<WDCE )|(1<<WDE )|  (1<<WDP2 )|(1<<WDP1)|(0<<WDP0);
+}
+
+/// reset watchdog. MUST be called every 1s after init or avr will reset.
+void wd_reset() 
+{
+  wdt_reset();
+  timeout_seconds=0; //reset counter for resets
+}
+
+//===========================================================================
+//=============================ISR               ============================
+//===========================================================================
+
 //Watchdog timer interrupt, called if main program blocks >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<<WDCE )|(1<<WDE ); //allow changes
-  WDTCSR = (1<<WDIF)|(1<<WDIE)| (1<<WDCE )|(1<<WDE )|  (1<<WDP2 )|(1<<WDP1)|(0<<WDP0);
-}
-
-/// reset watchdog. MUST be called every 1s after init or avr will reset.
-void wd_reset() 
-{
-  wdt_reset();
-  timeout_seconds=0; //reset counter for resets
-}
-
 #endif /* USE_WATCHDOG */