Parcourir la source

better visibility of public/private/imported variables

Bernhard Kubicek il y a 12 ans
Parent
révision
72ace55e6a
5 fichiers modifiés avec 132 ajouts et 57 suppressions
  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 Voir le fichier

@@ -65,7 +65,10 @@
65 65
 #include "temperature.h"
66 66
 #include "ultralcd.h"
67 67
 
68
-//public variables
68
+//===========================================================================
69
+//=============================public variables ============================
70
+//===========================================================================
71
+
69 72
 unsigned long minsegmenttime;
70 73
 float max_feedrate[4]; // set the max speeds
71 74
 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
77 80
 float max_z_jerk;
78 81
 float mintravelfeedrate;
79 82
 unsigned long axis_steps_per_sqr_second[NUM_AXIS];
83
+
84
+// The current position of the tool in absolute steps
80 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 91
 static block_t block_buffer[BLOCK_BUFFER_SIZE];            // A ring buffer for motion instfructions
85 92
 static volatile unsigned char block_buffer_head;           // Index of the next block to be pushed
86 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 100
 #define ONE_MINUTE_OF_MICROSECONDS 60000000.0
92 101
 
93 102
 // Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the 

+ 37
- 19
Marlin/stepper.cpp Voir le fichier

@@ -32,6 +32,38 @@
32 32
 
33 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 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 68
 // for debugging purposes only, should be disabled by default
37 69
 #ifdef DEBUG_STEPS
@@ -39,6 +71,10 @@
39 71
   volatile int count_direction[NUM_AXIS] = { 1, 1, 1, 1};
40 72
 #endif
41 73
 
74
+//===========================================================================
75
+//=============================functions         ============================
76
+//===========================================================================
77
+  
42 78
 
43 79
 // intRes = intIn1 * intIn2 >> 16
44 80
 // uses:
@@ -115,27 +151,9 @@ asm volatile ( \
115 151
 #define ENABLE_STEPPER_DRIVER_INTERRUPT()  TIMSK1 |= (1<<OCIE1A)
116 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 Voir le fichier

@@ -38,10 +38,29 @@
38 38
 #include "temperature.h"
39 39
 #include "watchdog.h"
40 40
 
41
-
41
+//===========================================================================
42
+//=============================public variables============================
43
+//===========================================================================
42 44
 int target_raw[3] = {0, 0, 0};
43 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 64
 static bool temp_meas_ready = false;
46 65
 
47 66
 static unsigned long previous_millis_heater, previous_millis_bed_heater;
@@ -53,23 +72,14 @@ static unsigned long previous_millis_heater, previous_millis_bed_heater;
53 72
   static float pTerm;
54 73
   static float iTerm;
55 74
   static float dTerm;
56
-      //int output;
75
+  //int output;
57 76
   static float pid_error;
58 77
   static float temp_iState_min;
59 78
   static float temp_iState_max;
60 79
   static float pid_input;
61 80
   static float pid_output;
62 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 83
 #endif //PIDTEMP
74 84
   
75 85
 #ifdef WATCHPERIOD
@@ -98,6 +108,10 @@ static unsigned long previous_millis_heater, previous_millis_bed_heater;
98 108
   static int bed_maxttemp = temp2analog(BED_MAXTEMP);
99 109
 #endif //BED_MAXTEMP
100 110
 
111
+//===========================================================================
112
+//=============================functions         ============================
113
+//===========================================================================
114
+  
101 115
 void manage_heater()
102 116
 {
103 117
   #ifdef USE_WATCHDOG
@@ -544,4 +558,5 @@ ISR(TIMER0_COMPB_vect)
544 558
   #endif
545 559
   }
546 560
 }
547
-

561
+
562
+

+ 28
- 8
Marlin/ultralcd.pde Voir le fichier

@@ -1,6 +1,9 @@
1 1
 #include "ultralcd.h"
2 2
 #ifdef ULTRA_LCD
3 3
 
4
+//===========================================================================
5
+//=============================imported variables============================
6
+//===========================================================================
4 7
 
5 8
 extern volatile int feedmultiply;
6 9
 extern volatile bool feedmultiplychanged;
@@ -8,25 +11,43 @@ extern volatile bool feedmultiplychanged;
8 11
 extern long position[4];   
9 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 25
 static char messagetext[LCD_WIDTH]="";
12 26
 
27
+//return for string conversion routines
28
+static char conv[8];
29
+
13 30
 #include <LiquidCrystal.h>
14 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 33
 static unsigned long previous_millis_lcd=0;
17 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 37
 #ifdef NEWPANEL
25 38
  static long blocking=0;
26 39
 #else
27 40
  static long blocking[8]={0,0,0,0,0,0,0,0};
28 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 52
 void lcd_status(const char* message)
32 53
 {
@@ -1106,7 +1127,7 @@ void MainMenu::showControl()
1106 1127
   } 
1107 1128
 }
1108 1129
 
1109
-#include "SdFat.h"
1130
+
1110 1131
 
1111 1132
 
1112 1133
 
@@ -1437,8 +1458,7 @@ void MainMenu::update()
1437 1458
 
1438 1459
 
1439 1460
 
1440
-//return for string conversion routines
1441
-static char conv[8];
1461
+
1442 1462
 
1443 1463
 //  convert float to string with +123.4 format
1444 1464
 char *ftostr3(const float &x)

+ 27
- 14
Marlin/watchdog.pde Voir le fichier

@@ -3,10 +3,37 @@
3 3
 #include  <avr/wdt.h>
4 4
 #include  <avr/interrupt.h>
5 5
 
6
+//===========================================================================
7
+//=============================private variables  ============================
8
+//===========================================================================
9
+
6 10
 static volatile uint8_t timeout_seconds=0;
7 11
 
8 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 37
 //Watchdog timer interrupt, called if main program blocks >1sec
11 38
 ISR(WDT_vect) 
12 39
 { 
@@ -31,18 +58,4 @@ ISR(WDT_vect)
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 61
 #endif /* USE_WATCHDOG */

Chargement…
Annuler
Enregistrer