Browse Source

Merge branch 'Development' into marlin_configurator

Latest upstream changes
Scott Lahteine 10 years ago
parent
commit
4b50205f11

+ 9
- 0
Marlin/Configuration.h View File

362
 #define Y_MAX_LENGTH (Y_MAX_POS - Y_MIN_POS)
362
 #define Y_MAX_LENGTH (Y_MAX_POS - Y_MIN_POS)
363
 #define Z_MAX_LENGTH (Z_MAX_POS - Z_MIN_POS)
363
 #define Z_MAX_LENGTH (Z_MAX_POS - Z_MIN_POS)
364
 
364
 
365
+//===========================================================================
366
+//============================= Filament Runout Sensor ======================
367
+//===========================================================================
368
+//#define FILAMENT_RUNOUT_SENSOR // Uncomment for defining a filament runout sensor such as a mechanical or opto endstop to check the existence of filament
369
+                                 // In RAMPS uses servo pin 2. Can be changed in pins file. For other boards pin definition should be made.
370
+                                 // It is assumed that when logic high = filament available
371
+                                 //                    when logic  low = filament ran out
372
+//const bool FIL_RUNOUT_INVERTING = true;  // Should be uncommented and true or false should assigned
373
+//#define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined.
365
 
374
 
366
 //===========================================================================
375
 //===========================================================================
367
 //============================= Bed Auto Leveling ===========================
376
 //============================= Bed Auto Leveling ===========================

+ 7
- 0
Marlin/Marlin.h View File

32
   #include "WProgram.h"
32
   #include "WProgram.h"
33
 #endif
33
 #endif
34
 
34
 
35
+#define BIT(b) (1<<(b))
36
+#define TEST(n,b) ((n)&BIT(b)!=0)
37
+
35
 // Arduino < 1.0.0 does not define this, so we need to do it ourselves
38
 // Arduino < 1.0.0 does not define this, so we need to do it ourselves
36
 #ifndef analogInputToDigitalPin
39
 #ifndef analogInputToDigitalPin
37
   #define analogInputToDigitalPin(p) ((p) + 0xA0)
40
   #define analogInputToDigitalPin(p) ((p) + 0xA0)
199
 void kill();
202
 void kill();
200
 void Stop();
203
 void Stop();
201
 
204
 
205
+#ifdef FILAMENT_RUNOUT_SENSOR
206
+void filrunout();
207
+#endif
208
+
202
 bool IsStopped();
209
 bool IsStopped();
203
 
210
 
204
 bool enquecommand(const char *cmd); //put a single ASCII command at the end of the current buffer or return false when it is full
211
 bool enquecommand(const char *cmd); //put a single ASCII command at the end of the current buffer or return false when it is full

+ 2
- 2
Marlin/Marlin.ino View File

47
   #endif
47
   #endif
48
 #endif
48
 #endif
49
 
49
 
50
-#if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1
51
-#include <SPI.h>
50
+#if HAS_DIGIPOTSS
51
+  #include <SPI.h>
52
 #endif
52
 #endif
53
 
53
 
54
 #if defined(DIGIPOT_I2C)
54
 #if defined(DIGIPOT_I2C)

+ 2
- 2
Marlin/Marlin.pde View File

47
   #endif
47
   #endif
48
 #endif
48
 #endif
49
 
49
 
50
-#if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1
51
-#include <SPI.h>
50
+#if HAS_DIGIPOTSS
51
+  #include <SPI.h>
52
 #endif
52
 #endif
53
 
53
 
54
 #if defined(DIGIPOT_I2C)
54
 #if defined(DIGIPOT_I2C)

+ 1
- 1
Marlin/MarlinSerial.cpp View File

76
   #endif
76
   #endif
77
   
77
   
78
   if (useU2X) {
78
   if (useU2X) {
79
-    M_UCSRxA = 1 << M_U2Xx;
79
+    M_UCSRxA = BIT(M_U2Xx);
80
     baud_setting = (F_CPU / 4 / baud - 1) / 2;
80
     baud_setting = (F_CPU / 4 / baud - 1) / 2;
81
   } else {
81
   } else {
82
     M_UCSRxA = 0;
82
     M_UCSRxA = 0;

+ 2
- 2
Marlin/MarlinSerial.h View File

97
     }
97
     }
98
 
98
 
99
     FORCE_INLINE void write(uint8_t c) {
99
     FORCE_INLINE void write(uint8_t c) {
100
-      while (!((M_UCSRxA) & (1 << M_UDREx)))
100
+      while (!TEST(M_UCSRxA, M_UDREx))
101
         ;
101
         ;
102
 
102
 
103
       M_UDRx = c;
103
       M_UDRx = c;
104
     }
104
     }
105
 
105
 
106
     FORCE_INLINE void checkRx(void) {
106
     FORCE_INLINE void checkRx(void) {
107
-      if ((M_UCSRxA & (1<<M_RXCx)) != 0) {
107
+      if (TEST(M_UCSRxA, M_RXCx)) {
108
         unsigned char c  =  M_UDRx;
108
         unsigned char c  =  M_UDRx;
109
         int i = (unsigned int)(rx_buffer.head + 1) % RX_BUFFER_SIZE;
109
         int i = (unsigned int)(rx_buffer.head + 1) % RX_BUFFER_SIZE;
110
 
110
 

+ 54
- 12
Marlin/Marlin_main.cpp View File

62
   #include "Servo.h"
62
   #include "Servo.h"
63
 #endif
63
 #endif
64
 
64
 
65
-#if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1
65
+#if HAS_DIGIPOTSS
66
   #include <SPI.h>
66
   #include <SPI.h>
67
 #endif
67
 #endif
68
 
68
 
370
   int meas_delay_cm = MEASUREMENT_DELAY_CM;  //distance delay setting
370
   int meas_delay_cm = MEASUREMENT_DELAY_CM;  //distance delay setting
371
 #endif
371
 #endif
372
 
372
 
373
+#ifdef FILAMENT_RUNOUT_SENSOR
374
+   static bool filrunoutEnqued = false;
375
+#endif
376
+
373
 const char errormagic[] PROGMEM = "Error:";
377
 const char errormagic[] PROGMEM = "Error:";
374
 const char echomagic[] PROGMEM = "echo:";
378
 const char echomagic[] PROGMEM = "echo:";
375
 
379
 
529
   #endif
533
   #endif
530
 }
534
 }
531
 
535
 
536
+void setup_filrunoutpin()
537
+{
538
+#if defined(FILRUNOUT_PIN) && FILRUNOUT_PIN > -1
539
+   pinMode(FILRUNOUT_PIN,INPUT);
540
+   #if defined(ENDSTOPPULLUP_FIL_RUNOUT)
541
+      WRITE(FILLRUNOUT_PIN,HIGH);
542
+   #endif
543
+#endif
544
+}
545
+
532
 // Set home pin
546
 // Set home pin
533
 void setup_homepin(void)
547
 void setup_homepin(void)
534
 {
548
 {
605
 void setup()
619
 void setup()
606
 {
620
 {
607
   setup_killpin();
621
   setup_killpin();
622
+  setup_filrunoutpin();
608
   setup_powerhold();
623
   setup_powerhold();
609
   MYSERIAL.begin(BAUDRATE);
624
   MYSERIAL.begin(BAUDRATE);
610
   SERIAL_PROTOCOLLNPGM("start");
625
   SERIAL_PROTOCOLLNPGM("start");
2015
 
2030
 
2016
       if (verbose_level) {
2031
       if (verbose_level) {
2017
         SERIAL_PROTOCOLPGM("Eqn coefficients: a: ");
2032
         SERIAL_PROTOCOLPGM("Eqn coefficients: a: ");
2018
-        SERIAL_PROTOCOL(plane_equation_coefficients[0] + 0.0001);
2033
+        SERIAL_PROTOCOL_F(plane_equation_coefficients[0], 8);
2019
         SERIAL_PROTOCOLPGM(" b: ");
2034
         SERIAL_PROTOCOLPGM(" b: ");
2020
-        SERIAL_PROTOCOL(plane_equation_coefficients[1] + 0.0001);
2035
+        SERIAL_PROTOCOL_F(plane_equation_coefficients[1], 8);
2021
         SERIAL_PROTOCOLPGM(" d: ");
2036
         SERIAL_PROTOCOLPGM(" d: ");
2022
-        SERIAL_PROTOCOLLN(plane_equation_coefficients[2] + 0.0001);
2037
+        SERIAL_PROTOCOL_F(plane_equation_coefficients[2], 8);
2038
+        SERIAL_EOL;
2023
         if (verbose_level > 2) {
2039
         if (verbose_level > 2) {
2024
           SERIAL_PROTOCOLPGM("Mean of sampled points: ");
2040
           SERIAL_PROTOCOLPGM("Mean of sampled points: ");
2025
-          SERIAL_PROTOCOL_F(mean, 6);
2041
+          SERIAL_PROTOCOL_F(mean, 8);
2026
           SERIAL_EOL;
2042
           SERIAL_EOL;
2027
         }
2043
         }
2028
       }
2044
       }
2033
 
2049
 
2034
         SERIAL_PROTOCOLPGM(" \nBed Height Topography: \n");
2050
         SERIAL_PROTOCOLPGM(" \nBed Height Topography: \n");
2035
         #if TOPO_ORIGIN == OriginFrontLeft
2051
         #if TOPO_ORIGIN == OriginFrontLeft
2052
+          SERIAL_PROTOCOLPGM("+-----------+\n");
2053
+          SERIAL_PROTOCOLPGM("|...Back....|\n");
2054
+          SERIAL_PROTOCOLPGM("|Left..Right|\n");
2055
+          SERIAL_PROTOCOLPGM("|...Front...|\n");
2056
+          SERIAL_PROTOCOLPGM("+-----------+\n");
2036
           for (yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--)
2057
           for (yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--)
2037
         #else
2058
         #else
2038
           for (yy = 0; yy < auto_bed_leveling_grid_points; yy++)
2059
           for (yy = 0; yy < auto_bed_leveling_grid_points; yy++)
2039
         #endif
2060
         #endif
2040
           {
2061
           {
2041
             #if TOPO_ORIGIN == OriginBackRight
2062
             #if TOPO_ORIGIN == OriginBackRight
2042
-              for (xx = auto_bed_leveling_grid_points - 1; xx >= 0; xx--)
2043
-            #else
2044
               for (xx = 0; xx < auto_bed_leveling_grid_points; xx++)
2063
               for (xx = 0; xx < auto_bed_leveling_grid_points; xx++)
2064
+            #else
2065
+              for (xx = auto_bed_leveling_grid_points - 1; xx >= 0; xx--)
2045
             #endif
2066
             #endif
2046
               {
2067
               {
2047
                 int ind =
2068
                 int ind =
4130
       plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], target[E_AXIS], fr60, active_extruder); //move z back
4151
       plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], target[E_AXIS], fr60, active_extruder); //move z back
4131
       plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], lastpos[E_AXIS], fr60, active_extruder); //final untretract
4152
       plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], lastpos[E_AXIS], fr60, active_extruder); //final untretract
4132
     #endif        
4153
     #endif        
4154
+
4155
+    #ifdef FILAMENT_RUNOUT_SENSOR
4156
+      filrunoutEnqued = false;
4157
+    #endif
4158
+    
4133
   }
4159
   }
4134
 
4160
 
4135
 #endif // FILAMENTCHANGEENABLE
4161
 #endif // FILAMENTCHANGEENABLE
4184
  * M907: Set digital trimpot motor current using axis codes X, Y, Z, E, B, S
4210
  * M907: Set digital trimpot motor current using axis codes X, Y, Z, E, B, S
4185
  */
4211
  */
4186
 inline void gcode_M907() {
4212
 inline void gcode_M907() {
4187
-  #if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1
4213
+  #if HAS_DIGIPOTSS
4188
     for (int i=0;i<NUM_AXIS;i++)
4214
     for (int i=0;i<NUM_AXIS;i++)
4189
       if (code_seen(axis_codes[i])) digipot_current(i, code_value());
4215
       if (code_seen(axis_codes[i])) digipot_current(i, code_value());
4190
     if (code_seen('B')) digipot_current(4, code_value());
4216
     if (code_seen('B')) digipot_current(4, code_value());
4207
   #endif
4233
   #endif
4208
 }
4234
 }
4209
 
4235
 
4210
-#if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1
4236
+#if HAS_DIGIPOTSS
4211
 
4237
 
4212
   /**
4238
   /**
4213
    * M908: Control digital trimpot directly (M908 P<pin> S<current>)
4239
    * M908: Control digital trimpot directly (M908 P<pin> S<current>)
4219
       );
4245
       );
4220
   }
4246
   }
4221
 
4247
 
4222
-#endif // DIGIPOTSS_PIN
4248
+#endif // HAS_DIGIPOTSS
4223
 
4249
 
4224
 // M350 Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers.
4250
 // M350 Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers.
4225
 inline void gcode_M350() {
4251
 inline void gcode_M350() {
4806
         gcode_M907();
4832
         gcode_M907();
4807
         break;
4833
         break;
4808
 
4834
 
4809
-      #if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1
4835
+      #if HAS_DIGIPOTSS
4810
         case 908: // M908 Control digital trimpot directly.
4836
         case 908: // M908 Control digital trimpot directly.
4811
           gcode_M908();
4837
           gcode_M908();
4812
           break;
4838
           break;
4813
-      #endif // DIGIPOTSS_PIN
4839
+      #endif // HAS_DIGIPOTSS
4814
 
4840
 
4815
       case 350: // M350 Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers.
4841
       case 350: // M350 Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers.
4816
         gcode_M350();
4842
         gcode_M350();
5269
    const int KILL_DELAY = 10000;
5295
    const int KILL_DELAY = 10000;
5270
 #endif
5296
 #endif
5271
 
5297
 
5298
+#if defined(FILRUNOUT_PIN) && FILRUNOUT_PIN > -1
5299
+    if(card.sdprinting) {
5300
+      if(!(READ(FILRUNOUT_PIN))^FIL_RUNOUT_INVERTING)
5301
+      filrunout();        }
5302
+#endif
5303
+
5272
 #if defined(HOME_PIN) && HOME_PIN > -1
5304
 #if defined(HOME_PIN) && HOME_PIN > -1
5273
    static int homeDebounceCount = 0;   // poor man's debouncing count
5305
    static int homeDebounceCount = 0;   // poor man's debouncing count
5274
    const int HOME_DEBOUNCE_DELAY = 10000;
5306
    const int HOME_DEBOUNCE_DELAY = 10000;
5417
   while(1) { /* Intentionally left empty */ } // Wait for reset
5449
   while(1) { /* Intentionally left empty */ } // Wait for reset
5418
 }
5450
 }
5419
 
5451
 
5452
+#ifdef FILAMENT_RUNOUT_SENSOR
5453
+   void filrunout()
5454
+   {
5455
+      if filrunoutEnqued == false {
5456
+         filrunoutEnqued = true;
5457
+         enquecommand("M600");
5458
+      }
5459
+   }
5460
+#endif
5461
+
5420
 void Stop()
5462
 void Stop()
5421
 {
5463
 {
5422
   disable_heater();
5464
   disable_heater();

+ 9
- 9
Marlin/Sd2Card.cpp View File

35
  */
35
  */
36
 static void spiInit(uint8_t spiRate) {
36
 static void spiInit(uint8_t spiRate) {
37
   // See avr processor documentation
37
   // See avr processor documentation
38
-  SPCR = (1 << SPE) | (1 << MSTR) | (spiRate >> 1);
39
-  SPSR = spiRate & 1 || spiRate == 6 ? 0 : 1 << SPI2X;
38
+  SPCR = BIT(SPE) | BIT(MSTR) | (spiRate >> 1);
39
+  SPSR = spiRate & 1 || spiRate == 6 ? 0 : BIT(SPI2X);
40
 }
40
 }
41
 //------------------------------------------------------------------------------
41
 //------------------------------------------------------------------------------
42
 /** SPI receive a byte */
42
 /** SPI receive a byte */
43
 static uint8_t spiRec() {
43
 static uint8_t spiRec() {
44
   SPDR = 0XFF;
44
   SPDR = 0XFF;
45
-  while (!(SPSR & (1 << SPIF))) { /* Intentionally left empty */ }
45
+  while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
46
   return SPDR;
46
   return SPDR;
47
 }
47
 }
48
 //------------------------------------------------------------------------------
48
 //------------------------------------------------------------------------------
52
   if (nbyte-- == 0) return;
52
   if (nbyte-- == 0) return;
53
   SPDR = 0XFF;
53
   SPDR = 0XFF;
54
   for (uint16_t i = 0; i < nbyte; i++) {
54
   for (uint16_t i = 0; i < nbyte; i++) {
55
-    while (!(SPSR & (1 << SPIF))) { /* Intentionally left empty */ }
55
+    while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
56
     buf[i] = SPDR;
56
     buf[i] = SPDR;
57
     SPDR = 0XFF;
57
     SPDR = 0XFF;
58
   }
58
   }
59
-  while (!(SPSR & (1 << SPIF))) { /* Intentionally left empty */ }
59
+  while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
60
   buf[nbyte] = SPDR;
60
   buf[nbyte] = SPDR;
61
 }
61
 }
62
 //------------------------------------------------------------------------------
62
 //------------------------------------------------------------------------------
63
 /** SPI send a byte */
63
 /** SPI send a byte */
64
 static void spiSend(uint8_t b) {
64
 static void spiSend(uint8_t b) {
65
   SPDR = b;
65
   SPDR = b;
66
-  while (!(SPSR & (1 << SPIF))) { /* Intentionally left empty */ }
66
+  while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
67
 }
67
 }
68
 //------------------------------------------------------------------------------
68
 //------------------------------------------------------------------------------
69
 /** SPI send block - only one call so force inline */
69
 /** SPI send block - only one call so force inline */
71
   void spiSendBlock(uint8_t token, const uint8_t* buf) {
71
   void spiSendBlock(uint8_t token, const uint8_t* buf) {
72
   SPDR = token;
72
   SPDR = token;
73
   for (uint16_t i = 0; i < 512; i += 2) {
73
   for (uint16_t i = 0; i < 512; i += 2) {
74
-    while (!(SPSR & (1 << SPIF))) { /* Intentionally left empty */ }
74
+    while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
75
     SPDR = buf[i];
75
     SPDR = buf[i];
76
-    while (!(SPSR & (1 << SPIF))) { /* Intentionally left empty */ }
76
+    while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
77
     SPDR = buf[i + 1];
77
     SPDR = buf[i + 1];
78
   }
78
   }
79
-  while (!(SPSR & (1 << SPIF))) { /* Intentionally left empty */ }
79
+  while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
80
 }
80
 }
81
 //------------------------------------------------------------------------------
81
 //------------------------------------------------------------------------------
82
 #else  // SOFTWARE_SPI
82
 #else  // SOFTWARE_SPI

+ 4
- 4
Marlin/Sd2PinMap.h View File

334
   void setPinMode(uint8_t pin, uint8_t mode) {
334
   void setPinMode(uint8_t pin, uint8_t mode) {
335
   if (__builtin_constant_p(pin) && pin < digitalPinCount) {
335
   if (__builtin_constant_p(pin) && pin < digitalPinCount) {
336
     if (mode) {
336
     if (mode) {
337
-      *digitalPinMap[pin].ddr |= 1 << digitalPinMap[pin].bit;
337
+      *digitalPinMap[pin].ddr |= BIT(digitalPinMap[pin].bit);
338
     } else {
338
     } else {
339
-      *digitalPinMap[pin].ddr &= ~(1 << digitalPinMap[pin].bit);
339
+      *digitalPinMap[pin].ddr &= ~BIT(digitalPinMap[pin].bit);
340
     }
340
     }
341
   } else {
341
   } else {
342
     badPinNumber();
342
     badPinNumber();
354
   void fastDigitalWrite(uint8_t pin, uint8_t value) {
354
   void fastDigitalWrite(uint8_t pin, uint8_t value) {
355
   if (__builtin_constant_p(pin) && pin < digitalPinCount) {
355
   if (__builtin_constant_p(pin) && pin < digitalPinCount) {
356
     if (value) {
356
     if (value) {
357
-      *digitalPinMap[pin].port |= 1 << digitalPinMap[pin].bit;
357
+      *digitalPinMap[pin].port |= BIT(digitalPinMap[pin].bit);
358
     } else {
358
     } else {
359
-      *digitalPinMap[pin].port &= ~(1 << digitalPinMap[pin].bit);
359
+      *digitalPinMap[pin].port &= ~BIT(digitalPinMap[pin].bit);
360
     }
360
     }
361
   } else {
361
   } else {
362
     badPinNumber();
362
     badPinNumber();

+ 2
- 2
Marlin/SdBaseFile.h View File

171
   return 2*(fatTime & 0X1F);
171
   return 2*(fatTime & 0X1F);
172
 }
172
 }
173
 /** Default date for file timestamps is 1 Jan 2000 */
173
 /** Default date for file timestamps is 1 Jan 2000 */
174
-uint16_t const FAT_DEFAULT_DATE = ((2000 - 1980) << 9) | (1 << 5) | 1;
174
+uint16_t const FAT_DEFAULT_DATE = ((2000 - 1980) << 9) | BIT(5) | 1;
175
 /** Default time for file timestamp is 1 am */
175
 /** Default time for file timestamp is 1 am */
176
-uint16_t const FAT_DEFAULT_TIME = (1 << 11);
176
+uint16_t const FAT_DEFAULT_TIME = BIT(11);
177
 //------------------------------------------------------------------------------
177
 //------------------------------------------------------------------------------
178
 /**
178
 /**
179
  * \class SdBaseFile
179
  * \class SdBaseFile

+ 1
- 1
Marlin/SdVolume.cpp View File

360
   blocksPerCluster_ = fbs->sectorsPerCluster;
360
   blocksPerCluster_ = fbs->sectorsPerCluster;
361
   // determine shift that is same as multiply by blocksPerCluster_
361
   // determine shift that is same as multiply by blocksPerCluster_
362
   clusterSizeShift_ = 0;
362
   clusterSizeShift_ = 0;
363
-  while (blocksPerCluster_ != (1 << clusterSizeShift_)) {
363
+  while (blocksPerCluster_ != BIT(clusterSizeShift_)) {
364
     // error if not power of 2
364
     // error if not power of 2
365
     if (clusterSizeShift_++ > 7) goto fail;
365
     if (clusterSizeShift_++ > 7) goto fail;
366
   }
366
   }

+ 3
- 3
Marlin/dogm_lcd_implementation.h View File

24
   #define BLEN_A 0
24
   #define BLEN_A 0
25
   #define BLEN_B 1
25
   #define BLEN_B 1
26
   #define BLEN_C 2
26
   #define BLEN_C 2
27
-  #define EN_A (1<<BLEN_A)
28
-  #define EN_B (1<<BLEN_B)
29
-  #define EN_C (1<<BLEN_C)
27
+  #define EN_A BIT(BLEN_A)
28
+  #define EN_B BIT(BLEN_B)
29
+  #define EN_C BIT(BLEN_C)
30
   #define LCD_CLICKED (buttons&EN_C)
30
   #define LCD_CLICKED (buttons&EN_C)
31
 #endif
31
 #endif
32
 
32
 

+ 1
- 2
Marlin/fastio.h View File

13
 */
13
 */
14
 
14
 
15
 #ifndef MASK
15
 #ifndef MASK
16
-/// MASKING- returns \f$2^PIN\f$
17
-#define MASK(PIN)  (1 << PIN)
16
+  #define MASK(PIN)  (1 << PIN)
18
 #endif
17
 #endif
19
 
18
 
20
 /*
19
 /*

+ 2
- 0
Marlin/pins.h View File

184
                         analogInputToDigitalPin(TEMP_BED_PIN) \
184
                         analogInputToDigitalPin(TEMP_BED_PIN) \
185
                        }
185
                        }
186
 
186
 
187
+#define HAS_DIGIPOTSS (DIGIPOTSS_PIN >= 0)
188
+
187
 #endif //__PINS_H
189
 #endif //__PINS_H

+ 5
- 0
Marlin/pins_RAMPS_13.h View File

61
   #define FILWIDTH_PIN        5
61
   #define FILWIDTH_PIN        5
62
 #endif
62
 #endif
63
 
63
 
64
+#if defined(FILAMENT_RUNOUT_SENSOR)
65
+  // define digital pin 4 for the filament runout sensor. Use the RAMPS 1.4 digital input 4 on the servos connector
66
+  #define FILRUNOUT_PIN        4
67
+#endif
68
+
64
 #if MB(RAMPS_13_EFB) || MB(RAMPS_13_EFF)
69
 #if MB(RAMPS_13_EFB) || MB(RAMPS_13_EFF)
65
   #define FAN_PIN            9 // (Sprinter config)
70
   #define FAN_PIN            9 // (Sprinter config)
66
   #if MB(RAMPS_13_EFF)
71
   #if MB(RAMPS_13_EFF)

+ 11
- 11
Marlin/planner.cpp View File

59
 #include "language.h"
59
 #include "language.h"
60
 
60
 
61
 //===========================================================================
61
 //===========================================================================
62
-//=============================public variables ============================
62
+//============================= public variables ============================
63
 //===========================================================================
63
 //===========================================================================
64
 
64
 
65
 unsigned long minsegmenttime;
65
 unsigned long minsegmenttime;
623
 #ifndef COREXY
623
 #ifndef COREXY
624
   if (target[X_AXIS] < position[X_AXIS])
624
   if (target[X_AXIS] < position[X_AXIS])
625
   {
625
   {
626
-    block->direction_bits |= (1<<X_AXIS); 
626
+    block->direction_bits |= BIT(X_AXIS); 
627
   }
627
   }
628
   if (target[Y_AXIS] < position[Y_AXIS])
628
   if (target[Y_AXIS] < position[Y_AXIS])
629
   {
629
   {
630
-    block->direction_bits |= (1<<Y_AXIS); 
630
+    block->direction_bits |= BIT(Y_AXIS); 
631
   }
631
   }
632
 #else
632
 #else
633
   if (target[X_AXIS] < position[X_AXIS])
633
   if (target[X_AXIS] < position[X_AXIS])
634
   {
634
   {
635
-    block->direction_bits |= (1<<X_HEAD); //AlexBorro: Save the real Extruder (head) direction in X Axis
635
+    block->direction_bits |= BIT(X_HEAD); //AlexBorro: Save the real Extruder (head) direction in X Axis
636
   }
636
   }
637
   if (target[Y_AXIS] < position[Y_AXIS])
637
   if (target[Y_AXIS] < position[Y_AXIS])
638
   {
638
   {
639
-    block->direction_bits |= (1<<Y_HEAD); //AlexBorro: Save the real Extruder (head) direction in Y Axis
639
+    block->direction_bits |= BIT(Y_HEAD); //AlexBorro: Save the real Extruder (head) direction in Y Axis
640
   }
640
   }
641
   if ((target[X_AXIS]-position[X_AXIS]) + (target[Y_AXIS]-position[Y_AXIS]) < 0)
641
   if ((target[X_AXIS]-position[X_AXIS]) + (target[Y_AXIS]-position[Y_AXIS]) < 0)
642
   {
642
   {
643
-    block->direction_bits |= (1<<X_AXIS); //AlexBorro: Motor A direction (Incorrectly implemented as X_AXIS)
643
+    block->direction_bits |= BIT(X_AXIS); //AlexBorro: Motor A direction (Incorrectly implemented as X_AXIS)
644
   }
644
   }
645
   if ((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-position[Y_AXIS]) < 0)
645
   if ((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-position[Y_AXIS]) < 0)
646
   {
646
   {
647
-    block->direction_bits |= (1<<Y_AXIS); //AlexBorro: Motor B direction (Incorrectly implemented as Y_AXIS)
647
+    block->direction_bits |= BIT(Y_AXIS); //AlexBorro: Motor B direction (Incorrectly implemented as Y_AXIS)
648
   }
648
   }
649
 #endif
649
 #endif
650
   if (target[Z_AXIS] < position[Z_AXIS])
650
   if (target[Z_AXIS] < position[Z_AXIS])
651
   {
651
   {
652
-    block->direction_bits |= (1<<Z_AXIS); 
652
+    block->direction_bits |= BIT(Z_AXIS); 
653
   }
653
   }
654
   if (target[E_AXIS] < position[E_AXIS])
654
   if (target[E_AXIS] < position[E_AXIS])
655
   {
655
   {
656
-    block->direction_bits |= (1<<E_AXIS); 
656
+    block->direction_bits |= BIT(E_AXIS); 
657
   }
657
   }
658
 
658
 
659
   block->active_extruder = extruder;
659
   block->active_extruder = extruder;
864
   old_direction_bits = block->direction_bits;
864
   old_direction_bits = block->direction_bits;
865
   segment_time = lround((float)segment_time / speed_factor);
865
   segment_time = lround((float)segment_time / speed_factor);
866
   
866
   
867
-  if((direction_change & (1<<X_AXIS)) == 0)
867
+  if((direction_change & BIT(X_AXIS)) == 0)
868
   {
868
   {
869
     x_segment_time[0] += segment_time;
869
     x_segment_time[0] += segment_time;
870
   }
870
   }
874
     x_segment_time[1] = x_segment_time[0];
874
     x_segment_time[1] = x_segment_time[0];
875
     x_segment_time[0] = segment_time;
875
     x_segment_time[0] = segment_time;
876
   }
876
   }
877
-  if((direction_change & (1<<Y_AXIS)) == 0)
877
+  if((direction_change & BIT(Y_AXIS)) == 0)
878
   {
878
   {
879
     y_segment_time[0] += segment_time;
879
     y_segment_time[0] += segment_time;
880
   }
880
   }

+ 523
- 739
Marlin/stepper.cpp
File diff suppressed because it is too large
View File


+ 5
- 5
Marlin/stepper.h View File

25
 #include "stepper_indirection.h"
25
 #include "stepper_indirection.h"
26
 
26
 
27
 #if EXTRUDERS > 3
27
 #if EXTRUDERS > 3
28
-  #define WRITE_E_STEP(v) { if(current_block->active_extruder == 3) { E3_STEP_WRITE(v); } else { if(current_block->active_extruder == 2) { E2_STEP_WRITE(v); } else { if(current_block->active_extruder == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}}}
28
+  #define E_STEP_WRITE(v) { if(current_block->active_extruder == 3) { E3_STEP_WRITE(v); } else { if(current_block->active_extruder == 2) { E2_STEP_WRITE(v); } else { if(current_block->active_extruder == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}}}
29
   #define NORM_E_DIR() { if(current_block->active_extruder == 3) { E3_DIR_WRITE( !INVERT_E3_DIR); } else { if(current_block->active_extruder == 2) { E2_DIR_WRITE(!INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { E1_DIR_WRITE(!INVERT_E1_DIR); } else { E0_DIR_WRITE(!INVERT_E0_DIR); }}}}
29
   #define NORM_E_DIR() { if(current_block->active_extruder == 3) { E3_DIR_WRITE( !INVERT_E3_DIR); } else { if(current_block->active_extruder == 2) { E2_DIR_WRITE(!INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { E1_DIR_WRITE(!INVERT_E1_DIR); } else { E0_DIR_WRITE(!INVERT_E0_DIR); }}}}
30
   #define REV_E_DIR() { if(current_block->active_extruder == 3) { E3_DIR_WRITE(INVERT_E3_DIR); } else { if(current_block->active_extruder == 2) { E2_DIR_WRITE(INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { E1_DIR_WRITE(INVERT_E1_DIR); } else { E0_DIR_WRITE(INVERT_E0_DIR); }}}}
30
   #define REV_E_DIR() { if(current_block->active_extruder == 3) { E3_DIR_WRITE(INVERT_E3_DIR); } else { if(current_block->active_extruder == 2) { E2_DIR_WRITE(INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { E1_DIR_WRITE(INVERT_E1_DIR); } else { E0_DIR_WRITE(INVERT_E0_DIR); }}}}
31
 #elif EXTRUDERS > 2
31
 #elif EXTRUDERS > 2
32
-  #define WRITE_E_STEP(v) { if(current_block->active_extruder == 2) { E2_STEP_WRITE(v); } else { if(current_block->active_extruder == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}}
32
+  #define E_STEP_WRITE(v) { if(current_block->active_extruder == 2) { E2_STEP_WRITE(v); } else { if(current_block->active_extruder == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}}
33
   #define NORM_E_DIR() { if(current_block->active_extruder == 2) { E2_DIR_WRITE(!INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { E1_DIR_WRITE(!INVERT_E1_DIR); } else { E0_DIR_WRITE(!INVERT_E0_DIR); }}}
33
   #define NORM_E_DIR() { if(current_block->active_extruder == 2) { E2_DIR_WRITE(!INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { E1_DIR_WRITE(!INVERT_E1_DIR); } else { E0_DIR_WRITE(!INVERT_E0_DIR); }}}
34
   #define REV_E_DIR() { if(current_block->active_extruder == 2) { E2_DIR_WRITE(INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { E1_DIR_WRITE(INVERT_E1_DIR); } else { E0_DIR_WRITE(INVERT_E0_DIR); }}}
34
   #define REV_E_DIR() { if(current_block->active_extruder == 2) { E2_DIR_WRITE(INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { E1_DIR_WRITE(INVERT_E1_DIR); } else { E0_DIR_WRITE(INVERT_E0_DIR); }}}
35
 #elif EXTRUDERS > 1
35
 #elif EXTRUDERS > 1
36
   #ifndef DUAL_X_CARRIAGE
36
   #ifndef DUAL_X_CARRIAGE
37
-    #define WRITE_E_STEP(v) { if(current_block->active_extruder == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}
37
+    #define E_STEP_WRITE(v) { if(current_block->active_extruder == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}
38
     #define NORM_E_DIR() { if(current_block->active_extruder == 1) { E1_DIR_WRITE(!INVERT_E1_DIR); } else { E0_DIR_WRITE(!INVERT_E0_DIR); }}
38
     #define NORM_E_DIR() { if(current_block->active_extruder == 1) { E1_DIR_WRITE(!INVERT_E1_DIR); } else { E0_DIR_WRITE(!INVERT_E0_DIR); }}
39
     #define REV_E_DIR() { if(current_block->active_extruder == 1) { E1_DIR_WRITE(INVERT_E1_DIR); } else { E0_DIR_WRITE(INVERT_E0_DIR); }}
39
     #define REV_E_DIR() { if(current_block->active_extruder == 1) { E1_DIR_WRITE(INVERT_E1_DIR); } else { E0_DIR_WRITE(INVERT_E0_DIR); }}
40
   #else
40
   #else
41
     extern bool extruder_duplication_enabled;
41
     extern bool extruder_duplication_enabled;
42
-    #define WRITE_E_STEP(v) { if(extruder_duplication_enabled) { E0_STEP_WRITE(v); E1_STEP_WRITE(v); } else if(current_block->active_extruder == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}
42
+    #define E_STEP_WRITE(v) { if(extruder_duplication_enabled) { E0_STEP_WRITE(v); E1_STEP_WRITE(v); } else if(current_block->active_extruder == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}
43
     #define NORM_E_DIR() { if(extruder_duplication_enabled) { E0_DIR_WRITE(!INVERT_E0_DIR); E1_DIR_WRITE(!INVERT_E1_DIR); } else if(current_block->active_extruder == 1) { E1_DIR_WRITE(!INVERT_E1_DIR); } else { E0_DIR_WRITE(!INVERT_E0_DIR); }}
43
     #define NORM_E_DIR() { if(extruder_duplication_enabled) { E0_DIR_WRITE(!INVERT_E0_DIR); E1_DIR_WRITE(!INVERT_E1_DIR); } else if(current_block->active_extruder == 1) { E1_DIR_WRITE(!INVERT_E1_DIR); } else { E0_DIR_WRITE(!INVERT_E0_DIR); }}
44
     #define REV_E_DIR() { if(extruder_duplication_enabled) { E0_DIR_WRITE(INVERT_E0_DIR); E1_DIR_WRITE(INVERT_E1_DIR); } else if(current_block->active_extruder == 1) { E1_DIR_WRITE(INVERT_E1_DIR); } else { E0_DIR_WRITE(INVERT_E0_DIR); }}
44
     #define REV_E_DIR() { if(extruder_duplication_enabled) { E0_DIR_WRITE(INVERT_E0_DIR); E1_DIR_WRITE(INVERT_E1_DIR); } else if(current_block->active_extruder == 1) { E1_DIR_WRITE(INVERT_E1_DIR); } else { E0_DIR_WRITE(INVERT_E0_DIR); }}
45
   #endif  
45
   #endif  
46
 #else
46
 #else
47
-  #define WRITE_E_STEP(v) E0_STEP_WRITE(v)
47
+  #define E_STEP_WRITE(v) E0_STEP_WRITE(v)
48
   #define NORM_E_DIR() E0_DIR_WRITE(!INVERT_E0_DIR)
48
   #define NORM_E_DIR() E0_DIR_WRITE(!INVERT_E0_DIR)
49
   #define REV_E_DIR() E0_DIR_WRITE(INVERT_E0_DIR)
49
   #define REV_E_DIR() E0_DIR_WRITE(INVERT_E0_DIR)
50
 #endif
50
 #endif

+ 114
- 110
Marlin/temperature.cpp View File

75
 //============================= public variables ============================
75
 //============================= public variables ============================
76
 //===========================================================================
76
 //===========================================================================
77
 
77
 
78
+#ifdef K1 // Defined in Configuration.h in the PID settings
79
+  #define K2 (1.0-K1)
80
+#endif
81
+
78
 // Sampling period of the temperature routine
82
 // Sampling period of the temperature routine
79
 #ifdef PID_dT
83
 #ifdef PID_dT
80
   #undef PID_dT
84
   #undef PID_dT
127
   static float pid_error[EXTRUDERS];
131
   static float pid_error[EXTRUDERS];
128
   static float temp_iState_min[EXTRUDERS];
132
   static float temp_iState_min[EXTRUDERS];
129
   static float temp_iState_max[EXTRUDERS];
133
   static float temp_iState_max[EXTRUDERS];
130
-  // static float pid_input[EXTRUDERS];
131
-  // static float pid_output[EXTRUDERS];
132
   static bool pid_reset[EXTRUDERS];
134
   static bool pid_reset[EXTRUDERS];
133
 #endif //PIDTEMP
135
 #endif //PIDTEMP
134
 #ifdef PIDTEMPBED
136
 #ifdef PIDTEMPBED
546
   _temp_error(-1, MSG_MAXTEMP_BED_OFF, MSG_ERR_MAXTEMP_BED);
548
   _temp_error(-1, MSG_MAXTEMP_BED_OFF, MSG_ERR_MAXTEMP_BED);
547
 }
549
 }
548
 
550
 
551
+float get_pid_output(int e) {
552
+  float pid_output;
553
+  #ifdef PIDTEMP
554
+    #ifndef PID_OPENLOOP
555
+      pid_error[e] = target_temperature[e] - current_temperature[e];
556
+      if (pid_error[e] > PID_FUNCTIONAL_RANGE) {
557
+        pid_output = BANG_MAX;
558
+        pid_reset[e] = true;
559
+      }
560
+      else if (pid_error[e] < -PID_FUNCTIONAL_RANGE || target_temperature[e] == 0) {
561
+        pid_output = 0;
562
+        pid_reset[e] = true;
563
+      }
564
+      else {
565
+        if (pid_reset[e]) {
566
+          temp_iState[e] = 0.0;
567
+          pid_reset[e] = false;
568
+        }
569
+        pTerm[e] = PID_PARAM(Kp,e) * pid_error[e];
570
+        temp_iState[e] += pid_error[e];
571
+        temp_iState[e] = constrain(temp_iState[e], temp_iState_min[e], temp_iState_max[e]);
572
+        iTerm[e] = PID_PARAM(Ki,e) * temp_iState[e];
573
+
574
+        dTerm[e] = K2 * PID_PARAM(Kd,e) * (current_temperature[e] - temp_dState[e]) + K1 * dTerm[e];
575
+        pid_output = pTerm[e] + iTerm[e] - dTerm[e];
576
+        if (pid_output > PID_MAX) {
577
+          if (pid_error[e] > 0) temp_iState[e] -= pid_error[e]; // conditional un-integration
578
+          pid_output = PID_MAX;
579
+        }
580
+        else if (pid_output < 0) {
581
+          if (pid_error[e] < 0) temp_iState[e] -= pid_error[e]; // conditional un-integration
582
+          pid_output = 0;
583
+        }
584
+      }
585
+      temp_dState[e] = current_temperature[e];
586
+    #else
587
+      pid_output = constrain(target_temperature[e], 0, PID_MAX);
588
+    #endif //PID_OPENLOOP
589
+
590
+    #ifdef PID_DEBUG
591
+      SERIAL_ECHO_START;
592
+      SERIAL_ECHO(MSG_PID_DEBUG);
593
+      SERIAL_ECHO(e);
594
+      SERIAL_ECHO(MSG_PID_DEBUG_INPUT);
595
+      SERIAL_ECHO(current_temperature[e]);
596
+      SERIAL_ECHO(MSG_PID_DEBUG_OUTPUT);
597
+      SERIAL_ECHO(pid_output);
598
+      SERIAL_ECHO(MSG_PID_DEBUG_PTERM);
599
+      SERIAL_ECHO(pTerm[e]);
600
+      SERIAL_ECHO(MSG_PID_DEBUG_ITERM);
601
+      SERIAL_ECHO(iTerm[e]);
602
+      SERIAL_ECHO(MSG_PID_DEBUG_DTERM);
603
+      SERIAL_ECHOLN(dTerm[e]);
604
+    #endif //PID_DEBUG
605
+
606
+  #else /* PID off */
607
+    pid_output = (current_temperature[e] < target_temperature[e]) ? PID_MAX : 0;
608
+  #endif
609
+
610
+  return pid_output;
611
+}
612
+
613
+#ifdef PIDTEMPBED
614
+  float get_pid_output_bed() {
615
+    float pid_output;
616
+    #ifndef PID_OPENLOOP
617
+      pid_error_bed = target_temperature_bed - current_temperature_bed;
618
+      pTerm_bed = bedKp * pid_error_bed;
619
+      temp_iState_bed += pid_error_bed;
620
+      temp_iState_bed = constrain(temp_iState_bed, temp_iState_min_bed, temp_iState_max_bed);
621
+      iTerm_bed = bedKi * temp_iState_bed;
622
+
623
+      dTerm_bed = K2 * bedKd * (current_temperature_bed - temp_dState_bed) + K1 * dTerm_bed;
624
+      temp_dState_bed = current_temperature_bed;
625
+
626
+      pid_output = pTerm_bed + iTerm_bed - dTerm_bed;
627
+      if (pid_output > MAX_BED_POWER) {
628
+        if (pid_error_bed > 0) temp_iState_bed -= pid_error_bed; // conditional un-integration
629
+        pid_output = MAX_BED_POWER;
630
+      }
631
+      else if (pid_output < 0) {
632
+        if (pid_error_bed < 0) temp_iState_bed -= pid_error_bed; // conditional un-integration
633
+        pid_output = 0;
634
+      }
635
+    #else
636
+      pid_output = constrain(target_temperature_bed, 0, MAX_BED_POWER);
637
+    #endif // PID_OPENLOOP
638
+
639
+    return pid_output;
640
+  }
641
+#endif
642
+
549
 void manage_heater() {
643
 void manage_heater() {
550
 
644
 
551
   if (!temp_meas_ready) return;
645
   if (!temp_meas_ready) return;
552
 
646
 
553
-  float pid_input, pid_output;
554
-
555
   updateTemperaturesFromRawValues();
647
   updateTemperaturesFromRawValues();
556
 
648
 
557
   #ifdef HEATER_0_USES_MAX6675
649
   #ifdef HEATER_0_USES_MAX6675
569
       thermal_runaway_protection(&thermal_runaway_state_machine[e], &thermal_runaway_timer[e], current_temperature[e], target_temperature[e], e, THERMAL_RUNAWAY_PROTECTION_PERIOD, THERMAL_RUNAWAY_PROTECTION_HYSTERESIS);
661
       thermal_runaway_protection(&thermal_runaway_state_machine[e], &thermal_runaway_timer[e], current_temperature[e], target_temperature[e], e, THERMAL_RUNAWAY_PROTECTION_PERIOD, THERMAL_RUNAWAY_PROTECTION_HYSTERESIS);
570
     #endif
662
     #endif
571
 
663
 
572
-    #ifdef PIDTEMP
573
-      pid_input = current_temperature[e];
574
-
575
-      #ifndef PID_OPENLOOP
576
-        pid_error[e] = target_temperature[e] - pid_input;
577
-        if (pid_error[e] > PID_FUNCTIONAL_RANGE) {
578
-          pid_output = BANG_MAX;
579
-          pid_reset[e] = true;
580
-        }
581
-        else if (pid_error[e] < -PID_FUNCTIONAL_RANGE || target_temperature[e] == 0) {
582
-          pid_output = 0;
583
-          pid_reset[e] = true;
584
-        }
585
-        else {
586
-          if (pid_reset[e] == true) {
587
-            temp_iState[e] = 0.0;
588
-            pid_reset[e] = false;
589
-          }
590
-          pTerm[e] = PID_PARAM(Kp,e) * pid_error[e];
591
-          temp_iState[e] += pid_error[e];
592
-          temp_iState[e] = constrain(temp_iState[e], temp_iState_min[e], temp_iState_max[e]);
593
-          iTerm[e] = PID_PARAM(Ki,e) * temp_iState[e];
594
-
595
-          //K1 defined in Configuration.h in the PID settings
596
-          #define K2 (1.0-K1)
597
-          dTerm[e] = (PID_PARAM(Kd,e) * (pid_input - temp_dState[e])) * K2 + (K1 * dTerm[e]);
598
-          pid_output = pTerm[e] + iTerm[e] - dTerm[e];
599
-          if (pid_output > PID_MAX) {
600
-            if (pid_error[e] > 0) temp_iState[e] -= pid_error[e]; // conditional un-integration
601
-            pid_output = PID_MAX;
602
-          }
603
-          else if (pid_output < 0) {
604
-            if (pid_error[e] < 0) temp_iState[e] -= pid_error[e]; // conditional un-integration
605
-            pid_output = 0;
606
-          }
607
-        }
608
-        temp_dState[e] = pid_input;
609
-      #else
610
-        pid_output = constrain(target_temperature[e], 0, PID_MAX);
611
-      #endif //PID_OPENLOOP
612
-
613
-      #ifdef PID_DEBUG
614
-        SERIAL_ECHO_START;
615
-        SERIAL_ECHO(MSG_PID_DEBUG);
616
-        SERIAL_ECHO(e);
617
-        SERIAL_ECHO(MSG_PID_DEBUG_INPUT);
618
-        SERIAL_ECHO(pid_input);
619
-        SERIAL_ECHO(MSG_PID_DEBUG_OUTPUT);
620
-        SERIAL_ECHO(pid_output);
621
-        SERIAL_ECHO(MSG_PID_DEBUG_PTERM);
622
-        SERIAL_ECHO(pTerm[e]);
623
-        SERIAL_ECHO(MSG_PID_DEBUG_ITERM);
624
-        SERIAL_ECHO(iTerm[e]);
625
-        SERIAL_ECHO(MSG_PID_DEBUG_DTERM);
626
-        SERIAL_ECHOLN(dTerm[e]);
627
-      #endif //PID_DEBUG
628
-
629
-    #else /* PID off */
630
-
631
-      pid_output = 0;
632
-      if (current_temperature[e] < target_temperature[e]) pid_output = PID_MAX;
633
-
634
-    #endif
664
+    float pid_output = get_pid_output(e);
635
 
665
 
636
     // Check if temperature is within the correct range
666
     // Check if temperature is within the correct range
637
     soft_pwm[e] = current_temperature[e] > minttemp[e] && current_temperature[e] < maxttemp[e] ? (int)pid_output >> 1 : 0;
667
     soft_pwm[e] = current_temperature[e] > minttemp[e] && current_temperature[e] < maxttemp[e] ? (int)pid_output >> 1 : 0;
678
     #endif
708
     #endif
679
 
709
 
680
     #ifdef PIDTEMPBED
710
     #ifdef PIDTEMPBED
681
-      pid_input = current_temperature_bed;
682
-
683
-      #ifndef PID_OPENLOOP
684
-        pid_error_bed = target_temperature_bed - pid_input;
685
-        pTerm_bed = bedKp * pid_error_bed;
686
-        temp_iState_bed += pid_error_bed;
687
-        temp_iState_bed = constrain(temp_iState_bed, temp_iState_min_bed, temp_iState_max_bed);
688
-        iTerm_bed = bedKi * temp_iState_bed;
689
-
690
-        //K1 defined in Configuration.h in the PID settings
691
-  		  #define K2 (1.0-K1)
692
-  		  dTerm_bed = (bedKd * (pid_input - temp_dState_bed))*K2 + (K1 * dTerm_bed);
693
-        temp_dState_bed = pid_input;
694
-
695
-        pid_output = pTerm_bed + iTerm_bed - dTerm_bed;
696
-        if (pid_output > MAX_BED_POWER) {
697
-          if (pid_error_bed > 0) temp_iState_bed -= pid_error_bed; // conditional un-integration
698
-          pid_output = MAX_BED_POWER;
699
-        }
700
-        else if (pid_output < 0) {
701
-          if (pid_error_bed < 0) temp_iState_bed -= pid_error_bed; // conditional un-integration
702
-          pid_output = 0;
703
-        }
704
-
705
-      #else
706
-        pid_output = constrain(target_temperature_bed, 0, MAX_BED_POWER);
707
-      #endif //PID_OPENLOOP
711
+      float pid_output = get_pid_output_bed();
708
 
712
 
709
       soft_pwm_bed = current_temperature_bed > BED_MINTEMP && current_temperature_bed < BED_MAXTEMP ? (int)pid_output >> 1 : 0;
713
       soft_pwm_bed = current_temperature_bed > BED_MINTEMP && current_temperature_bed < BED_MAXTEMP ? (int)pid_output >> 1 : 0;
710
 
714
 
878
 {
882
 {
879
   #if MB(RUMBA) && ((TEMP_SENSOR_0==-1)||(TEMP_SENSOR_1==-1)||(TEMP_SENSOR_2==-1)||(TEMP_SENSOR_BED==-1))
883
   #if MB(RUMBA) && ((TEMP_SENSOR_0==-1)||(TEMP_SENSOR_1==-1)||(TEMP_SENSOR_2==-1)||(TEMP_SENSOR_BED==-1))
880
     //disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector
884
     //disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector
881
-    MCUCR=(1<<JTD);
882
-    MCUCR=(1<<JTD);
885
+    MCUCR=BIT(JTD);
886
+    MCUCR=BIT(JTD);
883
   #endif
887
   #endif
884
   
888
   
885
   // Finish init of mult extruder arrays 
889
   // Finish init of mult extruder arrays 
937
   #endif //HEATER_0_USES_MAX6675
941
   #endif //HEATER_0_USES_MAX6675
938
 
942
 
939
   #ifdef DIDR2
943
   #ifdef DIDR2
940
-    #define ANALOG_SELECT(pin) do{ if (pin < 8) DIDR0 |= 1 << pin; else DIDR2 |= 1 << (pin - 8); }while(0)
944
+    #define ANALOG_SELECT(pin) do{ if (pin < 8) DIDR0 |= BIT(pin); else DIDR2 |= BIT(pin - 8); }while(0)
941
   #else
945
   #else
942
-    #define ANALOG_SELECT(pin) do{ DIDR0 |= 1 << pin; }while(0)
946
+    #define ANALOG_SELECT(pin) do{ DIDR0 |= BIT(pin); }while(0)
943
   #endif
947
   #endif
944
 
948
 
945
   // Set analog inputs
949
   // Set analog inputs
946
-  ADCSRA = 1<<ADEN | 1<<ADSC | 1<<ADIF | 0x07;
950
+  ADCSRA = BIT(ADEN) | BIT(ADSC) | BIT(ADIF) | 0x07;
947
   DIDR0 = 0;
951
   DIDR0 = 0;
948
   #ifdef DIDR2
952
   #ifdef DIDR2
949
     DIDR2 = 0;
953
     DIDR2 = 0;
970
   // Use timer0 for temperature measurement
974
   // Use timer0 for temperature measurement
971
   // Interleave temperature interrupt with millies interrupt
975
   // Interleave temperature interrupt with millies interrupt
972
   OCR0B = 128;
976
   OCR0B = 128;
973
-  TIMSK0 |= (1<<OCIE0B);  
977
+  TIMSK0 |= BIT(OCIE0B);  
974
   
978
   
975
   // Wait for temperature measurement to settle
979
   // Wait for temperature measurement to settle
976
   delay(250);
980
   delay(250);
1174
     max6675_temp = 0;
1178
     max6675_temp = 0;
1175
 
1179
 
1176
     #ifdef PRR
1180
     #ifdef PRR
1177
-      PRR &= ~(1<<PRSPI);
1181
+      PRR &= ~BIT(PRSPI);
1178
     #elif defined(PRR0)
1182
     #elif defined(PRR0)
1179
-      PRR0 &= ~(1<<PRSPI);
1183
+      PRR0 &= ~BIT(PRSPI);
1180
     #endif
1184
     #endif
1181
 
1185
 
1182
-    SPCR = (1<<MSTR) | (1<<SPE) | (1<<SPR0);
1186
+    SPCR = BIT(MSTR) | BIT(SPE) | BIT(SPR0);
1183
 
1187
 
1184
     // enable TT_MAX6675
1188
     // enable TT_MAX6675
1185
     WRITE(MAX6675_SS, 0);
1189
     WRITE(MAX6675_SS, 0);
1190
 
1194
 
1191
     // read MSB
1195
     // read MSB
1192
     SPDR = 0;
1196
     SPDR = 0;
1193
-    for (;(SPSR & (1<<SPIF)) == 0;);
1197
+    for (;(SPSR & BIT(SPIF)) == 0;);
1194
     max6675_temp = SPDR;
1198
     max6675_temp = SPDR;
1195
     max6675_temp <<= 8;
1199
     max6675_temp <<= 8;
1196
 
1200
 
1197
     // read LSB
1201
     // read LSB
1198
     SPDR = 0;
1202
     SPDR = 0;
1199
-    for (;(SPSR & (1<<SPIF)) == 0;);
1203
+    for (;(SPSR & BIT(SPIF)) == 0;);
1200
     max6675_temp |= SPDR;
1204
     max6675_temp |= SPDR;
1201
 
1205
 
1202
     // disable TT_MAX6675
1206
     // disable TT_MAX6675
1246
   static unsigned long raw_temp_3_value = 0;
1250
   static unsigned long raw_temp_3_value = 0;
1247
   static unsigned long raw_temp_bed_value = 0;
1251
   static unsigned long raw_temp_bed_value = 0;
1248
   static TempState temp_state = StartupDelay;
1252
   static TempState temp_state = StartupDelay;
1249
-  static unsigned char pwm_count = (1 << SOFT_PWM_SCALE);
1253
+  static unsigned char pwm_count = BIT(SOFT_PWM_SCALE);
1250
 
1254
 
1251
   // Static members for each heater
1255
   // Static members for each heater
1252
   #ifdef SLOW_PWM_HEATERS
1256
   #ifdef SLOW_PWM_HEATERS
1331
       if (soft_pwm_fan < pwm_count) WRITE_FAN(0);
1335
       if (soft_pwm_fan < pwm_count) WRITE_FAN(0);
1332
     #endif
1336
     #endif
1333
     
1337
     
1334
-    pwm_count += (1 << SOFT_PWM_SCALE);
1338
+    pwm_count += BIT(SOFT_PWM_SCALE);
1335
     pwm_count &= 0x7f;
1339
     pwm_count &= 0x7f;
1336
   
1340
   
1337
   #else // SLOW_PWM_HEATERS
1341
   #else // SLOW_PWM_HEATERS
1412
       if (soft_pwm_fan < pwm_count) WRITE_FAN(0);
1416
       if (soft_pwm_fan < pwm_count) WRITE_FAN(0);
1413
     #endif //FAN_SOFT_PWM
1417
     #endif //FAN_SOFT_PWM
1414
 
1418
 
1415
-    pwm_count += (1 << SOFT_PWM_SCALE);
1419
+    pwm_count += BIT(SOFT_PWM_SCALE);
1416
     pwm_count &= 0x7f;
1420
     pwm_count &= 0x7f;
1417
 
1421
 
1418
     // increment slow_pwm_count only every 64 pwm_count circa 65.5ms
1422
     // increment slow_pwm_count only every 64 pwm_count circa 65.5ms
1438
   
1442
   
1439
   #endif // SLOW_PWM_HEATERS
1443
   #endif // SLOW_PWM_HEATERS
1440
 
1444
 
1441
-  #define SET_ADMUX_ADCSRA(pin) ADMUX = (1 << REFS0) | (pin & 0x07); ADCSRA |= 1<<ADSC
1445
+  #define SET_ADMUX_ADCSRA(pin) ADMUX = BIT(REFS0) | (pin & 0x07); ADCSRA |= BIT(ADSC)
1442
   #ifdef MUX5
1446
   #ifdef MUX5
1443
-    #define START_ADC(pin) if (pin > 7) ADCSRB = 1 << MUX5; else ADCSRB = 0; SET_ADMUX_ADCSRA(pin)
1447
+    #define START_ADC(pin) if (pin > 7) ADCSRB = BIT(MUX5); else ADCSRB = 0; SET_ADMUX_ADCSRA(pin)
1444
   #else
1448
   #else
1445
     #define START_ADC(pin) ADCSRB = 0; SET_ADMUX_ADCSRA(pin)
1449
     #define START_ADC(pin) ADCSRB = 0; SET_ADMUX_ADCSRA(pin)
1446
   #endif
1450
   #endif

+ 2
- 2
Marlin/ultralcd.cpp View File

1426
       WRITE(SHIFT_LD, HIGH);
1426
       WRITE(SHIFT_LD, HIGH);
1427
       for(int8_t i = 0; i < 8; i++) {
1427
       for(int8_t i = 0; i < 8; i++) {
1428
         newbutton_reprapworld_keypad >>= 1;
1428
         newbutton_reprapworld_keypad >>= 1;
1429
-        if (READ(SHIFT_OUT)) newbutton_reprapworld_keypad |= (1 << 7);
1429
+        if (READ(SHIFT_OUT)) newbutton_reprapworld_keypad |= BIT(7);
1430
         WRITE(SHIFT_CLK, HIGH);
1430
         WRITE(SHIFT_CLK, HIGH);
1431
         WRITE(SHIFT_CLK, LOW);
1431
         WRITE(SHIFT_CLK, LOW);
1432
       }
1432
       }
1439
     unsigned char tmp_buttons = 0;
1439
     unsigned char tmp_buttons = 0;
1440
     for(int8_t i=0; i<8; i++) {
1440
     for(int8_t i=0; i<8; i++) {
1441
       newbutton >>= 1;
1441
       newbutton >>= 1;
1442
-      if (READ(SHIFT_OUT)) newbutton |= (1 << 7);
1442
+      if (READ(SHIFT_OUT)) newbutton |= BIT(7);
1443
       WRITE(SHIFT_CLK, HIGH);
1443
       WRITE(SHIFT_CLK, HIGH);
1444
       WRITE(SHIFT_CLK, LOW);
1444
       WRITE(SHIFT_CLK, LOW);
1445
     }
1445
     }

+ 19
- 19
Marlin/ultralcd.h View File

57
   void lcd_ignore_click(bool b=true);
57
   void lcd_ignore_click(bool b=true);
58
 
58
 
59
   #ifdef NEWPANEL
59
   #ifdef NEWPANEL
60
-    #define EN_C (1<<BLEN_C)
61
-    #define EN_B (1<<BLEN_B)
62
-    #define EN_A (1<<BLEN_A)
60
+    #define EN_C BIT(BLEN_C)
61
+    #define EN_B BIT(BLEN_B)
62
+    #define EN_A BIT(BLEN_A)
63
 
63
 
64
     #define LCD_CLICKED (buttons&EN_C)
64
     #define LCD_CLICKED (buttons&EN_C)
65
     #ifdef REPRAPWORLD_KEYPAD
65
     #ifdef REPRAPWORLD_KEYPAD
66
-  	  #define EN_REPRAPWORLD_KEYPAD_F3 (1<<BLEN_REPRAPWORLD_KEYPAD_F3)
67
-  	  #define EN_REPRAPWORLD_KEYPAD_F2 (1<<BLEN_REPRAPWORLD_KEYPAD_F2)
68
-  	  #define EN_REPRAPWORLD_KEYPAD_F1 (1<<BLEN_REPRAPWORLD_KEYPAD_F1)
69
-  	  #define EN_REPRAPWORLD_KEYPAD_UP (1<<BLEN_REPRAPWORLD_KEYPAD_UP)
70
-  	  #define EN_REPRAPWORLD_KEYPAD_RIGHT (1<<BLEN_REPRAPWORLD_KEYPAD_RIGHT)
71
-  	  #define EN_REPRAPWORLD_KEYPAD_MIDDLE (1<<BLEN_REPRAPWORLD_KEYPAD_MIDDLE)
72
-  	  #define EN_REPRAPWORLD_KEYPAD_DOWN (1<<BLEN_REPRAPWORLD_KEYPAD_DOWN)
73
-  	  #define EN_REPRAPWORLD_KEYPAD_LEFT (1<<BLEN_REPRAPWORLD_KEYPAD_LEFT)
66
+  	  #define EN_REPRAPWORLD_KEYPAD_F3 BIT(BLEN_REPRAPWORLD_KEYPAD_F3)
67
+  	  #define EN_REPRAPWORLD_KEYPAD_F2 BIT(BLEN_REPRAPWORLD_KEYPAD_F2)
68
+  	  #define EN_REPRAPWORLD_KEYPAD_F1 BIT(BLEN_REPRAPWORLD_KEYPAD_F1)
69
+  	  #define EN_REPRAPWORLD_KEYPAD_UP BIT(BLEN_REPRAPWORLD_KEYPAD_UP)
70
+  	  #define EN_REPRAPWORLD_KEYPAD_RIGHT BIT(BLEN_REPRAPWORLD_KEYPAD_RIGHT)
71
+  	  #define EN_REPRAPWORLD_KEYPAD_MIDDLE BIT(BLEN_REPRAPWORLD_KEYPAD_MIDDLE)
72
+  	  #define EN_REPRAPWORLD_KEYPAD_DOWN BIT(BLEN_REPRAPWORLD_KEYPAD_DOWN)
73
+  	  #define EN_REPRAPWORLD_KEYPAD_LEFT BIT(BLEN_REPRAPWORLD_KEYPAD_LEFT)
74
 
74
 
75
   	  #define LCD_CLICKED ((buttons&EN_C) || (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_F1))
75
   	  #define LCD_CLICKED ((buttons&EN_C) || (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_F1))
76
   	  #define REPRAPWORLD_KEYPAD_MOVE_Z_UP (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_F2)
76
   	  #define REPRAPWORLD_KEYPAD_MOVE_Z_UP (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_F2)
83
     #endif //REPRAPWORLD_KEYPAD
83
     #endif //REPRAPWORLD_KEYPAD
84
   #else
84
   #else
85
     //atomic, do not change
85
     //atomic, do not change
86
-    #define B_LE (1<<BL_LE)
87
-    #define B_UP (1<<BL_UP)
88
-    #define B_MI (1<<BL_MI)
89
-    #define B_DW (1<<BL_DW)
90
-    #define B_RI (1<<BL_RI)
91
-    #define B_ST (1<<BL_ST)
92
-    #define EN_B (1<<BLEN_B)
93
-    #define EN_A (1<<BLEN_A)
86
+    #define B_LE BIT(BL_LE)
87
+    #define B_UP BIT(BL_UP)
88
+    #define B_MI BIT(BL_MI)
89
+    #define B_DW BIT(BL_DW)
90
+    #define B_RI BIT(BL_RI)
91
+    #define B_ST BIT(BL_ST)
92
+    #define EN_B BIT(BLEN_B)
93
+    #define EN_A BIT(BLEN_A)
94
     
94
     
95
     #define LCD_CLICKED ((buttons&B_MI)||(buttons&B_ST))
95
     #define LCD_CLICKED ((buttons&B_MI)||(buttons&B_ST))
96
   #endif//NEWPANEL
96
   #endif//NEWPANEL

+ 17
- 17
Marlin/ultralcd_implementation_hitachi_HD44780.h View File

24
 #define BLEN_B 1
24
 #define BLEN_B 1
25
 #define BLEN_A 0
25
 #define BLEN_A 0
26
 
26
 
27
-#define EN_B (1<<BLEN_B) // The two encoder pins are connected through BTN_EN1 and BTN_EN2
28
-#define EN_A (1<<BLEN_A)
27
+#define EN_B BIT(BLEN_B) // The two encoder pins are connected through BTN_EN1 and BTN_EN2
28
+#define EN_A BIT(BLEN_A)
29
 
29
 
30
 #if defined(BTN_ENC) && BTN_ENC > -1
30
 #if defined(BTN_ENC) && BTN_ENC > -1
31
   // encoder click is directly connected
31
   // encoder click is directly connected
32
   #define BLEN_C 2 
32
   #define BLEN_C 2 
33
-  #define EN_C (1<<BLEN_C) 
33
+  #define EN_C BIT(BLEN_C) 
34
 #endif 
34
 #endif 
35
   
35
   
36
 //
36
 //
85
     
85
     
86
     #define REPRAPWORLD_BTN_OFFSET 3 // bit offset into buttons for shift register values
86
     #define REPRAPWORLD_BTN_OFFSET 3 // bit offset into buttons for shift register values
87
 
87
 
88
-    #define EN_REPRAPWORLD_KEYPAD_F3 (1<<(BLEN_REPRAPWORLD_KEYPAD_F3+REPRAPWORLD_BTN_OFFSET))
89
-    #define EN_REPRAPWORLD_KEYPAD_F2 (1<<(BLEN_REPRAPWORLD_KEYPAD_F2+REPRAPWORLD_BTN_OFFSET))
90
-    #define EN_REPRAPWORLD_KEYPAD_F1 (1<<(BLEN_REPRAPWORLD_KEYPAD_F1+REPRAPWORLD_BTN_OFFSET))
91
-    #define EN_REPRAPWORLD_KEYPAD_UP (1<<(BLEN_REPRAPWORLD_KEYPAD_UP+REPRAPWORLD_BTN_OFFSET))
92
-    #define EN_REPRAPWORLD_KEYPAD_RIGHT (1<<(BLEN_REPRAPWORLD_KEYPAD_RIGHT+REPRAPWORLD_BTN_OFFSET))
93
-    #define EN_REPRAPWORLD_KEYPAD_MIDDLE (1<<(BLEN_REPRAPWORLD_KEYPAD_MIDDLE+REPRAPWORLD_BTN_OFFSET))
94
-    #define EN_REPRAPWORLD_KEYPAD_DOWN (1<<(BLEN_REPRAPWORLD_KEYPAD_DOWN+REPRAPWORLD_BTN_OFFSET))
95
-    #define EN_REPRAPWORLD_KEYPAD_LEFT (1<<(BLEN_REPRAPWORLD_KEYPAD_LEFT+REPRAPWORLD_BTN_OFFSET))
88
+    #define EN_REPRAPWORLD_KEYPAD_F3 BIT((BLEN_REPRAPWORLD_KEYPAD_F3+REPRAPWORLD_BTN_OFFSET))
89
+    #define EN_REPRAPWORLD_KEYPAD_F2 BIT((BLEN_REPRAPWORLD_KEYPAD_F2+REPRAPWORLD_BTN_OFFSET))
90
+    #define EN_REPRAPWORLD_KEYPAD_F1 BIT((BLEN_REPRAPWORLD_KEYPAD_F1+REPRAPWORLD_BTN_OFFSET))
91
+    #define EN_REPRAPWORLD_KEYPAD_UP BIT((BLEN_REPRAPWORLD_KEYPAD_UP+REPRAPWORLD_BTN_OFFSET))
92
+    #define EN_REPRAPWORLD_KEYPAD_RIGHT BIT((BLEN_REPRAPWORLD_KEYPAD_RIGHT+REPRAPWORLD_BTN_OFFSET))
93
+    #define EN_REPRAPWORLD_KEYPAD_MIDDLE BIT((BLEN_REPRAPWORLD_KEYPAD_MIDDLE+REPRAPWORLD_BTN_OFFSET))
94
+    #define EN_REPRAPWORLD_KEYPAD_DOWN BIT((BLEN_REPRAPWORLD_KEYPAD_DOWN+REPRAPWORLD_BTN_OFFSET))
95
+    #define EN_REPRAPWORLD_KEYPAD_LEFT BIT((BLEN_REPRAPWORLD_KEYPAD_LEFT+REPRAPWORLD_BTN_OFFSET))
96
 
96
 
97
     #define LCD_CLICKED ((buttons&EN_C) || (buttons&EN_REPRAPWORLD_KEYPAD_F1))
97
     #define LCD_CLICKED ((buttons&EN_C) || (buttons&EN_REPRAPWORLD_KEYPAD_F1))
98
     #define REPRAPWORLD_KEYPAD_MOVE_Y_DOWN (buttons&EN_REPRAPWORLD_KEYPAD_DOWN)
98
     #define REPRAPWORLD_KEYPAD_MOVE_Y_DOWN (buttons&EN_REPRAPWORLD_KEYPAD_DOWN)
113
   #define BL_ST 2
113
   #define BL_ST 2
114
 
114
 
115
   //automatic, do not change
115
   //automatic, do not change
116
-  #define B_LE (1<<BL_LE)
117
-  #define B_UP (1<<BL_UP)
118
-  #define B_MI (1<<BL_MI)
119
-  #define B_DW (1<<BL_DW)
120
-  #define B_RI (1<<BL_RI)
121
-  #define B_ST (1<<BL_ST)
116
+  #define B_LE BIT(BL_LE)
117
+  #define B_UP BIT(BL_UP)
118
+  #define B_MI BIT(BL_MI)
119
+  #define B_DW BIT(BL_DW)
120
+  #define B_RI BIT(BL_RI)
121
+  #define B_ST BIT(BL_ST)
122
   
122
   
123
   #define LCD_CLICKED (buttons&(B_MI|B_ST))
123
   #define LCD_CLICKED (buttons&(B_MI|B_ST))
124
 #endif
124
 #endif

+ 6
- 0
Marlin/ultralcd_st7920_u8glib_rrd.h View File

27
   for( i=0; i<8; i++ )
27
   for( i=0; i<8; i++ )
28
   {
28
   {
29
     WRITE(ST7920_CLK_PIN,0);
29
     WRITE(ST7920_CLK_PIN,0);
30
+    #if F_CPU == 20000000
31
+      __asm__("nop\n\t"); 
32
+    #endif
30
     WRITE(ST7920_DAT_PIN,val&0x80); 
33
     WRITE(ST7920_DAT_PIN,val&0x80); 
31
     val<<=1;
34
     val<<=1;
32
     WRITE(ST7920_CLK_PIN,1);
35
     WRITE(ST7920_CLK_PIN,1);
36
+    #if F_CPU == 20000000
37
+      __asm__("nop\n\t""nop\n\t"); 
38
+    #endif
33
   }
39
   }
34
 }
40
 }
35
 
41
 

+ 4
- 4
Marlin/vector_3.cpp View File

79
 {
79
 {
80
 	SERIAL_PROTOCOL(title);
80
 	SERIAL_PROTOCOL(title);
81
 	SERIAL_PROTOCOLPGM(" x: ");
81
 	SERIAL_PROTOCOLPGM(" x: ");
82
-	SERIAL_PROTOCOL(x);
82
+	SERIAL_PROTOCOL_F(x, 6);
83
 	SERIAL_PROTOCOLPGM(" y: ");
83
 	SERIAL_PROTOCOLPGM(" y: ");
84
-	SERIAL_PROTOCOL(y);
84
+	SERIAL_PROTOCOL_F(y, 6);
85
 	SERIAL_PROTOCOLPGM(" z: ");
85
 	SERIAL_PROTOCOLPGM(" z: ");
86
-	SERIAL_PROTOCOL(z);
86
+	SERIAL_PROTOCOL_F(z, 6);
87
 	SERIAL_EOL;
87
 	SERIAL_EOL;
88
 }
88
 }
89
 
89
 
150
   int count = 0;
150
   int count = 0;
151
   for(int i=0; i<3; i++) {
151
   for(int i=0; i<3; i++) {
152
     for(int j=0; j<3; j++) {
152
     for(int j=0; j<3; j++) {
153
-      SERIAL_PROTOCOL(matrix[count] + 0.0001);
153
+      SERIAL_PROTOCOL_F(matrix[count], 6);
154
       SERIAL_PROTOCOLPGM(" ");
154
       SERIAL_PROTOCOLPGM(" ");
155
       count++;
155
       count++;
156
     }
156
     }

Loading…
Cancel
Save