Browse Source

moved the variables in the ISR, thats the most normal use case of static.

Bernhard Kubicek 12 years ago
parent
commit
ea86a5e10f
1 changed files with 8 additions and 5 deletions
  1. 8
    5
      Marlin/temperature.cpp

+ 8
- 5
Marlin/temperature.cpp View File

@@ -322,15 +322,18 @@ void tp_init()
322 322
   TIMSK0 |= (1<<OCIE0B);  
323 323
 }
324 324
 
325
-static unsigned char temp_count = 0;
326
-static unsigned long raw_temp_0_value = 0;
327
-static unsigned long raw_temp_1_value = 0;
328
-static unsigned long raw_temp_2_value = 0;
329
-static unsigned char temp_state = 0;
325
+
330 326
 
331 327
 // Timer 0 is shared with millies
332 328
 ISR(TIMER0_COMPB_vect)
333 329
 {
330
+  //these variables are only accesible from the ISR, but static, so they don't loose their value
331
+  static unsigned char temp_count = 0;
332
+  static unsigned long raw_temp_0_value = 0;
333
+  static unsigned long raw_temp_1_value = 0;
334
+  static unsigned long raw_temp_2_value = 0;
335
+  static unsigned char temp_state = 0;
336
+  
334 337
   switch(temp_state) {
335 338
     case 0: // Prepare TEMP_0
336 339
             #if (TEMP_0_PIN > -1)

Loading…
Cancel
Save