Bläddra i källkod

solved some compiler warnings that are now visible in arduino 1.0.

Found a couple of unused variables, that I commented.
Tried to solve the program memory warning message, and failed.
Bernhard 13 år sedan
förälder
incheckning
7714b98da7

+ 15
- 6
Marlin/Marlin.h Visa fil

@@ -16,7 +16,6 @@
16 16
 #include "Configuration.h"
17 17
 #include "MarlinSerial.h"
18 18
 
19
-
20 19
 #define  FORCE_INLINE __attribute__((always_inline)) inline
21 20
 //#define SERIAL_ECHO(x) Serial << "echo: " << x;
22 21
 //#define SERIAL_ECHOLN(x) Serial << "echo: "<<x<<endl;
@@ -25,15 +24,25 @@
25 24
 //#define SERIAL_PROTOCOL(x) Serial << x;
26 25
 //#define SERIAL_PROTOCOLLN(x) Serial << x<<endl;
27 26
 
27
+//this is a unfinsihed attemp to removes a lot of warning messages, see:
28
+// http://www.avrfreaks.net/index.php?name=PNphpBB2&file=printview&t=57011
29
+//typedef char prog_char PROGMEM; 
30
+// //#define PSTR    (s )        ((const PROGMEM char *)(s))
31
+// //# define MYPGM(s) (__extension__({static prog_char __c[] = (s); &__c[0];})) 
32
+// //#define MYPGM(s) ((const prog_char *g PROGMEM=s))
33
+// //#define MYPGM(s) PSTR(s)
34
+#define MYPGM(s)  (__extension__({static char __c[] __attribute__((__progmem__)) = (s); &__c[0];}))  //This is the normal behaviour
35
+//#define MYPGM(s)  (__extension__({static prog_char __c[]  = (s); &__c[0];})) //this does not work but hides the warnings
28 36
 
29 37
 
30 38
 #define SERIAL_PROTOCOL(x) MSerial.print(x);
31
-#define SERIAL_PROTOCOLPGM(x) serialprintPGM(PSTR(x));
39
+#define SERIAL_PROTOCOLPGM(x) serialprintPGM(MYPGM(x));
32 40
 #define SERIAL_PROTOCOLLN(x) {MSerial.print(x);MSerial.write('\n');}
33
-#define SERIAL_PROTOCOLLNPGM(x) {serialprintPGM(PSTR(x));MSerial.write('\n');}
41
+#define SERIAL_PROTOCOLLNPGM(x) {serialprintPGM(MYPGM(x));MSerial.write('\n');}
42
+
34 43
 
35
-const char errormagic[] PROGMEM ="Error:";
36
-const char echomagic[] PROGMEM ="echo:";
44
+const prog_char errormagic[] PROGMEM ="Error:";
45
+const prog_char echomagic[] PROGMEM ="echo:";
37 46
 #define SERIAL_ERROR_START serialprintPGM(errormagic);
38 47
 #define SERIAL_ERROR(x) SERIAL_PROTOCOL(x)
39 48
 #define SERIAL_ERRORPGM(x) SERIAL_PROTOCOLPGM(x)
@@ -50,7 +59,7 @@ const char echomagic[] PROGMEM ="echo:";
50 59
 
51 60
 
52 61
 //things to write to serial from Programmemory. saves 400 to 2k of RAM.
53
-#define SerialprintPGM(x) serialprintPGM(PSTR(x))
62
+#define SerialprintPGM(x) serialprintPGM(MYPGM(x))
54 63
 FORCE_INLINE void serialprintPGM(const char *str)
55 64
 {
56 65
   char ch=pgm_read_byte(str);

+ 2
- 1
Marlin/Marlin.pde Visa fil

@@ -167,7 +167,8 @@ static char *strchr_pointer; // just a pointer to find chars in the cmd string l
167 167
 
168 168
 const int sensitive_pins[] = SENSITIVE_PINS; // Sensitive pin list for M42
169 169
 
170
-static float tt = 0, bt = 0;
170
+//static float tt = 0;
171
+//static float bt = 0;
171 172
 
172 173
 //Inactivity shutdown variables
173 174
 static unsigned long previous_millis_cmd = 0;

+ 1
- 0
Marlin/MarlinSerial.cpp Visa fil

@@ -20,6 +20,7 @@
20 20
   Modified 28 September 2010 by Mark Sproul
21 21
 */
22 22
 
23
+
23 24
 #include <stdlib.h>
24 25
 #include <stdio.h>
25 26
 #include <string.h>

+ 1
- 1
Marlin/MarlinSerial.h Visa fil

@@ -120,7 +120,7 @@ class MarlinSerial //: public Stream
120 120
 
121 121
     FORCE_INLINE void print(const String &s)
122 122
     {
123
-      for (int i = 0; i < s.length(); i++) {
123
+      for (int i = 0; i < (int)s.length(); i++) {
124 124
         write(s[i]);
125 125
       }
126 126
     }

+ 1
- 1
Marlin/cardreader.h Visa fil

@@ -59,7 +59,7 @@ private:
59 59
   LsAction lsAction; //stored for recursion.
60 60
   int16_t nrFiles; //counter for the files in the current directory and recycled as position counter for getting the nrFiles'th name in the directory.
61 61
   char* diveDirName;
62
-  void lsDive(char *prepend,SdFile parent);
62
+  void lsDive(const char *prepend,SdFile parent);
63 63
 };
64 64
   
65 65
 

+ 1
- 1
Marlin/cardreader.pde Visa fil

@@ -40,7 +40,7 @@ char *createFilename(char *buffer,const dir_t &p) //buffer>12characters
40 40
 }
41 41
 
42 42
 
43
-void  CardReader::lsDive(char *prepend,SdFile parent)
43
+void  CardReader::lsDive(const char *prepend,SdFile parent)
44 44
 {
45 45
   dir_t p;
46 46
  uint8_t cnt=0;

+ 13
- 10
Marlin/planner.cpp Visa fil

@@ -107,10 +107,12 @@ volatile unsigned char block_buffer_tail;           // Index of the block to pro
107 107
 //=============================private variables ============================
108 108
 //===========================================================================
109 109
 
110
-// Used for the frequency limit
111
-static unsigned char old_direction_bits = 0;               // Old direction bits. Used for speed calculations
112
-static long x_segment_time[3]={0,0,0};                     // Segment times (in us). Used for speed calculations
113
-static long y_segment_time[3]={0,0,0};
110
+#ifdef XY_FREQUENCY_LIMIT
111
+  // Used for the frequency limit
112
+  static unsigned char old_direction_bits = 0;               // Old direction bits. Used for speed calculations
113
+  static long x_segment_time[3]={0,0,0};                     // Segment times (in us). Used for speed calculations
114
+  static long y_segment_time[3]={0,0,0};
115
+#endif
114 116
 
115 117
 // Returns the index of the next block in the ring buffer
116 118
 // NOTE: Removed modulo (%) operator, which uses an expensive divide and multiplication.
@@ -255,7 +257,7 @@ void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *n
255 257
 // planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This 
256 258
 // implements the reverse pass.
257 259
 void planner_reverse_pass() {
258
-  char block_index = block_buffer_head;
260
+  uint8_t block_index = block_buffer_head;
259 261
   if(((block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1)) > 3) {
260 262
     block_index = (block_buffer_head - 3) & (BLOCK_BUFFER_SIZE - 1);
261 263
     block_t *block[3] = { NULL, NULL, NULL };
@@ -294,7 +296,7 @@ void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *n
294 296
 // planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This 
295 297
 // implements the forward pass.
296 298
 void planner_forward_pass() {
297
-  char block_index = block_buffer_tail;
299
+  uint8_t block_index = block_buffer_tail;
298 300
   block_t *block[3] = { NULL, NULL, NULL };
299 301
 
300 302
   while(block_index != block_buffer_head) {
@@ -384,7 +386,7 @@ void getHighESpeed()
384 386
     return; //do nothing
385 387
   
386 388
   float high=0;
387
-  char block_index = block_buffer_tail;
389
+  uint8_t block_index = block_buffer_tail;
388 390
   
389 391
   while(block_index != block_buffer_head) {
390 392
     float se=block_buffer[block_index].steps_e/float(block_buffer[block_index].step_event_count)*block_buffer[block_index].nominal_rate;
@@ -423,7 +425,7 @@ void check_axes_activity() {
423 425
   block_t *block;
424 426
 
425 427
   if(block_buffer_tail != block_buffer_head) {
426
-    char block_index = block_buffer_tail;
428
+    uint8_t block_index = block_buffer_tail;
427 429
     while(block_index != block_buffer_head) {
428 430
       block = &block_buffer[block_index];
429 431
       if(block->steps_x != 0) x_active++;
@@ -519,8 +521,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
519 521
   block->nominal_speed = block->millimeters * inverse_second; // (mm/sec) Always > 0
520 522
   block->nominal_rate = ceil(block->step_event_count * inverse_second); // (step/sec) Always > 0
521 523
 
522
-  //  segment time im micro seconds
523
-  long segment_time = lround(1000000.0/inverse_second);
524
+  
524 525
  
525 526
 
526 527
   if (block->steps_e == 0) {
@@ -538,6 +539,8 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
538 539
 #endif
539 540
 
540 541
 /*
542
+  //  segment time im micro seconds
543
+  long segment_time = lround(1000000.0/inverse_second);
541 544
   if ((blockcount>0) && (blockcount < (BLOCK_BUFFER_SIZE - 4))) {
542 545
     if (segment_time<minsegmenttime)  { // buffer is draining, add extra time.  The amount of time added increases if the buffer is still emptied more.
543 546
         segment_time=segment_time+lround(2*(minsegmenttime-segment_time)/blockcount);

+ 4
- 3
Marlin/stepper.cpp Visa fil

@@ -21,6 +21,7 @@
21 21
 /* The timer calculations of this module informed by the 'RepRap cartesian firmware' by Zack Smith
22 22
    and Philipp Tiefenbacher. */
23 23
 
24
+
24 25
 #include "stepper.h"
25 26
 #include "Configuration.h"
26 27
 #include "Marlin.h"
@@ -444,7 +445,7 @@ ISR(TIMER1_COMPA_vect)
444 445
     // Calculare new timer value
445 446
     unsigned short timer;
446 447
     unsigned short step_rate;
447
-    if (step_events_completed <= current_block->accelerate_until) {
448
+    if (step_events_completed <= (unsigned long int)current_block->accelerate_until) {
448 449
       
449 450
       MultiU24X24toH16(acc_step_rate, acceleration_time, current_block->acceleration_rate);
450 451
       acc_step_rate += current_block->initial_rate;
@@ -463,7 +464,7 @@ ISR(TIMER1_COMPA_vect)
463 464
         }
464 465
       #endif
465 466
     } 
466
-    else if (step_events_completed > current_block->decelerate_after) {   
467
+    else if (step_events_completed > (unsigned long int)current_block->decelerate_after) {   
467 468
       MultiU24X24toH16(step_rate, deceleration_time, current_block->acceleration_rate);
468 469
       
469 470
       if(step_rate > acc_step_rate) { // Check step_rate stays positive
@@ -678,7 +679,7 @@ void st_set_e_position(const long &e)
678 679
   CRITICAL_SECTION_END;
679 680
 }
680 681
 
681
-long st_get_position(char axis)
682
+long st_get_position(uint8_t axis)
682 683
 {
683 684
   long count_pos;
684 685
   CRITICAL_SECTION_START;

+ 1
- 1
Marlin/stepper.h Visa fil

@@ -34,7 +34,7 @@ void st_set_position(const long &x, const long &y, const long &z, const long &e)
34 34
 void st_set_e_position(const long &e);
35 35
 
36 36
 // Get current position in steps
37
-long st_get_position(char axis);
37
+long st_get_position(uint8_t axis);
38 38
 
39 39
 // The stepper subsystem goes to sleep when it runs out of things to execute. Call this
40 40
 // to notify the subsystem that it is time to go to work.

+ 14
- 5
Marlin/temperature.cpp Visa fil

@@ -67,7 +67,8 @@ int heatingtarget_raw[3]= {0, 0, 0};
67 67
 //===========================================================================
68 68
 static bool temp_meas_ready = false;
69 69
 
70
-static unsigned long previous_millis_heater, previous_millis_bed_heater;
70
+static unsigned long  previous_millis_bed_heater;
71
+//static unsigned long previous_millis_heater;
71 72
 
72 73
 #ifdef PIDTEMP
73 74
   //static cannot be external:
@@ -80,8 +81,8 @@ static unsigned long previous_millis_heater, previous_millis_bed_heater;
80 81
   static float pid_error;
81 82
   static float temp_iState_min;
82 83
   static float temp_iState_max;
83
-  static float pid_input;
84
-  static float pid_output;
84
+ // static float pid_input; 
85
+ // static float pid_output;
85 86
   static bool pid_reset;
86 87
  
87 88
 #endif //PIDTEMP
@@ -94,8 +95,8 @@ static unsigned long previous_millis_heater, previous_millis_bed_heater;
94 95
 // Init min and max temp with extreme values to prevent false errors during startup
95 96
   static int minttemp_0   = 0;
96 97
   static int maxttemp_0   = 16383;
97
-  static int minttemp_1   = 0;
98
-  static int maxttemp_1   = 16383;
98
+  //static int minttemp_1   = 0;
99
+  //static int maxttemp_1   = 16383;
99 100
   static int bed_minttemp = 0;
100 101
   static int bed_maxttemp = 16383;
101 102
 
@@ -268,7 +269,10 @@ int temp2analogBed(int celsius) {
268 269
     return (1023 * OVERSAMPLENR) - raw;
269 270
   #elif defined BED_USES_AD595
270 271
     return lround(celsius * (1024.0 * OVERSAMPLENR/ (5.0 * 100.0) ) );
272
+  #else
273
+    #warning No heater-type defined for the bed.
271 274
   #endif
275
+  return 0;
272 276
 }
273 277
 
274 278
 // Derived from RepRap FiveD extruder::getTemperature()
@@ -296,6 +300,8 @@ float analog2temp(int raw) {
296 300
     return celsius;
297 301
   #elif defined HEATER_0_USES_AD595
298 302
     return raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR;
303
+  #else
304
+    #error PLEASE DEFINE HEATER TYPE 
299 305
   #endif
300 306
 }
301 307
 
@@ -328,7 +334,10 @@ float analog2tempBed(int raw) {
328 334
     
329 335
   #elif defined BED_USES_AD595
330 336
     return raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR;
337
+  #else
338
+    #warning No heater-type defined for the bed.
331 339
   #endif
340
+  return 0;
332 341
 }
333 342
 
334 343
 void tp_init()

+ 5
- 3
Marlin/temperature.h Visa fil

@@ -86,7 +86,7 @@ FORCE_INLINE void setTargetHotend0(const float &celsius)
86 86
   #endif //PIDTEMP
87 87
 };
88 88
 FORCE_INLINE void setTargetHotend1(const float &celsius) {  target_raw[TEMPSENSOR_HOTEND_1]=temp2analog(celsius);};
89
-FORCE_INLINE float setTargetHotend(const float &celcius, uint8_t extruder){  
89
+FORCE_INLINE void setTargetHotend(const float &celcius, uint8_t extruder){  
90 90
   if(extruder == 0) setTargetHotend0(celcius);
91 91
   if(extruder == 1) setTargetHotend1(celcius);
92 92
 };
@@ -94,17 +94,19 @@ FORCE_INLINE void setTargetBed(const float &celsius)     {  target_raw[TEMPSENSO
94 94
 
95 95
 FORCE_INLINE bool isHeatingHotend0() {return heatingtarget_raw[TEMPSENSOR_HOTEND_0] > current_raw[TEMPSENSOR_HOTEND_0];};
96 96
 FORCE_INLINE bool isHeatingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] > current_raw[TEMPSENSOR_HOTEND_1];};
97
-FORCE_INLINE float isHeatingHotend(uint8_t extruder){  
97
+FORCE_INLINE bool isHeatingHotend(uint8_t extruder){  
98 98
   if(extruder == 0) return heatingtarget_raw[TEMPSENSOR_HOTEND_0] > current_raw[TEMPSENSOR_HOTEND_0];
99 99
   if(extruder == 1) return target_raw[TEMPSENSOR_HOTEND_1] > current_raw[TEMPSENSOR_HOTEND_1];
100
+  return false; 
100 101
 };
101 102
 FORCE_INLINE bool isHeatingBed() {return target_raw[TEMPSENSOR_BED] > current_raw[TEMPSENSOR_BED];};
102 103
 
103 104
 FORCE_INLINE bool isCoolingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] < current_raw[TEMPSENSOR_HOTEND_0];};
104 105
 FORCE_INLINE bool isCoolingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] < current_raw[TEMPSENSOR_HOTEND_1];};
105
-FORCE_INLINE float isCoolingHotend(uint8_t extruder){  
106
+FORCE_INLINE bool isCoolingHotend(uint8_t extruder){  
106 107
   if(extruder == 0) return target_raw[TEMPSENSOR_HOTEND_0] < current_raw[TEMPSENSOR_HOTEND_0];
107 108
   if(extruder == 1) return target_raw[TEMPSENSOR_HOTEND_1] < current_raw[TEMPSENSOR_HOTEND_1];
109
+  return false; 
108 110
 };
109 111
 FORCE_INLINE bool isCoolingBed() {return target_raw[TEMPSENSOR_BED] < current_raw[TEMPSENSOR_BED];};
110 112
 

+ 2
- 3
Marlin/ultralcd.h Visa fil

@@ -1,7 +1,7 @@
1 1
 #ifndef __ULTRALCDH
2 2
 #define __ULTRALCDH
3 3
 #include "Configuration.h"
4
-
4
+#include "Marlin.h"
5 5
 #ifdef ULTRA_LCD
6 6
 
7 7
   void lcd_status();
@@ -104,7 +104,6 @@
104 104
             curencoderpos=maxlines*lcdslow; 
105 105
         } 
106 106
         lastencoderpos=encoderpos=curencoderpos;
107
-        int lastactiveline=activeline;
108 107
         activeline=curencoderpos/lcdslow;
109 108
         if(activeline<0) activeline=0;
110 109
         if(activeline>LCD_HEIGHT-1) activeline=LCD_HEIGHT-1;
@@ -137,7 +136,7 @@
137 136
 
138 137
 
139 138
   #define LCD_MESSAGE(x) lcd_status(x);
140
-  #define LCD_MESSAGEPGM(x) lcd_statuspgm(PSTR(x));
139
+  #define LCD_MESSAGEPGM(x) lcd_statuspgm(MYPGM(x));
141 140
   #define LCD_STATUS lcd_status()
142 141
 #else //no lcd
143 142
   #define LCD_STATUS

+ 3
- 3
Marlin/ultralcd.pde Visa fil

@@ -53,7 +53,7 @@ void lcdProgMemprint(const char *str)
53 53
     ch=pgm_read_byte(++str);
54 54
   }
55 55
 }
56
-#define lcdprintPGM(x) lcdProgMemprint(PSTR(x))
56
+#define lcdprintPGM(x) lcdProgMemprint(MYPGM(x))
57 57
 
58 58
 
59 59
 //===========================================================================
@@ -159,8 +159,8 @@ void lcd_status()
159 159
 {
160 160
   #ifdef ULTIPANEL
161 161
     static uint8_t oldbuttons=0;
162
-    static long previous_millis_buttons=0;
163
-    static long previous_lcdinit=0;
162
+    //static long previous_millis_buttons=0;
163
+    //static long previous_lcdinit=0;
164 164
   //  buttons_check(); // Done in temperature interrupt
165 165
     //previous_millis_buttons=millis();
166 166
     

Laddar…
Avbryt
Spara