Browse Source

better visibility of public/private/imported variables

Bernhard Kubicek 13 years ago
parent
commit
72ace55e6a
5 changed files with 132 additions and 57 deletions
  1. 12
    3
      Marlin/planner.cpp
  2. 37
    19
      Marlin/stepper.cpp
  3. 28
    13
      Marlin/temperature.cpp
  4. 28
    8
      Marlin/ultralcd.pde
  5. 27
    14
      Marlin/watchdog.pde

+ 12
- 3
Marlin/planner.cpp View File

65
 #include "temperature.h"
65
 #include "temperature.h"
66
 #include "ultralcd.h"
66
 #include "ultralcd.h"
67
 
67
 
68
-//public variables
68
+//===========================================================================
69
+//=============================public variables ============================
70
+//===========================================================================
71
+
69
 unsigned long minsegmenttime;
72
 unsigned long minsegmenttime;
70
 float max_feedrate[4]; // set the max speeds
73
 float max_feedrate[4]; // set the max speeds
71
 float axis_steps_per_unit[4];
74
 float axis_steps_per_unit[4];
77
 float max_z_jerk;
80
 float max_z_jerk;
78
 float mintravelfeedrate;
81
 float mintravelfeedrate;
79
 unsigned long axis_steps_per_sqr_second[NUM_AXIS];
82
 unsigned long axis_steps_per_sqr_second[NUM_AXIS];
83
+
84
+// The current position of the tool in absolute steps
80
 long position[4];   //rescaled from extern when axis_steps_per_unit are changed by gcode
85
 long position[4];   //rescaled from extern when axis_steps_per_unit are changed by gcode
81
 
86
 
82
 
87
 
83
-//private variables
88
+//===========================================================================
89
+//=============================private variables ============================
90
+//===========================================================================
84
 static block_t block_buffer[BLOCK_BUFFER_SIZE];            // A ring buffer for motion instfructions
91
 static block_t block_buffer[BLOCK_BUFFER_SIZE];            // A ring buffer for motion instfructions
85
 static volatile unsigned char block_buffer_head;           // Index of the next block to be pushed
92
 static volatile unsigned char block_buffer_head;           // Index of the next block to be pushed
86
 static volatile unsigned char block_buffer_tail;           // Index of the block to process now
93
 static volatile unsigned char block_buffer_tail;           // Index of the block to process now
87
 
94
 
88
-// The current position of the tool in absolute steps
89
 
95
 
90
 
96
 
97
+//===========================================================================
98
+//=============================functions         ============================
99
+//===========================================================================
91
 #define ONE_MINUTE_OF_MICROSECONDS 60000000.0
100
 #define ONE_MINUTE_OF_MICROSECONDS 60000000.0
92
 
101
 
93
 // Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the 
102
 // Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the 

+ 37
- 19
Marlin/stepper.cpp View File

32
 
32
 
33
 #include "speed_lookuptable.h"
33
 #include "speed_lookuptable.h"
34
 
34
 
35
+
36
+//===========================================================================
37
+//=============================public variables  ============================
38
+//===========================================================================
39
+block_t *current_block;  // A pointer to the block currently being traced
40
+
41
+
42
+//===========================================================================
43
+//=============================private variables ============================
44
+//===========================================================================
45
+//static makes it inpossible to be called from outside of this file by extern.!
46
+
47
+// Variables used by The Stepper Driver Interrupt
48
+static unsigned char out_bits;        // The next stepping-bits to be output
49
+static long counter_x,       // Counter variables for the bresenham line tracer
50
+            counter_y, 
51
+            counter_z,       
52
+            counter_e;
53
+static unsigned long step_events_completed; // The number of step events executed in the current block
54
+#ifdef ADVANCE
55
+  static long advance_rate, advance, final_advance = 0;
56
+  static short old_advance = 0;
57
+  static short e_steps;
58
+#endif
59
+static unsigned char busy = false; // TRUE when SIG_OUTPUT_COMPARE1A is being serviced. Used to avoid retriggering that handler.
60
+static long acceleration_time, deceleration_time;
61
+//static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate;
62
+static unsigned short acc_step_rate; // needed for deccelaration start point
63
+static char step_loops;
64
+
65
+
66
+
35
 // if DEBUG_STEPS is enabled, M114 can be used to compare two methods of determining the X,Y,Z position of the printer.
67
 // if DEBUG_STEPS is enabled, M114 can be used to compare two methods of determining the X,Y,Z position of the printer.
36
 // for debugging purposes only, should be disabled by default
68
 // for debugging purposes only, should be disabled by default
37
 #ifdef DEBUG_STEPS
69
 #ifdef DEBUG_STEPS
39
   volatile int count_direction[NUM_AXIS] = { 1, 1, 1, 1};
71
   volatile int count_direction[NUM_AXIS] = { 1, 1, 1, 1};
40
 #endif
72
 #endif
41
 
73
 
74
+//===========================================================================
75
+//=============================functions         ============================
76
+//===========================================================================
77
+  
42
 
78
 
43
 // intRes = intIn1 * intIn2 >> 16
79
 // intRes = intIn1 * intIn2 >> 16
44
 // uses:
80
 // uses:
115
 #define ENABLE_STEPPER_DRIVER_INTERRUPT()  TIMSK1 |= (1<<OCIE1A)
151
 #define ENABLE_STEPPER_DRIVER_INTERRUPT()  TIMSK1 |= (1<<OCIE1A)
116
 #define DISABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 &= ~(1<<OCIE1A)
152
 #define DISABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 &= ~(1<<OCIE1A)
117
 
153
 
118
-block_t *current_block;  // A pointer to the block currently being traced
119
 
154
 
120
-//static makes it inpossible to be called from outside of this file by extern.!
121
 
155
 
122
-// Variables used by The Stepper Driver Interrupt
123
-static unsigned char out_bits;        // The next stepping-bits to be output
124
-static long counter_x,       // Counter variables for the bresenham line tracer
125
-            counter_y, 
126
-            counter_z,       
127
-            counter_e;
128
-static unsigned long step_events_completed; // The number of step events executed in the current block
129
-#ifdef ADVANCE
130
-  static long advance_rate, advance, final_advance = 0;
131
-  static short old_advance = 0;
132
-  static short e_steps;
133
-#endif
134
-static unsigned char busy = false; // TRUE when SIG_OUTPUT_COMPARE1A is being serviced. Used to avoid retriggering that handler.
135
-static long acceleration_time, deceleration_time;
136
-//static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate;
137
-static unsigned short acc_step_rate; // needed for deccelaration start point
138
-static char step_loops;
156
+
139
 
157
 
140
 
158
 
141
 //         __________________________
159
 //         __________________________

+ 28
- 13
Marlin/temperature.cpp View File

38
 #include "temperature.h"
38
 #include "temperature.h"
39
 #include "watchdog.h"
39
 #include "watchdog.h"
40
 
40
 
41
-
41
+//===========================================================================
42
+//=============================public variables============================
43
+//===========================================================================
42
 int target_raw[3] = {0, 0, 0};
44
 int target_raw[3] = {0, 0, 0};
43
 int current_raw[3] = {0, 0, 0};
45
 int current_raw[3] = {0, 0, 0};
44
 
46
 
47
+#ifdef PIDTEMP
48
+  
49
+  // probably used external
50
+  float HeaterPower;
51
+  float pid_setpoint = 0.0;
52
+
53
+  
54
+  float Kp=DEFAULT_Kp;
55
+  float Ki=DEFAULT_Ki;
56
+  float Kd=DEFAULT_Kd;
57
+  float Kc=DEFAULT_Kc;
58
+#endif //PIDTEMP
59
+  
60
+  
61
+//===========================================================================
62
+//=============================private variables============================
63
+//===========================================================================
45
 static bool temp_meas_ready = false;
64
 static bool temp_meas_ready = false;
46
 
65
 
47
 static unsigned long previous_millis_heater, previous_millis_bed_heater;
66
 static unsigned long previous_millis_heater, previous_millis_bed_heater;
53
   static float pTerm;
72
   static float pTerm;
54
   static float iTerm;
73
   static float iTerm;
55
   static float dTerm;
74
   static float dTerm;
56
-      //int output;
75
+  //int output;
57
   static float pid_error;
76
   static float pid_error;
58
   static float temp_iState_min;
77
   static float temp_iState_min;
59
   static float temp_iState_max;
78
   static float temp_iState_max;
60
   static float pid_input;
79
   static float pid_input;
61
   static float pid_output;
80
   static float pid_output;
62
   static bool pid_reset;
81
   static bool pid_reset;
63
-  
64
-  // probably used external
65
-  float HeaterPower;
66
-  float pid_setpoint = 0.0;
67
-
68
-  
69
-  float Kp=DEFAULT_Kp;
70
-  float Ki=DEFAULT_Ki;
71
-  float Kd=DEFAULT_Kd;
72
-  float Kc=DEFAULT_Kc;
82
+ 
73
 #endif //PIDTEMP
83
 #endif //PIDTEMP
74
   
84
   
75
 #ifdef WATCHPERIOD
85
 #ifdef WATCHPERIOD
98
   static int bed_maxttemp = temp2analog(BED_MAXTEMP);
108
   static int bed_maxttemp = temp2analog(BED_MAXTEMP);
99
 #endif //BED_MAXTEMP
109
 #endif //BED_MAXTEMP
100
 
110
 
111
+//===========================================================================
112
+//=============================functions         ============================
113
+//===========================================================================
114
+  
101
 void manage_heater()
115
 void manage_heater()
102
 {
116
 {
103
   #ifdef USE_WATCHDOG
117
   #ifdef USE_WATCHDOG
544
   #endif
558
   #endif
545
   }
559
   }
546
 }
560
 }
547
-

561
+
562
+

+ 28
- 8
Marlin/ultralcd.pde View File

1
 #include "ultralcd.h"
1
 #include "ultralcd.h"
2
 #ifdef ULTRA_LCD
2
 #ifdef ULTRA_LCD
3
 
3
 
4
+//===========================================================================
5
+//=============================imported variables============================
6
+//===========================================================================
4
 
7
 
5
 extern volatile int feedmultiply;
8
 extern volatile int feedmultiply;
6
 extern volatile bool feedmultiplychanged;
9
 extern volatile bool feedmultiplychanged;
8
 extern long position[4];   
11
 extern long position[4];   
9
 extern CardReader card;
12
 extern CardReader card;
10
 
13
 
14
+//===========================================================================
15
+//=============================public variables============================
16
+//===========================================================================
17
+volatile char buttons=0;  //the last checked buttons in a bit array.
18
+int encoderpos=0;
19
+short lastenc=0;
20
+
21
+
22
+//===========================================================================
23
+//=============================private  variables============================
24
+//===========================================================================
11
 static char messagetext[LCD_WIDTH]="";
25
 static char messagetext[LCD_WIDTH]="";
12
 
26
 
27
+//return for string conversion routines
28
+static char conv[8];
29
+
13
 #include <LiquidCrystal.h>
30
 #include <LiquidCrystal.h>
14
 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 
31
 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 
15
 
32
 
16
 static unsigned long previous_millis_lcd=0;
33
 static unsigned long previous_millis_lcd=0;
17
 static long previous_millis_buttons=0;
34
 static long previous_millis_buttons=0;
18
 
35
 
19
-inline int intround(const float &x){return int(0.5+x);}
20
 
36
 
21
-volatile char buttons=0;  //the last checked buttons in a bit array.
22
-int encoderpos=0;
23
-short lastenc=0;
24
 #ifdef NEWPANEL
37
 #ifdef NEWPANEL
25
  static long blocking=0;
38
  static long blocking=0;
26
 #else
39
 #else
27
  static long blocking[8]={0,0,0,0,0,0,0,0};
40
  static long blocking[8]={0,0,0,0,0,0,0,0};
28
 #endif
41
 #endif
29
-MainMenu menu;
42
+ 
43
+static MainMenu menu;
44
+
45
+
46
+//===========================================================================
47
+//=============================functions         ============================
48
+//===========================================================================
49
+
50
+inline int intround(const float &x){return int(0.5+x);}
30
 
51
 
31
 void lcd_status(const char* message)
52
 void lcd_status(const char* message)
32
 {
53
 {
1106
   } 
1127
   } 
1107
 }
1128
 }
1108
 
1129
 
1109
-#include "SdFat.h"
1130
+
1110
 
1131
 
1111
 
1132
 
1112
 
1133
 
1437
 
1458
 
1438
 
1459
 
1439
 
1460
 
1440
-//return for string conversion routines
1441
-static char conv[8];
1461
+
1442
 
1462
 
1443
 //  convert float to string with +123.4 format
1463
 //  convert float to string with +123.4 format
1444
 char *ftostr3(const float &x)
1464
 char *ftostr3(const float &x)

+ 27
- 14
Marlin/watchdog.pde View File

3
 #include  <avr/wdt.h>
3
 #include  <avr/wdt.h>
4
 #include  <avr/interrupt.h>
4
 #include  <avr/interrupt.h>
5
 
5
 
6
+//===========================================================================
7
+//=============================private variables  ============================
8
+//===========================================================================
9
+
6
 static volatile uint8_t timeout_seconds=0;
10
 static volatile uint8_t timeout_seconds=0;
7
 
11
 
8
 void(* ctrlaltdelete) (void) = 0; //does not work on my atmega2560
12
 void(* ctrlaltdelete) (void) = 0; //does not work on my atmega2560
9
 
13
 
14
+//===========================================================================
15
+//=============================functinos         ============================
16
+//===========================================================================
17
+
18
+
19
+/// intialise watch dog with a 1 sec interrupt time
20
+void wd_init() 
21
+{
22
+  WDTCSR = (1<<WDCE )|(1<<WDE ); //allow changes
23
+  WDTCSR = (1<<WDIF)|(1<<WDIE)| (1<<WDCE )|(1<<WDE )|  (1<<WDP2 )|(1<<WDP1)|(0<<WDP0);
24
+}
25
+
26
+/// reset watchdog. MUST be called every 1s after init or avr will reset.
27
+void wd_reset() 
28
+{
29
+  wdt_reset();
30
+  timeout_seconds=0; //reset counter for resets
31
+}
32
+
33
+//===========================================================================
34
+//=============================ISR               ============================
35
+//===========================================================================
36
+
10
 //Watchdog timer interrupt, called if main program blocks >1sec
37
 //Watchdog timer interrupt, called if main program blocks >1sec
11
 ISR(WDT_vect) 
38
 ISR(WDT_vect) 
12
 { 
39
 { 
31
   }
58
   }
32
 }
59
 }
33
 
60
 
34
-/// intialise watch dog with a 1 sec interrupt time
35
-void wd_init() 
36
-{
37
-  WDTCSR = (1<<WDCE )|(1<<WDE ); //allow changes
38
-  WDTCSR = (1<<WDIF)|(1<<WDIE)| (1<<WDCE )|(1<<WDE )|  (1<<WDP2 )|(1<<WDP1)|(0<<WDP0);
39
-}
40
-
41
-/// reset watchdog. MUST be called every 1s after init or avr will reset.
42
-void wd_reset() 
43
-{
44
-  wdt_reset();
45
-  timeout_seconds=0; //reset counter for resets
46
-}
47
-
48
 #endif /* USE_WATCHDOG */
61
 #endif /* USE_WATCHDOG */

Loading…
Cancel
Save