chiark / gitweb /
moved the variables in the ISR, thats the most normal use case of static.
authorBernhard Kubicek <kubicek@gmx.at>
Sat, 5 Nov 2011 15:53:37 +0000 (16:53 +0100)
committerBernhard Kubicek <kubicek@gmx.at>
Sat, 5 Nov 2011 15:53:37 +0000 (16:53 +0100)
Marlin/temperature.cpp

index ebc772e1d883f211f0fcbd6066057029471ae24f..25df2f7014367f5c091f78ccdc8c73f849eb08c5 100644 (file)
@@ -322,15 +322,18 @@ void tp_init()
   TIMSK0 |= (1<<OCIE0B);  \r
 }\r
 \r
-static unsigned char temp_count = 0;\r
-static unsigned long raw_temp_0_value = 0;\r
-static unsigned long raw_temp_1_value = 0;\r
-static unsigned long raw_temp_2_value = 0;\r
-static unsigned char temp_state = 0;\r
+\r
 \r
 // Timer 0 is shared with millies\r
 ISR(TIMER0_COMPB_vect)\r
 {\r
+  //these variables are only accesible from the ISR, but static, so they don't loose their value\r
+  static unsigned char temp_count = 0;\r
+  static unsigned long raw_temp_0_value = 0;\r
+  static unsigned long raw_temp_1_value = 0;\r
+  static unsigned long raw_temp_2_value = 0;\r
+  static unsigned char temp_state = 0;\r
+  \r
   switch(temp_state) {\r
     case 0: // Prepare TEMP_0\r
             #if (TEMP_0_PIN > -1)\r