Ver código fonte

Merge branch 'Marlin_v1', remote-tracking branch 'origin/Marlin_v1' into Marlin_v1

Erik van der Zalm 13 anos atrás
pai
commit
95a0b28acb

+ 1
- 0
Marlin/Configuration.h Ver arquivo

@@ -214,6 +214,7 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
214 214
 #define X_HOME_RETRACT_MM 5 
215 215
 #define Y_HOME_RETRACT_MM 5 
216 216
 #define Z_HOME_RETRACT_MM 1 
217
+#define QUICK_HOME  //if this is defined, if both x and y are to be homed, a diagonal move will be performed initially.
217 218
 
218 219
 #define AXIS_RELATIVE_MODES {false, false, false, false}
219 220
 

+ 15
- 6
Marlin/Marlin.h Ver arquivo

@@ -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);

+ 5
- 2
Marlin/Marlin.pde Ver arquivo

@@ -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;
@@ -532,7 +533,7 @@ FORCE_INLINE void process_commands()
532 533
       }
533 534
       feedrate = 0.0;
534 535
       home_all_axis = !((code_seen(axis_codes[0])) || (code_seen(axis_codes[1])) || (code_seen(axis_codes[2])));
535
-      
536
+      #ifdef QUICK_HOME
536 537
       if( code_seen(axis_codes[0]) && code_seen(axis_codes[1]) )  //first diagonal move
537 538
       {
538 539
         current_position[X_AXIS] = 0; current_position[Y_AXIS] = 0;
@@ -545,6 +546,7 @@ FORCE_INLINE void process_commands()
545 546
         prepare_move();
546 547
         current_position[X_AXIS] = 0; current_position[Y_AXIS] = 0;
547 548
       }
549
+      #endif
548 550
       
549 551
       if((home_all_axis) || (code_seen(axis_codes[X_AXIS]))) 
550 552
       {
@@ -669,6 +671,7 @@ FORCE_INLINE void process_commands()
669 671
       SERIAL_ECHO_START;
670 672
       SERIAL_ECHOLN(time);
671 673
       LCD_MESSAGE(time);
674
+      autotempShutdown();
672 675
     }
673 676
     break;
674 677
     case 42: //M42 -Change pin status via gcode

+ 1
- 0
Marlin/MarlinSerial.cpp Ver arquivo

@@ -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 Ver arquivo

@@ -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 Ver arquivo

@@ -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
 

+ 2
- 1
Marlin/cardreader.pde Ver arquivo

@@ -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;
@@ -436,5 +436,6 @@ void CardReader::printingHasFinished()
436 436
  {
437 437
    finishAndDisableSteppers();
438 438
  }
439
+ autotempShutdown();
439 440
 }
440 441
 #endif //SDSUPPORT

+ 14
- 11
Marlin/planner.cpp Ver arquivo

@@ -91,7 +91,7 @@ static float previous_nominal_speed; // Nominal speed of previous path line segm
91 91
 #ifdef AUTOTEMP
92 92
     float autotemp_max=250;
93 93
     float autotemp_min=210;
94
-    float autotemp_factor=1;
94
+    float autotemp_factor=0.1;
95 95
     bool autotemp_enabled=false;
96 96
 #endif
97 97
 
@@ -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.
@@ -254,7 +256,7 @@ void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *n
254 256
 // planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This 
255 257
 // implements the reverse pass.
256 258
 void planner_reverse_pass() {
257
-  char block_index = block_buffer_head;
259
+  uint8_t block_index = block_buffer_head;
258 260
   if(((block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1)) > 3) {
259 261
     block_index = (block_buffer_head - 3) & (BLOCK_BUFFER_SIZE - 1);
260 262
     block_t *block[3] = { NULL, NULL, NULL };
@@ -293,7 +295,7 @@ void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *n
293 295
 // planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This 
294 296
 // implements the forward pass.
295 297
 void planner_forward_pass() {
296
-  char block_index = block_buffer_tail;
298
+  uint8_t block_index = block_buffer_tail;
297 299
   block_t *block[3] = { NULL, NULL, NULL };
298 300
 
299 301
   while(block_index != block_buffer_head) {
@@ -383,7 +385,7 @@ void getHighESpeed()
383 385
     return; //do nothing
384 386
   
385 387
   float high=0;
386
-  char block_index = block_buffer_tail;
388
+  uint8_t block_index = block_buffer_tail;
387 389
   
388 390
   while(block_index != block_buffer_head) {
389 391
     float se=block_buffer[block_index].steps_e/float(block_buffer[block_index].step_event_count)*block_buffer[block_index].nominal_rate;
@@ -422,7 +424,7 @@ void check_axes_activity() {
422 424
   block_t *block;
423 425
 
424 426
   if(block_buffer_tail != block_buffer_head) {
425
-    char block_index = block_buffer_tail;
427
+    uint8_t block_index = block_buffer_tail;
426 428
     while(block_index != block_buffer_head) {
427 429
       block = &block_buffer[block_index];
428 430
       if(block->steps_x != 0) x_active++;
@@ -518,8 +520,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
518 520
   block->nominal_speed = block->millimeters * inverse_second; // (mm/sec) Always > 0
519 521
   block->nominal_rate = ceil(block->step_event_count * inverse_second); // (step/sec) Always > 0
520 522
 
521
-  //  segment time im micro seconds
522
-  long segment_time = lround(1000000.0/inverse_second);
523
+  
523 524
  
524 525
 
525 526
   if (block->steps_e == 0) {
@@ -537,6 +538,8 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
537 538
 #endif
538 539
 
539 540
 /*
541
+  //  segment time im micro seconds
542
+  long segment_time = lround(1000000.0/inverse_second);
540 543
   if ((blockcount>0) && (blockcount < (BLOCK_BUFFER_SIZE - 4))) {
541 544
     if (segment_time<minsegmenttime)  { // buffer is draining, add extra time.  The amount of time added increases if the buffer is still emptied more.
542 545
         segment_time=segment_time+lround(2*(minsegmenttime-segment_time)/blockcount);

+ 4
- 3
Marlin/stepper.cpp Ver arquivo

@@ -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"
@@ -454,7 +455,7 @@ ISR(TIMER1_COMPA_vect)
454 455
     // Calculare new timer value
455 456
     unsigned short timer;
456 457
     unsigned short step_rate;
457
-    if (step_events_completed <= current_block->accelerate_until) {
458
+    if (step_events_completed <= (unsigned long int)current_block->accelerate_until) {
458 459
       
459 460
       MultiU24X24toH16(acc_step_rate, acceleration_time, current_block->acceleration_rate);
460 461
       acc_step_rate += current_block->initial_rate;
@@ -478,7 +479,7 @@ ISR(TIMER1_COMPA_vect)
478 479
         
479 480
       #endif
480 481
     } 
481
-    else if (step_events_completed > current_block->decelerate_after) {   
482
+    else if (step_events_completed > (unsigned long int)current_block->decelerate_after) {   
482 483
       MultiU24X24toH16(step_rate, deceleration_time, current_block->acceleration_rate);
483 484
       
484 485
       if(step_rate > acc_step_rate) { // Check step_rate stays positive
@@ -695,7 +696,7 @@ void st_set_e_position(const long &e)
695 696
   CRITICAL_SECTION_END;
696 697
 }
697 698
 
698
-long st_get_position(char axis)
699
+long st_get_position(uint8_t axis)
699 700
 {
700 701
   long count_pos;
701 702
   CRITICAL_SECTION_START;

+ 1
- 1
Marlin/stepper.h Ver arquivo

@@ -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 Ver arquivo

@@ -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()

+ 15
- 3
Marlin/temperature.h Ver arquivo

@@ -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,20 +94,32 @@ 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
 
113
+FORCE_INLINE void autotempShutdown(){
114
+ #ifdef AUTOTEMP
115
+ if(autotemp_enabled)
116
+ {
117
+  autotemp_enabled=false;
118
+  if(degTargetHotend0()>autotemp_min)
119
+    setTargetHotend0(0);
120
+ }
121
+ #endif
122
+}
111 123
 void disable_heater();
112 124
 void setWatch();
113 125
 void updatePID();

+ 2
- 3
Marlin/ultralcd.h Ver arquivo

@@ -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

+ 439
- 412
Marlin/ultralcd.pde
Diferenças do arquivo suprimidas por serem muito extensas
Ver arquivo


Carregando…
Cancelar
Salvar