Ver código fonte

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

Bernhard Kubicek 12 anos atrás
pai
commit
ea86a5e10f
1 arquivos alterados com 8 adições e 5 exclusões
  1. 8
    5
      Marlin/temperature.cpp

+ 8
- 5
Marlin/temperature.cpp Ver arquivo

322
   TIMSK0 |= (1<<OCIE0B);  
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
 // Timer 0 is shared with millies
327
 // Timer 0 is shared with millies
332
 ISR(TIMER0_COMPB_vect)
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
   switch(temp_state) {
337
   switch(temp_state) {
335
     case 0: // Prepare TEMP_0
338
     case 0: // Prepare TEMP_0
336
             #if (TEMP_0_PIN > -1)
339
             #if (TEMP_0_PIN > -1)

Carregando…
Cancelar
Salvar