Browse Source

Buffer size > 16

Erik van der Zalm 13 years ago
parent
commit
331e82dcd3
3 changed files with 129 additions and 127 deletions
  1. 2
    2
      Marlin/Configuration.h
  2. 25
    24
      Marlin/temperature.cpp
  3. 102
    101
      Marlin/ultralcd.h

+ 2
- 2
Marlin/Configuration.h View File

311
 // The number of linear motions that can be in the plan at any give time.  
311
 // The number of linear motions that can be in the plan at any give time.  
312
 // THE BLOCK_BUFFER_SIZE NEEDS TO BE A POWER OF 2, i.g. 8,16,32 because shifts and ors are used to do the ringbuffering.
312
 // THE BLOCK_BUFFER_SIZE NEEDS TO BE A POWER OF 2, i.g. 8,16,32 because shifts and ors are used to do the ringbuffering.
313
 #if defined SDSUPPORT
313
 #if defined SDSUPPORT
314
-  #define BLOCK_BUFFER_SIZE 8   // SD,LCD,Buttons take more memory, block buffer needs to be smaller
314
+  #define BLOCK_BUFFER_SIZE 16   // SD,LCD,Buttons take more memory, block buffer needs to be smaller
315
 #else
315
 #else
316
-  #define BLOCK_BUFFER_SIZE 8 // maximize block buffer
316
+  #define BLOCK_BUFFER_SIZE 16 // maximize block buffer
317
 #endif
317
 #endif
318
 
318
 
319
 
319
 

+ 25
- 24
Marlin/temperature.cpp View File

203
   #endif
203
   #endif
204
 }
204
 }
205
 
205
 
206
+#define PGM_RD_W(x)   (short)pgm_read_word(&x)
206
 // Takes hot end temperature value as input and returns corresponding raw value. 
207
 // Takes hot end temperature value as input and returns corresponding raw value. 
207
 // For a thermistor, it uses the RepRap thermistor temp table.
208
 // For a thermistor, it uses the RepRap thermistor temp table.
208
 // This is needed because PID in hydra firmware hovers around a given analog value, not a temp value.
209
 // This is needed because PID in hydra firmware hovers around a given analog value, not a temp value.
214
 
215
 
215
     for (i=1; i<NUMTEMPS_HEATER_0; i++)
216
     for (i=1; i<NUMTEMPS_HEATER_0; i++)
216
     {
217
     {
217
-      if (pgm_read_word(&(heater_0_temptable[i][1])) < celsius)
218
+      if (PGM_RD_W(heater_0_temptable[i][1]) < celsius)
218
       {
219
       {
219
-        raw = pgm_read_word(&(heater_0_temptable[i-1][0])) + 
220
-          (celsius - pgm_read_word(&(heater_0_temptable[i-1][1]))) * 
221
-          (pgm_read_word(&(heater_0_temptable[i][0])) - pgm_read_word(&(heater_0_temptable[i-1][0]))) /
222
-          (pgm_read_word(&(heater_0_temptable[i][1])) - pgm_read_word(&(heater_0_temptable[i-1][1])));  
220
+        raw = PGM_RD_W(heater_0_temptable[i-1][0]) + 
221
+          (celsius - PGM_RD_W(heater_0_temptable[i-1][1])) * 
222
+          (PGM_RD_W(heater_0_temptable[i][0]) - PGM_RD_W(heater_0_temptable[i-1][0])) /
223
+          (PGM_RD_W(heater_0_temptable[i][1]) - PGM_RD_W(heater_0_temptable[i-1][1]));  
223
         break;
224
         break;
224
       }
225
       }
225
     }
226
     }
226
 
227
 
227
     // Overflow: Set to last value in the table
228
     // Overflow: Set to last value in the table
228
-    if (i == NUMTEMPS_HEATER_0) raw = pgm_read_word(&(heater_0_temptable[i-1][0]));
229
+    if (i == NUMTEMPS_HEATER_0) raw = PGM_RD_W(heater_0_temptable[i-1][0]);
229
 
230
 
230
     return (1023 * OVERSAMPLENR) - raw;
231
     return (1023 * OVERSAMPLENR) - raw;
231
   #elif defined HEATER_0_USES_AD595
232
   #elif defined HEATER_0_USES_AD595
245
     
246
     
246
     for (i=1; i<BNUMTEMPS; i++)
247
     for (i=1; i<BNUMTEMPS; i++)
247
     {
248
     {
248
-      if (pgm_read_word(&)bedtemptable[i][1])) < celsius)
249
+      if (PGM_RD_W(bedtemptable[i][1]) < celsius)
249
       {
250
       {
250
-        raw = pgm_read_word(&(bedtemptable[i-1][0])) + 
251
-          (celsius - pgm_read_word(&(bedtemptable[i-1][1]))) * 
252
-          (pgm_read_word(&(bedtemptable[i][0])) - pgm_read_word(&(bedtemptable[i-1][0]))) /
253
-          (pgm_read_word(&(bedtemptable[i][1])) - pgm_read_word(&(bedtemptable[i-1][1])));
251
+        raw = PGM_RD_W(bedtemptable[i-1][0]) + 
252
+          (celsius - PGM_RD_W(bedtemptable[i-1][1])) * 
253
+          (PGM_RD_W(bedtemptable[i][0]) - PGM_RD_W(bedtemptable[i-1][0])) /
254
+          (PGM_RD_W(bedtemptable[i][1]) - PGM_RD_W(bedtemptable[i-1][1]));
254
       
255
       
255
         break;
256
         break;
256
       }
257
       }
257
     }
258
     }
258
 
259
 
259
     // Overflow: Set to last value in the table
260
     // Overflow: Set to last value in the table
260
-    if (i == BNUMTEMPS) raw = pgm_read_word(&(bedtemptable[i-1][0]));
261
+    if (i == BNUMTEMPS) raw = PGM_RD_W(bedtemptable[i-1][0]);
261
 
262
 
262
     return (1023 * OVERSAMPLENR) - raw;
263
     return (1023 * OVERSAMPLENR) - raw;
263
   #elif defined BED_USES_AD595
264
   #elif defined BED_USES_AD595
274
     raw = (1023 * OVERSAMPLENR) - raw;
275
     raw = (1023 * OVERSAMPLENR) - raw;
275
     for (i=1; i<NUMTEMPS_HEATER_0; i++)
276
     for (i=1; i<NUMTEMPS_HEATER_0; i++)
276
     {
277
     {
277
-      if ((short)pgm_read_word(&heater_0_temptable[i][0]) > raw)
278
+      if (PGM_RD_W(heater_0_temptable[i][0]) > raw)
278
       {
279
       {
279
-        celsius  = (short)pgm_read_word(&heater_0_temptable[i-1][1]) + 
280
-          (raw - (short)pgm_read_word(&heater_0_temptable[i-1][0])) * 
281
-          (float)((short)pgm_read_word(&heater_0_temptable[i][1]) - (short)pgm_read_word(&heater_0_temptable[i-1][1])) /
282
-          (float)((short)pgm_read_word(&heater_0_temptable[i][0]) - (short)pgm_read_word(&heater_0_temptable[i-1][0]));
280
+        celsius  = PGM_RD_W(heater_0_temptable[i-1][1]) + 
281
+          (raw - PGM_RD_W(heater_0_temptable[i-1][0])) * 
282
+          (float)(PGM_RD_W(heater_0_temptable[i][1]) - PGM_RD_W(heater_0_temptable[i-1][1])) /
283
+          (float)(PGM_RD_W(heater_0_temptable[i][0]) - PGM_RD_W(heater_0_temptable[i-1][0]));
283
         break;
284
         break;
284
       }
285
       }
285
     }
286
     }
286
 
287
 
287
     // Overflow: Set to last value in the table
288
     // Overflow: Set to last value in the table
288
-    if (i == NUMTEMPS_HEATER_0) celsius = (short)pgm_read_word(&(heater_0_temptable[i-1][1]));
289
+    if (i == NUMTEMPS_HEATER_0) celsius = PGM_RD_W(heater_0_temptable[i-1][1]);
289
 
290
 
290
     return celsius;
291
     return celsius;
291
   #elif defined HEATER_0_USES_AD595
292
   #elif defined HEATER_0_USES_AD595
304
 
305
 
305
     for (i=1; i<BNUMTEMPS; i++)
306
     for (i=1; i<BNUMTEMPS; i++)
306
     {
307
     {
307
-      if (pgm_read_word(&(bedtemptable[i][0])) > raw)
308
+      if (PGM_RD_W(bedtemptable[i][0]) > raw)
308
       {
309
       {
309
-        celsius  = pgm_read_word(&(bedtemptable[i-1][1])) + 
310
-          (raw - pgm_read_word(&(bedtemptable[i-1][0]))) * 
311
-          (pgm_read_word(&(bedtemptable[i][1])) - pgm_read_word(&(bedtemptable[i-1][1]))) /
312
-          (pgm_read_word(&(bedtemptable[i][0])) - pgm_read_word(&(bedtemptable[i-1][0])));
310
+        celsius  = PGM_RD_W(bedtemptable[i-1][1]) + 
311
+          (raw - PGM_RD_W(bedtemptable[i-1][0])) * 
312
+          (PGM_RD_W(bedtemptable[i][1]) - PGM_RD_W(bedtemptable[i-1][1])) /
313
+          (PGM_RD_W(bedtemptable[i][0]) - PGM_RD_W(bedtemptable[i-1][0]));
313
 
314
 
314
         break;
315
         break;
315
       }
316
       }
316
     }
317
     }
317
 
318
 
318
     // Overflow: Set to last value in the table
319
     // Overflow: Set to last value in the table
319
-    if (i == BNUMTEMPS) celsius = pgm_read_word(&(bedtemptable[i-1][1]));
320
+    if (i == BNUMTEMPS) celsius = PGM_RD_W(bedtemptable[i-1][1]);
320
 
321
 
321
     return celsius;
322
     return celsius;
322
     
323
     

+ 102
- 101
Marlin/ultralcd.h View File

1
-#ifndef __ULTRALCDH
2
-#define __ULTRALCDH
3
-#include "Configuration.h"
4
-
5
-#ifdef ULTRA_LCD
6
-
7
-  void lcd_status();
8
-  void lcd_init();
9
-  void lcd_status(const char* message);
10
-  void beep();
11
-  void buttons_check();
12
-
13
-
14
-  #define LCD_UPDATE_INTERVAL 100
15
-  #define STATUSTIMEOUT 15000
16
-
17
-
18
-  #include <LiquidCrystal.h>
19
-  extern LiquidCrystal lcd;
20
-
21
-
22
-  #ifdef NEWPANEL
23
-
24
-    
25
-    #define EN_C (1<<BLEN_C)
26
-    #define EN_B (1<<BLEN_B)
27
-    #define EN_A (1<<BLEN_A)
28
-    
29
-    #define CLICKED (buttons&EN_C)
30
-    #define BLOCK {blocking=millis()+blocktime;}
31
-    #define CARDINSERTED (READ(SDCARDDETECT)==0)
32
-    
33
-  #else
34
-
35
-    //atomatic, do not change
36
-    #define B_LE (1<<BL_LE)
37
-    #define B_UP (1<<BL_UP)
38
-    #define B_MI (1<<BL_MI)
39
-    #define B_DW (1<<BL_DW)
40
-    #define B_RI (1<<BL_RI)
41
-    #define B_ST (1<<BL_ST)
42
-    #define EN_B (1<<BLEN_B)
43
-    #define EN_A (1<<BLEN_A)
44
-    
45
-    #define CLICKED ((buttons&B_MI)||(buttons&B_ST))
46
-    #define BLOCK {blocking[BL_MI]=millis()+blocktime;blocking[BL_ST]=millis()+blocktime;}
47
-    
48
-  #endif
49
-    
50
-  // blocking time for recognizing a new keypress of one key, ms
51
-  #define blocktime 500
52
-  #define lcdslow 5
53
-    
54
-  enum MainStatus{Main_Status, Main_Menu, Main_Prepare, Main_Control, Main_SD};
55
-
56
-  class MainMenu{
57
-  public:
58
-    MainMenu();
59
-    void update();
60
-    uint8_t activeline;
61
-    MainStatus status;
62
-    uint8_t displayStartingRow;
63
-    
64
-    void showStatus();
65
-    void showMainMenu();
66
-    void showPrepare();
67
-    void showControl();
68
-    void showSD();
69
-    bool force_lcd_update;
70
-    int lastencoderpos;
71
-    int8_t lineoffset;
72
-    int8_t lastlineoffset;
73
-    
74
-    bool linechanging;
75
-  };
76
-
77
-  //conversion routines, could need some overworking
78
-  char *fillto(int8_t n,char *c);
79
-  char *ftostr51(const float &x);
80
-  char *ftostr31(const float &x);
81
-  char *ftostr3(const float &x);
82
-
83
-
84
-
85
-  #define LCD_MESSAGE(x) lcd_status(x);
86
-  #define LCD_MESSAGEPGM(x) lcd_statuspgm(PSTR(x));
87
-  #define LCD_STATUS lcd_status()
88
-#else //no lcd
89
-  #define LCD_STATUS
90
-  #define LCD_MESSAGE(x)
91
-  inline void lcd_status() {};
92
-#endif
93
-  
94
-#ifndef ULTIPANEL  
95
- #define CLICKED false
96
-  #define BLOCK ;
97
-#endif 
98
-  
99
-  
100
-  
101
-#endif //ULTRALCD
1
+#ifndef __ULTRALCDH
2
+#define __ULTRALCDH
3
+#include "Configuration.h"
4
+
5
+#ifdef ULTRA_LCD
6
+
7
+  void lcd_status();
8
+  void lcd_init();
9
+  void lcd_status(const char* message);
10
+  void beep();
11
+  void buttons_check();
12
+
13
+
14
+  #define LCD_UPDATE_INTERVAL 100
15
+  #define STATUSTIMEOUT 15000
16
+
17
+
18
+  #include <LiquidCrystal.h>
19
+  extern LiquidCrystal lcd;
20
+
21
+
22
+  #ifdef NEWPANEL
23
+
24
+    
25
+    #define EN_C (1<<BLEN_C)
26
+    #define EN_B (1<<BLEN_B)
27
+    #define EN_A (1<<BLEN_A)
28
+    
29
+    #define CLICKED (buttons&EN_C)
30
+    #define BLOCK {blocking=millis()+blocktime;}
31
+    #define CARDINSERTED (READ(SDCARDDETECT)==0)
32
+    
33
+  #else
34
+
35
+    //atomatic, do not change
36
+    #define B_LE (1<<BL_LE)
37
+    #define B_UP (1<<BL_UP)
38
+    #define B_MI (1<<BL_MI)
39
+    #define B_DW (1<<BL_DW)
40
+    #define B_RI (1<<BL_RI)
41
+    #define B_ST (1<<BL_ST)
42
+    #define EN_B (1<<BLEN_B)
43
+    #define EN_A (1<<BLEN_A)
44
+    
45
+    #define CLICKED ((buttons&B_MI)||(buttons&B_ST))
46
+    #define BLOCK {blocking[BL_MI]=millis()+blocktime;blocking[BL_ST]=millis()+blocktime;}
47
+    
48
+  #endif
49
+    
50
+  // blocking time for recognizing a new keypress of one key, ms
51
+  #define blocktime 500
52
+  #define lcdslow 5
53
+    
54
+  enum MainStatus{Main_Status, Main_Menu, Main_Prepare, Main_Control, Main_SD};
55
+
56
+  class MainMenu{
57
+  public:
58
+    MainMenu();
59
+    void update();
60
+    uint8_t activeline;
61
+    MainStatus status;
62
+    uint8_t displayStartingRow;
63
+    
64
+    void showStatus();
65
+    void showMainMenu();
66
+    void showPrepare();
67
+    void showControl();
68
+    void showSD();
69
+    bool force_lcd_update;
70
+    int lastencoderpos;
71
+    int8_t lineoffset;
72
+    int8_t lastlineoffset;
73
+    
74
+    bool linechanging;
75
+  };
76
+
77
+  //conversion routines, could need some overworking
78
+  char *fillto(int8_t n,char *c);
79
+  char *ftostr51(const float &x);
80
+  char *ftostr31(const float &x);
81
+  char *ftostr3(const float &x);
82
+
83
+
84
+
85
+  #define LCD_MESSAGE(x) lcd_status(x);
86
+  #define LCD_MESSAGEPGM(x) lcd_statuspgm(PSTR(x));
87
+  #define LCD_STATUS lcd_status()
88
+#else //no lcd
89
+  #define LCD_STATUS
90
+  #define LCD_MESSAGE(x)
91
+  #define LCD_MESSAGEPGM(x)
92
+  inline void lcd_status() {};
93
+#endif
94
+  
95
+#ifndef ULTIPANEL  
96
+ #define CLICKED false
97
+  #define BLOCK ;
98
+#endif 
99
+  
100
+  
101
+  
102
+#endif //ULTRALCD
102
 
103
 

Loading…
Cancel
Save