Browse Source

Merge branch 'Marlin_v1' of https://github.com/ErikZalm/Marlin into Marlin_v1

This should fix issues with pull request 467, I hope.

Conflicts:
	Marlin/Configuration.h
	Marlin/Marlin.pde
	Marlin/ultralcd_implementation_hitachi_HD44780.h
kiyoshigawa 12 years ago
parent
commit
6a81291c57

+ 129
- 43
Marlin/Configuration.h View File

@@ -2,7 +2,7 @@
2 2
 #define CONFIGURATION_H
3 3
 
4 4
 // This configurtion file contains the basic settings.
5
-// Advanced settings can be found in Configuration_adv.h 
5
+// Advanced settings can be found in Configuration_adv.h
6 6
 // BASIC SETTINGS: select your board type, temperature sensor type, axis scaling, and endstop configuration
7 7
 
8 8
 //User specified version info of this build to display in [Pronterface, etc] terminal window during startup.
@@ -43,6 +43,8 @@
43 43
 // 82 = Brainwave (AT90USB646)
44 44
 // 9  = Gen3+
45 45
 // 70 = Megatronics
46
+// 701= Megatronics v2.0
47
+// 702= Minitronics v1.0
46 48
 // 90 = Alpha OMCA board
47 49
 // 91 = Final OMCA board
48 50
 // 301 = Rambo
@@ -52,6 +54,9 @@
52 54
 #define MOTHERBOARD 7
53 55
 #endif
54 56
 
57
+// This defines the number of extruders
58
+#define EXTRUDERS 1
59
+
55 60
 //// The following define selects which power supply you have. Please choose the one that matches your setup
56 61
 // 1 = ATX
57 62
 // 2 = X-Box 360 203Watts (the blue wire connected to PS_ON and the red wire to VCC)
@@ -79,24 +84,28 @@
79 84
 // 9 is 100k GE Sensing AL03006-58.2K-97-G1 (4.7k pullup)
80 85
 // 10 is 100k RS thermistor 198-961 (4.7k pullup)
81 86
 //
82
-//    1k ohm pullup tables - This is not normal, you would have to have changed out your 4.7k for 1k 
87
+//    1k ohm pullup tables - This is not normal, you would have to have changed out your 4.7k for 1k
83 88
 //                          (but gives greater accuracy and more stable PID)
84 89
 // 51 is 100k thermistor - EPCOS (1k pullup)
85 90
 // 52 is 200k thermistor - ATC Semitec 204GT-2 (1k pullup)
86 91
 // 55 is 100k thermistor - ATC Semitec 104GT-2 (Used in ParCan) (1k pullup)
87 92
 
88 93
 #define TEMP_SENSOR_0 -1
89
-#define TEMP_SENSOR_1 0
94
+#define TEMP_SENSOR_1 -1
90 95
 #define TEMP_SENSOR_2 0
91 96
 #define TEMP_SENSOR_BED 0
92 97
 
98
+// This makes temp sensor 1 a redundant sensor for sensor 0. If the temperatures difference between these sensors is to high the print will be aborted.
99
+//#define TEMP_SENSOR_1_AS_REDUNDANT 
100
+#define MAX_REDUNDANT_TEMP_SENSOR_DIFF 10
101
+
93 102
 // Actual temperature must be close to target for this long before M109 returns success
94
-#define TEMP_RESIDENCY_TIME 10	// (seconds)
103
+#define TEMP_RESIDENCY_TIME 10  // (seconds)
95 104
 #define TEMP_HYSTERESIS 3       // (degC) range of +/- temperatures considered "close" to the target one
96 105
 #define TEMP_WINDOW     1       // (degC) Window around target to start the recidency timer x degC early.
97 106
 
98 107
 // The minimal temperature defines the temperature below which the heater will not be enabled It is used
99
-// to check that the wiring to the thermistor is not broken. 
108
+// to check that the wiring to the thermistor is not broken.
100 109
 // Otherwise this would lead to the heater being powered on all the time.
101 110
 #define HEATER_0_MINTEMP 5
102 111
 #define HEATER_1_MINTEMP 5
@@ -122,7 +131,7 @@
122 131
 #define BANG_MAX 256 // limits current to nozzle while in bang-bang mode; 256=full current
123 132
 #define PID_MAX 256 // limits current to nozzle while PID is active (see PID_FUNCTIONAL_RANGE below); 256=full current
124 133
 #ifdef PIDTEMP
125
-  //#define PID_DEBUG // Sends debug data to the serial port. 
134
+  //#define PID_DEBUG // Sends debug data to the serial port.
126 135
   //#define PID_OPENLOOP 1 // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX
127 136
   #define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature
128 137
                                   // is more then PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max.
@@ -133,15 +142,15 @@
133 142
 // If you are using a preconfigured hotend then you can use one of the value sets by uncommenting it
134 143
 // Ultimaker
135 144
     #define  DEFAULT_Kp 22.2
136
-    #define  DEFAULT_Ki 1.08  
137
-    #define  DEFAULT_Kd 114  
145
+    #define  DEFAULT_Ki 1.08
146
+    #define  DEFAULT_Kd 114
138 147
 
139 148
 // Makergear
140 149
 //    #define  DEFAULT_Kp 7.0
141
-//    #define  DEFAULT_Ki 0.1  
142
-//    #define  DEFAULT_Kd 12  
150
+//    #define  DEFAULT_Ki 0.1
151
+//    #define  DEFAULT_Kd 12
143 152
 
144
-// Mendel Parts V9 on 12V    
153
+// Mendel Parts V9 on 12V
145 154
 //    #define  DEFAULT_Kp 63.0
146 155
 //    #define  DEFAULT_Ki 2.25
147 156
 //    #define  DEFAULT_Kd 440
@@ -150,11 +159,11 @@
150 159
 // Bed Temperature Control
151 160
 // Select PID or bang-bang with PIDTEMPBED.  If bang-bang, BED_LIMIT_SWITCHING will enable hysteresis
152 161
 //
153
-// uncomment this to enable PID on the bed.   It uses the same ferquency PWM as the extruder. 
162
+// uncomment this to enable PID on the bed.   It uses the same frequency PWM as the extruder.
154 163
 // If your PID_dT above is the default, and correct for your hardware/configuration, that means 7.689Hz,
155 164
 // which is fine for driving a square wave into a resistive load and does not significantly impact you FET heating.
156
-// This also works fine on a Fotek SSR-10DA Solid State Relay into a 250W heater. 
157
-// If your configuration is significantly different than this and you don't understand the issues involved, you proabaly 
165
+// This also works fine on a Fotek SSR-10DA Solid State Relay into a 250W heater.
166
+// If your configuration is significantly different than this and you don't understand the issues involved, you proabaly
158 167
 // shouldn't use bed PID until someone else verifies your hardware works.
159 168
 // If this is enabled, find your own PID constants below.
160 169
 //#define PIDTEMPBED
@@ -224,9 +233,9 @@
224 233
 #endif
225 234
 
226 235
 // The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins.
227
-const bool X_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops. 
228
-const bool Y_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops. 
229
-const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops. 
236
+const bool X_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
237
+const bool Y_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
238
+const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
230 239
 //#define DISABLE_MAX_ENDSTOPS
231 240
 
232 241
 // For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
@@ -281,13 +290,13 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
281 290
 #define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
282 291
 #define HOMING_FEEDRATE {50*60, 50*60, 4*60, 0}  // set the homing speeds (mm/min)
283 292
 
284
-// default settings 
293
+// default settings
285 294
 
286 295
 #define DEFAULT_AXIS_STEPS_PER_UNIT   {78.7402,78.7402,200.0*8/3,760*1.1}  // default steps per unit for ultimaker
287 296
 #define DEFAULT_MAX_FEEDRATE          {500, 500, 5, 25}    // (mm/sec)
288 297
 #define DEFAULT_MAX_ACCELERATION      {9000,9000,100,10000}    // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for skeinforge 40+, for older versions raise them a lot.
289 298
 
290
-#define DEFAULT_ACCELERATION          3000    // X, Y, Z and E max acceleration in mm/s^2 for printing moves 
299
+#define DEFAULT_ACCELERATION          3000    // X, Y, Z and E max acceleration in mm/s^2 for printing moves
291 300
 #define DEFAULT_RETRACT_ACCELERATION  3000   // X, Y, Z and E max acceleration in mm/s^2 for r retracts
292 301
 
293 302
 // Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
@@ -308,7 +317,7 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
308 317
 // EEPROM
309 318
 // the microcontroller can store settings in the EEPROM, e.g. max velocity...
310 319
 // M500 - stores paramters in EEPROM
311
-// M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).  
320
+// M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).
312 321
 // M502 - reverts to the default "factory settings".  You still need to store them in EEPROM afterwards if you want to.
313 322
 //define this to enable eeprom support
314 323
 //#define EEPROM_SETTINGS
@@ -316,9 +325,18 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
316 325
 // please keep turned on if you can.
317 326
 //#define EEPROM_CHITCHAT
318 327
 
328
+// Preheat Constants
329
+#define PLA_PREHEAT_HOTEND_TEMP 180 
330
+#define PLA_PREHEAT_HPB_TEMP 70
331
+#define PLA_PREHEAT_FAN_SPEED 255   // Insert Value between 0 and 255
332
+
333
+#define ABS_PREHEAT_HOTEND_TEMP 240
334
+#define ABS_PREHEAT_HPB_TEMP 100
335
+#define ABS_PREHEAT_FAN_SPEED 255   // Insert Value between 0 and 255
336
+
319 337
 //LCD and SD support
320 338
 //#define ULTRA_LCD  //general lcd support, also 16x2
321
-//#define DOGLCD	// Support for SPI LCD 128x64 (Controller ST7565R graphic Display Family)
339
+//#define DOGLCD  // Support for SPI LCD 128x64 (Controller ST7565R graphic Display Family)
322 340
 //#define SDSUPPORT // Enable SD Card Support in Hardware Console
323 341
 //#define SDSLOW // Use slower SD transfer mode (not normally needed - uncomment if you're getting volume init error)
324 342
 
@@ -339,6 +357,11 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
339 357
 // ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: http://code.google.com/p/u8glib/wiki/u8glib
340 358
 //#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
341 359
 
360
+// The RepRapWorld REPRAPWORLD_KEYPAD v1.1
361
+// http://reprapworld.com/?products_details&products_id=202&cPath=1591_1626
362
+//#define REPRAPWORLD_KEYPAD
363
+//#define REPRAPWORLD_KEYPAD_MOVE_STEP 10.0 // how much should be moved when a key is pressed, eg 10.0 means 10mm per click
364
+
342 365
 // The Elefu RA Board Control Panel
343 366
 // http://www.elefu.com/index.php?route=product/product&product_id=53
344 367
 // REMEMBER TO INSTALL LiquidCrystal_I2C.h in your ARUDINO library folder: https://github.com/kiyoshigawa/LiquidCrystal_I2C
@@ -356,6 +379,10 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
356 379
  #define NEWPANEL
357 380
 #endif
358 381
 
382
+#if defined(REPRAPWORLD_KEYPAD)
383
+  #define NEWPANEL
384
+  #define ULTIPANEL
385
+#endif
359 386
 #if defined(RA_CONTROL_PANEL)
360 387
  #define ULTIPANEL
361 388
  #define NEWPANEL
@@ -363,36 +390,67 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
363 390
  #define LCD_I2C_ADDRESS 0x27   // I2C Address of the port expander
364 391
 #endif
365 392
 
366
-// Preheat Constants
367
-#define PLA_PREHEAT_HOTEND_TEMP 180 
368
-#define PLA_PREHEAT_HPB_TEMP 70
369
-#define PLA_PREHEAT_FAN_SPEED 255		// Insert Value between 0 and 255
393
+//I2C PANELS
370 394
 
371
-#define ABS_PREHEAT_HOTEND_TEMP 240
372
-#define ABS_PREHEAT_HPB_TEMP 100
373
-#define ABS_PREHEAT_FAN_SPEED 255		// Insert Value between 0 and 255
395
+//#define LCD_I2C_SAINSMART_YWROBOT
396
+#ifdef LCD_I2C_SAINSMART_YWROBOT
397
+  // This uses the LiquidCrystal_I2C library ( https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home )
398
+  // Make sure it is placed in the Arduino libraries directory.
399
+  #define LCD_I2C_TYPE_PCF8575
400
+  #define LCD_I2C_ADDRESS 0x27   // I2C Address of the port expander
401
+  #define NEWPANEL
402
+  #define ULTIPANEL 
403
+#endif
374 404
 
405
+// PANELOLU2 LCD with status LEDs, separate encoder and click inputs
406
+//#define LCD_I2C_PANELOLU2
407
+#ifdef LCD_I2C_PANELOLU2
408
+  // This uses the LiquidTWI2 library v1.2.3 or later ( https://github.com/lincomatic/LiquidTWI2 )
409
+  // Make sure the LiquidTWI2 directory is placed in the Arduino or Sketchbook libraries subdirectory.
410
+  // (v1.2.3 no longer requires you to define PANELOLU in the LiquidTWI2.h library header file)
411
+  // Note: The PANELOLU2 encoder click input can either be directly connected to a pin 
412
+  //       (if BTN_ENC defined to != -1) or read through I2C (when BTN_ENC == -1). 
413
+  #define LCD_I2C_TYPE_MCP23017
414
+  #define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander
415
+  #define LCD_USE_I2C_BUZZER //comment out to disable buzzer on LCD
416
+  #define NEWPANEL
417
+  #define ULTIPANEL 
418
+#endif
419
+
420
+// Panucatt VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs
421
+//#define LCD_I2C_VIKI
422
+#ifdef LCD_I2C_VIKI
423
+  // This uses the LiquidTWI2 library v1.2.3 or later ( https://github.com/lincomatic/LiquidTWI2 )
424
+  // Make sure the LiquidTWI2 directory is placed in the Arduino or Sketchbook libraries subdirectory.
425
+  // Note: The pause/stop/resume LCD button pin should be connected to the Arduino
426
+  //       BTN_ENC pin (or set BTN_ENC to -1 if not used)
427
+  #define LCD_I2C_TYPE_MCP23017 
428
+  #define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander
429
+  #define LCD_USE_I2C_BUZZER //comment out to disable buzzer on LCD (requires LiquidTWI2 v1.2.3 or later)
430
+  #define NEWPANEL
431
+  #define ULTIPANEL 
432
+#endif
375 433
 
376 434
 #ifdef ULTIPANEL
377 435
 //  #define NEWPANEL  //enable this if you have a click-encoder panel
378 436
   #define SDSUPPORT
379 437
   #define ULTRA_LCD
380
-	#ifdef DOGLCD	// Change number of lines to match the DOG graphic display
381
-		#define LCD_WIDTH 20
382
-		#define LCD_HEIGHT 5
383
-	#else
384
-		#define LCD_WIDTH 20
385
-		#define LCD_HEIGHT 4
386
-	#endif
387
-#else //no panel but just lcd 
438
+  #ifdef DOGLCD // Change number of lines to match the DOG graphic display
439
+    #define LCD_WIDTH 20
440
+    #define LCD_HEIGHT 5
441
+  #else
442
+    #define LCD_WIDTH 20
443
+    #define LCD_HEIGHT 4
444
+  #endif
445
+#else //no panel but just lcd
388 446
   #ifdef ULTRA_LCD
389
-	#ifdef DOGLCD	// Change number of lines to match the 128x64 graphics display
390
-		#define LCD_WIDTH 20
391
-		#define LCD_HEIGHT 5
392
-	#else
393
-		#define LCD_WIDTH 16
394
-		#define LCD_HEIGHT 2
395
-	#endif    
447
+  #ifdef DOGLCD // Change number of lines to match the 128x64 graphics display
448
+    #define LCD_WIDTH 20
449
+    #define LCD_HEIGHT 5
450
+  #else
451
+    #define LCD_WIDTH 16
452
+    #define LCD_HEIGHT 2
453
+  #endif
396 454
   #endif
397 455
 #endif
398 456
 
@@ -406,6 +464,34 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
406 464
 // SF send wrong arc g-codes when using Arc Point as fillet procedure
407 465
 //#define SF_ARC_FIX
408 466
 
467
+// Support for the BariCUDA Paste Extruder.
468
+//#define BARICUDA
469
+
470
+/*********************************************************************\
471
+*
472
+* R/C SERVO support
473
+*
474
+* Sponsored by TrinityLabs, Reworked by codexmas
475
+*
476
+**********************************************************************/
477
+
478
+// Number of servos
479
+//
480
+// If you select a configuration below, this will receive a default value and does not need to be set manually
481
+// set it manually if you have more servos than extruders and wish to manually control some
482
+// leaving it undefined or defining as 0 will disable the servo subsystem
483
+// If unsure, leave commented / disabled
484
+//
485
+//#define NUM_SERVOS 3 // Servo index starts with 0
486
+
487
+// Servo Endstops
488
+// 
489
+// This allows for servo actuated endstops, primary usage is for the Z Axis to eliminate calibration or bed height changes.
490
+// Use M206 command to correct for switch height offset to actual nozzle height. Store that setting with M500.
491
+// 
492
+//#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1
493
+//#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 70,0} // X,Y,Z Axis Extend and Retract angles
494
+
409 495
 #include "Configuration_adv.h"
410 496
 #include "thermistortables.h"
411 497
 

+ 22
- 9
Marlin/Configuration_adv.h View File

@@ -63,21 +63,31 @@
63 63
 //This is for controlling a fan to cool down the stepper drivers
64 64
 //it will turn on when any driver is enabled
65 65
 //and turn off after the set amount of seconds from last driver being disabled again
66
-//#define CONTROLLERFAN_PIN 23 //Pin used for the fan to cool controller, comment out to disable this function
67
-#define CONTROLLERFAN_SEC 60 //How many seconds, after all motors were disabled, the fan should run
66
+#define CONTROLLERFAN_PIN -1 //Pin used for the fan to cool controller (-1 to disable)
67
+#define CONTROLLERFAN_SECS 60 //How many seconds, after all motors were disabled, the fan should run
68
+#define CONTROLLERFAN_SPEED 255  // == full speed
68 69
 
69 70
 // When first starting the main fan, run it at full speed for the
70 71
 // given number of milliseconds.  This gets the fan spinning reliably
71 72
 // before setting a PWM value. (Does not work with software PWM for fan on Sanguinololu)
72 73
 //#define FAN_KICKSTART_TIME 100
73 74
 
75
+// Extruder cooling fans
76
+// Configure fan pin outputs to automatically turn on/off when the associated
77
+// extruder temperature is above/below EXTRUDER_AUTO_FAN_TEMPERATURE.
78
+// Multiple extruders can be assigned to the same pin in which case 
79
+// the fan will turn on when any selected extruder is above the threshold.
80
+#define EXTRUDER_0_AUTO_FAN_PIN   -1
81
+#define EXTRUDER_1_AUTO_FAN_PIN   -1
82
+#define EXTRUDER_2_AUTO_FAN_PIN   -1
83
+#define EXTRUDER_AUTO_FAN_TEMPERATURE 50
84
+#define EXTRUDER_AUTO_FAN_SPEED   255  // == full speed
85
+
86
+
74 87
 //===========================================================================
75 88
 //=============================Mechanical Settings===========================
76 89
 //===========================================================================
77 90
 
78
-// This defines the number of extruders
79
-#define EXTRUDERS 1
80
-
81 91
 #define ENDSTOPS_ONLY_FOR_HOMING // If defined the endstops will only be used for homing
82 92
 
83 93
 
@@ -210,9 +220,9 @@
210 220
 //  However, THIS FEATURE IS UNSAFE!, as it will only work if interrupts are disabled. And the code could hang in an interrupt routine with interrupts disabled.
211 221
 //#define WATCHDOG_RESET_MANUAL
212 222
 #endif
213
-
214
-// Enable the option to stop SD printing when hitting and endstops, needs to be enabled from the LCD menu when this option is enabled.
215
-//#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
223
+
224
+// Enable the option to stop SD printing when hitting and endstops, needs to be enabled from the LCD menu when this option is enabled.
225
+//#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
216 226
 
217 227
 // extruder advance constant (s2/mm3)
218 228
 //
@@ -276,7 +286,7 @@ const unsigned int dropsegments=5; //everything with less than this number of st
276 286
 #else
277 287
   #define BLOCK_BUFFER_SIZE 16 // maximize block buffer
278 288
 #endif
279
-
289
+
280 290
 
281 291
 //The ASCII buffer for recieving from the serial:
282 292
 #define MAX_CMD_SIZE 96
@@ -308,6 +318,9 @@ const unsigned int dropsegments=5; //everything with less than this number of st
308 318
 //===========================================================================
309 319
 //=============================  Define Defines  ============================
310 320
 //===========================================================================
321
+#if EXTRUDERS > 1 && defined TEMP_SENSOR_1_AS_REDUNDANT
322
+  #error "You cannot use  TEMP_SENSOR_1_AS_REDUNDANT if EXTRUDERS > 1"
323
+#endif
311 324
 
312 325
 #if TEMP_SENSOR_0 > 0
313 326
   #define THERMISTORHEATER_0 TEMP_SENSOR_0

+ 3
- 3
Marlin/DOGMbitmaps.h View File

@@ -1,7 +1,7 @@
1 1
 #define START_BMPWIDTH 	60	//Width in pixels
2 2
 #define START_BMPHEIGHT 	64	//Height in pixels
3 3
 #define START_BMPBYTEWIDTH 	8	//Width in bytes
4
-unsigned char start_bmp[574] PROGMEM = { //AVR-GCC, WinAVR
4
+const unsigned char start_bmp[574] PROGMEM = { //AVR-GCC, WinAVR
5 5
 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,
6 6
 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,
7 7
 0xFF,0xFF,0xFF,0xF9,0xFF,0xFF,0xFF,0xF0,
@@ -71,7 +71,7 @@ unsigned char start_bmp[574] PROGMEM = { //AVR-GCC, WinAVR
71 71
 #define STATUS_SCREENWIDTH 		115	//Width in pixels
72 72
 #define STATUS_SCREENHEIGHT 	19	//Height in pixels
73 73
 #define STATUS_SCREENBYTEWIDTH 	15	//Width in bytes
74
-unsigned char status_screen0_bmp[] PROGMEM = { //AVR-GCC, WinAVR
74
+const unsigned char status_screen0_bmp[] PROGMEM = { //AVR-GCC, WinAVR
75 75
 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xE0,
76 76
 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0xE0,
77 77
 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x0C,0x60,
@@ -96,7 +96,7 @@ unsigned char status_screen0_bmp[] PROGMEM = { //AVR-GCC, WinAVR
96 96
 #define STATUS_SCREENWIDTH 		115	//Width in pixels
97 97
 #define STATUS_SCREENHEIGHT 	19	//Height in pixels
98 98
 #define STATUS_SCREENBYTEWIDTH 	15	//Width in bytes
99
-unsigned char status_screen1_bmp[] PROGMEM = { //AVR-GCC, WinAVR
99
+const unsigned char status_screen1_bmp[] PROGMEM = { //AVR-GCC, WinAVR
100 100
 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xE0,
101 101
 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0xE0,
102 102
 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x61,0xF8,0x60,

+ 10
- 10
Marlin/Makefile View File

@@ -1,12 +1,12 @@
1 1
 # Sprinter Arduino Project Makefile
2
-# 
2
+#
3 3
 # Makefile Based on:
4 4
 # Arduino 0011 Makefile
5 5
 # Arduino adaptation by mellis, eighthave, oli.keller
6 6
 # Marlin adaption by Daid
7 7
 #
8 8
 # This has been tested with Arduino 0022.
9
-# 
9
+#
10 10
 # This makefile allows you to build sketches from the command line
11 11
 # without the Arduino environment (or Java).
12 12
 #
@@ -21,7 +21,7 @@
21 21
 #     (e.g. UPLOAD_PORT = /dev/tty.USB0).  If the exact name of this file
22 22
 #     changes, you can use * as a wildcard (e.g. UPLOAD_PORT = /dev/tty.usb*).
23 23
 #
24
-#  3. Set the line containing "MCU" to match your board's processor. 
24
+#  3. Set the line containing "MCU" to match your board's processor.
25 25
 #     Older one's are atmega8 based, newer ones like Arduino Mini, Bluetooth
26 26
 #     or Diecimila have the atmega168.  If you're using a LilyPad Arduino,
27 27
 #     change F_CPU to 8000000. If you are using Gen7 electronics, you
@@ -44,7 +44,7 @@ ARDUINO_INSTALL_DIR  ?= ../../arduino-0022
44 44
 ARDUINO_VERSION      ?= 22
45 45
 
46 46
 # You can optionally set a path to the avr-gcc tools. Requires a trailing slash. (ex: /usr/local/avr-gcc/bin)
47
-AVR_TOOLS_PATH ?= 
47
+AVR_TOOLS_PATH ?=
48 48
 
49 49
 #Programmer configuration
50 50
 UPLOAD_RATE        ?= 115200
@@ -213,7 +213,7 @@ CXXSRC = WMath.cpp WString.cpp Print.cpp Marlin_main.cpp	\
213 213
 	SdFile.cpp SdVolume.cpp motion_control.cpp planner.cpp		\
214 214
 	stepper.cpp temperature.cpp cardreader.cpp ConfigurationStore.cpp \
215 215
 	watchdog.cpp
216
-CXXSRC += LiquidCrystal.cpp ultralcd.cpp SPI.cpp
216
+CXXSRC += LiquidCrystal.cpp ultralcd.cpp SPI.cpp Servo.cpp
217 217
 
218 218
 #Check for Arduino 1.0.0 or higher and use the correct sourcefiles for that version
219 219
 ifeq ($(shell [ $(ARDUINO_VERSION) -ge 100 ] && echo true), true)
@@ -317,19 +317,19 @@ endif
317 317
 # Default target.
318 318
 all: sizeafter
319 319
 
320
-build: $(BUILD_DIR) elf hex 
320
+build: $(BUILD_DIR) elf hex
321 321
 
322 322
 # Creates the object directory
323
-$(BUILD_DIR): 
323
+$(BUILD_DIR):
324 324
 	$P mkdir -p $(BUILD_DIR)
325 325
 
326 326
 elf: $(BUILD_DIR)/$(TARGET).elf
327 327
 hex: $(BUILD_DIR)/$(TARGET).hex
328 328
 eep: $(BUILD_DIR)/$(TARGET).eep
329
-lss: $(BUILD_DIR)/$(TARGET).lss 
329
+lss: $(BUILD_DIR)/$(TARGET).lss
330 330
 sym: $(BUILD_DIR)/$(TARGET).sym
331 331
 
332
-# Program the device.  
332
+# Program the device.
333 333
 # Do not try to reset an arduino if it's not one
334 334
 upload: $(BUILD_DIR)/$(TARGET).hex
335 335
 ifeq (${AVRDUDE_PROGRAMMER}, arduino)
@@ -356,7 +356,7 @@ COFFCONVERT=$(OBJCOPY) --debugging \
356 356
 	--change-section-address .data-0x800000 \
357 357
 	--change-section-address .bss-0x800000 \
358 358
 	--change-section-address .noinit-0x800000 \
359
-	--change-section-address .eeprom-0x810000 
359
+	--change-section-address .eeprom-0x810000
360 360
 
361 361
 
362 362
 coff: $(BUILD_DIR)/$(TARGET).elf

+ 7
- 3
Marlin/Marlin.h View File

@@ -96,7 +96,7 @@ void process_commands();
96 96
 
97 97
 void manage_inactivity();
98 98
 
99
-#if X_ENABLE_PIN > -1
99
+#if defined(X_ENABLE_PIN) && X_ENABLE_PIN > -1
100 100
   #define  enable_x() WRITE(X_ENABLE_PIN, X_ENABLE_ON)
101 101
   #define disable_x() WRITE(X_ENABLE_PIN,!X_ENABLE_ON)
102 102
 #else
@@ -104,7 +104,7 @@ void manage_inactivity();
104 104
   #define disable_x() ;
105 105
 #endif
106 106
 
107
-#if Y_ENABLE_PIN > -1
107
+#if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1
108 108
   #define  enable_y() WRITE(Y_ENABLE_PIN, Y_ENABLE_ON)
109 109
   #define disable_y() WRITE(Y_ENABLE_PIN,!Y_ENABLE_ON)
110 110
 #else
@@ -112,7 +112,7 @@ void manage_inactivity();
112 112
   #define disable_y() ;
113 113
 #endif
114 114
 
115
-#if Z_ENABLE_PIN > -1
115
+#if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1
116 116
   #ifdef Z_DUAL_STEPPER_DRIVERS
117 117
     #define  enable_z() { WRITE(Z_ENABLE_PIN, Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN, Z_ENABLE_ON); }
118 118
     #define disable_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN,!Z_ENABLE_ON); }
@@ -186,6 +186,10 @@ extern float add_homeing[3];
186 186
 extern float min_pos[3];
187 187
 extern float max_pos[3];
188 188
 extern int fanSpeed;
189
+#ifdef BARICUDA
190
+extern int ValvePressure;
191
+extern int EtoPPressure;
192
+#endif
189 193
 
190 194
 #ifdef FWRETRACT
191 195
 extern bool autoretract_enabled;

+ 2
- 2
Marlin/Marlin.pde View File

@@ -40,13 +40,13 @@
40 40
   #elif defined(LCD_I2C_TYPE_MCP23017) || defined(LCD_I2C_TYPE_MCP23008)
41 41
     #include <Wire.h>
42 42
     #include <LiquidTWI2.h>
43
-  #elif defined DOGLCD
43
+  #elif defined(DOGLCD)
44 44
     #include <U8glib.h> // library for graphics LCD by Oli Kraus (https://code.google.com/p/u8glib/)
45 45
   #else
46 46
     #include <LiquidCrystal.h> // library for character LCD
47 47
   #endif
48 48
 #endif
49 49
 
50
-#if DIGIPOTSS_PIN > -1
50
+#if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1
51 51
 #include <SPI.h>
52 52
 #endif

+ 423
- 309
Marlin/Marlin_main.cpp
File diff suppressed because it is too large
View File


+ 341
- 0
Marlin/Servo.cpp View File

@@ -0,0 +1,341 @@
1
+/*
2
+ Servo.cpp - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2
3
+ Copyright (c) 2009 Michael Margolis.  All right reserved.
4
+
5
+ This library is free software; you can redistribute it and/or
6
+ modify it under the terms of the GNU Lesser General Public
7
+ License as published by the Free Software Foundation; either
8
+ version 2.1 of the License, or (at your option) any later version.
9
+
10
+ This library is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+ Lesser General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Lesser General Public
16
+ License along with this library; if not, write to the Free Software
17
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
+ */
19
+
20
+/*
21
+
22
+ A servo is activated by creating an instance of the Servo class passing the desired pin to the attach() method.
23
+ The servos are pulsed in the background using the value most recently written using the write() method
24
+
25
+ Note that analogWrite of PWM on pins associated with the timer are disabled when the first servo is attached.
26
+ Timers are seized as needed in groups of 12 servos - 24 servos use two timers, 48 servos will use four.
27
+
28
+ The methods are:
29
+
30
+ Servo - Class for manipulating servo motors connected to Arduino pins.
31
+
32
+ attach(pin )  - Attaches a servo motor to an i/o pin.
33
+ attach(pin, min, max  ) - Attaches to a pin setting min and max values in microseconds
34
+ default min is 544, max is 2400
35
+
36
+ write()     - Sets the servo angle in degrees.  (invalid angle that is valid as pulse in microseconds is treated as microseconds)
37
+ writeMicroseconds() - Sets the servo pulse width in microseconds
38
+ read()      - Gets the last written servo pulse width as an angle between 0 and 180.
39
+ readMicroseconds()   - Gets the last written servo pulse width in microseconds. (was read_us() in first release)
40
+ attached()  - Returns true if there is a servo attached.
41
+ detach()    - Stops an attached servos from pulsing its i/o pin.
42
+
43
+*/
44
+#include "Configuration.h" 
45
+
46
+#ifdef NUM_SERVOS
47
+#include <avr/interrupt.h>
48
+#include <Arduino.h>
49
+
50
+#include "Servo.h"
51
+
52
+#define usToTicks(_us)    (( clockCyclesPerMicrosecond()* _us) / 8)     // converts microseconds to tick (assumes prescale of 8)  // 12 Aug 2009
53
+#define ticksToUs(_ticks) (( (unsigned)_ticks * 8)/ clockCyclesPerMicrosecond() ) // converts from ticks back to microseconds
54
+
55
+
56
+#define TRIM_DURATION       2                               // compensation ticks to trim adjust for digitalWrite delays // 12 August 2009
57
+
58
+//#define NBR_TIMERS        (MAX_SERVOS / SERVOS_PER_TIMER)
59
+
60
+static servo_t servos[MAX_SERVOS];                          // static array of servo structures
61
+static volatile int8_t Channel[_Nbr_16timers ];             // counter for the servo being pulsed for each timer (or -1 if refresh interval)
62
+
63
+uint8_t ServoCount = 0;                                     // the total number of attached servos
64
+
65
+
66
+// convenience macros
67
+#define SERVO_INDEX_TO_TIMER(_servo_nbr) ((timer16_Sequence_t)(_servo_nbr / SERVOS_PER_TIMER)) // returns the timer controlling this servo
68
+#define SERVO_INDEX_TO_CHANNEL(_servo_nbr) (_servo_nbr % SERVOS_PER_TIMER)       // returns the index of the servo on this timer
69
+#define SERVO_INDEX(_timer,_channel)  ((_timer*SERVOS_PER_TIMER) + _channel)     // macro to access servo index by timer and channel
70
+#define SERVO(_timer,_channel)  (servos[SERVO_INDEX(_timer,_channel)])            // macro to access servo class by timer and channel
71
+
72
+#define SERVO_MIN() (MIN_PULSE_WIDTH - this->min * 4)  // minimum value in uS for this servo
73
+#define SERVO_MAX() (MAX_PULSE_WIDTH - this->max * 4)  // maximum value in uS for this servo
74
+
75
+/************ static functions common to all instances ***********************/
76
+
77
+static inline void handle_interrupts(timer16_Sequence_t timer, volatile uint16_t *TCNTn, volatile uint16_t* OCRnA)
78
+{
79
+  if( Channel[timer] < 0 )
80
+    *TCNTn = 0; // channel set to -1 indicated that refresh interval completed so reset the timer
81
+  else{
82
+    if( SERVO_INDEX(timer,Channel[timer]) < ServoCount && SERVO(timer,Channel[timer]).Pin.isActive == true )
83
+      digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,LOW); // pulse this channel low if activated
84
+  }
85
+
86
+  Channel[timer]++;    // increment to the next channel
87
+  if( SERVO_INDEX(timer,Channel[timer]) < ServoCount && Channel[timer] < SERVOS_PER_TIMER) {
88
+    *OCRnA = *TCNTn + SERVO(timer,Channel[timer]).ticks;
89
+    if(SERVO(timer,Channel[timer]).Pin.isActive == true)     // check if activated
90
+      digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,HIGH); // its an active channel so pulse it high
91
+  }
92
+  else {
93
+    // finished all channels so wait for the refresh period to expire before starting over
94
+    if( ((unsigned)*TCNTn) + 4 < usToTicks(REFRESH_INTERVAL) )  // allow a few ticks to ensure the next OCR1A not missed
95
+      *OCRnA = (unsigned int)usToTicks(REFRESH_INTERVAL);
96
+    else
97
+      *OCRnA = *TCNTn + 4;  // at least REFRESH_INTERVAL has elapsed
98
+    Channel[timer] = -1; // this will get incremented at the end of the refresh period to start again at the first channel
99
+  }
100
+}
101
+
102
+#ifndef WIRING // Wiring pre-defines signal handlers so don't define any if compiling for the Wiring platform
103
+// Interrupt handlers for Arduino
104
+#if defined(_useTimer1)
105
+SIGNAL (TIMER1_COMPA_vect)
106
+{
107
+  handle_interrupts(_timer1, &TCNT1, &OCR1A);
108
+}
109
+#endif
110
+
111
+#if defined(_useTimer3)
112
+SIGNAL (TIMER3_COMPA_vect)
113
+{
114
+  handle_interrupts(_timer3, &TCNT3, &OCR3A);
115
+}
116
+#endif
117
+
118
+#if defined(_useTimer4)
119
+SIGNAL (TIMER4_COMPA_vect)
120
+{
121
+  handle_interrupts(_timer4, &TCNT4, &OCR4A);
122
+}
123
+#endif
124
+
125
+#if defined(_useTimer5)
126
+SIGNAL (TIMER5_COMPA_vect)
127
+{
128
+  handle_interrupts(_timer5, &TCNT5, &OCR5A);
129
+}
130
+#endif
131
+
132
+#elif defined WIRING
133
+// Interrupt handlers for Wiring
134
+#if defined(_useTimer1)
135
+void Timer1Service()
136
+{
137
+  handle_interrupts(_timer1, &TCNT1, &OCR1A);
138
+}
139
+#endif
140
+#if defined(_useTimer3)
141
+void Timer3Service()
142
+{
143
+  handle_interrupts(_timer3, &TCNT3, &OCR3A);
144
+}
145
+#endif
146
+#endif
147
+
148
+
149
+static void initISR(timer16_Sequence_t timer)
150
+{
151
+#if defined (_useTimer1)
152
+  if(timer == _timer1) {
153
+    TCCR1A = 0;             // normal counting mode
154
+    TCCR1B = _BV(CS11);     // set prescaler of 8
155
+    TCNT1 = 0;              // clear the timer count
156
+#if defined(__AVR_ATmega8__)|| defined(__AVR_ATmega128__)
157
+    TIFR |= _BV(OCF1A);      // clear any pending interrupts;
158
+    TIMSK |=  _BV(OCIE1A) ;  // enable the output compare interrupt
159
+#else
160
+    // here if not ATmega8 or ATmega128
161
+    TIFR1 |= _BV(OCF1A);     // clear any pending interrupts;
162
+    TIMSK1 |=  _BV(OCIE1A) ; // enable the output compare interrupt
163
+#endif
164
+#if defined(WIRING)
165
+    timerAttach(TIMER1OUTCOMPAREA_INT, Timer1Service);
166
+#endif
167
+  }
168
+#endif
169
+
170
+#if defined (_useTimer3)
171
+  if(timer == _timer3) {
172
+    TCCR3A = 0;             // normal counting mode
173
+    TCCR3B = _BV(CS31);     // set prescaler of 8
174
+    TCNT3 = 0;              // clear the timer count
175
+#if defined(__AVR_ATmega128__)
176
+    TIFR |= _BV(OCF3A);     // clear any pending interrupts;
177
+	ETIMSK |= _BV(OCIE3A);  // enable the output compare interrupt
178
+#else
179
+    TIFR3 = _BV(OCF3A);     // clear any pending interrupts;
180
+    TIMSK3 =  _BV(OCIE3A) ; // enable the output compare interrupt
181
+#endif
182
+#if defined(WIRING)
183
+    timerAttach(TIMER3OUTCOMPAREA_INT, Timer3Service);  // for Wiring platform only
184
+#endif
185
+  }
186
+#endif
187
+
188
+#if defined (_useTimer4)
189
+  if(timer == _timer4) {
190
+    TCCR4A = 0;             // normal counting mode
191
+    TCCR4B = _BV(CS41);     // set prescaler of 8
192
+    TCNT4 = 0;              // clear the timer count
193
+    TIFR4 = _BV(OCF4A);     // clear any pending interrupts;
194
+    TIMSK4 =  _BV(OCIE4A) ; // enable the output compare interrupt
195
+  }
196
+#endif
197
+
198
+#if defined (_useTimer5)
199
+  if(timer == _timer5) {
200
+    TCCR5A = 0;             // normal counting mode
201
+    TCCR5B = _BV(CS51);     // set prescaler of 8
202
+    TCNT5 = 0;              // clear the timer count
203
+    TIFR5 = _BV(OCF5A);     // clear any pending interrupts;
204
+    TIMSK5 =  _BV(OCIE5A) ; // enable the output compare interrupt
205
+  }
206
+#endif
207
+}
208
+
209
+static void finISR(timer16_Sequence_t timer)
210
+{
211
+    //disable use of the given timer
212
+#if defined WIRING   // Wiring
213
+  if(timer == _timer1) {
214
+    #if defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__)
215
+    TIMSK1 &=  ~_BV(OCIE1A) ;  // disable timer 1 output compare interrupt
216
+    #else
217
+    TIMSK &=  ~_BV(OCIE1A) ;  // disable timer 1 output compare interrupt
218
+    #endif
219
+    timerDetach(TIMER1OUTCOMPAREA_INT);
220
+  }
221
+  else if(timer == _timer3) {
222
+    #if defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__)
223
+    TIMSK3 &= ~_BV(OCIE3A);    // disable the timer3 output compare A interrupt
224
+    #else
225
+    ETIMSK &= ~_BV(OCIE3A);    // disable the timer3 output compare A interrupt
226
+    #endif
227
+    timerDetach(TIMER3OUTCOMPAREA_INT);
228
+  }
229
+#else
230
+    //For arduino - in future: call here to a currently undefined function to reset the timer
231
+#endif
232
+}
233
+
234
+static boolean isTimerActive(timer16_Sequence_t timer)
235
+{
236
+  // returns true if any servo is active on this timer
237
+  for(uint8_t channel=0; channel < SERVOS_PER_TIMER; channel++) {
238
+    if(SERVO(timer,channel).Pin.isActive == true)
239
+      return true;
240
+  }
241
+  return false;
242
+}
243
+
244
+
245
+/****************** end of static functions ******************************/
246
+
247
+Servo::Servo()
248
+{
249
+  if( ServoCount < MAX_SERVOS) {
250
+    this->servoIndex = ServoCount++;                    // assign a servo index to this instance
251
+	servos[this->servoIndex].ticks = usToTicks(DEFAULT_PULSE_WIDTH);   // store default values  - 12 Aug 2009
252
+  }
253
+  else
254
+    this->servoIndex = INVALID_SERVO ;  // too many servos
255
+}
256
+
257
+uint8_t Servo::attach(int pin)
258
+{
259
+  return this->attach(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
260
+}
261
+
262
+uint8_t Servo::attach(int pin, int min, int max)
263
+{
264
+  if(this->servoIndex < MAX_SERVOS ) {
265
+    pinMode( pin, OUTPUT) ;                                   // set servo pin to output
266
+    servos[this->servoIndex].Pin.nbr = pin;
267
+    // todo min/max check: abs(min - MIN_PULSE_WIDTH) /4 < 128
268
+    this->min  = (MIN_PULSE_WIDTH - min)/4; //resolution of min/max is 4 uS
269
+    this->max  = (MAX_PULSE_WIDTH - max)/4;
270
+    // initialize the timer if it has not already been initialized
271
+    timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex);
272
+    if(isTimerActive(timer) == false)
273
+      initISR(timer);
274
+    servos[this->servoIndex].Pin.isActive = true;  // this must be set after the check for isTimerActive
275
+  }
276
+  return this->servoIndex ;
277
+}
278
+
279
+void Servo::detach()
280
+{
281
+  servos[this->servoIndex].Pin.isActive = false;
282
+  timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex);
283
+  if(isTimerActive(timer) == false) {
284
+    finISR(timer);
285
+  }
286
+}
287
+
288
+void Servo::write(int value)
289
+{
290
+  if(value < MIN_PULSE_WIDTH)
291
+  {  // treat values less than 544 as angles in degrees (valid values in microseconds are handled as microseconds)
292
+    if(value < 0) value = 0;
293
+    if(value > 180) value = 180;
294
+    value = map(value, 0, 180, SERVO_MIN(),  SERVO_MAX());
295
+  }
296
+  this->writeMicroseconds(value);
297
+}
298
+
299
+void Servo::writeMicroseconds(int value)
300
+{
301
+  // calculate and store the values for the given channel
302
+  byte channel = this->servoIndex;
303
+  if( (channel < MAX_SERVOS) )   // ensure channel is valid
304
+  {
305
+    if( value < SERVO_MIN() )          // ensure pulse width is valid
306
+      value = SERVO_MIN();
307
+    else if( value > SERVO_MAX() )
308
+      value = SERVO_MAX();
309
+
310
+  	value = value - TRIM_DURATION;
311
+    value = usToTicks(value);  // convert to ticks after compensating for interrupt overhead - 12 Aug 2009
312
+
313
+    uint8_t oldSREG = SREG;
314
+    cli();
315
+    servos[channel].ticks = value;
316
+    SREG = oldSREG;
317
+  }
318
+}
319
+
320
+int Servo::read() // return the value as degrees
321
+{
322
+  return  map( this->readMicroseconds()+1, SERVO_MIN(), SERVO_MAX(), 0, 180);
323
+}
324
+
325
+int Servo::readMicroseconds()
326
+{
327
+  unsigned int pulsewidth;
328
+  if( this->servoIndex != INVALID_SERVO )
329
+    pulsewidth = ticksToUs(servos[this->servoIndex].ticks)  + TRIM_DURATION ;   // 12 aug 2009
330
+  else
331
+    pulsewidth  = 0;
332
+
333
+  return pulsewidth;
334
+}
335
+
336
+bool Servo::attached()
337
+{
338
+  return servos[this->servoIndex].Pin.isActive ;
339
+}
340
+
341
+#endif

+ 132
- 0
Marlin/Servo.h View File

@@ -0,0 +1,132 @@
1
+/*
2
+  Servo.h - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2
3
+  Copyright (c) 2009 Michael Margolis.  All right reserved.
4
+
5
+  This library is free software; you can redistribute it and/or
6
+  modify it under the terms of the GNU Lesser General Public
7
+  License as published by the Free Software Foundation; either
8
+  version 2.1 of the License, or (at your option) any later version.
9
+
10
+  This library is distributed in the hope that it will be useful,
11
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+  Lesser General Public License for more details.
14
+
15
+  You should have received a copy of the GNU Lesser General Public
16
+  License along with this library; if not, write to the Free Software
17
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
+*/
19
+
20
+/*
21
+
22
+  A servo is activated by creating an instance of the Servo class passing the desired pin to the attach() method.
23
+  The servos are pulsed in the background using the value most recently written using the write() method
24
+
25
+  Note that analogWrite of PWM on pins associated with the timer are disabled when the first servo is attached.
26
+  Timers are seized as needed in groups of 12 servos - 24 servos use two timers, 48 servos will use four.
27
+  The sequence used to sieze timers is defined in timers.h
28
+
29
+  The methods are:
30
+
31
+   Servo - Class for manipulating servo motors connected to Arduino pins.
32
+
33
+   attach(pin )  - Attaches a servo motor to an i/o pin.
34
+   attach(pin, min, max  ) - Attaches to a pin setting min and max values in microseconds
35
+   default min is 544, max is 2400
36
+
37
+   write()     - Sets the servo angle in degrees.  (invalid angle that is valid as pulse in microseconds is treated as microseconds)
38
+   writeMicroseconds() - Sets the servo pulse width in microseconds
39
+   read()      - Gets the last written servo pulse width as an angle between 0 and 180.
40
+   readMicroseconds()   - Gets the last written servo pulse width in microseconds. (was read_us() in first release)
41
+   attached()  - Returns true if there is a servo attached.
42
+   detach()    - Stops an attached servos from pulsing its i/o pin.
43
+ */
44
+
45
+#ifndef Servo_h
46
+#define Servo_h
47
+
48
+#include <inttypes.h>
49
+
50
+/*
51
+ * Defines for 16 bit timers used with  Servo library
52
+ *
53
+ * If _useTimerX is defined then TimerX is a 16 bit timer on the curent board
54
+ * timer16_Sequence_t enumerates the sequence that the timers should be allocated
55
+ * _Nbr_16timers indicates how many 16 bit timers are available.
56
+ *
57
+ */
58
+
59
+// Say which 16 bit timers can be used and in what order
60
+#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
61
+#define _useTimer5
62
+//#define _useTimer1
63
+#define _useTimer3
64
+#define _useTimer4
65
+//typedef enum { _timer5, _timer1, _timer3, _timer4, _Nbr_16timers } timer16_Sequence_t ;
66
+typedef enum { _timer5, _timer3, _timer4, _Nbr_16timers } timer16_Sequence_t ;
67
+
68
+#elif defined(__AVR_ATmega32U4__)
69
+//#define _useTimer1
70
+#define _useTimer3
71
+//typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t ;
72
+typedef enum { _timer3, _Nbr_16timers } timer16_Sequence_t ;
73
+
74
+#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
75
+#define _useTimer3
76
+//#define _useTimer1
77
+//typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t ;
78
+typedef enum { _timer3, _Nbr_16timers } timer16_Sequence_t ;
79
+
80
+#elif defined(__AVR_ATmega128__) ||defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__)
81
+#define _useTimer3
82
+//#define _useTimer1
83
+//typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t ;
84
+typedef enum { _timer3, _Nbr_16timers } timer16_Sequence_t ;
85
+
86
+#else  // everything else
87
+//#define _useTimer1
88
+//typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t ;
89
+typedef enum { _Nbr_16timers } timer16_Sequence_t ;
90
+#endif
91
+
92
+#define Servo_VERSION           2      // software version of this library
93
+
94
+#define MIN_PULSE_WIDTH       544     // the shortest pulse sent to a servo
95
+#define MAX_PULSE_WIDTH      2400     // the longest pulse sent to a servo
96
+#define DEFAULT_PULSE_WIDTH  1500     // default pulse width when servo is attached
97
+#define REFRESH_INTERVAL    20000     // minumim time to refresh servos in microseconds
98
+
99
+#define SERVOS_PER_TIMER       12     // the maximum number of servos controlled by one timer
100
+#define MAX_SERVOS   (_Nbr_16timers  * SERVOS_PER_TIMER)
101
+
102
+#define INVALID_SERVO         255     // flag indicating an invalid servo index
103
+
104
+typedef struct  {
105
+  uint8_t nbr        :6 ;             // a pin number from 0 to 63
106
+  uint8_t isActive   :1 ;             // true if this channel is enabled, pin not pulsed if false
107
+} ServoPin_t   ;
108
+
109
+typedef struct {
110
+  ServoPin_t Pin;
111
+  unsigned int ticks;
112
+} servo_t;
113
+
114
+class Servo
115
+{
116
+public:
117
+  Servo();
118
+  uint8_t attach(int pin);           // attach the given pin to the next free channel, sets pinMode, returns channel number or 0 if failure
119
+  uint8_t attach(int pin, int min, int max); // as above but also sets min and max values for writes.
120
+  void detach();
121
+  void write(int value);             // if value is < 200 its treated as an angle, otherwise as pulse width in microseconds
122
+  void writeMicroseconds(int value); // Write pulse width in microseconds
123
+  int read();                        // returns current pulse width as an angle between 0 and 180 degrees
124
+  int readMicroseconds();            // returns current pulse width in microseconds for this servo (was read_us() in first release)
125
+  bool attached();                   // return true if this servo is attached, otherwise false
126
+private:
127
+   uint8_t servoIndex;               // index into the channel data for this servo
128
+   int8_t min;                       // minimum is this value times 4 added to MIN_PULSE_WIDTH
129
+   int8_t max;                       // maximum is this value times 4 added to MAX_PULSE_WIDTH
130
+};
131
+
132
+#endif

+ 20
- 8
Marlin/dogm_lcd_implementation.h View File

@@ -19,12 +19,25 @@
19 19
 * Implementation of the LCD display routines for a DOGM128 graphic display. These are common LCD 128x64 pixel graphic displays.
20 20
 **/
21 21
 
22
+#ifdef ULTIPANEL
23
+#define BLEN_A 0
24
+#define BLEN_B 1
25
+#define BLEN_C 2
26
+#define EN_A (1<<BLEN_A)
27
+#define EN_B (1<<BLEN_B)
28
+#define EN_C (1<<BLEN_C)
29
+#define encrot0 0
30
+#define encrot1 2
31
+#define encrot2 3
32
+#define encrot3 1
33
+#define LCD_CLICKED (buttons&EN_C)
34
+#endif
22 35
 
23
-// CHANGE_DE begin ***
24
-#include <U8glib.h>	// DE_U8glib
36
+#include <U8glib.h>
25 37
 #include "DOGMbitmaps.h"
26 38
 #include "dogm_font_data_marlin.h"
27 39
 #include "ultralcd.h"
40
+#include "ultralcd_st7920_u8glib_rrd.h"
28 41
 
29 42
 
30 43
 /* Russian language not supported yet, needs custom font
@@ -61,11 +74,10 @@
61 74
 
62 75
 #define FONT_STATUSMENU	u8g_font_6x9
63 76
 
64
-
65 77
 // LCD selection
66 78
 #ifdef U8GLIB_ST7920
67
-// SPI Com: SCK = en = (D4), MOSI = rw = (RS), CS = di = (ENABLE)
68
-U8GLIB_ST7920_128X64_1X u8g(LCD_PINS_D4, LCD_PINS_ENABLE, LCD_PINS_RS);
79
+//U8GLIB_ST7920_128X64_RRD u8g(0,0,0);
80
+U8GLIB_ST7920_128X64_RRD u8g(0);
69 81
 #else
70 82
 U8GLIB_DOGM128 u8g(DOGLCD_CS, DOGLCD_A0);	// HW-SPI Com: CS, A0
71 83
 #endif
@@ -88,11 +100,11 @@ static void lcd_implementation_init()
88 100
 	u8g.setRot90();	// Rotate screen by 90°
89 101
 #endif
90 102
 
91
-#ifdef LCD_SCREEN_ROT_180;
103
+#ifdef LCD_SCREEN_ROT_180
92 104
 	u8g.setRot180();	// Rotate screen by 180°
93 105
 #endif
94 106
 
95
-#ifdef LCD_SCREEN_ROT_270;
107
+#ifdef LCD_SCREEN_ROT_270
96 108
 	u8g.setRot270();	// Rotate screen by 270°
97 109
 #endif
98 110
 
@@ -266,7 +278,7 @@ static void lcd_implementation_status_screen()
266 278
  // Fan
267 279
  u8g.setFont(FONT_STATUSMENU);
268 280
  u8g.setPrintPos(104,27);
269
- #if FAN_PIN > 0
281
+ #if defined(FAN_PIN) && FAN_PIN > -1
270 282
  u8g.print(itostr3(int((fanSpeed*100)/256 + 1)));
271 283
  u8g.print("%");
272 284
  #else

+ 695
- 1
Marlin/fastio.h View File

@@ -2575,8 +2575,702 @@ pins
2575 2575
 #define PF7_DDR			DDRF
2576 2576
 #endif
2577 2577
 
2578
+
2579
+#if defined (__AVR_ATmega1281__) || defined (__AVR_ATmega2561__)
2580
+// UART
2581
+#define	RXD					DIO0
2582
+#define	TXD					DIO1
2583
+
2584
+// SPI
2585
+#define	SCK					DIO10
2586
+#define	MISO				DIO12
2587
+#define	MOSI				DIO11
2588
+#define	SS					DIO16
2589
+
2590
+// TWI (I2C)
2591
+#define	SCL					DIO17
2592
+#define	SDA					DIO18
2593
+
2594
+// timers and PWM
2595
+#define	OC0A				DIO9
2596
+#define	OC0B				DIO4
2597
+#define	OC1A				DIO7
2598
+#define	OC1B				DIO8
2599
+#define	OC2A				DIO6
2600
+#define	OC3A				DIO5
2601
+#define	OC3B				DIO2
2602
+#define	OC3C				DIO3
2603
+
2604
+
2605
+// change for your board
2606
+#define	DEBUG_LED		DIO46
2607
+
2608
+/*
2609
+pins
2610
+*/
2611
+#define	DIO0_PIN		PINE0
2612
+#define	DIO0_RPORT	PINE
2613
+#define	DIO0_WPORT	PORTE
2614
+#define	DIO0_DDR		DDRE
2615
+#define DIO0_PWM		NULL
2616
+
2617
+#define	DIO1_PIN		PINE1
2618
+#define	DIO1_RPORT	PINE
2619
+#define	DIO1_WPORT	PORTE
2620
+#define	DIO1_DDR		DDRE
2621
+#define DIO1_PWM		NULL
2622
+
2623
+#define	DIO2_PIN		PINE4
2624
+#define	DIO2_RPORT	PINE
2625
+#define	DIO2_WPORT	PORTE
2626
+#define	DIO2_DDR		DDRE
2627
+#define DIO2_PWM		&OCR3BL
2628
+
2629
+#define	DIO3_PIN		PINE5
2630
+#define	DIO3_RPORT	PINE
2631
+#define	DIO3_WPORT	PORTE
2632
+#define	DIO3_DDR		DDRE
2633
+#define DIO3_PWM		&OCR3CL
2634
+
2635
+#define	DIO4_PIN		PING5
2636
+#define	DIO4_RPORT	PING
2637
+#define	DIO4_WPORT	PORTG
2638
+#define	DIO4_DDR		DDRG
2639
+#define DIO4_PWM		&OCR0B
2640
+
2641
+#define	DIO5_PIN		PINE3
2642
+#define	DIO5_RPORT	PINE
2643
+#define	DIO5_WPORT	PORTE
2644
+#define	DIO5_DDR		DDRE
2645
+#define DIO5_PWM		&OCR3AL
2646
+
2647
+#define	DIO6_PIN		PINB4
2648
+#define	DIO6_RPORT	PINB
2649
+#define	DIO6_WPORT	PORTB
2650
+#define	DIO6_DDR		DDRB
2651
+#define DIO6_PWM		&OCR2AL
2652
+
2653
+#define	DIO7_PIN		PINB5
2654
+#define	DIO7_RPORT	PINB
2655
+#define	DIO7_WPORT	PORTB
2656
+#define	DIO7_DDR		DDRB
2657
+#define DIO7_PWM		&OCR1AL
2658
+
2659
+#define	DIO8_PIN		PINB6
2660
+#define	DIO8_RPORT	PINB
2661
+#define	DIO8_WPORT	PORTB
2662
+#define	DIO8_DDR		DDRB
2663
+#define DIO8_PWM		&OCR1BL
2664
+
2665
+#define	DIO9_PIN		PINB7
2666
+#define	DIO9_RPORT	PINB
2667
+#define	DIO9_WPORT	PORTB
2668
+#define	DIO9_DDR		DDRB
2669
+#define DIO9_PWM		&OCR0AL
2670
+
2671
+#define	DIO10_PIN		PINB1
2672
+#define	DIO10_RPORT	PINB
2673
+#define	DIO10_WPORT	PORTB
2674
+#define	DIO10_DDR		DDRB
2675
+#define DIO10_PWM		NULL
2676
+
2677
+#define	DIO11_PIN		PINB2
2678
+#define	DIO11_RPORT	PINB
2679
+#define	DIO11_WPORT	PORTB
2680
+#define	DIO11_DDR		DDRB
2681
+#define DIO11_PWM		NULL
2682
+
2683
+#define	DIO12_PIN		PINB3
2684
+#define	DIO12_RPORT	PINB
2685
+#define	DIO12_WPORT	PORTB
2686
+#define	DIO12_DDR		DDRB
2687
+#define DIO12_PWM		NULL
2688
+
2689
+#define	DIO13_PIN		PINE2
2690
+#define	DIO13_RPORT	PINE
2691
+#define	DIO13_WPORT	PORTE
2692
+#define	DIO13_DDR		DDRE
2693
+#define DIO13_PWM		NULL
2694
+
2695
+#define	DIO14_PIN		PINE6
2696
+#define	DIO14_RPORT	PINE
2697
+#define	DIO14_WPORT	PORTE
2698
+#define	DIO14_DDR		DDRE
2699
+#define DIO14_PWM		NULL
2700
+
2701
+#define	DIO15_PIN		PINE7
2702
+#define	DIO15_RPORT	PINE
2703
+#define	DIO15_WPORT	PORTE
2704
+#define	DIO15_DDR		DDRE
2705
+#define DIO15_PWM		NULL
2706
+
2707
+#define	DIO16_PIN		PINB0
2708
+#define	DIO16_RPORT	PINB
2709
+#define	DIO16_WPORT	PORTB
2710
+#define	DIO16_DDR		DDRB
2711
+#define DIO16_PWM		NULL
2712
+
2713
+#define	DIO17_PIN		PIND0
2714
+#define	DIO17_RPORT	PIND
2715
+#define	DIO17_WPORT	PORTD
2716
+#define	DIO17_DDR		DDRD
2717
+#define DIO17_PWM		NULL
2718
+
2719
+#define	DIO18_PIN		PIND1
2720
+#define	DIO18_RPORT	PIND
2721
+#define	DIO18_WPORT	PORTD
2722
+#define	DIO18_DDR		DDRD
2723
+#define DIO18_PWM		NULL
2724
+
2725
+#define	DIO19_PIN		PIND2
2726
+#define	DIO19_RPORT	PIND
2727
+#define	DIO19_WPORT	PORTD
2728
+#define	DIO19_DDR		DDRD
2729
+#define DIO19_PWM		NULL
2730
+
2731
+#define	DIO20_PIN		PIND3
2732
+#define	DIO20_RPORT	PIND
2733
+#define	DIO20_WPORT	PORTD
2734
+#define	DIO20_DDR		DDRD
2735
+#define DIO20_PWM		NULL
2736
+
2737
+#define	DIO21_PIN		PIND4
2738
+#define	DIO21_RPORT	PIND
2739
+#define	DIO21_WPORT	PORTD
2740
+#define	DIO21_DDR		DDRD
2741
+#define DIO21_PWM		NULL
2742
+
2743
+#define	DIO22_PIN		PIND5
2744
+#define	DIO22_RPORT	PIND
2745
+#define	DIO22_WPORT	PORTD
2746
+#define	DIO22_DDR		DDRD
2747
+#define DIO22_PWM		NULL
2748
+
2749
+#define	DIO23_PIN		PIND6
2750
+#define	DIO23_RPORT	PIND
2751
+#define	DIO23_WPORT	PORTD
2752
+#define	DIO23_DDR		DDRD
2753
+#define DIO23_PWM		NULL
2754
+
2755
+#define	DIO24_PIN		PIND7
2756
+#define	DIO24_RPORT	PIND
2757
+#define	DIO24_WPORT	PORTD
2758
+#define	DIO24_DDR		DDRD
2759
+#define DIO24_PWM		NULL
2760
+
2761
+#define	DIO25_PIN		PING0
2762
+#define	DIO25_RPORT	PING
2763
+#define	DIO25_WPORT	PORTG
2764
+#define	DIO25_DDR		DDRG
2765
+#define DIO25_PWM		NULL
2766
+
2767
+#define	DIO26_PIN		PING1
2768
+#define	DIO26_RPORT	PING
2769
+#define	DIO26_WPORT	PORTG
2770
+#define	DIO26_DDR		DDRG
2771
+#define DIO26_PWM		NULL
2772
+
2773
+#define	DIO27_PIN		PING2
2774
+#define	DIO27_RPORT	PING
2775
+#define	DIO27_WPORT	PORTG
2776
+#define	DIO27_DDR		DDRG
2777
+#define DIO27_PWM		NULL
2778
+
2779
+#define	DIO28_PIN		PING3
2780
+#define	DIO28_RPORT	PING
2781
+#define	DIO28_WPORT	PORTG
2782
+#define	DIO28_DDR		DDRG
2783
+#define DIO28_PWM		NULL
2784
+
2785
+#define	DIO29_PIN		PING4
2786
+#define	DIO29_RPORT	PING
2787
+#define	DIO29_WPORT	PORTG
2788
+#define	DIO29_DDR		DDRG
2789
+#define DIO29_PWM		NULL
2790
+
2791
+#define	DIO30_PIN		PINC0
2792
+#define	DIO30_RPORT	PINC
2793
+#define	DIO30_WPORT	PORTC
2794
+#define	DIO30_DDR		DDRC
2795
+#define DIO30_PWM		NULL
2796
+
2797
+#define	DIO31_PIN		PINC1
2798
+#define	DIO31_RPORT	PINC
2799
+#define	DIO31_WPORT	PORTC
2800
+#define	DIO31_DDR		DDRC
2801
+#define DIO31_PWM		NULL
2802
+
2803
+#define	DIO32_PIN		PINC2
2804
+#define	DIO32_RPORT	PINC
2805
+#define	DIO32_WPORT	PORTC
2806
+#define	DIO32_DDR		DDRC
2807
+#define DIO32_PWM		NULL
2808
+
2809
+#define	DIO33_PIN		PINC3
2810
+#define	DIO33_RPORT	PINC
2811
+#define	DIO33_WPORT	PORTC
2812
+#define	DIO33_DDR		DDRC
2813
+#define DIO33_PWM		NULL
2814
+
2815
+#define	DIO34_PIN		PINC4
2816
+#define	DIO34_RPORT	PINC
2817
+#define	DIO34_WPORT	PORTC
2818
+#define	DIO34_DDR		DDRC
2819
+#define DIO34_PWM		NULL
2820
+
2821
+#define	DIO35_PIN		PINC5
2822
+#define	DIO35_RPORT	PINC
2823
+#define	DIO35_WPORT	PORTC
2824
+#define	DIO35_DDR		DDRC
2825
+#define DIO35_PWM		NULL
2826
+
2827
+#define	DIO36_PIN		PINC6
2828
+#define	DIO36_RPORT	PINC
2829
+#define	DIO36_WPORT	PORTC
2830
+#define	DIO36_DDR		DDRC
2831
+#define DIO36_PWM		NULL
2832
+
2833
+#define	DIO37_PIN		PINC7
2834
+#define	DIO37_RPORT	PINC
2835
+#define	DIO37_WPORT	PORTC
2836
+#define	DIO37_DDR		DDRC
2837
+#define DIO37_PWM		NULL
2838
+
2839
+#define	DIO38_PIN		PINA0
2840
+#define	DIO38_RPORT	PINA
2841
+#define	DIO38_WPORT	PORTA
2842
+#define	DIO38_DDR		DDRA
2843
+#define DIO38_PWM		NULL
2844
+
2845
+#define	DIO39_PIN		PINA1
2846
+#define	DIO39_RPORT	PINA
2847
+#define	DIO39_WPORT	PORTA
2848
+#define	DIO39_DDR		DDRA
2849
+#define DIO39_PWM		NULL
2850
+
2851
+#define	DIO40_PIN		PINA2
2852
+#define	DIO40_RPORT	PINA
2853
+#define	DIO40_WPORT	PORTA
2854
+#define	DIO40_DDR		DDRA
2855
+#define DIO40_PWM		NULL
2856
+
2857
+#define	DIO41_PIN		PINA3
2858
+#define	DIO41_RPORT	PINA
2859
+#define	DIO41_WPORT	PORTA
2860
+#define	DIO41_DDR		DDRA
2861
+#define DIO41_PWM		NULL
2862
+
2863
+#define	DIO42_PIN		PINA4
2864
+#define	DIO42_RPORT	PINA
2865
+#define	DIO42_WPORT	PORTA
2866
+#define	DIO42_DDR		DDRA
2867
+#define DIO42_PWM		NULL
2868
+
2869
+#define	DIO43_PIN		PINA5
2870
+#define	DIO43_RPORT	PINA
2871
+#define	DIO43_WPORT	PORTA
2872
+#define	DIO43_DDR		DDRA
2873
+#define DIO43_PWM		NULL
2874
+
2875
+#define	DIO44_PIN		PINA6
2876
+#define	DIO44_RPORT	PINA
2877
+#define	DIO44_WPORT	PORTA
2878
+#define	DIO44_DDR		DDRA
2879
+#define DIO44_PWM		NULL
2880
+
2881
+#define	DIO45_PIN		PINA7
2882
+#define	DIO45_RPORT	PINA
2883
+#define	DIO45_WPORT	PORTA
2884
+#define	DIO45_DDR		DDRA
2885
+#define DIO45_PWM		NULL
2886
+
2887
+#define	DIO46_PIN		PINF0
2888
+#define	DIO46_RPORT	PINF
2889
+#define	DIO46_WPORT	PORTF
2890
+#define	DIO46_DDR		DDRF
2891
+#define DIO46_PWM		NULL
2892
+
2893
+#define	DIO47_PIN		PINF1
2894
+#define	DIO47_RPORT	PINF
2895
+#define	DIO47_WPORT	PORTF
2896
+#define	DIO47_DDR		DDRF
2897
+#define DIO47_PWM		NULL
2898
+
2899
+#define	DIO48_PIN		PINF2
2900
+#define	DIO48_RPORT	PINF
2901
+#define	DIO48_WPORT	PORTF
2902
+#define	DIO48_DDR		DDRF
2903
+#define DIO48_PWM		NULL
2904
+
2905
+#define	DIO49_PIN		PINF3
2906
+#define	DIO49_RPORT	PINF
2907
+#define	DIO49_WPORT	PORTF
2908
+#define	DIO49_DDR		DDRF
2909
+#define DIO49_PWM		NULL
2910
+
2911
+#define	DIO50_PIN		PINF4
2912
+#define	DIO50_RPORT	PINF
2913
+#define	DIO50_WPORT	PORTF
2914
+#define	DIO50_DDR		DDRF
2915
+#define DIO50_PWM		NULL
2916
+
2917
+#define	DIO51_PIN		PINF5
2918
+#define	DIO51_RPORT	PINF
2919
+#define	DIO51_WPORT	PORTF
2920
+#define	DIO51_DDR		DDRF
2921
+#define DIO51_PWM		NULL
2922
+
2923
+#define	DIO52_PIN		PINF6
2924
+#define	DIO52_RPORT	PINF
2925
+#define	DIO52_WPORT	PORTF
2926
+#define	DIO52_DDR		DDRF
2927
+#define DIO52_PWM		NULL
2928
+
2929
+#define	DIO53_PIN		PINF7
2930
+#define	DIO53_RPORT	PINF
2931
+#define	DIO53_WPORT	PORTF
2932
+#define	DIO53_DDR		DDRF
2933
+#define DIO53_PWM		NULL
2934
+
2935
+
2936
+
2937
+
2938
+#undef PA0
2939
+#define PA0_PIN			PINA0
2940
+#define PA0_RPORT		PINA
2941
+#define PA0_WPORT		PORTA
2942
+#define PA0_DDR			DDRA
2943
+#define PA0_PWM			NULL
2944
+#undef PA1
2945
+#define PA1_PIN			PINA1
2946
+#define PA1_RPORT		PINA
2947
+#define PA1_WPORT		PORTA
2948
+#define PA1_DDR			DDRA
2949
+#define PA1_PWM			NULL
2950
+#undef PA2
2951
+#define PA2_PIN			PINA2
2952
+#define PA2_RPORT		PINA
2953
+#define PA2_WPORT		PORTA
2954
+#define PA2_DDR			DDRA
2955
+#define PA2_PWM			NULL
2956
+#undef PA3
2957
+#define PA3_PIN			PINA3
2958
+#define PA3_RPORT		PINA
2959
+#define PA3_WPORT		PORTA
2960
+#define PA3_DDR			DDRA
2961
+#define PA3_PWM			NULL
2962
+#undef PA4
2963
+#define PA4_PIN			PINA4
2964
+#define PA4_RPORT		PINA
2965
+#define PA4_WPORT		PORTA
2966
+#define PA4_DDR			DDRA
2967
+#define PA4_PWM			NULL
2968
+#undef PA5
2969
+#define PA5_PIN			PINA5
2970
+#define PA5_RPORT		PINA
2971
+#define PA5_WPORT		PORTA
2972
+#define PA5_DDR			DDRA
2973
+#define PA5_PWM			NULL
2974
+#undef PA6
2975
+#define PA6_PIN			PINA6
2976
+#define PA6_RPORT		PINA
2977
+#define PA6_WPORT		PORTA
2978
+#define PA6_DDR			DDRA
2979
+#define PA6_PWM			NULL
2980
+#undef PA7
2981
+#define PA7_PIN			PINA7
2982
+#define PA7_RPORT		PINA
2983
+#define PA7_WPORT		PORTA
2984
+#define PA7_DDR			DDRA
2985
+#define PA7_PWM			NULL
2986
+
2987
+#undef PB0
2988
+#define PB0_PIN			PINB0
2989
+#define PB0_RPORT		PINB
2990
+#define PB0_WPORT		PORTB
2991
+#define PB0_DDR			DDRB
2992
+#define PB0_PWM			NULL
2993
+#undef PB1
2994
+#define PB1_PIN			PINB1
2995
+#define PB1_RPORT		PINB
2996
+#define PB1_WPORT		PORTB
2997
+#define PB1_DDR			DDRB
2998
+#define PB1_PWM			NULL
2999
+#undef PB2
3000
+#define PB2_PIN			PINB2
3001
+#define PB2_RPORT		PINB
3002
+#define PB2_WPORT		PORTB
3003
+#define PB2_DDR			DDRB
3004
+#define PB2_PWM			NULL
3005
+#undef PB3
3006
+#define PB3_PIN			PINB3
3007
+#define PB3_RPORT		PINB
3008
+#define PB3_WPORT		PORTB
3009
+#define PB3_DDR			DDRB
3010
+#define PB3_PWM			NULL
3011
+#undef PB4
3012
+#define PB4_PIN			PINB4
3013
+#define PB4_RPORT		PINB
3014
+#define PB4_WPORT		PORTB
3015
+#define PB4_DDR			DDRB
3016
+#define PB4_PWM			&OCR2A
3017
+#undef PB5
3018
+#define PB5_PIN			PINB5
3019
+#define PB5_RPORT		PINB
3020
+#define PB5_WPORT		PORTB
3021
+#define PB5_DDR			DDRB
3022
+#define PB5_PWM			NULL
3023
+#undef PB6
3024
+#define PB6_PIN			PINB6
3025
+#define PB6_RPORT		PINB
3026
+#define PB6_WPORT		PORTB
3027
+#define PB6_DDR			DDRB
3028
+#define PB6_PWM			NULL
3029
+#undef PB7
3030
+#define PB7_PIN			PINB7
3031
+#define PB7_RPORT		PINB
3032
+#define PB7_WPORT		PORTB
3033
+#define PB7_DDR			DDRB
3034
+#define PB7_PWM			&OCR0A
3035
+
3036
+#undef PC0
3037
+#define PC0_PIN			PINC0
3038
+#define PC0_RPORT		PINC
3039
+#define PC0_WPORT		PORTC
3040
+#define PC0_DDR			DDRC
3041
+#define PC0_PWM			NULL
3042
+#undef PC1
3043
+#define PC1_PIN			PINC1
3044
+#define PC1_RPORT		PINC
3045
+#define PC1_WPORT		PORTC
3046
+#define PC1_DDR			DDRC
3047
+#define PC1_PWM			NULL
3048
+#undef PC2
3049
+#define PC2_PIN			PINC2
3050
+#define PC2_RPORT		PINC
3051
+#define PC2_WPORT		PORTC
3052
+#define PC2_DDR			DDRC
3053
+#define PC2_PWM			NULL
3054
+#undef PC3
3055
+#define PC3_PIN			PINC3
3056
+#define PC3_RPORT		PINC
3057
+#define PC3_WPORT		PORTC
3058
+#define PC3_DDR			DDRC
3059
+#define PC3_PWM			NULL
3060
+#undef PC4
3061
+#define PC4_PIN			PINC4
3062
+#define PC4_RPORT		PINC
3063
+#define PC4_WPORT		PORTC
3064
+#define PC4_DDR			DDRC
3065
+#define PC4_PWM			NULL
3066
+#undef PC5
3067
+#define PC5_PIN			PINC5
3068
+#define PC5_RPORT		PINC
3069
+#define PC5_WPORT		PORTC
3070
+#define PC5_DDR			DDRC
3071
+#define PC5_PWM			NULL
3072
+#undef PC6
3073
+#define PC6_PIN			PINC6
3074
+#define PC6_RPORT		PINC
3075
+#define PC6_WPORT		PORTC
3076
+#define PC6_DDR			DDRC
3077
+#define PC6_PWM			NULL
3078
+#undef PC7
3079
+#define PC7_PIN			PINC7
3080
+#define PC7_RPORT		PINC
3081
+#define PC7_WPORT		PORTC
3082
+#define PC7_DDR			DDRC
3083
+#define PC7_PWM			NULL
3084
+
3085
+#undef PD0
3086
+#define PD0_PIN			PIND0
3087
+#define PD0_RPORT		PIND
3088
+#define PD0_WPORT		PORTD
3089
+#define PD0_DDR			DDRD
3090
+#define PD0_PWM			NULL
3091
+#undef PD1
3092
+#define PD1_PIN			PIND1
3093
+#define PD1_RPORT		PIND
3094
+#define PD1_WPORT		PORTD
3095
+#define PD1_DDR			DDRD
3096
+#define PD1_PWM			NULL
3097
+#undef PD2
3098
+#define PD2_PIN			PIND2
3099
+#define PD2_RPORT		PIND
3100
+#define PD2_WPORT		PORTD
3101
+#define PD2_DDR			DDRD
3102
+#define PD2_PWM			NULL
3103
+#undef PD3
3104
+#define PD3_PIN			PIND3
3105
+#define PD3_RPORT		PIND
3106
+#define PD3_WPORT		PORTD
3107
+#define PD3_DDR			DDRD
3108
+#define PD3_PWM			NULL
3109
+#undef PD4
3110
+#define PD4_PIN			PIND4
3111
+#define PD4_RPORT		PIND
3112
+#define PD4_WPORT		PORTD
3113
+#define PD4_DDR			DDRD
3114
+#define PD4_PWM			NULL
3115
+#undef PD5
3116
+#define PD5_PIN			PIND5
3117
+#define PD5_RPORT		PIND
3118
+#define PD5_WPORT		PORTD
3119
+#define PD5_DDR			DDRD
3120
+#define PD5_PWM			NULL
3121
+#undef PD6
3122
+#define PD6_PIN			PIND6
3123
+#define PD6_RPORT		PIND
3124
+#define PD6_WPORT		PORTD
3125
+#define PD6_DDR			DDRD
3126
+#define PD6_PWM			NULL
3127
+#undef PD7
3128
+#define PD7_PIN			PIND7
3129
+#define PD7_RPORT		PIND
3130
+#define PD7_WPORT		PORTD
3131
+#define PD7_DDR			DDRD
3132
+#define PD7_PWM			NULL
3133
+
3134
+#undef PE0
3135
+#define PE0_PIN			PINE0
3136
+#define PE0_RPORT		PINE
3137
+#define PE0_WPORT		PORTE
3138
+#define PE0_DDR			DDRE
3139
+#define PE0_PWM			NULL
3140
+#undef PE1
3141
+#define PE1_PIN			PINE1
3142
+#define PE1_RPORT		PINE
3143
+#define PE1_WPORT		PORTE
3144
+#define PE1_DDR			DDRE
3145
+#define PE1_PWM			NULL
3146
+#undef PE2
3147
+#define PE2_PIN			PINE2
3148
+#define PE2_RPORT		PINE
3149
+#define PE2_WPORT		PORTE
3150
+#define PE2_DDR			DDRE
3151
+#define PE2_PWM			NULL
3152
+#undef PE3
3153
+#define PE3_PIN			PINE3
3154
+#define PE3_RPORT		PINE
3155
+#define PE3_WPORT		PORTE
3156
+#define PE3_DDR			DDRE
3157
+#define PE3_PWM			&OCR3AL
3158
+#undef PE4
3159
+#define PE4_PIN			PINE4
3160
+#define PE4_RPORT		PINE
3161
+#define PE4_WPORT		PORTE
3162
+#define PE4_DDR			DDRE
3163
+#define PE4_PWM			&OCR3BL
3164
+#undef PE5
3165
+#define PE5_PIN			PINE5
3166
+#define PE5_RPORT		PINE
3167
+#define PE5_WPORT		PORTE
3168
+#define PE5_DDR			DDRE
3169
+#define PE5_PWM			&OCR3CL
3170
+#undef PE6
3171
+#define PE6_PIN			PINE6
3172
+#define PE6_RPORT		PINE
3173
+#define PE6_WPORT		PORTE
3174
+#define PE6_DDR			DDRE
3175
+#define PE6_PWM			NULL
3176
+#undef PE7
3177
+#define PE7_PIN			PINE7
3178
+#define PE7_RPORT		PINE
3179
+#define PE7_WPORT		PORTE
3180
+#define PE7_DDR			DDRE
3181
+#define PE7_PWM			NULL
3182
+
3183
+#undef PF0
3184
+#define PF0_PIN			PINF0
3185
+#define PF0_RPORT		PINF
3186
+#define PF0_WPORT		PORTF
3187
+#define PF0_DDR			DDRF
3188
+#define PF0_PWM			NULL
3189
+#undef PF1
3190
+#define PF1_PIN			PINF1
3191
+#define PF1_RPORT		PINF
3192
+#define PF1_WPORT		PORTF
3193
+#define PF1_DDR			DDRF
3194
+#define PF1_PWM			NULL
3195
+#undef PF2
3196
+#define PF2_PIN			PINF2
3197
+#define PF2_RPORT		PINF
3198
+#define PF2_WPORT		PORTF
3199
+#define PF2_DDR			DDRF
3200
+#define PF2_PWM			NULL
3201
+#undef PF3
3202
+#define PF3_PIN			PINF3
3203
+#define PF3_RPORT		PINF
3204
+#define PF3_WPORT		PORTF
3205
+#define PF3_DDR			DDRF
3206
+#define PF3_PWM			NULL
3207
+#undef PF4
3208
+#define PF4_PIN			PINF4
3209
+#define PF4_RPORT		PINF
3210
+#define PF4_WPORT		PORTF
3211
+#define PF4_DDR			DDRF
3212
+#define PF4_PWM			NULL
3213
+#undef PF5
3214
+#define PF5_PIN			PINF5
3215
+#define PF5_RPORT		PINF
3216
+#define PF5_WPORT		PORTF
3217
+#define PF5_DDR			DDRF
3218
+#define PF5_PWM			NULL
3219
+#undef PF6
3220
+#define PF6_PIN			PINF6
3221
+#define PF6_RPORT		PINF
3222
+#define PF6_WPORT		PORTF
3223
+#define PF6_DDR			DDRF
3224
+#define PF6_PWM			NULL
3225
+#undef PF7
3226
+#define PF7_PIN			PINF7
3227
+#define PF7_RPORT		PINF
3228
+#define PF7_WPORT		PORTF
3229
+#define PF7_DDR			DDRF
3230
+#define PF7_PWM			NULL
3231
+
3232
+#undef PG0
3233
+#define PG0_PIN			PING0
3234
+#define PG0_RPORT		PING
3235
+#define PG0_WPORT		PORTG
3236
+#define PG0_DDR			DDRG
3237
+#define PG0_PWM			NULL
3238
+#undef PG1
3239
+#define PG1_PIN			PING1
3240
+#define PG1_RPORT		PING
3241
+#define PG1_WPORT		PORTG
3242
+#define PG1_DDR			DDRG
3243
+#define PG1_PWM			NULL
3244
+#undef PG2
3245
+#define PG2_PIN			PING2
3246
+#define PG2_RPORT		PING
3247
+#define PG2_WPORT		PORTG
3248
+#define PG2_DDR			DDRG
3249
+#define PG2_PWM			NULL
3250
+#undef PG3
3251
+#define PG3_PIN			PING3
3252
+#define PG3_RPORT		PING
3253
+#define PG3_WPORT		PORTG
3254
+#define PG3_DDR			DDRG
3255
+#define PG3_PWM			NULL
3256
+#undef PG4
3257
+#define PG4_PIN			PING4
3258
+#define PG4_RPORT		PING
3259
+#define PG4_WPORT		PORTG
3260
+#define PG4_DDR			DDRG
3261
+#define PG4_PWM			NULL
3262
+#undef PG5
3263
+#define PG5_PIN			PING5
3264
+#define PG5_RPORT		PING
3265
+#define PG5_WPORT		PORTG
3266
+#define PG5_DDR			DDRG
3267
+#define PG5_PWM			&OCR0B
3268
+
3269
+
3270
+#endif
3271
+
2578 3272
 #ifndef	DIO0_PIN
2579 3273
 #error pins for this chip not defined in arduino.h! If you write an appropriate pin definition and have this firmware work on your chip, please submit a pull request
2580 3274
 #endif
2581 3275
 
2582
-#endif /* _FASTIO_ARDUINO_H */
3276
+#endif /* _FASTIO_ARDUINO_H */

+ 531
- 329
Marlin/pins.h
File diff suppressed because it is too large
View File


+ 29
- 7
Marlin/planner.cpp View File

@@ -98,7 +98,7 @@ volatile unsigned char block_buffer_tail;           // Index of the block to pro
98 98
 //=============================private variables ============================
99 99
 //===========================================================================
100 100
 #ifdef PREVENT_DANGEROUS_EXTRUDE
101
-bool allow_cold_extrude=false;
101
+float extrude_min_temp=EXTRUDE_MINTEMP;
102 102
 #endif
103 103
 #ifdef XY_FREQUENCY_LIMIT
104 104
 #define MAX_FREQ_TIME (1000000.0/XY_FREQUENCY_LIMIT)
@@ -439,12 +439,20 @@ void check_axes_activity()
439 439
   unsigned char z_active = 0;
440 440
   unsigned char e_active = 0;
441 441
   unsigned char tail_fan_speed = fanSpeed;
442
+  #ifdef BARICUDA
443
+  unsigned char tail_valve_pressure = ValvePressure;
444
+  unsigned char tail_e_to_p_pressure = EtoPPressure;
445
+  #endif
442 446
   block_t *block;
443 447
 
444 448
   if(block_buffer_tail != block_buffer_head)
445 449
   {
446 450
     uint8_t block_index = block_buffer_tail;
447 451
     tail_fan_speed = block_buffer[block_index].fan_speed;
452
+    #ifdef BARICUDA
453
+    tail_valve_pressure = block_buffer[block_index].valve_pressure;
454
+    tail_e_to_p_pressure = block_buffer[block_index].e_to_p_pressure;
455
+    #endif
448 456
     while(block_index != block_buffer_head)
449 457
     {
450 458
       block = &block_buffer[block_index];
@@ -464,7 +472,7 @@ void check_axes_activity()
464 472
     disable_e1();
465 473
     disable_e2(); 
466 474
   }
467
-#if FAN_PIN > -1
475
+#if defined(FAN_PIN) && FAN_PIN > -1
468 476
   #ifndef FAN_SOFT_PWM
469 477
     #ifdef FAN_KICKSTART_TIME
470 478
       static unsigned long fan_kick_end;
@@ -486,6 +494,16 @@ void check_axes_activity()
486 494
 #ifdef AUTOTEMP
487 495
   getHighESpeed();
488 496
 #endif
497
+
498
+#ifdef BARICUDA
499
+  #if defined(HEATER_1_PIN) && HEATER_1_PIN > -1
500
+      analogWrite(HEATER_1_PIN,tail_valve_pressure);
501
+  #endif
502
+
503
+  #if defined(HEATER_2_PIN) && HEATER_2_PIN > -1
504
+      analogWrite(HEATER_2_PIN,tail_e_to_p_pressure);
505
+  #endif
506
+#endif
489 507
 }
490 508
 
491 509
 
@@ -519,7 +537,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
519 537
   #ifdef PREVENT_DANGEROUS_EXTRUDE
520 538
   if(target[E_AXIS]!=position[E_AXIS])
521 539
   {
522
-    if(degHotend(active_extruder)<EXTRUDE_MINTEMP && !allow_cold_extrude)
540
+    if(degHotend(active_extruder)<extrude_min_temp)
523 541
     {
524 542
       position[E_AXIS]=target[E_AXIS]; //behave as if the move really took place, but ignore E part
525 543
       SERIAL_ECHO_START;
@@ -559,6 +577,10 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
559 577
   }
560 578
 
561 579
   block->fan_speed = fanSpeed;
580
+  #ifdef BARICUDA
581
+  block->valve_pressure = ValvePressure;
582
+  block->e_to_p_pressure = EtoPPressure;
583
+  #endif
562 584
 
563 585
   // Compute direction bits for this block 
564 586
   block->direction_bits = 0;
@@ -896,12 +918,12 @@ uint8_t movesplanned()
896 918
   return (block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1);
897 919
 }
898 920
 
899
-void allow_cold_extrudes(bool allow)
900
-{
901 921
 #ifdef PREVENT_DANGEROUS_EXTRUDE
902
-  allow_cold_extrude=allow;
903
-#endif
922
+void set_extrude_min_temp(float temp)
923
+{
924
+  extrude_min_temp=temp;
904 925
 }
926
+#endif
905 927
 
906 928
 // Calculate the steps/s^2 acceleration rates, based on the mm/s^s
907 929
 void reset_acceleration_rates()

+ 7
- 1
Marlin/planner.h View File

@@ -60,6 +60,10 @@ typedef struct {
60 60
   unsigned long final_rate;                          // The minimal rate at exit
61 61
   unsigned long acceleration_st;                     // acceleration steps/sec^2
62 62
   unsigned long fan_speed;
63
+  #ifdef BARICUDA
64
+  unsigned long valve_pressure;
65
+  unsigned long e_to_p_pressure;
66
+  #endif
63 67
   volatile char busy;
64 68
 } block_t;
65 69
 
@@ -135,7 +139,9 @@ FORCE_INLINE bool blocks_queued()
135 139
     return true;
136 140
 }
137 141
 
138
-void allow_cold_extrudes(bool allow);
142
+#ifdef PREVENT_DANGEROUS_EXTRUDE
143
+void set_extrude_min_temp(float temp);
144
+#endif
139 145
 
140 146
 void reset_acceleration_rates();
141 147
 #endif

+ 42
- 46
Marlin/stepper.cpp View File

@@ -29,7 +29,7 @@
29 29
 #include "language.h"
30 30
 #include "cardreader.h"
31 31
 #include "speed_lookuptable.h"
32
-#if DIGIPOTSS_PIN > -1
32
+#if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1
33 33
 #include <SPI.h>
34 34
 #endif
35 35
 
@@ -69,9 +69,9 @@ volatile long endstops_stepsTotal,endstops_stepsDone;
69 69
 static volatile bool endstop_x_hit=false;
70 70
 static volatile bool endstop_y_hit=false;
71 71
 static volatile bool endstop_z_hit=false;
72
-#ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
73
-bool abort_on_endstop_hit = false;
74
-#endif
72
+#ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
73
+bool abort_on_endstop_hit = false;
74
+#endif
75 75
 
76 76
 static bool old_x_min_endstop=false;
77 77
 static bool old_x_max_endstop=false;
@@ -184,20 +184,20 @@ void checkHitEndstops()
184 184
      SERIAL_ECHOPAIR(" Z:",(float)endstops_trigsteps[Z_AXIS]/axis_steps_per_unit[Z_AXIS]);
185 185
      LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "Z");
186 186
    }
187
-   SERIAL_ECHOLN("");
187
+   SERIAL_ECHOLN("");
188 188
    endstop_x_hit=false;
189 189
    endstop_y_hit=false;
190
-   endstop_z_hit=false;
191
-#ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
192
-   if (abort_on_endstop_hit)
193
-   {
190
+   endstop_z_hit=false;
191
+#ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
192
+   if (abort_on_endstop_hit)
193
+   {
194 194
      card.sdprinting = false;
195 195
      card.closefile();
196
-     quickStop();
196
+     quickStop();
197 197
      setTargetHotend0(0);
198 198
      setTargetHotend1(0);
199 199
      setTargetHotend2(0);
200
-   }
200
+   }
201 201
 #endif
202 202
  }
203 203
 }
@@ -353,7 +353,7 @@ ISR(TIMER1_COMPA_vect)
353 353
       count_direction[X_AXIS]=-1;
354 354
       CHECK_ENDSTOPS
355 355
       {
356
-        #if X_MIN_PIN > -1
356
+        #if defined(X_MIN_PIN) && X_MIN_PIN > -1
357 357
           bool x_min_endstop=(READ(X_MIN_PIN) != X_ENDSTOPS_INVERTING);
358 358
           if(x_min_endstop && old_x_min_endstop && (current_block->steps_x > 0)) {
359 359
             endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
@@ -372,7 +372,7 @@ ISR(TIMER1_COMPA_vect)
372 372
       count_direction[X_AXIS]=1;
373 373
       CHECK_ENDSTOPS 
374 374
       {
375
-        #if X_MAX_PIN > -1
375
+        #if defined(X_MAX_PIN) && X_MAX_PIN > -1
376 376
           bool x_max_endstop=(READ(X_MAX_PIN) != X_ENDSTOPS_INVERTING);
377 377
           if(x_max_endstop && old_x_max_endstop && (current_block->steps_x > 0)){
378 378
             endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
@@ -391,7 +391,7 @@ ISR(TIMER1_COMPA_vect)
391 391
       count_direction[Y_AXIS]=-1;
392 392
       CHECK_ENDSTOPS
393 393
       {
394
-        #if Y_MIN_PIN > -1
394
+        #if defined(Y_MIN_PIN) && Y_MIN_PIN > -1
395 395
           bool y_min_endstop=(READ(Y_MIN_PIN) != Y_ENDSTOPS_INVERTING);
396 396
           if(y_min_endstop && old_y_min_endstop && (current_block->steps_y > 0)) {
397 397
             endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
@@ -409,7 +409,7 @@ ISR(TIMER1_COMPA_vect)
409 409
       count_direction[Y_AXIS]=1;
410 410
       CHECK_ENDSTOPS
411 411
       {
412
-        #if Y_MAX_PIN > -1
412
+        #if defined(Y_MAX_PIN) && Y_MAX_PIN > -1
413 413
           bool y_max_endstop=(READ(Y_MAX_PIN) != Y_ENDSTOPS_INVERTING);
414 414
           if(y_max_endstop && old_y_max_endstop && (current_block->steps_y > 0)){
415 415
             endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
@@ -452,7 +452,7 @@ ISR(TIMER1_COMPA_vect)
452 452
       count_direction[Z_AXIS]=-1;
453 453
       CHECK_ENDSTOPS
454 454
       {
455
-        #if Z_MIN_PIN > -1
455
+        #if defined(Z_MIN_PIN) && Z_MIN_PIN > -1
456 456
           bool z_min_endstop=(READ(Z_MIN_PIN) != Z_ENDSTOPS_INVERTING);
457 457
           if(z_min_endstop && old_z_min_endstop && (current_block->steps_z > 0)) {
458 458
             endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
@@ -473,7 +473,7 @@ ISR(TIMER1_COMPA_vect)
473 473
       count_direction[Z_AXIS]=1;
474 474
       CHECK_ENDSTOPS
475 475
       {
476
-        #if Z_MAX_PIN > -1
476
+        #if defined(Z_MAX_PIN) && Z_MAX_PIN > -1
477 477
           bool z_max_endstop=(READ(Z_MAX_PIN) != Z_ENDSTOPS_INVERTING);
478 478
           if(z_max_endstop && old_z_max_endstop && (current_block->steps_z > 0)) {
479 479
             endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
@@ -743,20 +743,20 @@ void st_init()
743 743
   microstep_init(); //Initialize Microstepping Pins
744 744
   
745 745
   //Initialize Dir Pins
746
-  #if X_DIR_PIN > -1
746
+  #if defined(X_DIR_PIN) && X_DIR_PIN > -1
747 747
     SET_OUTPUT(X_DIR_PIN);
748 748
   #endif
749
-  #if Y_DIR_PIN > -1 
749
+  #if defined(Y_DIR_PIN) && Y_DIR_PIN > -1 
750 750
     SET_OUTPUT(Y_DIR_PIN);
751 751
   #endif
752
-  #if Z_DIR_PIN > -1 
752
+  #if defined(Z_DIR_PIN) && Z_DIR_PIN > -1 
753 753
     SET_OUTPUT(Z_DIR_PIN);
754 754
 
755
-    #if defined(Z_DUAL_STEPPER_DRIVERS) && (Z2_DIR_PIN > -1)
755
+    #if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_DIR_PIN) && (Z2_DIR_PIN > -1)
756 756
       SET_OUTPUT(Z2_DIR_PIN);
757 757
     #endif
758 758
   #endif
759
-  #if E0_DIR_PIN > -1 
759
+  #if defined(E0_DIR_PIN) && E0_DIR_PIN > -1 
760 760
     SET_OUTPUT(E0_DIR_PIN);
761 761
   #endif
762 762
   #if defined(E1_DIR_PIN) && (E1_DIR_PIN > -1)
@@ -768,24 +768,24 @@ void st_init()
768 768
 
769 769
   //Initialize Enable Pins - steppers default to disabled.
770 770
 
771
-  #if (X_ENABLE_PIN > -1)
771
+  #if defined(X_ENABLE_PIN) && X_ENABLE_PIN > -1
772 772
     SET_OUTPUT(X_ENABLE_PIN);
773 773
     if(!X_ENABLE_ON) WRITE(X_ENABLE_PIN,HIGH);
774 774
   #endif
775
-  #if (Y_ENABLE_PIN > -1)
775
+  #if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1
776 776
     SET_OUTPUT(Y_ENABLE_PIN);
777 777
     if(!Y_ENABLE_ON) WRITE(Y_ENABLE_PIN,HIGH);
778 778
   #endif
779
-  #if (Z_ENABLE_PIN > -1)
779
+  #if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1
780 780
     SET_OUTPUT(Z_ENABLE_PIN);
781 781
     if(!Z_ENABLE_ON) WRITE(Z_ENABLE_PIN,HIGH);
782 782
     
783
-    #if defined(Z_DUAL_STEPPER_DRIVERS) && (Z2_ENABLE_PIN > -1)
783
+    #if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_ENABLE_PIN) && (Z2_ENABLE_PIN > -1)
784 784
       SET_OUTPUT(Z2_ENABLE_PIN);
785 785
       if(!Z_ENABLE_ON) WRITE(Z2_ENABLE_PIN,HIGH);
786 786
     #endif
787 787
   #endif
788
-  #if (E0_ENABLE_PIN > -1)
788
+  #if defined(E0_ENABLE_PIN) && (E0_ENABLE_PIN > -1)
789 789
     SET_OUTPUT(E0_ENABLE_PIN);
790 790
     if(!E_ENABLE_ON) WRITE(E0_ENABLE_PIN,HIGH);
791 791
   #endif
@@ -800,42 +800,42 @@ void st_init()
800 800
 
801 801
   //endstops and pullups
802 802
   
803
-  #if X_MIN_PIN > -1
803
+  #if defined(X_MIN_PIN) && X_MIN_PIN > -1
804 804
     SET_INPUT(X_MIN_PIN); 
805 805
     #ifdef ENDSTOPPULLUP_XMIN
806 806
       WRITE(X_MIN_PIN,HIGH);
807 807
     #endif
808 808
   #endif
809 809
       
810
-  #if Y_MIN_PIN > -1
810
+  #if defined(Y_MIN_PIN) && Y_MIN_PIN > -1
811 811
     SET_INPUT(Y_MIN_PIN); 
812 812
     #ifdef ENDSTOPPULLUP_YMIN
813 813
       WRITE(Y_MIN_PIN,HIGH);
814 814
     #endif
815 815
   #endif
816 816
   
817
-  #if Z_MIN_PIN > -1
817
+  #if defined(Z_MIN_PIN) && Z_MIN_PIN > -1
818 818
     SET_INPUT(Z_MIN_PIN); 
819 819
     #ifdef ENDSTOPPULLUP_ZMIN
820 820
       WRITE(Z_MIN_PIN,HIGH);
821 821
     #endif
822 822
   #endif
823 823
       
824
-  #if X_MAX_PIN > -1
824
+  #if defined(X_MAX_PIN) && X_MAX_PIN > -1
825 825
     SET_INPUT(X_MAX_PIN); 
826 826
     #ifdef ENDSTOPPULLUP_XMAX
827 827
       WRITE(X_MAX_PIN,HIGH);
828 828
     #endif
829 829
   #endif
830 830
       
831
-  #if Y_MAX_PIN > -1
831
+  #if defined(Y_MAX_PIN) && Y_MAX_PIN > -1
832 832
     SET_INPUT(Y_MAX_PIN); 
833 833
     #ifdef ENDSTOPPULLUP_YMAX
834 834
       WRITE(Y_MAX_PIN,HIGH);
835 835
     #endif
836 836
   #endif
837 837
   
838
-  #if Z_MAX_PIN > -1
838
+  #if defined(Z_MAX_PIN) && Z_MAX_PIN > -1
839 839
     SET_INPUT(Z_MAX_PIN); 
840 840
     #ifdef ENDSTOPPULLUP_ZMAX
841 841
       WRITE(Z_MAX_PIN,HIGH);
@@ -844,26 +844,26 @@ void st_init()
844 844
  
845 845
 
846 846
   //Initialize Step Pins
847
-  #if (X_STEP_PIN > -1) 
847
+  #if defined(X_STEP_PIN) && (X_STEP_PIN > -1) 
848 848
     SET_OUTPUT(X_STEP_PIN);
849 849
     WRITE(X_STEP_PIN,INVERT_X_STEP_PIN);
850 850
     disable_x();
851 851
   #endif  
852
-  #if (Y_STEP_PIN > -1) 
852
+  #if defined(Y_STEP_PIN) && (Y_STEP_PIN > -1) 
853 853
     SET_OUTPUT(Y_STEP_PIN);
854 854
     WRITE(Y_STEP_PIN,INVERT_Y_STEP_PIN);
855 855
     disable_y();
856 856
   #endif  
857
-  #if (Z_STEP_PIN > -1) 
857
+  #if defined(Z_STEP_PIN) && (Z_STEP_PIN > -1) 
858 858
     SET_OUTPUT(Z_STEP_PIN);
859 859
     WRITE(Z_STEP_PIN,INVERT_Z_STEP_PIN);
860
-    #if defined(Z_DUAL_STEPPER_DRIVERS) && (Z2_STEP_PIN > -1)
860
+    #if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_STEP_PIN) && (Z2_STEP_PIN > -1)
861 861
       SET_OUTPUT(Z2_STEP_PIN);
862 862
       WRITE(Z2_STEP_PIN,INVERT_Z_STEP_PIN);
863 863
     #endif
864 864
     disable_z();
865 865
   #endif  
866
-  #if (E0_STEP_PIN > -1) 
866
+  #if defined(E0_STEP_PIN) && (E0_STEP_PIN > -1) 
867 867
     SET_OUTPUT(E0_STEP_PIN);
868 868
     WRITE(E0_STEP_PIN,INVERT_E_STEP_PIN);
869 869
     disable_e0();
@@ -879,10 +879,6 @@ void st_init()
879 879
     disable_e2();
880 880
   #endif  
881 881
 
882
-  #ifdef CONTROLLERFAN_PIN
883
-    SET_OUTPUT(CONTROLLERFAN_PIN); //Set pin used for driver cooling fan
884
-  #endif
885
-  
886 882
   // waveform generation = 0100 = CTC
887 883
   TCCR1B &= ~(1<<WGM13);
888 884
   TCCR1B |=  (1<<WGM12);
@@ -978,7 +974,7 @@ void quickStop()
978 974
 
979 975
 void digitalPotWrite(int address, int value) // From Arduino DigitalPotControl example
980 976
 {
981
-  #if DIGIPOTSS_PIN > -1
977
+  #if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1
982 978
     digitalWrite(DIGIPOTSS_PIN,LOW); // take the SS pin low to select the chip
983 979
     SPI.transfer(address); //  send in the address and value via SPI:
984 980
     SPI.transfer(value);
@@ -989,7 +985,7 @@ void digitalPotWrite(int address, int value) // From Arduino DigitalPotControl e
989 985
 
990 986
 void digipot_init() //Initialize Digipot Motor Current
991 987
 {
992
-  #if DIGIPOTSS_PIN > -1
988
+  #if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1
993 989
     const uint8_t digipot_motor_current[] = DIGIPOT_MOTOR_CURRENT;
994 990
     
995 991
     SPI.begin(); 
@@ -1002,7 +998,7 @@ void digipot_init() //Initialize Digipot Motor Current
1002 998
 
1003 999
 void digipot_current(uint8_t driver, int current)
1004 1000
 {
1005
-  #if DIGIPOTSS_PIN > -1
1001
+  #if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1
1006 1002
     const uint8_t digipot_ch[] = DIGIPOT_CHANNELS;
1007 1003
     digitalPotWrite(digipot_ch[driver], current);
1008 1004
   #endif
@@ -1010,7 +1006,7 @@ void digipot_current(uint8_t driver, int current)
1010 1006
 
1011 1007
 void microstep_init()
1012 1008
 {
1013
-  #if X_MS1_PIN > -1
1009
+  #if defined(X_MS1_PIN) && X_MS1_PIN > -1
1014 1010
   const uint8_t microstep_modes[] = MICROSTEP_MODES;
1015 1011
   pinMode(X_MS2_PIN,OUTPUT);
1016 1012
   pinMode(Y_MS2_PIN,OUTPUT);

+ 196
- 76
Marlin/temperature.cpp View File

@@ -40,10 +40,13 @@
40 40
 int target_temperature[EXTRUDERS] = { 0 };
41 41
 int target_temperature_bed = 0;
42 42
 int current_temperature_raw[EXTRUDERS] = { 0 };
43
-float current_temperature[EXTRUDERS] = { 0 };
43
+float current_temperature[EXTRUDERS] = { 0.0 };
44 44
 int current_temperature_bed_raw = 0;
45
-float current_temperature_bed = 0;
46
-
45
+float current_temperature_bed = 0.0;
46
+#ifdef TEMP_SENSOR_1_AS_REDUNDANT
47
+  int redundant_temperature_raw = 0;
48
+  float redundant_temperature = 0.0;
49
+#endif
47 50
 #ifdef PIDTEMP
48 51
   float Kp=DEFAULT_Kp;
49 52
   float Ki=(DEFAULT_Ki*PID_dT);
@@ -99,17 +102,20 @@ static volatile bool temp_meas_ready = false;
99 102
 #ifdef FAN_SOFT_PWM
100 103
   static unsigned char soft_pwm_fan;
101 104
 #endif
105
+#if (defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1) || \
106
+    (defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1) || \
107
+    (defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1)
108
+  static unsigned long extruder_autofan_last_check;
109
+#endif  
102 110
 
103
-
104
-  
105 111
 #if EXTRUDERS > 3
106
-# error Unsupported number of extruders
112
+  # error Unsupported number of extruders
107 113
 #elif EXTRUDERS > 2
108
-# define ARRAY_BY_EXTRUDERS(v1, v2, v3) { v1, v2, v3 }
114
+  # define ARRAY_BY_EXTRUDERS(v1, v2, v3) { v1, v2, v3 }
109 115
 #elif EXTRUDERS > 1
110
-# define ARRAY_BY_EXTRUDERS(v1, v2, v3) { v1, v2 }
116
+  # define ARRAY_BY_EXTRUDERS(v1, v2, v3) { v1, v2 }
111 117
 #else
112
-# define ARRAY_BY_EXTRUDERS(v1, v2, v3) { v1 }
118
+  # define ARRAY_BY_EXTRUDERS(v1, v2, v3) { v1 }
113 119
 #endif
114 120
 
115 121
 // Init min and max temp with extreme values to prevent false errors during startup
@@ -121,8 +127,14 @@ static int maxttemp[EXTRUDERS] = ARRAY_BY_EXTRUDERS( 16383, 16383, 16383 );
121 127
 #ifdef BED_MAXTEMP
122 128
 static int bed_maxttemp_raw = HEATER_BED_RAW_HI_TEMP;
123 129
 #endif
124
-static void *heater_ttbl_map[EXTRUDERS] = ARRAY_BY_EXTRUDERS( (void *)HEATER_0_TEMPTABLE, (void *)HEATER_1_TEMPTABLE, (void *)HEATER_2_TEMPTABLE );
125
-static uint8_t heater_ttbllen_map[EXTRUDERS] = ARRAY_BY_EXTRUDERS( HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN, HEATER_2_TEMPTABLE_LEN );
130
+
131
+#ifdef TEMP_SENSOR_1_AS_REDUNDANT
132
+  static void *heater_ttbl_map[2] = {(void *)HEATER_0_TEMPTABLE, (void *)HEATER_1_TEMPTABLE };
133
+  static uint8_t heater_ttbllen_map[2] = { HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN };
134
+#else
135
+  static void *heater_ttbl_map[EXTRUDERS] = ARRAY_BY_EXTRUDERS( (void *)HEATER_0_TEMPTABLE, (void *)HEATER_1_TEMPTABLE, (void *)HEATER_2_TEMPTABLE );
136
+  static uint8_t heater_ttbllen_map[EXTRUDERS] = ARRAY_BY_EXTRUDERS( HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN, HEATER_2_TEMPTABLE_LEN );
137
+#endif
126 138
 
127 139
 static float analog2temp(int raw, uint8_t e);
128 140
 static float analog2tempBed(int raw);
@@ -154,28 +166,28 @@ void PID_autotune(float temp, int extruder, int ncycles)
154 166
   float Kp, Ki, Kd;
155 167
   float max = 0, min = 10000;
156 168
 
157
-	if ((extruder > EXTRUDERS)
169
+  if ((extruder > EXTRUDERS)
158 170
   #if (TEMP_BED_PIN <= -1)
159
-		||(extruder < 0)
160
-	#endif
161
-	){
162
-  	SERIAL_ECHOLN("PID Autotune failed. Bad extruder number.");
163
-  	return;
164
-	}
171
+       ||(extruder < 0)
172
+  #endif
173
+       ){
174
+          SERIAL_ECHOLN("PID Autotune failed. Bad extruder number.");
175
+          return;
176
+        }
165 177
 	
166 178
   SERIAL_ECHOLN("PID Autotune start");
167 179
   
168 180
   disable_heater(); // switch off all heaters.
169 181
 
170
-	if (extruder<0)
171
-	{
172
-	 	soft_pwm_bed = (MAX_BED_POWER)/2;
173
-		bias = d = (MAX_BED_POWER)/2;
174
-  }
175
-	else
176
-	{
177
-	  soft_pwm[extruder] = (PID_MAX)/2;
178
-		bias = d = (PID_MAX)/2;
182
+  if (extruder<0)
183
+  {
184
+     soft_pwm_bed = (MAX_BED_POWER)/2;
185
+     bias = d = (MAX_BED_POWER)/2;
186
+   }
187
+   else
188
+   {
189
+     soft_pwm[extruder] = (PID_MAX)/2;
190
+     bias = d = (PID_MAX)/2;
179 191
   }
180 192
 
181 193
 
@@ -193,10 +205,10 @@ void PID_autotune(float temp, int extruder, int ncycles)
193 205
       if(heating == true && input > temp) {
194 206
         if(millis() - t2 > 5000) { 
195 207
           heating=false;
196
-					if (extruder<0)
197
-						soft_pwm_bed = (bias - d) >> 1;
198
-					else
199
-						soft_pwm[extruder] = (bias - d) >> 1;
208
+          if (extruder<0)
209
+            soft_pwm_bed = (bias - d) >> 1;
210
+          else
211
+            soft_pwm[extruder] = (bias - d) >> 1;
200 212
           t1=millis();
201 213
           t_high=t1 - t2;
202 214
           max=temp;
@@ -247,10 +259,10 @@ void PID_autotune(float temp, int extruder, int ncycles)
247 259
               */
248 260
             }
249 261
           }
250
-					if (extruder<0)
251
-						soft_pwm_bed = (bias + d) >> 1;
252
-					else
253
-						soft_pwm[extruder] = (bias + d) >> 1;
262
+          if (extruder<0)
263
+            soft_pwm_bed = (bias + d) >> 1;
264
+          else
265
+            soft_pwm[extruder] = (bias + d) >> 1;
254 266
           cycles++;
255 267
           min=temp;
256 268
         }
@@ -261,14 +273,14 @@ void PID_autotune(float temp, int extruder, int ncycles)
261 273
       return;
262 274
     }
263 275
     if(millis() - temp_millis > 2000) {
264
-			int p;
265
-			if (extruder<0){
266
-	      p=soft_pwm_bed;       
267
-	      SERIAL_PROTOCOLPGM("ok B:");
268
-			}else{
269
-	      p=soft_pwm[extruder];       
270
-	      SERIAL_PROTOCOLPGM("ok T:");
271
-			}
276
+      int p;
277
+      if (extruder<0){
278
+        p=soft_pwm_bed;       
279
+        SERIAL_PROTOCOLPGM("ok B:");
280
+      }else{
281
+        p=soft_pwm[extruder];       
282
+        SERIAL_PROTOCOLPGM("ok T:");
283
+      }
272 284
 			
273 285
       SERIAL_PROTOCOL(input);   
274 286
       SERIAL_PROTOCOLPGM(" @:");
@@ -306,6 +318,78 @@ int getHeaterPower(int heater) {
306 318
   return soft_pwm[heater];
307 319
 }
308 320
 
321
+#if (defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1) || \
322
+    (defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1) || \
323
+    (defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1)
324
+
325
+  #if defined(FAN_PIN) && FAN_PIN > -1
326
+    #if EXTRUDER_0_AUTO_FAN_PIN == FAN_PIN 
327
+       #error "You cannot set EXTRUDER_0_AUTO_FAN_PIN equal to FAN_PIN"
328
+    #endif
329
+    #if EXTRUDER_1_AUTO_FAN_PIN == FAN_PIN 
330
+       #error "You cannot set EXTRUDER_1_AUTO_FAN_PIN equal to FAN_PIN"
331
+    #endif
332
+    #if EXTRUDER_2_AUTO_FAN_PIN == FAN_PIN 
333
+       #error "You cannot set EXTRUDER_2_AUTO_FAN_PIN equal to FAN_PIN"
334
+    #endif
335
+  #endif 
336
+
337
+void setExtruderAutoFanState(int pin, bool state)
338
+{
339
+  unsigned char newFanSpeed = (state != 0) ? EXTRUDER_AUTO_FAN_SPEED : 0;
340
+  // this idiom allows both digital and PWM fan outputs (see M42 handling).
341
+  pinMode(pin, OUTPUT);
342
+  digitalWrite(pin, newFanSpeed);
343
+  analogWrite(pin, newFanSpeed);
344
+}
345
+
346
+void checkExtruderAutoFans()
347
+{
348
+  uint8_t fanState = 0;
349
+
350
+  // which fan pins need to be turned on?      
351
+  #if defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1
352
+    if (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE) 
353
+      fanState |= 1;
354
+  #endif
355
+  #if defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1
356
+    if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE) 
357
+    {
358
+      if (EXTRUDER_1_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) 
359
+        fanState |= 1;
360
+      else
361
+        fanState |= 2;
362
+    }
363
+  #endif
364
+  #if defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1
365
+    if (current_temperature[2] > EXTRUDER_AUTO_FAN_TEMPERATURE) 
366
+    {
367
+      if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) 
368
+        fanState |= 1;
369
+      else if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN) 
370
+        fanState |= 2;
371
+      else
372
+        fanState |= 4;
373
+    }
374
+  #endif
375
+  
376
+  // update extruder auto fan states
377
+  #if defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1
378
+    setExtruderAutoFanState(EXTRUDER_0_AUTO_FAN_PIN, (fanState & 1) != 0);
379
+  #endif 
380
+  #if defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1
381
+    if (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN) 
382
+      setExtruderAutoFanState(EXTRUDER_1_AUTO_FAN_PIN, (fanState & 2) != 0);
383
+  #endif 
384
+  #if defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1
385
+    if (EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN 
386
+        && EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_1_AUTO_FAN_PIN)
387
+      setExtruderAutoFanState(EXTRUDER_2_AUTO_FAN_PIN, (fanState & 4) != 0);
388
+  #endif 
389
+}
390
+
391
+#endif // any extruder auto fan pins set
392
+
309 393
 void manage_heater()
310 394
 {
311 395
   float pid_input;
@@ -396,10 +480,31 @@ void manage_heater()
396 480
         }
397 481
     }
398 482
     #endif
399
-
483
+    #ifdef TEMP_SENSOR_1_AS_REDUNDANT
484
+      if(fabs(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) {
485
+        disable_heater();
486
+        if(IsStopped() == false) {
487
+          SERIAL_ERROR_START;
488
+          SERIAL_ERRORLNPGM("Extruder switched off. Temperature difference between temp sensors is too high !");
489
+          LCD_ALERTMESSAGEPGM("Err: REDUNDANT TEMP ERROR");
490
+        }
491
+        #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
492
+          Stop();
493
+        #endif
494
+      }
495
+    #endif
400 496
   } // End extruder for loop
401
-  
402 497
 
498
+  #if (defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1) || \
499
+      (defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1) || \
500
+      (defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1)
501
+  if(millis() - extruder_autofan_last_check > 2500)  // only need to check fan state very infrequently
502
+  {
503
+    checkExtruderAutoFans();
504
+    extruder_autofan_last_check = millis();
505
+  }  
506
+  #endif       
507
+  
403 508
   #ifndef PIDTEMPBED
404 509
   if(millis() - previous_millis_bed_heater < BED_CHECK_INTERVAL)
405 510
     return;
@@ -481,7 +586,11 @@ void manage_heater()
481 586
 // Derived from RepRap FiveD extruder::getTemperature()
482 587
 // For hot end temperature measurement.
483 588
 static float analog2temp(int raw, uint8_t e) {
589
+#ifdef TEMP_SENSOR_1_AS_REDUNDANT
590
+  if(e > EXTRUDERS)
591
+#else
484 592
   if(e >= EXTRUDERS)
593
+#endif
485 594
   {
486 595
       SERIAL_ERROR_START;
487 596
       SERIAL_ERROR((int)e);
@@ -560,7 +669,9 @@ static void updateTemperaturesFromRawValues()
560 669
         current_temperature[e] = analog2temp(current_temperature_raw[e], e);
561 670
     }
562 671
     current_temperature_bed = analog2tempBed(current_temperature_bed_raw);
563
-
672
+    #ifdef TEMP_SENSOR_1_AS_REDUNDANT
673
+      redundant_temperature = analog2temp(redundant_temperature_raw, 1);
674
+    #endif
564 675
     //Reset the watchdog after we know we have a temperature measurement.
565 676
     watchdog_reset();
566 677
 
@@ -571,6 +682,12 @@ static void updateTemperaturesFromRawValues()
571 682
 
572 683
 void tp_init()
573 684
 {
685
+#if (MOTHERBOARD == 80) && ((TEMP_SENSOR_0==-1)||(TEMP_SENSOR_1==-1)||(TEMP_SENSOR_2==-1)||(TEMP_SENSOR_BED==-1))
686
+  //disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector
687
+  MCUCR=(1<<JTD); 
688
+  MCUCR=(1<<JTD);
689
+#endif
690
+  
574 691
   // Finish init of mult extruder arrays 
575 692
   for(int e = 0; e < EXTRUDERS; e++) {
576 693
     // populate with the first value 
@@ -585,19 +702,19 @@ void tp_init()
585 702
 #endif //PIDTEMPBED
586 703
   }
587 704
 
588
-  #if (HEATER_0_PIN > -1) 
705
+  #if defined(HEATER_0_PIN) && (HEATER_0_PIN > -1) 
589 706
     SET_OUTPUT(HEATER_0_PIN);
590 707
   #endif  
591
-  #if (HEATER_1_PIN > -1) 
708
+  #if defined(HEATER_1_PIN) && (HEATER_1_PIN > -1) 
592 709
     SET_OUTPUT(HEATER_1_PIN);
593 710
   #endif  
594
-  #if (HEATER_2_PIN > -1) 
711
+  #if defined(HEATER_2_PIN) && (HEATER_2_PIN > -1) 
595 712
     SET_OUTPUT(HEATER_2_PIN);
596 713
   #endif  
597
-  #if (HEATER_BED_PIN > -1) 
714
+  #if defined(HEATER_BED_PIN) && (HEATER_BED_PIN > -1) 
598 715
     SET_OUTPUT(HEATER_BED_PIN);
599 716
   #endif  
600
-  #if (FAN_PIN > -1) 
717
+  #if defined(FAN_PIN) && (FAN_PIN > -1) 
601 718
     SET_OUTPUT(FAN_PIN);
602 719
     #ifdef FAST_PWM_FAN
603 720
     setPwmFrequency(FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
@@ -629,28 +746,28 @@ void tp_init()
629 746
   #ifdef DIDR2
630 747
     DIDR2 = 0;
631 748
   #endif
632
-  #if (TEMP_0_PIN > -1)
749
+  #if defined(TEMP_0_PIN) && (TEMP_0_PIN > -1)
633 750
     #if TEMP_0_PIN < 8
634 751
        DIDR0 |= 1 << TEMP_0_PIN; 
635 752
     #else
636 753
        DIDR2 |= 1<<(TEMP_0_PIN - 8); 
637 754
     #endif
638 755
   #endif
639
-  #if (TEMP_1_PIN > -1)
756
+  #if defined(TEMP_1_PIN) && (TEMP_1_PIN > -1)
640 757
     #if TEMP_1_PIN < 8
641 758
        DIDR0 |= 1<<TEMP_1_PIN; 
642 759
     #else
643 760
        DIDR2 |= 1<<(TEMP_1_PIN - 8); 
644 761
     #endif
645 762
   #endif
646
-  #if (TEMP_2_PIN > -1)
763
+  #if defined(TEMP_2_PIN) && (TEMP_2_PIN > -1)
647 764
     #if TEMP_2_PIN < 8
648 765
        DIDR0 |= 1 << TEMP_2_PIN; 
649 766
     #else
650
-       DIDR2 = 1<<(TEMP_2_PIN - 8); 
767
+       DIDR2 |= 1<<(TEMP_2_PIN - 8); 
651 768
     #endif
652 769
   #endif
653
-  #if (TEMP_BED_PIN > -1)
770
+  #if defined(TEMP_BED_PIN) && (TEMP_BED_PIN > -1)
654 771
     #if TEMP_BED_PIN < 8
655 772
        DIDR0 |= 1<<TEMP_BED_PIN; 
656 773
     #else
@@ -689,7 +806,7 @@ void tp_init()
689 806
 
690 807
 #if (EXTRUDERS > 1) && defined(HEATER_1_MINTEMP)
691 808
   minttemp[1] = HEATER_1_MINTEMP;
692
-  while(analog2temp(minttemp_raw[1], 1) > HEATER_1_MINTEMP) {
809
+  while(analog2temp(minttemp_raw[1], 1) < HEATER_1_MINTEMP) {
693 810
 #if HEATER_1_RAW_LO_TEMP < HEATER_1_RAW_HI_TEMP
694 811
     minttemp_raw[1] += OVERSAMPLENR;
695 812
 #else
@@ -710,7 +827,7 @@ void tp_init()
710 827
 
711 828
 #if (EXTRUDERS > 2) && defined(HEATER_2_MINTEMP)
712 829
   minttemp[2] = HEATER_2_MINTEMP;
713
-  while(analog2temp(minttemp_raw[2], 2) > HEATER_2_MINTEMP) {
830
+  while(analog2temp(minttemp_raw[2], 2) < HEATER_2_MINTEMP) {
714 831
 #if HEATER_2_RAW_LO_TEMP < HEATER_2_RAW_HI_TEMP
715 832
     minttemp_raw[2] += OVERSAMPLENR;
716 833
 #else
@@ -771,34 +888,34 @@ void disable_heater()
771 888
   for(int i=0;i<EXTRUDERS;i++)
772 889
     setTargetHotend(0,i);
773 890
   setTargetBed(0);
774
-  #if TEMP_0_PIN > -1
891
+  #if defined(TEMP_0_PIN) && TEMP_0_PIN > -1
775 892
   target_temperature[0]=0;
776 893
   soft_pwm[0]=0;
777
-   #if HEATER_0_PIN > -1  
894
+   #if defined(HEATER_0_PIN) && HEATER_0_PIN > -1  
778 895
      WRITE(HEATER_0_PIN,LOW);
779 896
    #endif
780 897
   #endif
781 898
      
782
-  #if TEMP_1_PIN > -1
899
+  #if defined(TEMP_1_PIN) && TEMP_1_PIN > -1
783 900
     target_temperature[1]=0;
784 901
     soft_pwm[1]=0;
785
-    #if HEATER_1_PIN > -1 
902
+    #if defined(HEATER_1_PIN) && HEATER_1_PIN > -1 
786 903
       WRITE(HEATER_1_PIN,LOW);
787 904
     #endif
788 905
   #endif
789 906
       
790
-  #if TEMP_2_PIN > -1
907
+  #if defined(TEMP_2_PIN) && TEMP_2_PIN > -1
791 908
     target_temperature[2]=0;
792 909
     soft_pwm[2]=0;
793
-    #if HEATER_2_PIN > -1  
910
+    #if defined(HEATER_2_PIN) && HEATER_2_PIN > -1  
794 911
       WRITE(HEATER_2_PIN,LOW);
795 912
     #endif
796 913
   #endif 
797 914
 
798
-  #if TEMP_BED_PIN > -1
915
+  #if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1
799 916
     target_temperature_bed=0;
800 917
     soft_pwm_bed=0;
801
-    #if HEATER_BED_PIN > -1  
918
+    #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1  
802 919
       WRITE(HEATER_BED_PIN,LOW);
803 920
     #endif
804 921
   #endif 
@@ -934,7 +1051,7 @@ ISR(TIMER0_COMPB_vect)
934 1051
     soft_pwm_2 = soft_pwm[2];
935 1052
     if(soft_pwm_2 > 0) WRITE(HEATER_2_PIN,1);
936 1053
     #endif
937
-    #if HEATER_BED_PIN > -1
1054
+    #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1
938 1055
     soft_pwm_b = soft_pwm_bed;
939 1056
     if(soft_pwm_b > 0) WRITE(HEATER_BED_PIN,1);
940 1057
     #endif
@@ -950,7 +1067,7 @@ ISR(TIMER0_COMPB_vect)
950 1067
   #if EXTRUDERS > 2
951 1068
   if(soft_pwm_2 <= pwm_count) WRITE(HEATER_2_PIN,0);
952 1069
   #endif
953
-  #if HEATER_BED_PIN > -1
1070
+  #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1
954 1071
   if(soft_pwm_b <= pwm_count) WRITE(HEATER_BED_PIN,0);
955 1072
   #endif
956 1073
   #ifdef FAN_SOFT_PWM
@@ -962,7 +1079,7 @@ ISR(TIMER0_COMPB_vect)
962 1079
   
963 1080
   switch(temp_state) {
964 1081
     case 0: // Prepare TEMP_0
965
-      #if (TEMP_0_PIN > -1)
1082
+      #if defined(TEMP_0_PIN) && (TEMP_0_PIN > -1)
966 1083
         #if TEMP_0_PIN > 7
967 1084
           ADCSRB = 1<<MUX5;
968 1085
         #else
@@ -975,7 +1092,7 @@ ISR(TIMER0_COMPB_vect)
975 1092
       temp_state = 1;
976 1093
       break;
977 1094
     case 1: // Measure TEMP_0
978
-      #if (TEMP_0_PIN > -1)
1095
+      #if defined(TEMP_0_PIN) && (TEMP_0_PIN > -1)
979 1096
         raw_temp_0_value += ADC;
980 1097
       #endif
981 1098
       #ifdef HEATER_0_USES_MAX6675 // TODO remove the blocking
@@ -984,7 +1101,7 @@ ISR(TIMER0_COMPB_vect)
984 1101
       temp_state = 2;
985 1102
       break;
986 1103
     case 2: // Prepare TEMP_BED
987
-      #if (TEMP_BED_PIN > -1)
1104
+      #if defined(TEMP_BED_PIN) && (TEMP_BED_PIN > -1)
988 1105
         #if TEMP_BED_PIN > 7
989 1106
           ADCSRB = 1<<MUX5;
990 1107
         #else
@@ -997,13 +1114,13 @@ ISR(TIMER0_COMPB_vect)
997 1114
       temp_state = 3;
998 1115
       break;
999 1116
     case 3: // Measure TEMP_BED
1000
-      #if (TEMP_BED_PIN > -1)
1117
+      #if defined(TEMP_BED_PIN) && (TEMP_BED_PIN > -1)
1001 1118
         raw_temp_bed_value += ADC;
1002 1119
       #endif
1003 1120
       temp_state = 4;
1004 1121
       break;
1005 1122
     case 4: // Prepare TEMP_1
1006
-      #if (TEMP_1_PIN > -1)
1123
+      #if defined(TEMP_1_PIN) && (TEMP_1_PIN > -1)
1007 1124
         #if TEMP_1_PIN > 7
1008 1125
           ADCSRB = 1<<MUX5;
1009 1126
         #else
@@ -1016,13 +1133,13 @@ ISR(TIMER0_COMPB_vect)
1016 1133
       temp_state = 5;
1017 1134
       break;
1018 1135
     case 5: // Measure TEMP_1
1019
-      #if (TEMP_1_PIN > -1)
1136
+      #if defined(TEMP_1_PIN) && (TEMP_1_PIN > -1)
1020 1137
         raw_temp_1_value += ADC;
1021 1138
       #endif
1022 1139
       temp_state = 6;
1023 1140
       break;
1024 1141
     case 6: // Prepare TEMP_2
1025
-      #if (TEMP_2_PIN > -1)
1142
+      #if defined(TEMP_2_PIN) && (TEMP_2_PIN > -1)
1026 1143
         #if TEMP_2_PIN > 7
1027 1144
           ADCSRB = 1<<MUX5;
1028 1145
         #else
@@ -1035,7 +1152,7 @@ ISR(TIMER0_COMPB_vect)
1035 1152
       temp_state = 7;
1036 1153
       break;
1037 1154
     case 7: // Measure TEMP_2
1038
-      #if (TEMP_2_PIN > -1)
1155
+      #if defined(TEMP_2_PIN) && (TEMP_2_PIN > -1)
1039 1156
         raw_temp_2_value += ADC;
1040 1157
       #endif
1041 1158
       temp_state = 0;
@@ -1055,6 +1172,9 @@ ISR(TIMER0_COMPB_vect)
1055 1172
 #if EXTRUDERS > 1
1056 1173
       current_temperature_raw[1] = raw_temp_1_value;
1057 1174
 #endif
1175
+#ifdef TEMP_SENSOR_1_AS_REDUNDANT
1176
+      redundant_temperature_raw = raw_temp_1_value;
1177
+#endif
1058 1178
 #if EXTRUDERS > 2
1059 1179
       current_temperature_raw[2] = raw_temp_2_value;
1060 1180
 #endif

+ 3
- 0
Marlin/temperature.h View File

@@ -37,6 +37,9 @@ extern int target_temperature[EXTRUDERS];
37 37
 extern float current_temperature[EXTRUDERS];
38 38
 extern int target_temperature_bed;
39 39
 extern float current_temperature_bed;
40
+#ifdef TEMP_SENSOR_1_AS_REDUNDANT
41
+  extern float redundant_temperature;
42
+#endif
40 43
 
41 44
 #ifdef PIDTEMP
42 45
   extern float Kp,Ki,Kd,Kc;

+ 156
- 33
Marlin/ultralcd.cpp View File

@@ -76,7 +76,14 @@ static void menu_action_setting_edit_callback_float51(const char* pstr, float* p
76 76
 static void menu_action_setting_edit_callback_float52(const char* pstr, float* ptr, float minValue, float maxValue, menuFunc_t callbackFunc);
77 77
 static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned long* ptr, unsigned long minValue, unsigned long maxValue, menuFunc_t callbackFunc);
78 78
 
79
-#define ENCODER_STEPS_PER_MENU_ITEM 5
79
+#define ENCODER_FEEDRATE_DEADZONE 10
80
+
81
+#if !defined(LCD_I2C_VIKI)
82
+  #define ENCODER_STEPS_PER_MENU_ITEM 5
83
+#else
84
+  #define ENCODER_STEPS_PER_MENU_ITEM 2 // VIKI LCD rotary encoder uses a different number of steps per rotation
85
+#endif
86
+
80 87
 
81 88
 /* Helper macros for menus */
82 89
 #define START_MENU() do { \
@@ -112,14 +119,18 @@ static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned l
112 119
     } } while(0)
113 120
 
114 121
 /** Used variables to keep track of the menu */
122
+#ifndef REPRAPWORLD_KEYPAD
115 123
 volatile uint8_t buttons;//Contains the bits of the currently pressed buttons.
124
+#else
125
+volatile uint16_t buttons;//Contains the bits of the currently pressed buttons (extended).
126
+#endif
116 127
 
117 128
 uint8_t currentMenuViewOffset;              /* scroll offset in the current menu */
118 129
 uint32_t blocking_enc;
119 130
 uint8_t lastEncoderBits;
120 131
 int8_t encoderDiff; /* encoderDiff is updated from interrupt context and added to encoderPosition every LCD update */
121 132
 uint32_t encoderPosition;
122
-#if (SDCARDDETECT > -1)
133
+#if (SDCARDDETECT > 0)
123 134
 bool lcd_oldcardstatus;
124 135
 #endif
125 136
 #endif//ULTIPANEL
@@ -157,10 +168,34 @@ static void lcd_status_screen()
157 168
     if (LCD_CLICKED)
158 169
     {
159 170
         currentMenu = lcd_main_menu;
171
+        encoderPosition = 0;
160 172
         lcd_quick_feedback();
161 173
     }
162
-    feedmultiply += int(encoderPosition);
163
-    encoderPosition = 0;
174
+
175
+    // Dead zone at 100% feedrate
176
+    if (feedmultiply < 100 && (feedmultiply + int(encoderPosition)) > 100 ||
177
+            feedmultiply > 100 && (feedmultiply + int(encoderPosition)) < 100)
178
+    {
179
+        encoderPosition = 0;
180
+        feedmultiply = 100;
181
+    }
182
+
183
+    if (feedmultiply == 100 && int(encoderPosition) > ENCODER_FEEDRATE_DEADZONE)
184
+    {
185
+        feedmultiply += int(encoderPosition) - ENCODER_FEEDRATE_DEADZONE;
186
+        encoderPosition = 0;
187
+    }
188
+    else if (feedmultiply == 100 && int(encoderPosition) < -ENCODER_FEEDRATE_DEADZONE)
189
+    {
190
+        feedmultiply += int(encoderPosition) + ENCODER_FEEDRATE_DEADZONE;
191
+        encoderPosition = 0;	
192
+    }
193
+    else if (feedmultiply != 100)
194
+    {
195
+        feedmultiply += int(encoderPosition);
196
+        encoderPosition = 0;
197
+    }
198
+
164 199
     if (feedmultiply < 10)
165 200
         feedmultiply = 10;
166 201
     if (feedmultiply > 999)
@@ -221,14 +256,14 @@ static void lcd_main_menu()
221 256
         }else{
222 257
             MENU_ITEM(submenu, MSG_CARD_MENU, lcd_sdcard_menu);
223 258
 #if SDCARDDETECT < 1
224
-			MENU_ITEM(gcode, MSG_CNG_SDCARD, PSTR("M21"));	// SD-card changed by user
225
-#endif			
259
+            MENU_ITEM(gcode, MSG_CNG_SDCARD, PSTR("M21"));  // SD-card changed by user
260
+#endif
226 261
         }
227 262
     }else{
228 263
         MENU_ITEM(submenu, MSG_NO_CARD, lcd_sdcard_menu);
229
-#if SDCARDDETECT < 1		
230
-		MENU_ITEM(gcode, MSG_INIT_SDCARD, PSTR("M21"));	// Manually initialize the SD-card via user interface
231
-#endif		
264
+#if SDCARDDETECT < 1
265
+        MENU_ITEM(gcode, MSG_INIT_SDCARD, PSTR("M21")); // Manually initialize the SD-card via user interface
266
+#endif
232 267
     }
233 268
 #endif
234 269
     END_MENU();
@@ -251,6 +286,7 @@ void lcd_preheat_pla()
251 286
     setTargetBed(plaPreheatHPBTemp);
252 287
     fanSpeed = plaPreheatFanSpeed;
253 288
     lcd_return_to_status();
289
+    setWatch(); // heater sanity check timer
254 290
 }
255 291
 
256 292
 void lcd_preheat_abs()
@@ -261,6 +297,16 @@ void lcd_preheat_abs()
261 297
     setTargetBed(absPreheatHPBTemp);
262 298
     fanSpeed = absPreheatFanSpeed;
263 299
     lcd_return_to_status();
300
+    setWatch(); // heater sanity check timer
301
+}
302
+
303
+static void lcd_cooldown()
304
+{
305
+    setTargetHotend0(0);
306
+    setTargetHotend1(0);
307
+    setTargetHotend2(0);
308
+    setTargetBed(0);
309
+    lcd_return_to_status();
264 310
 }
265 311
 
266 312
 static void lcd_tune_menu()
@@ -298,7 +344,7 @@ static void lcd_prepare_menu()
298 344
     //MENU_ITEM(gcode, MSG_SET_ORIGIN, PSTR("G92 X0 Y0 Z0"));
299 345
     MENU_ITEM(function, MSG_PREHEAT_PLA, lcd_preheat_pla);
300 346
     MENU_ITEM(function, MSG_PREHEAT_ABS, lcd_preheat_abs);
301
-    MENU_ITEM(gcode, MSG_COOLDOWN, PSTR("M104 S0\nM140 S0"));
347
+    MENU_ITEM(function, MSG_COOLDOWN, lcd_cooldown);
302 348
     MENU_ITEM(submenu, MSG_MOVE_AXIS, lcd_move_menu);
303 349
     END_MENU();
304 350
 }
@@ -459,10 +505,10 @@ static void lcd_control_menu()
459 505
 
460 506
 static void lcd_control_temperature_menu()
461 507
 {
462
-	// set up temp variables - undo the default scaling
463
-	raw_Ki = unscalePID_i(Ki);
464
-	raw_Kd = unscalePID_d(Kd);
465
-	
508
+    // set up temp variables - undo the default scaling
509
+    raw_Ki = unscalePID_i(Ki);
510
+    raw_Kd = unscalePID_d(Kd);
511
+
466 512
     START_MENU();
467 513
     MENU_ITEM(back, MSG_CONTROL, lcd_control_menu);
468 514
     MENU_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15);
@@ -484,7 +530,7 @@ static void lcd_control_temperature_menu()
484 530
 #endif
485 531
 #ifdef PIDTEMP
486 532
     MENU_ITEM_EDIT(float52, MSG_PID_P, &Kp, 1, 9990);
487
-	// i is typically a small value so allows values below 1
533
+    // i is typically a small value so allows values below 1
488 534
     MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I, &raw_Ki, 0.01, 9990, copy_and_scalePID_i);
489 535
     MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D, &raw_Kd, 1, 9990, copy_and_scalePID_d);
490 536
 # ifdef PID_ADD_EXTRUSION_RATE
@@ -687,6 +733,24 @@ menu_edit_type(float, float51, ftostr51, 10)
687 733
 menu_edit_type(float, float52, ftostr52, 100)
688 734
 menu_edit_type(unsigned long, long5, ftostr5, 0.01)
689 735
 
736
+#ifdef REPRAPWORLD_KEYPAD
737
+    static void reprapworld_keypad_move_y_down() {
738
+        encoderPosition = 1;
739
+        move_menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP;
740
+        lcd_move_y();
741
+    }
742
+    static void reprapworld_keypad_move_y_up() {
743
+        encoderPosition = -1;
744
+        move_menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP;
745
+        lcd_move_y();
746
+    }
747
+    static void reprapworld_keypad_move_home() {
748
+        //enquecommand_P((PSTR("G28"))); // move all axis home
749
+        // TODO gregor: move all axis home, i have currently only one axis on my prusa i3
750
+        enquecommand_P((PSTR("G28 Y")));
751
+    }
752
+#endif
753
+
690 754
 /** End of menus **/
691 755
 
692 756
 static void lcd_quick_feedback()
@@ -745,11 +809,20 @@ void lcd_init()
745 809
 #ifdef NEWPANEL
746 810
     pinMode(BTN_EN1,INPUT);
747 811
     pinMode(BTN_EN2,INPUT); 
748
-    pinMode(BTN_ENC,INPUT); 
749 812
     pinMode(SDCARDDETECT,INPUT);
750 813
     WRITE(BTN_EN1,HIGH);
751 814
     WRITE(BTN_EN2,HIGH);
815
+  #if BTN_ENC > 0
816
+    pinMode(BTN_ENC,INPUT); 
752 817
     WRITE(BTN_ENC,HIGH);
818
+  #endif    
819
+  #ifdef REPRAPWORLD_KEYPAD
820
+    pinMode(SHIFT_CLK,OUTPUT);
821
+    pinMode(SHIFT_LD,OUTPUT);
822
+    pinMode(SHIFT_OUT,INPUT);
823
+    WRITE(SHIFT_OUT,HIGH);
824
+    WRITE(SHIFT_LD,HIGH);
825
+  #endif
753 826
 #else
754 827
     pinMode(SHIFT_CLK,OUTPUT);
755 828
     pinMode(SHIFT_LD,OUTPUT);
@@ -759,12 +832,14 @@ void lcd_init()
759 832
     WRITE(SHIFT_LD,HIGH); 
760 833
     WRITE(SHIFT_EN,LOW);
761 834
 #endif//!NEWPANEL
762
-#if (SDCARDDETECT > -1)
835
+#if (SDCARDDETECT > 0)
763 836
     WRITE(SDCARDDETECT, HIGH);
764 837
     lcd_oldcardstatus = IS_SD_INSERTED;
765
-#endif//(SDCARDDETECT > -1)
838
+#endif//(SDCARDDETECT > 0)
766 839
     lcd_buttons_update();
840
+#ifdef ULTIPANEL    
767 841
     encoderDiff = 0;
842
+#endif    
768 843
 }
769 844
 
770 845
 void lcd_update()
@@ -773,7 +848,11 @@ void lcd_update()
773 848
     
774 849
     lcd_buttons_update();
775 850
     
776
-    #if (SDCARDDETECT > -1)
851
+    #ifdef LCD_HAS_SLOW_BUTTONS
852
+    buttons |= lcd_implementation_read_slow_buttons(); // buttons which take too long to read in interrupt context
853
+    #endif
854
+    
855
+    #if (SDCARDDETECT > 0)
777 856
     if((IS_SD_INSERTED != lcd_oldcardstatus))
778 857
     {
779 858
         lcdDrawUpdate = 2;
@@ -796,6 +875,17 @@ void lcd_update()
796 875
     if (lcd_next_update_millis < millis())
797 876
     {
798 877
 #ifdef ULTIPANEL
878
+        #ifdef REPRAPWORLD_KEYPAD
879
+        if (REPRAPWORLD_KEYPAD_MOVE_Y_DOWN) {
880
+            reprapworld_keypad_move_y_down();
881
+        }
882
+        if (REPRAPWORLD_KEYPAD_MOVE_Y_UP) {
883
+            reprapworld_keypad_move_y_up();
884
+        }
885
+        if (REPRAPWORLD_KEYPAD_MOVE_HOME) {
886
+            reprapworld_keypad_move_home();
887
+        }
888
+        #endif
799 889
         if (encoderDiff)
800 890
         {
801 891
             lcdDrawUpdate = 1;
@@ -808,21 +898,26 @@ void lcd_update()
808 898
 #endif//ULTIPANEL
809 899
 
810 900
 #ifdef DOGLCD        // Changes due to different driver architecture of the DOGM display
811
-		blink++;	   // Variable for fan animation and alive dot
812
-		u8g.firstPage();
813
-		do {
814
-				u8g.setFont(u8g_font_6x10_marlin);
815
-				u8g.setPrintPos(125,0);
816
-				if (blink % 2) u8g.setColorIndex(1); else u8g.setColorIndex(0); // Set color for the alive dot
817
-				u8g.drawPixel(127,63);	// draw alive dot
818
-				u8g.setColorIndex(1);	// black on white
819
-				(*currentMenu)();
820
-				if (!lcdDrawUpdate)  break; // Terminate display update, when nothing new to draw. This must be done before the last dogm.next()
821
-		   } while( u8g.nextPage() );
901
+        blink++;     // Variable for fan animation and alive dot
902
+        u8g.firstPage();
903
+        do 
904
+        {
905
+            u8g.setFont(u8g_font_6x10_marlin);
906
+            u8g.setPrintPos(125,0);
907
+            if (blink % 2) u8g.setColorIndex(1); else u8g.setColorIndex(0); // Set color for the alive dot
908
+            u8g.drawPixel(127,63); // draw alive dot
909
+            u8g.setColorIndex(1); // black on white
910
+            (*currentMenu)();
911
+            if (!lcdDrawUpdate)  break; // Terminate display update, when nothing new to draw. This must be done before the last dogm.next()
912
+        } while( u8g.nextPage() );
822 913
 #else        
823 914
         (*currentMenu)();
824 915
 #endif
825 916
 
917
+#ifdef LCD_HAS_STATUS_INDICATORS
918
+        lcd_implementation_update_indicators();
919
+#endif
920
+
826 921
 #ifdef ULTIPANEL
827 922
         if(timeoutToStatus < millis() && currentMenu != lcd_status_screen)
828 923
         {
@@ -873,8 +968,24 @@ void lcd_buttons_update()
873 968
     uint8_t newbutton=0;
874 969
     if(READ(BTN_EN1)==0)  newbutton|=EN_A;
875 970
     if(READ(BTN_EN2)==0)  newbutton|=EN_B;
971
+  #if BTN_ENC > 0
876 972
     if((blocking_enc<millis()) && (READ(BTN_ENC)==0))
877 973
         newbutton |= EN_C;
974
+  #endif      
975
+  #ifdef REPRAPWORLD_KEYPAD
976
+    // for the reprapworld_keypad
977
+    uint8_t newbutton_reprapworld_keypad=0;
978
+    WRITE(SHIFT_LD,LOW);
979
+    WRITE(SHIFT_LD,HIGH);
980
+    for(int8_t i=0;i<8;i++) {
981
+        newbutton_reprapworld_keypad = newbutton_reprapworld_keypad>>1;
982
+        if(READ(SHIFT_OUT))
983
+            newbutton_reprapworld_keypad|=(1<<7);
984
+        WRITE(SHIFT_CLK,HIGH);
985
+        WRITE(SHIFT_CLK,LOW);
986
+    }
987
+    newbutton |= ((~newbutton_reprapworld_keypad) << REPRAPWORLD_BTN_OFFSET); //invert it, because a pressed switch produces a logical 0
988
+  #endif
878 989
     buttons = newbutton;
879 990
 #else   //read it from the shift register
880 991
     uint8_t newbutton=0;
@@ -930,6 +1041,18 @@ void lcd_buttons_update()
930 1041
     }
931 1042
     lastEncoderBits = enc;
932 1043
 }
1044
+
1045
+void lcd_buzz(long duration, uint16_t freq)
1046
+{ 
1047
+#ifdef LCD_USE_I2C_BUZZER
1048
+  lcd.buzz(duration,freq);
1049
+#endif   
1050
+}
1051
+
1052
+bool lcd_clicked() 
1053
+{ 
1054
+  return LCD_CLICKED;
1055
+}
933 1056
 #endif//ULTIPANEL
934 1057
 
935 1058
 /********************************/
@@ -1131,7 +1254,7 @@ void copy_and_scalePID_i()
1131 1254
 {
1132 1255
   Ki = scalePID_i(raw_Ki);
1133 1256
   updatePID();
1134
-}	
1257
+}
1135 1258
 
1136 1259
 // Callback for after editing PID d value
1137 1260
 // grab the pid d value out of the temp variable; scale it; then update the PID driver
@@ -1139,6 +1262,6 @@ void copy_and_scalePID_d()
1139 1262
 {
1140 1263
   Kd = scalePID_d(raw_Kd);
1141 1264
   updatePID();
1142
-}	
1143
-	
1265
+}
1266
+
1144 1267
 #endif //ULTRA_LCD

+ 3
- 20
Marlin/ultralcd.h View File

@@ -22,7 +22,6 @@
22 22
 
23 23
   #ifdef ULTIPANEL
24 24
   void lcd_buttons_update();
25
-  extern volatile uint8_t buttons;  //the last checked buttons in a bit array.
26 25
   #else
27 26
   FORCE_INLINE void lcd_buttons_update() {}
28 27
   #endif
@@ -35,25 +34,8 @@
35 34
   extern int absPreheatHPBTemp;
36 35
   extern int absPreheatFanSpeed;
37 36
     
38
-  #ifdef NEWPANEL
39
-    #define EN_C (1<<BLEN_C)
40
-    #define EN_B (1<<BLEN_B)
41
-    #define EN_A (1<<BLEN_A)
42
-
43
-    #define LCD_CLICKED (buttons&EN_C)
44
-  #else
45
-    //atomatic, do not change
46
-    #define B_LE (1<<BL_LE)
47
-    #define B_UP (1<<BL_UP)
48
-    #define B_MI (1<<BL_MI)
49
-    #define B_DW (1<<BL_DW)
50
-    #define B_RI (1<<BL_RI)
51
-    #define B_ST (1<<BL_ST)
52
-    #define EN_B (1<<BLEN_B)
53
-    #define EN_A (1<<BLEN_A)
54
-    
55
-    #define LCD_CLICKED ((buttons&B_MI)||(buttons&B_ST))
56
-  #endif//NEWPANEL
37
+  void lcd_buzz(long duration,uint16_t freq);
38
+  bool lcd_clicked();
57 39
 
58 40
 #else //no lcd
59 41
   FORCE_INLINE void lcd_update() {}
@@ -61,6 +43,7 @@
61 43
   FORCE_INLINE void lcd_setstatus(const char* message) {}
62 44
   FORCE_INLINE void lcd_buttons_update() {}
63 45
   FORCE_INLINE void lcd_reset_alert_level() {}
46
+  FORCE_INLINE void lcd_buzz(long duration,uint16_t freq) {}
64 47
 
65 48
   #define LCD_MESSAGEPGM(x) 
66 49
   #define LCD_ALERTMESSAGEPGM(x) 

+ 260
- 24
Marlin/ultralcd_implementation_hitachi_HD44780.h View File

@@ -6,10 +6,11 @@
6 6
 * When selecting the rusian language, a slightly different LCD implementation is used to handle UTF8 characters.
7 7
 **/
8 8
 
9
-#if LANGUAGE_CHOICE == 6
10
-#include "LiquidCrystalRus.h"
11
-#define LCD_CLASS LiquidCrystalRus
9
+#ifndef REPRAPWORLD_KEYPAD
10
+extern volatile uint8_t buttons;  //the last checked buttons in a bit array.
12 11
 #else
12
+extern volatile uint16_t buttons;  //an extended version of the last checked buttons in a bit array.
13
+
13 14
   #ifdef  LCD_I2C_TYPE_PCA8574
14 15
     #include <LiquidCrystal_I2C.h>
15 16
     #define LCD_CLASS LiquidCrystal_I2C
@@ -19,6 +20,187 @@
19 20
   #endif
20 21
 #endif
21 22
 
23
+////////////////////////////////////
24
+// Setup button and encode mappings for each panel (into 'buttons' variable)
25
+//
26
+// This is just to map common functions (across different panels) onto the same 
27
+// macro name. The mapping is independent of whether the button is directly connected or 
28
+// via a shift/i2c register.
29
+
30
+#ifdef ULTIPANEL
31
+// All Ultipanels might have an encoder - so this is always be mapped onto first two bits
32
+#define BLEN_B 1
33
+#define BLEN_A 0
34
+
35
+#define EN_B (1<<BLEN_B) // The two encoder pins are connected through BTN_EN1 and BTN_EN2
36
+#define EN_A (1<<BLEN_A)
37
+
38
+#if defined(BTN_ENC) && BTN_ENC > -1
39
+  // encoder click is directly connected
40
+  #define BLEN_C 2 
41
+  #define EN_C (1<<BLEN_C) 
42
+#endif 
43
+  
44
+//
45
+// Setup other button mappings of each panel
46
+//
47
+#if defined(LCD_I2C_VIKI)
48
+  #define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
49
+  
50
+  // button and encoder bit positions within 'buttons'
51
+  #define B_LE (BUTTON_LEFT<<B_I2C_BTN_OFFSET)    // The remaining normalized buttons are all read via I2C
52
+  #define B_UP (BUTTON_UP<<B_I2C_BTN_OFFSET)
53
+  #define B_MI (BUTTON_SELECT<<B_I2C_BTN_OFFSET)
54
+  #define B_DW (BUTTON_DOWN<<B_I2C_BTN_OFFSET)
55
+  #define B_RI (BUTTON_RIGHT<<B_I2C_BTN_OFFSET)
56
+
57
+  #if defined(BTN_ENC) && BTN_ENC > -1 
58
+    // the pause/stop/restart button is connected to BTN_ENC when used
59
+    #define B_ST (EN_C)                            // Map the pause/stop/resume button into its normalized functional name 
60
+    #define LCD_CLICKED (buttons&(B_MI|B_RI|B_ST)) // pause/stop button also acts as click until we implement proper pause/stop.
61
+  #else
62
+    #define LCD_CLICKED (buttons&(B_MI|B_RI))
63
+  #endif  
64
+
65
+  // I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update
66
+  #define LCD_HAS_SLOW_BUTTONS
67
+
68
+#elif defined(LCD_I2C_PANELOLU2)
69
+  // encoder click can be read through I2C if not directly connected
70
+  #if BTN_ENC <= 0 
71
+    #define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
72
+  
73
+    #define B_MI (PANELOLU2_ENCODER_C<<B_I2C_BTN_OFFSET) // requires LiquidTWI2 library v1.2.3 or later
74
+
75
+    #define LCD_CLICKED (buttons&B_MI)
76
+
77
+    // I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update
78
+    #define LCD_HAS_SLOW_BUTTONS
79
+  #else
80
+    #define LCD_CLICKED (buttons&EN_C)  
81
+  #endif
82
+
83
+#elif defined(REPRAPWORLD_KEYPAD)
84
+    // define register bit values, don't change it
85
+    #define BLEN_REPRAPWORLD_KEYPAD_F3 0
86
+    #define BLEN_REPRAPWORLD_KEYPAD_F2 1
87
+    #define BLEN_REPRAPWORLD_KEYPAD_F1 2
88
+    #define BLEN_REPRAPWORLD_KEYPAD_UP 3
89
+    #define BLEN_REPRAPWORLD_KEYPAD_RIGHT 4
90
+    #define BLEN_REPRAPWORLD_KEYPAD_MIDDLE 5
91
+    #define BLEN_REPRAPWORLD_KEYPAD_DOWN 6
92
+    #define BLEN_REPRAPWORLD_KEYPAD_LEFT 7
93
+    
94
+    #define REPRAPWORLD_BTN_OFFSET 3 // bit offset into buttons for shift register values
95
+
96
+    #define EN_REPRAPWORLD_KEYPAD_F3 (1<<(BLEN_REPRAPWORLD_KEYPAD_F3+REPRAPWORLD_BTN_OFFSET))
97
+    #define EN_REPRAPWORLD_KEYPAD_F2 (1<<(BLEN_REPRAPWORLD_KEYPAD_F2+REPRAPWORLD_BTN_OFFSET))
98
+    #define EN_REPRAPWORLD_KEYPAD_F1 (1<<(BLEN_REPRAPWORLD_KEYPAD_F1+REPRAPWORLD_BTN_OFFSET))
99
+    #define EN_REPRAPWORLD_KEYPAD_UP (1<<(BLEN_REPRAPWORLD_KEYPAD_UP+REPRAPWORLD_BTN_OFFSET))
100
+    #define EN_REPRAPWORLD_KEYPAD_RIGHT (1<<(BLEN_REPRAPWORLD_KEYPAD_RIGHT+REPRAPWORLD_BTN_OFFSET))
101
+    #define EN_REPRAPWORLD_KEYPAD_MIDDLE (1<<(BLEN_REPRAPWORLD_KEYPAD_MIDDLE+REPRAPWORLD_BTN_OFFSET))
102
+    #define EN_REPRAPWORLD_KEYPAD_DOWN (1<<(BLEN_REPRAPWORLD_KEYPAD_DOWN+REPRAPWORLD_BTN_OFFSET))
103
+    #define EN_REPRAPWORLD_KEYPAD_LEFT (1<<(BLEN_REPRAPWORLD_KEYPAD_LEFT+REPRAPWORLD_BTN_OFFSET))
104
+
105
+    #define LCD_CLICKED ((buttons&EN_C) || (buttons&EN_REPRAPWORLD_KEYPAD_F1))
106
+    #define REPRAPWORLD_KEYPAD_MOVE_Y_DOWN (buttons&EN_REPRAPWORLD_KEYPAD_DOWN)
107
+    #define REPRAPWORLD_KEYPAD_MOVE_Y_UP (buttons&EN_REPRAPWORLD_KEYPAD_UP)
108
+    #define REPRAPWORLD_KEYPAD_MOVE_HOME (buttons&EN_REPRAPWORLD_KEYPAD_MIDDLE)
109
+
110
+#elif defined(NEWPANEL)
111
+  #define LCD_CLICKED (buttons&EN_C)
112
+  
113
+#else // old style ULTIPANEL
114
+  //bits in the shift register that carry the buttons for:
115
+  // left up center down right red(stop)
116
+  #define BL_LE 7
117
+  #define BL_UP 6
118
+  #define BL_MI 5
119
+  #define BL_DW 4
120
+  #define BL_RI 3
121
+  #define BL_ST 2
122
+
123
+  //automatic, do not change
124
+  #define B_LE (1<<BL_LE)
125
+  #define B_UP (1<<BL_UP)
126
+  #define B_MI (1<<BL_MI)
127
+  #define B_DW (1<<BL_DW)
128
+  #define B_RI (1<<BL_RI)
129
+  #define B_ST (1<<BL_ST)
130
+  
131
+  #define LCD_CLICKED (buttons&(B_MI|B_ST))
132
+#endif
133
+
134
+////////////////////////
135
+// Setup Rotary Encoder Bit Values (for two pin encoders to indicate movement)
136
+// These values are independent of which pins are used for EN_A and EN_B indications
137
+// The rotary encoder part is also independent to the chipset used for the LCD
138
+#if defined(EN_A) && defined(EN_B)
139
+  #ifndef ULTIMAKERCONTROLLER
140
+    #define encrot0 0
141
+    #define encrot1 2
142
+    #define encrot2 3
143
+    #define encrot3 1
144
+  #else
145
+    #define encrot0 0
146
+    #define encrot1 1
147
+    #define encrot2 3
148
+    #define encrot3 2
149
+  #endif
150
+#endif 
151
+
152
+#endif //ULTIPANEL
153
+
154
+////////////////////////////////////
155
+// Create LCD class instance and chipset-specific information
156
+#if defined(LCD_I2C_TYPE_PCF8575)
157
+  // note: these are register mapped pins on the PCF8575 controller not Arduino pins
158
+  #define LCD_I2C_PIN_BL  3
159
+  #define LCD_I2C_PIN_EN  2
160
+  #define LCD_I2C_PIN_RW  1
161
+  #define LCD_I2C_PIN_RS  0
162
+  #define LCD_I2C_PIN_D4  4
163
+  #define LCD_I2C_PIN_D5  5
164
+  #define LCD_I2C_PIN_D6  6
165
+  #define LCD_I2C_PIN_D7  7
166
+
167
+  #include <Wire.h>
168
+  #include <LCD.h>
169
+  #include <LiquidCrystal_I2C.h>
170
+  #define LCD_CLASS LiquidCrystal_I2C
171
+  LCD_CLASS lcd(LCD_I2C_ADDRESS,LCD_I2C_PIN_EN,LCD_I2C_PIN_RW,LCD_I2C_PIN_RS,LCD_I2C_PIN_D4,LCD_I2C_PIN_D5,LCD_I2C_PIN_D6,LCD_I2C_PIN_D7);
172
+  
173
+#elif defined(LCD_I2C_TYPE_MCP23017)
174
+  //for the LED indicators (which maybe mapped to different things in lcd_implementation_update_indicators())
175
+  #define LED_A 0x04 //100
176
+  #define LED_B 0x02 //010
177
+  #define LED_C 0x01 //001
178
+
179
+  #define LCD_HAS_STATUS_INDICATORS
180
+
181
+  #include <Wire.h>
182
+  #include <LiquidTWI2.h>
183
+  #define LCD_CLASS LiquidTWI2
184
+  LCD_CLASS lcd(LCD_I2C_ADDRESS);
185
+  
186
+#elif defined(LCD_I2C_TYPE_MCP23008)
187
+  #include <Wire.h>
188
+  #include <LiquidTWI2.h>
189
+  #define LCD_CLASS LiquidTWI2
190
+  LCD_CLASS lcd(LCD_I2C_ADDRESS);  
191
+  
192
+#else
193
+  // Standard directly connected LCD implementations
194
+  #if LANGUAGE_CHOICE == 6
195
+    #include "LiquidCrystalRus.h"
196
+    #define LCD_CLASS LiquidCrystalRus
197
+  #else 
198
+    #include <LiquidCrystal.h>
199
+    #define LCD_CLASS LiquidCrystal
200
+  #endif  
201
+  LCD_CLASS lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7);  //RS,Enable,D4,D5,D6,D7
202
+#endif
203
+
22 204
 /* Custom characters defined in the first 8 characters of the LCD */
23 205
 #define LCD_STR_BEDTEMP     "\x00"
24 206
 #define LCD_STR_DEGREE      "\x01"
@@ -125,8 +307,27 @@ static void lcd_implementation_init()
125 307
       lcd.init();
126 308
       lcd.backlight();
127 309
     #else
128
-      lcd.begin(LCD_WIDTH, LCD_HEIGHT);
310
+	  if defined(LCDI2C_TYPE_PCF8575)
311
+        lcd.begin(LCD_WIDTH, LCD_HEIGHT);
129 312
     #endif
313
+  #ifdef LCD_I2C_PIN_BL
314
+    lcd.setBacklightPin(LCD_I2C_PIN_BL,POSITIVE);
315
+    lcd.setBacklight(HIGH);
316
+  #endif
317
+  
318
+#elif defined(LCD_I2C_TYPE_MCP23017)
319
+    lcd.setMCPType(LTI_TYPE_MCP23017);
320
+    lcd.begin(LCD_WIDTH, LCD_HEIGHT);
321
+    lcd.setBacklight(0); //set all the LEDs off to begin with
322
+    
323
+#elif defined(LCD_I2C_TYPE_MCP23008)
324
+    lcd.setMCPType(LTI_TYPE_MCP23008);
325
+    lcd.begin(LCD_WIDTH, LCD_HEIGHT);
326
+    
327
+#else
328
+    lcd.begin(LCD_WIDTH, LCD_HEIGHT);
329
+#endif
330
+
130 331
     lcd.createChar(LCD_STR_BEDTEMP[0], bedTemp);
131 332
     lcd.createChar(LCD_STR_DEGREE[0], degree);
132 333
     lcd.createChar(LCD_STR_THERMOMETER[0], thermometer);
@@ -314,13 +515,13 @@ static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, c
314 515
     char c;
315 516
     //Use all characters in narrow LCDs
316 517
   #if LCD_WIDTH < 20
317
-    	uint8_t n = LCD_WIDTH - 1 - 1;
518
+      uint8_t n = LCD_WIDTH - 1 - 1;
318 519
     #else
319
-    	uint8_t n = LCD_WIDTH - 1 - 2;
520
+      uint8_t n = LCD_WIDTH - 1 - 2;
320 521
   #endif
321 522
     lcd.setCursor(0, row);
322 523
     lcd.print(pre_char);
323
-    while((c = pgm_read_byte(pstr)) != '\0')
524
+    while( ((c = pgm_read_byte(pstr)) != '\0') && (n>0) )
324 525
     {
325 526
         lcd.print(c);
326 527
         pstr++;
@@ -336,13 +537,13 @@ static void lcd_implementation_drawmenu_setting_edit_generic(uint8_t row, const
336 537
     char c;
337 538
     //Use all characters in narrow LCDs
338 539
   #if LCD_WIDTH < 20
339
-    	uint8_t n = LCD_WIDTH - 1 - 1 - strlen(data);
540
+      uint8_t n = LCD_WIDTH - 1 - 1 - strlen(data);
340 541
     #else
341
-    	uint8_t n = LCD_WIDTH - 1 - 2 - strlen(data);
542
+      uint8_t n = LCD_WIDTH - 1 - 2 - strlen(data);
342 543
   #endif
343 544
     lcd.setCursor(0, row);
344 545
     lcd.print(pre_char);
345
-    while((c = pgm_read_byte(pstr)) != '\0')
546
+    while( ((c = pgm_read_byte(pstr)) != '\0') && (n>0) )
346 547
     {
347 548
         lcd.print(c);
348 549
         pstr++;
@@ -358,13 +559,13 @@ static void lcd_implementation_drawmenu_setting_edit_generic_P(uint8_t row, cons
358 559
     char c;
359 560
     //Use all characters in narrow LCDs
360 561
   #if LCD_WIDTH < 20
361
-    	uint8_t n = LCD_WIDTH - 1 - 1 - strlen_P(data);
562
+      uint8_t n = LCD_WIDTH - 1 - 1 - strlen_P(data);
362 563
     #else
363
-    	uint8_t n = LCD_WIDTH - 1 - 2 - strlen_P(data);
564
+      uint8_t n = LCD_WIDTH - 1 - 2 - strlen_P(data);
364 565
   #endif
365 566
     lcd.setCursor(0, row);
366 567
     lcd.print(pre_char);
367
-    while((c = pgm_read_byte(pstr)) != '\0')
568
+    while( ((c = pgm_read_byte(pstr)) != '\0') && (n>0) )
368 569
     {
369 570
         lcd.print(c);
370 571
         pstr++;
@@ -417,9 +618,9 @@ void lcd_implementation_drawedit(const char* pstr, char* value)
417 618
     lcd_printPGM(pstr);
418 619
     lcd.print(':');
419 620
    #if LCD_WIDTH < 20
420
-    	lcd.setCursor(LCD_WIDTH - strlen(value), 1);
621
+      lcd.setCursor(LCD_WIDTH - strlen(value), 1);
421 622
     #else
422
-    	lcd.setCursor(LCD_WIDTH -1 - strlen(value), 1);
623
+      lcd.setCursor(LCD_WIDTH -1 - strlen(value), 1);
423 624
    #endif
424 625
     lcd.print(value);
425 626
 }
@@ -434,7 +635,7 @@ static void lcd_implementation_drawmenu_sdfile_selected(uint8_t row, const char*
434 635
         filename = longFilename;
435 636
         longFilename[LCD_WIDTH-1] = '\0';
436 637
     }
437
-    while((c = *filename) != '\0')
638
+    while( ((c = *filename) != '\0') && (n>0) )
438 639
     {
439 640
         lcd.print(c);
440 641
         filename++;
@@ -454,7 +655,7 @@ static void lcd_implementation_drawmenu_sdfile(uint8_t row, const char* pstr, co
454 655
         filename = longFilename;
455 656
         longFilename[LCD_WIDTH-1] = '\0';
456 657
     }
457
-    while((c = *filename) != '\0')
658
+    while( ((c = *filename) != '\0') && (n>0) )
458 659
     {
459 660
         lcd.print(c);
460 661
         filename++;
@@ -475,7 +676,7 @@ static void lcd_implementation_drawmenu_sddirectory_selected(uint8_t row, const
475 676
         filename = longFilename;
476 677
         longFilename[LCD_WIDTH-2] = '\0';
477 678
     }
478
-    while((c = *filename) != '\0')
679
+    while( ((c = *filename) != '\0') && (n>0) )
479 680
     {
480 681
         lcd.print(c);
481 682
         filename++;
@@ -496,7 +697,7 @@ static void lcd_implementation_drawmenu_sddirectory(uint8_t row, const char* pst
496 697
         filename = longFilename;
497 698
         longFilename[LCD_WIDTH-2] = '\0';
498 699
     }
499
-    while((c = *filename) != '\0')
700
+    while( ((c = *filename) != '\0') && (n>0) )
500 701
     {
501 702
         lcd.print(c);
502 703
         filename++;
@@ -516,15 +717,50 @@ static void lcd_implementation_drawmenu_sddirectory(uint8_t row, const char* pst
516 717
 
517 718
 static void lcd_implementation_quick_feedback()
518 719
 {
519
-#if BEEPER > -1
720
+#ifdef LCD_USE_I2C_BUZZER
721
+    lcd.buzz(60,1000/6);
722
+#elif defined(BEEPER) && BEEPER > -1
520 723
     SET_OUTPUT(BEEPER);
521 724
     for(int8_t i=0;i<10;i++)
522 725
     {
523
-		WRITE(BEEPER,HIGH);
524
-		delay(3);
525
-		WRITE(BEEPER,LOW);
526
-		delay(3);
726
+      WRITE(BEEPER,HIGH);
727
+      delay(3);
728
+      WRITE(BEEPER,LOW);
729
+      delay(3);
730
+    }
731
+#endif
732
+}
733
+
734
+#ifdef LCD_HAS_STATUS_INDICATORS
735
+static void lcd_implementation_update_indicators()
736
+{
737
+  #if defined(LCD_I2C_PANELOLU2) || defined(LCD_I2C_VIKI)
738
+    //set the LEDS - referred to as backlights by the LiquidTWI2 library 
739
+    static uint8_t ledsprev = 0;
740
+    uint8_t leds = 0;
741
+    if (target_temperature_bed > 0) leds |= LED_A;
742
+    if (target_temperature[0] > 0) leds |= LED_B;
743
+    if (fanSpeed) leds |= LED_C;
744
+    #if EXTRUDERS > 1  
745
+      if (target_temperature[1] > 0) leds |= LED_C;
746
+    #endif
747
+    if (leds != ledsprev) {
748
+      lcd.setBacklight(leds);
749
+      ledsprev = leds;
527 750
     }
751
+  #endif
752
+}
528 753
 #endif
754
+
755
+#ifdef LCD_HAS_SLOW_BUTTONS
756
+static uint8_t lcd_implementation_read_slow_buttons()
757
+{
758
+  #ifdef LCD_I2C_TYPE_MCP23017
759
+    // Reading these buttons this is likely to be too slow to call inside interrupt context
760
+    // so they are called during normal lcd_update
761
+    return lcd.readButtons() << B_I2C_BTN_OFFSET; 
762
+  #endif
529 763
 }
764
+#endif
765
+
530 766
 #endif//ULTRA_LCD_IMPLEMENTATION_HITACHI_HD44780_H

+ 131
- 0
Marlin/ultralcd_st7920_u8glib_rrd.h View File

@@ -0,0 +1,131 @@
1
+#ifndef ULCDST7920_H
2
+#define ULCDST7920_H
3
+
4
+#include "Marlin.h"
5
+
6
+#ifdef U8GLIB_ST7920
7
+
8
+//set optimization so ARDUINO optimizes this file
9
+#pragma GCC optimize (3)
10
+
11
+#define ST7920_CLK_PIN  LCD_PINS_D4
12
+#define ST7920_DAT_PIN  LCD_PINS_ENABLE
13
+#define ST7920_CS_PIN   LCD_PINS_RS
14
+
15
+//#define PAGE_HEIGHT 8   //128 byte frambuffer
16
+//#define PAGE_HEIGHT 16  //256 byte frambuffer
17
+#define PAGE_HEIGHT 32  //512 byte framebuffer
18
+
19
+#define WIDTH 128
20
+#define HEIGHT 64
21
+
22
+#include <U8glib.h>
23
+
24
+static void ST7920_SWSPI_SND_8BIT(uint8_t val)
25
+{
26
+  uint8_t i;
27
+  for( i=0; i<8; i++ )
28
+  {
29
+    WRITE(ST7920_CLK_PIN,0);
30
+    WRITE(ST7920_DAT_PIN,val&0x80); 
31
+    val<<=1;
32
+    WRITE(ST7920_CLK_PIN,1);
33
+  }
34
+}
35
+
36
+#define ST7920_CS()              {WRITE(ST7920_CS_PIN,1);u8g_10MicroDelay();}
37
+#define ST7920_NCS()             {WRITE(ST7920_CS_PIN,0);}
38
+#define ST7920_SET_CMD()         {ST7920_SWSPI_SND_8BIT(0xf8);u8g_10MicroDelay();}
39
+#define ST7920_SET_DAT()         {ST7920_SWSPI_SND_8BIT(0xfa);u8g_10MicroDelay();}
40
+#define ST7920_WRITE_BYTE(a)     {ST7920_SWSPI_SND_8BIT((a)&0xf0);ST7920_SWSPI_SND_8BIT((a)<<4);u8g_10MicroDelay();}
41
+#define ST7920_WRITE_BYTES(p,l)  {uint8_t i;for(i=0;i<l;i++){ST7920_SWSPI_SND_8BIT(*p&0xf0);ST7920_SWSPI_SND_8BIT(*p<<4);p++;}u8g_10MicroDelay();}
42
+
43
+uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
44
+{
45
+  uint8_t i,y;
46
+  switch(msg)
47
+  {
48
+    case U8G_DEV_MSG_INIT:
49
+      {
50
+        SET_OUTPUT(ST7920_CS_PIN);
51
+        WRITE(ST7920_CS_PIN,0);
52
+        SET_OUTPUT(ST7920_DAT_PIN);
53
+        WRITE(ST7920_DAT_PIN,0);
54
+        SET_OUTPUT(ST7920_CLK_PIN);
55
+        WRITE(ST7920_CLK_PIN,1);
56
+
57
+        ST7920_CS();
58
+        u8g_Delay(90);                 //initial delay for boot up
59
+        ST7920_SET_CMD();
60
+        ST7920_WRITE_BYTE(0x08);       //display off, cursor+blink off
61
+        ST7920_WRITE_BYTE(0x01);       //clear CGRAM ram
62
+        u8g_Delay(10);                 //delay for cgram clear
63
+        ST7920_WRITE_BYTE(0x3E);       //extended mode + gdram active
64
+        for(y=0;y<HEIGHT/2;y++)        //clear GDRAM
65
+        {
66
+          ST7920_WRITE_BYTE(0x80|y);   //set y
67
+          ST7920_WRITE_BYTE(0x80);     //set x = 0
68
+          ST7920_SET_DAT();
69
+          for(i=0;i<2*WIDTH/8;i++)     //2x width clears both segments
70
+            ST7920_WRITE_BYTE(0);
71
+          ST7920_SET_CMD();
72
+        }
73
+        ST7920_WRITE_BYTE(0x0C); //display on, cursor+blink off
74
+        ST7920_NCS();
75
+      }
76
+      break;
77
+
78
+    case U8G_DEV_MSG_STOP:
79
+      break;
80
+    case U8G_DEV_MSG_PAGE_NEXT:
81
+      {
82
+        uint8_t *ptr;
83
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
84
+        y = pb->p.page_y0;
85
+        ptr = (uint8_t*)pb->buf;
86
+
87
+        ST7920_CS();
88
+        for( i = 0; i < PAGE_HEIGHT; i ++ )
89
+        {
90
+          ST7920_SET_CMD();
91
+          if ( y < 32 )
92
+          {
93
+            ST7920_WRITE_BYTE(0x80 | y);       //y
94
+            ST7920_WRITE_BYTE(0x80);           //x=0
95
+          }
96
+          else
97
+          {
98
+            ST7920_WRITE_BYTE(0x80 | (y-32));  //y
99
+            ST7920_WRITE_BYTE(0x80 | 8);       //x=64
100
+          }
101
+
102
+          ST7920_SET_DAT();
103
+          ST7920_WRITE_BYTES(ptr,WIDTH/8); //ptr is incremented inside of macro
104
+          y++;
105
+        }
106
+        ST7920_NCS();
107
+      }
108
+      break;
109
+  }
110
+#if PAGE_HEIGHT == 8
111
+  return u8g_dev_pb8h1_base_fn(u8g, dev, msg, arg);
112
+#elif PAGE_HEIGHT == 16
113
+  return u8g_dev_pb16h1_base_fn(u8g, dev, msg, arg);
114
+#else
115
+  return u8g_dev_pb32h1_base_fn(u8g, dev, msg, arg);
116
+#endif
117
+}
118
+
119
+uint8_t   u8g_dev_st7920_128x64_rrd_buf[WIDTH*(PAGE_HEIGHT/8)] U8G_NOCOMMON;
120
+u8g_pb_t  u8g_dev_st7920_128x64_rrd_pb = {{PAGE_HEIGHT,HEIGHT,0,0,0},WIDTH,u8g_dev_st7920_128x64_rrd_buf};
121
+u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi = {u8g_dev_rrd_st7920_128x64_fn,&u8g_dev_st7920_128x64_rrd_pb,&u8g_com_null_fn};
122
+
123
+class U8GLIB_ST7920_128X64_RRD : public U8GLIB
124
+{
125
+  public:
126
+    U8GLIB_ST7920_128X64_RRD(uint8_t dummy) : U8GLIB(&u8g_dev_st7920_128x64_rrd_sw_spi) {}
127
+};
128
+
129
+
130
+#endif //U8GLIB_ST7920
131
+#endif //ULCDST7920_H

+ 249
- 223
README.md View File

@@ -1,223 +1,249 @@
1
-WARNING: 
2
---------
3
-THIS IS RELEASE CANDIDATE 2 FOR MARLIN 1.0.0
4
-
5
-The configuration is now split in two files
6
-Configuration.h for the normal settings
7
-Configuration_adv.h for the advanced settings
8
-
9
-Gen7T is not supported.
10
-
11
-Quick Information
12
-===================
13
-This RepRap firmware is a mashup between <a href="https://github.com/kliment/Sprinter">Sprinter</a>, <a href="https://github.com/simen/grbl/tree">grbl</a> and many original parts.
14
-
15
-Derived from Sprinter and Grbl by Erik van der Zalm.
16
-Sprinters lead developers are Kliment and caru.
17
-Grbls lead developer is Simen Svale Skogsrud. Sonney Jeon (Chamnit) improved some parts of grbl
18
-A fork by bkubicek for the Ultimaker was merged, and further development was aided by him.
19
-Some features have been added by:
20
-Lampmaker, Bradley Feldman, and others...
21
-
22
-
23
-Features:
24
-
25
-*   Interrupt based movement with real linear acceleration
26
-*   High steprate
27
-*   Look ahead (Keep the speed high when possible. High cornering speed)
28
-*   Interrupt based temperature protection
29
-*   preliminary support for Matthew Roberts advance algorithm 
30
-    For more info see: http://reprap.org/pipermail/reprap-dev/2011-May/003323.html
31
-*   Full endstop support
32
-*   SD Card support
33
-*   SD Card folders (works in pronterface)
34
-*   SD Card autostart support
35
-*   LCD support (ideally 20x4) 
36
-*   LCD menu system for autonomous SD card printing, controlled by an click-encoder. 
37
-*   EEPROM storage of e.g. max-velocity, max-acceleration, and similar variables
38
-*   many small but handy things originating from bkubicek's fork.
39
-*   Arc support
40
-*   Temperature oversampling
41
-*   Dynamic Temperature setpointing aka "AutoTemp"
42
-*   Support for QTMarlin, a very beta GUI for PID-tuning and velocity-acceleration testing. https://github.com/bkubicek/QTMarlin
43
-*   Endstop trigger reporting to the host software.
44
-*   Updated sdcardlib
45
-*   Heater power reporting. Useful for PID monitoring.
46
-*   PID tuning
47
-*   CoreXY kinematics (www.corexy.com/theory.html)
48
-*   Configurable serial port to support connection of wireless adaptors.
49
-
50
-The default baudrate is 250000. This baudrate has less jitter and hence errors than the usual 115200 baud, but is less supported by drivers and host-environments.
51
-
52
-
53
-Differences and additions to the already good Sprinter firmware:
54
-================================================================
55
-
56
-*Look-ahead:*
57
-
58
-Marlin has look-ahead. While sprinter has to break and re-accelerate at each corner, 
59
-lookahead will only decelerate and accelerate to a velocity, 
60
-so that the change in vectorial velocity magnitude is less than the xy_jerk_velocity.
61
-This is only possible, if some future moves are already processed, hence the name. 
62
-It leads to less over-deposition at corners, especially at flat angles.
63
-
64
-*Arc support:*
65
-
66
-Slic3r can find curves that, although broken into segments, were ment to describe an arc.
67
-Marlin is able to print those arcs. The advantage is the firmware can choose the resolution,
68
-and can perform the arc with nearly constant velocity, resulting in a nice finish. 
69
-Also, less serial communication is needed.
70
-
71
-*Temperature Oversampling:*
72
-
73
-To reduce noise and make the PID-differential term more useful, 16 ADC conversion results are averaged.
74
-
75
-*AutoTemp:*
76
-
77
-If your gcode contains a wide spread of extruder velocities, or you realtime change the building speed, the temperature should be changed accordingly.
78
-Usually, higher speed requires higher temperature.
79
-This can now be performed by the AutoTemp function
80
-By calling M109 S<mintemp> T<maxtemp> F<factor> you enter the autotemp mode.
81
-
82
-You can leave it by calling M109 without any F.
83
-If active, the maximal extruder stepper rate of all buffered moves will be calculated, and named "maxerate" [steps/sec].
84
-The wanted temperature then will be set to t=tempmin+factor*maxerate, while being limited between tempmin and tempmax.
85
-If the target temperature is set manually or by gcode to a value less then tempmin, it will be kept without change.
86
-Ideally, your gcode can be completely free of temperature controls, apart from a M109 S T F in the start.gcode, and a M109 S0 in the end.gcode.
87
-
88
-*EEPROM:*
89
-
90
-If you know your PID values, the acceleration and max-velocities of your unique machine, you can set them, and finally store them in the EEPROM.
91
-After each reboot, it will magically load them from EEPROM, independent what your Configuration.h says.
92
-
93
-*LCD Menu:*
94
-
95
-If your hardware supports it, you can build yourself a LCD-CardReader+Click+encoder combination. It will enable you to realtime tune temperatures,
96
-accelerations, velocities, flow rates, select and print files from the SD card, preheat, disable the steppers, and do other fancy stuff.
97
-One working hardware is documented here: http://www.thingiverse.com/thing:12663 
98
-Also, with just a 20x4 or 16x2 display, useful data is shown.
99
-
100
-*SD card folders:*
101
-
102
-If you have an SD card reader attached to your controller, also folders work now. Listing the files in pronterface will show "/path/subpath/file.g".
103
-You can write to file in a subfolder by specifying a similar text using small letters in the path.
104
-Also, backup copies of various operating systems are hidden, as well as files not ending with ".g".
105
-
106
-*SD card folders:*
107
-
108
-If you place a file auto[0-9].g into the root of the sd card, it will be automatically executed if you boot the printer. The same file will be executed by selecting "Autostart" from the menu.
109
-First *0 will be performed, than *1 and so on. That way, you can heat up or even print automatically without user interaction.
110
-
111
-*Endstop trigger reporting:*
112
-
113
-If an endstop is hit while moving towards the endstop, the location at which the firmware thinks that the endstop was triggered is outputed on the serial port.
114
-This is useful, because the user gets a warning message.
115
-However, also tools like QTMarlin can use this for finding acceptable combinations of velocity+acceleration.
116
-
117
-*Coding paradigm:*
118
-
119
-Not relevant from a user side, but Marlin was split into thematic junks, and has tried to partially enforced private variables.
120
-This is intended to make it clearer, what interacts which what, and leads to a higher level of modularization.
121
-We think that this is a useful prestep for porting this firmware to e.g. an ARM platform in the future.
122
-A lot of RAM (with enabled LCD ~2200 bytes) was saved by storing char []="some message" in Program memory.
123
-In the serial communication, a #define based level of abstraction was enforced, so that it is clear that
124
-some transfer is information (usually beginning with "echo:"), an error "error:", or just normal protocol,
125
-necessary for backwards compatibility.
126
-
127
-*Interrupt based temperature measurements:*
128
-
129
-An interrupt is used to manage ADC conversions, and enforce checking for critical temperatures.
130
-This leads to less blocking in the heater management routine.
131
-
132
-
133
-Non-standard M-Codes, different to an old version of sprinter:
134
-==============================================================
135
-Movement:
136
-
137
-*   G2  - CW ARC
138
-*   G3  - CCW ARC
139
-
140
-General:
141
-
142
-*   M17  - Enable/Power all stepper motors. Compatibility to ReplicatorG.
143
-*   M18  - Disable all stepper motors; same as M84.Compatibility to ReplicatorG.
144
-*   M30  - Print time since last M109 or SD card start to serial
145
-*   M42  - Change pin status via gcode
146
-*   M80  - Turn on Power Supply
147
-*   M81  - Turn off Power Supply
148
-*   M114 - Output current position to serial port 
149
-*   M119 - Output Endstop status to serial port
150
-
151
-Movement variables:
152
-
153
-*   M202 - Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000) Unused in Marlin!!
154
-*   M203 - Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in mm/sec
155
-*   M204 - Set default acceleration: S normal moves T filament only moves (M204 S3000 T7000) im mm/sec^2  also sets minimum segment time in ms (B20000) to prevent buffer underruns and M20 minimum feedrate
156
-*   M206 - set home offsets.  This sets the X,Y,Z coordinates of the endstops (and is added to the {X,Y,Z}_HOME_POS configuration options (and is also added to the coordinates, if any, provided to G82, as with earlier firmware)
157
-*   M220 - set build speed mulitplying S:factor in percent ; aka "realtime tuneing in the gcode". So you can slow down if you have islands in one height-range, and speed up otherwise.
158
-*   M221 - set the extrude multiplying S:factor in percent
159
-*   M400 - Finish all buffered moves.
160
-
161
-Temperature variables:
162
-*   M301 - Set PID parameters P I and D
163
-*   M302 - Allow cold extrudes
164
-*   M303 - PID relay autotune S<temperature> sets the target temperature. (default target temperature = 150C)
165
-
166
-Advance:
167
-
168
-*   M200 - Set filament diameter for advance
169
-*   M205 - advanced settings:  minimum travel speed S=while printing T=travel only,  B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk
170
-
171
-EEPROM:
172
-
173
-*   M500 - stores paramters in EEPROM. This parameters are stored:  axis_steps_per_unit,  max_feedrate, max_acceleration  ,acceleration,retract_acceleration,
174
-  minimumfeedrate,mintravelfeedrate,minsegmenttime,  jerk velocities, PID
175
-*   M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).  
176
-*   M502 - reverts to the default "factory settings".  You still need to store them in EEPROM afterwards if you want to.
177
-*   M503 - print the current settings (from memory not from eeprom)
178
-
179
-MISC:
180
-
181
-*   M240 - Trigger a camera to take a photograph
182
-*   M999 - Restart after being stopped by error
183
-
184
-Configuring and compilation:
185
-============================
186
-
187
-Install the arduino software IDE/toolset v23 (Some configurations also work with 1.x.x)
188
-   http://www.arduino.cc/en/Main/Software
189
-
190
-For gen6/gen7 and sanguinololu the Sanguino directory in the Marlin dir needs to be copied to the arduino environment.
191
-  copy ArduinoAddons\Arduino_x.x.x\sanguino <arduino home>\hardware\Sanguino
192
-
193
-Install Ultimaker's RepG 25 build
194
-    http://software.ultimaker.com
195
-For SD handling and as better substitute (apart from stl manipulation) download
196
-the very nice Kliment's printrun/pronterface  https://github.com/kliment/Printrun
197
-
198
-Copy the Ultimaker Marlin firmware
199
-   https://github.com/ErikZalm/Marlin/tree/Marlin_v1
200
-   (Use the download button)
201
-
202
-Start the arduino IDE.
203
-Select Tools -> Board -> Arduino Mega 2560    or your microcontroller
204
-Select the correct serial port in Tools ->Serial Port
205
-Open Marlin.pde
206
-
207
-Click the Verify/Compile button
208
-
209
-Click the Upload button
210
-If all goes well the firmware is uploading
211
-
212
-Start Ultimaker's Custom RepG 25
213
-Make sure Show Experimental Profiles is enabled in Preferences
214
-Select Sprinter as the Driver
215
-
216
-Press the Connect button.
217
-
218
-KNOWN ISSUES: RepG will display:  Unknown: marlin x.y.z
219
-
220
-That's ok.  Enjoy Silky Smooth Printing.
221
-
222
-
223
-
1
+==========================
2
+Marlin 3D Printer Firmware
3
+==========================
4
+
5
+[![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=ErikZalm&url=https://github.com/ErikZalm/Marlin&title=Marlin&language=&tags=github&category=software)
6
+
7
+Quick Information
8
+===================
9
+This RepRap firmware is a mashup between <a href="https://github.com/kliment/Sprinter">Sprinter</a>, <a href="https://github.com/simen/grbl/tree">grbl</a> and many original parts.
10
+
11
+Derived from Sprinter and Grbl by Erik van der Zalm.
12
+Sprinters lead developers are Kliment and caru.
13
+Grbls lead developer is Simen Svale Skogsrud. Sonney Jeon (Chamnit) improved some parts of grbl
14
+A fork by bkubicek for the Ultimaker was merged, and further development was aided by him.
15
+Some features have been added by:
16
+Lampmaker, Bradley Feldman, and others...
17
+
18
+
19
+Features:
20
+
21
+*   Interrupt based movement with real linear acceleration
22
+*   High steprate
23
+*   Look ahead (Keep the speed high when possible. High cornering speed)
24
+*   Interrupt based temperature protection
25
+*   preliminary support for Matthew Roberts advance algorithm 
26
+    For more info see: http://reprap.org/pipermail/reprap-dev/2011-May/003323.html
27
+*   Full endstop support
28
+*   SD Card support
29
+*   SD Card folders (works in pronterface)
30
+*   SD Card autostart support
31
+*   LCD support (ideally 20x4) 
32
+*   LCD menu system for autonomous SD card printing, controlled by an click-encoder. 
33
+*   EEPROM storage of e.g. max-velocity, max-acceleration, and similar variables
34
+*   many small but handy things originating from bkubicek's fork.
35
+*   Arc support
36
+*   Temperature oversampling
37
+*   Dynamic Temperature setpointing aka "AutoTemp"
38
+*   Support for QTMarlin, a very beta GUI for PID-tuning and velocity-acceleration testing. https://github.com/bkubicek/QTMarlin
39
+*   Endstop trigger reporting to the host software.
40
+*   Updated sdcardlib
41
+*   Heater power reporting. Useful for PID monitoring.
42
+*   PID tuning
43
+*   CoreXY kinematics (www.corexy.com/theory.html)
44
+*   Configurable serial port to support connection of wireless adaptors.
45
+*   Automatic operation of extruder/cold-end cooling fans based on nozzle temperature
46
+
47
+The default baudrate is 250000. This baudrate has less jitter and hence errors than the usual 115200 baud, but is less supported by drivers and host-environments.
48
+
49
+
50
+Differences and additions to the already good Sprinter firmware:
51
+================================================================
52
+
53
+*Look-ahead:*
54
+
55
+Marlin has look-ahead. While sprinter has to break and re-accelerate at each corner, 
56
+lookahead will only decelerate and accelerate to a velocity, 
57
+so that the change in vectorial velocity magnitude is less than the xy_jerk_velocity.
58
+This is only possible, if some future moves are already processed, hence the name. 
59
+It leads to less over-deposition at corners, especially at flat angles.
60
+
61
+*Arc support:*
62
+
63
+Slic3r can find curves that, although broken into segments, were ment to describe an arc.
64
+Marlin is able to print those arcs. The advantage is the firmware can choose the resolution,
65
+and can perform the arc with nearly constant velocity, resulting in a nice finish. 
66
+Also, less serial communication is needed.
67
+
68
+*Temperature Oversampling:*
69
+
70
+To reduce noise and make the PID-differential term more useful, 16 ADC conversion results are averaged.
71
+
72
+*AutoTemp:*
73
+
74
+If your gcode contains a wide spread of extruder velocities, or you realtime change the building speed, the temperature should be changed accordingly.
75
+Usually, higher speed requires higher temperature.
76
+This can now be performed by the AutoTemp function
77
+By calling M109 S<mintemp> T<maxtemp> F<factor> you enter the autotemp mode.
78
+
79
+You can leave it by calling M109 without any F.
80
+If active, the maximal extruder stepper rate of all buffered moves will be calculated, and named "maxerate" [steps/sec].
81
+The wanted temperature then will be set to t=tempmin+factor*maxerate, while being limited between tempmin and tempmax.
82
+If the target temperature is set manually or by gcode to a value less then tempmin, it will be kept without change.
83
+Ideally, your gcode can be completely free of temperature controls, apart from a M109 S T F in the start.gcode, and a M109 S0 in the end.gcode.
84
+
85
+*EEPROM:*
86
+
87
+If you know your PID values, the acceleration and max-velocities of your unique machine, you can set them, and finally store them in the EEPROM.
88
+After each reboot, it will magically load them from EEPROM, independent what your Configuration.h says.
89
+
90
+*LCD Menu:*
91
+
92
+If your hardware supports it, you can build yourself a LCD-CardReader+Click+encoder combination. It will enable you to realtime tune temperatures,
93
+accelerations, velocities, flow rates, select and print files from the SD card, preheat, disable the steppers, and do other fancy stuff.
94
+One working hardware is documented here: http://www.thingiverse.com/thing:12663 
95
+Also, with just a 20x4 or 16x2 display, useful data is shown.
96
+
97
+*SD card folders:*
98
+
99
+If you have an SD card reader attached to your controller, also folders work now. Listing the files in pronterface will show "/path/subpath/file.g".
100
+You can write to file in a subfolder by specifying a similar text using small letters in the path.
101
+Also, backup copies of various operating systems are hidden, as well as files not ending with ".g".
102
+
103
+*SD card folders:*
104
+
105
+If you place a file auto[0-9].g into the root of the sd card, it will be automatically executed if you boot the printer. The same file will be executed by selecting "Autostart" from the menu.
106
+First *0 will be performed, than *1 and so on. That way, you can heat up or even print automatically without user interaction.
107
+
108
+*Endstop trigger reporting:*
109
+
110
+If an endstop is hit while moving towards the endstop, the location at which the firmware thinks that the endstop was triggered is outputed on the serial port.
111
+This is useful, because the user gets a warning message.
112
+However, also tools like QTMarlin can use this for finding acceptable combinations of velocity+acceleration.
113
+
114
+*Coding paradigm:*
115
+
116
+Not relevant from a user side, but Marlin was split into thematic junks, and has tried to partially enforced private variables.
117
+This is intended to make it clearer, what interacts which what, and leads to a higher level of modularization.
118
+We think that this is a useful prestep for porting this firmware to e.g. an ARM platform in the future.
119
+A lot of RAM (with enabled LCD ~2200 bytes) was saved by storing char []="some message" in Program memory.
120
+In the serial communication, a #define based level of abstraction was enforced, so that it is clear that
121
+some transfer is information (usually beginning with "echo:"), an error "error:", or just normal protocol,
122
+necessary for backwards compatibility.
123
+
124
+*Interrupt based temperature measurements:*
125
+
126
+An interrupt is used to manage ADC conversions, and enforce checking for critical temperatures.
127
+This leads to less blocking in the heater management routine.
128
+
129
+Implemented G Codes:
130
+====================
131
+
132
+*  G0  -> G1
133
+*  G1  - Coordinated Movement X Y Z E
134
+*  G2  - CW ARC
135
+*  G3  - CCW ARC
136
+*  G4  - Dwell S<seconds> or P<milliseconds>
137
+*  G10 - retract filament according to settings of M207
138
+*  G11 - retract recover filament according to settings of M208
139
+*  G28 - Home all Axis
140
+*  G90 - Use Absolute Coordinates
141
+*  G91 - Use Relative Coordinates
142
+*  G92 - Set current position to cordinates given
143
+
144
+RepRap M Codes
145
+*  M0   - Unconditional stop - Wait for user to press a button on the LCD (Only if ULTRA_LCD is enabled)
146
+*  M1   - Same as M0
147
+*  M104 - Set extruder target temp
148
+*  M105 - Read current temp
149
+*  M106 - Fan on
150
+*  M107 - Fan off
151
+*  M109 - Wait for extruder current temp to reach target temp.
152
+*  M114 - Display current position
153
+
154
+Custom M Codes
155
+*  M17  - Enable/Power all stepper motors
156
+*  M18  - Disable all stepper motors; same as M84
157
+*  M20  - List SD card
158
+*  M21  - Init SD card
159
+*  M22  - Release SD card
160
+*  M23  - Select SD file (M23 filename.g)
161
+*  M24  - Start/resume SD print
162
+*  M25  - Pause SD print
163
+*  M26  - Set SD position in bytes (M26 S12345)
164
+*  M27  - Report SD print status
165
+*  M28  - Start SD write (M28 filename.g)
166
+*  M29  - Stop SD write
167
+*  M30  - Delete file from SD (M30 filename.g)
168
+*  M31  - Output time since last M109 or SD card start to serial
169
+*  M42  - Change pin status via gcode Use M42 Px Sy to set pin x to value y, when omitting Px the onboard led will be used.
170
+*  M80  - Turn on Power Supply
171
+*  M81  - Turn off Power Supply
172
+*  M82  - Set E codes absolute (default)
173
+*  M83  - Set E codes relative while in Absolute Coordinates (G90) mode
174
+*  M84  - Disable steppers until next move, or use S<seconds> to specify an inactivity timeout, after which the steppers will be disabled.  S0 to disable the timeout.
175
+*  M85  - Set inactivity shutdown timer with parameter S<seconds>. To disable set zero (default)
176
+*  M92  - Set axis_steps_per_unit - same syntax as G92
177
+*  M114 - Output current position to serial port
178
+*  M115 - Capabilities string
179
+*  M117 - display message
180
+*  M119 - Output Endstop status to serial port
181
+*  M126 - Solenoid Air Valve Open (BariCUDA support by jmil)
182
+*  M127 - Solenoid Air Valve Closed (BariCUDA vent to atmospheric pressure by jmil)
183
+*  M128 - EtoP Open (BariCUDA EtoP = electricity to air pressure transducer by jmil)
184
+*  M129 - EtoP Closed (BariCUDA EtoP = electricity to air pressure transducer by jmil)
185
+*  M140 - Set bed target temp
186
+*  M190 - Wait for bed current temp to reach target temp.
187
+*  M200 - Set filament diameter
188
+*  M201 - Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000)
189
+*  M202 - Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000) Unused in Marlin!!
190
+*  M203 - Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in mm/sec
191
+*  M204 - Set default acceleration: S normal moves T filament only moves (M204 S3000 T7000) im mm/sec^2  also sets minimum segment time in ms (B20000) to prevent buffer underruns and M20 minimum feedrate
192
+*  M205 -  advanced settings:  minimum travel speed S=while printing T=travel only,  B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk, E=maximum E jerk
193
+*  M206 - set additional homeing offset
194
+*  M207 - set retract length S[positive mm] F[feedrate mm/sec] Z[additional zlift/hop]
195
+*  M208 - set recover=unretract length S[positive mm surplus to the M207 S*] F[feedrate mm/sec]
196
+*  M209 - S<1=true/0=false> enable automatic retract detect if the slicer did not support G10/11: every normal extrude-only move will be classified as retract depending on the direction.
197
+*  M218 - set hotend offset (in mm): T<extruder_number> X<offset_on_X> Y<offset_on_Y>
198
+*  M220 S<factor in percent>- set speed factor override percentage
199
+*  M221 S<factor in percent>- set extrude factor override percentage
200
+*  M240 - Trigger a camera to take a photograph
201
+*  M280 - set servo position absolute. P: servo index, S: angle or microseconds
202
+*  M300 - Play beepsound S<frequency Hz> P<duration ms>
203
+*  M301 - Set PID parameters P I and D
204
+*  M302 - Allow cold extrudes
205
+*  M303 - PID relay autotune S<temperature> sets the target temperature. (default target temperature = 150C)
206
+*  M304 - Set bed PID parameters P I and D
207
+*  M400 - Finish all moves
208
+*  M500 - stores paramters in EEPROM
209
+*  M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).
210
+*  M502 - reverts to the default "factory settings".  You still need to store them in EEPROM afterwards if you want to.
211
+*  M503 - print the current settings (from memory not from eeprom)
212
+*  M540 - Use S[0|1] to enable or disable the stop SD card print on endstop hit (requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
213
+*  M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
214
+*  M907 - Set digital trimpot motor current using axis codes.
215
+*  M908 - Control digital trimpot directly.
216
+*  M350 - Set microstepping mode.
217
+*  M351 - Toggle MS1 MS2 pins directly.
218
+*  M928 - Start SD logging (M928 filename.g) - ended by M29
219
+*  M999 - Restart after being stopped by error
220
+
221
+
222
+Configuring and compilation:
223
+============================
224
+
225
+Install the arduino software IDE/toolset v23 (Some configurations also work with 1.x.x)
226
+   http://www.arduino.cc/en/Main/Software
227
+
228
+For gen6/gen7 and sanguinololu the Sanguino directory in the Marlin dir needs to be copied to the arduino environment.
229
+  copy ArduinoAddons\Arduino_x.x.x\sanguino <arduino home>\hardware\Sanguino
230
+
231
+Copy the Marlin firmware
232
+   https://github.com/ErikZalm/Marlin/tree/Marlin_v1
233
+   (Use the download button)
234
+
235
+Start the arduino IDE.
236
+Select Tools -> Board -> Arduino Mega 2560    or your microcontroller
237
+Select the correct serial port in Tools ->Serial Port
238
+Open Marlin.pde
239
+
240
+Click the Verify/Compile button
241
+
242
+Click the Upload button
243
+If all goes well the firmware is uploading
244
+
245
+That's ok.  Enjoy Silky Smooth Printing.
246
+
247
+
248
+
249
+

Loading…
Cancel
Save