瀏覽代碼

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

bkubicek 11 年之前
父節點
當前提交
2fb2a0a119

+ 29
- 0
Marlin/BlinkM.cpp 查看文件

@@ -0,0 +1,29 @@
1
+/*
2
+  BlinkM.cpp - Library for controlling a BlinkM over i2c
3
+  Created by Tim Koster, August 21 2013.
4
+*/
5
+#include "Marlin.h"
6
+#ifdef BLINKM
7
+
8
+#if (ARDUINO >= 100)
9
+  # include "Arduino.h"
10
+#else
11
+  # include "WProgram.h"
12
+#endif
13
+
14
+#include "BlinkM.h"
15
+
16
+void SendColors(byte red, byte grn, byte blu)
17
+{
18
+  Wire.begin(); 
19
+  Wire.beginTransmission(0x09);
20
+  Wire.write('o');                    //to disable ongoing script, only needs to be used once
21
+  Wire.write('n');
22
+  Wire.write(red);
23
+  Wire.write(grn);
24
+  Wire.write(blu);
25
+  Wire.endTransmission();
26
+}
27
+
28
+#endif //BLINKM
29
+

+ 14
- 0
Marlin/BlinkM.h 查看文件

@@ -0,0 +1,14 @@
1
+/*
2
+  BlinkM.h
3
+  Library header file for BlinkM library
4
+ */
5
+#if (ARDUINO >= 100)
6
+  # include "Arduino.h"
7
+#else
8
+  # include "WProgram.h"
9
+#endif
10
+
11
+#include "Wire.h"
12
+
13
+void SendColors(byte red, byte grn, byte blu);
14
+

+ 12
- 6
Marlin/Configuration.h 查看文件

@@ -309,7 +309,10 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
309 309
   #define X_PROBE_OFFSET_FROM_EXTRUDER -25
310 310
   #define Y_PROBE_OFFSET_FROM_EXTRUDER -29
311 311
   #define Z_PROBE_OFFSET_FROM_EXTRUDER -12.35
312
-  
312
+
313
+  #define Z_RAISE_BEFORE_HOMING 4       // (in mm) Raise Z before homing (G28) for Probe Clearance.
314
+                                        // Be sure you have this distance over your Z_MAX_POS in case
315
+    
313 316
   #define XY_TRAVEL_SPEED 8000         // X and Y axis travel speed between probes, in mm/min
314 317
   
315 318
   #define Z_RAISE_BEFORE_PROBING 15    //How much the extruder will be raised before traveling to the first probing point.
@@ -330,12 +333,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
330 333
 #define Y_MAX_POS 205
331 334
 #define Y_MIN_POS 0
332 335
 #define Z_MAX_POS 200
333
-
334
-#ifndef ENABLE_AUTO_BED_LEVELING
335 336
 #define Z_MIN_POS 0
336
-#else
337
-#define Z_MIN_POS (-1*Z_PROBE_OFFSET_FROM_EXTRUDER)  //With Auto Bed Leveling, the Z_MIN MUST have the same distance as Z_PROBE
338
-#endif
339 337
 
340 338
 #define X_MAX_LENGTH (X_MAX_POS - X_MIN_POS)
341 339
 #define Y_MAX_LENGTH (Y_MAX_POS - Y_MIN_POS)
@@ -542,6 +540,11 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
542 540
 // Increase the FAN pwm frequency. Removes the PWM noise but increases heating in the FET/Arduino
543 541
 //#define FAST_PWM_FAN
544 542
 
543
+// Temperature status leds that display the hotend and bet temperature.
544
+// If alle hotends and bed temperature and temperature setpoint are < 54C then the BLUE led is on.
545
+// Otherwise the RED led is on. There is 1C hysteresis.
546
+//#define TEMP_STAT_LEDS
547
+
545 548
 // Use software PWM to drive the fan, as for the heaters. This uses a very low frequency
546 549
 // which is not ass annoying as with the hardware PWM. On the other hand, if this frequency
547 550
 // is too low, you should also increment SOFT_PWM_SCALE.
@@ -563,6 +566,9 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
563 566
 // Support for the BariCUDA Paste Extruder.
564 567
 //#define BARICUDA
565 568
 
569
+//define BlinkM/CyzRgb Support
570
+//#define BLINKM
571
+
566 572
 /*********************************************************************\
567 573
 * R/C SERVO support
568 574
 * Sponsored by TrinityLabs, Reworked by codexmas

+ 19
- 0
Marlin/Configuration_adv.h 查看文件

@@ -40,6 +40,10 @@
40 40
   #define AUTOTEMP_OLDWEIGHT 0.98
41 41
 #endif
42 42
 
43
+//Show Temperature ADC value
44
+//The M105 command return, besides traditional information, the ADC value read from temperature sensors.
45
+//#define SHOW_TEMP_ADC_VALUES
46
+
43 47
 //  extruder run-out prevention. 
44 48
 //if the machine is idle, and the temperature over MINTEMP, every couple of SECONDS some filament is extruded
45 49
 //#define EXTRUDER_RUNOUT_PREVENT  
@@ -146,6 +150,21 @@
146 150
   #define EXTRUDERS 1
147 151
 #endif
148 152
 
153
+// Same again but for Y Axis.
154
+//#define Y_DUAL_STEPPER_DRIVERS
155
+
156
+// Define if the two Y drives need to rotate in opposite directions
157
+#define INVERT_Y2_VS_Y_DIR true
158
+
159
+#ifdef Y_DUAL_STEPPER_DRIVERS
160
+  #undef EXTRUDERS
161
+  #define EXTRUDERS 1
162
+#endif
163
+
164
+#ifdef Z_DUAL_STEPPER_DRIVERS && Y_DUAL_STEPPER_DRIVERS
165
+  #error "You cannot have dual drivers for both Y and Z"
166
+#endif 
167
+
149 168
 // Enable this for dual x-carriage printers. 
150 169
 // A dual x-carriage design has the advantage that the inactive extruder can be parked which
151 170
 // prevents hot-end ooze contaminating the print. It also reduces the weight of each x-carriage

+ 7
- 2
Marlin/Marlin.h 查看文件

@@ -109,8 +109,13 @@ void manage_inactivity();
109 109
 #endif
110 110
 
111 111
 #if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1
112
-  #define  enable_y() WRITE(Y_ENABLE_PIN, Y_ENABLE_ON)
113
-  #define disable_y() WRITE(Y_ENABLE_PIN,!Y_ENABLE_ON)
112
+  #ifdef Y_DUAL_STEPPER_DRIVERS
113
+    #define  enable_y() { WRITE(Y_ENABLE_PIN, Y_ENABLE_ON); WRITE(Y2_ENABLE_PIN,  Y_ENABLE_ON); }
114
+    #define disable_y() { WRITE(Y_ENABLE_PIN,!Y_ENABLE_ON); WRITE(Y2_ENABLE_PIN, !Y_ENABLE_ON); }
115
+  #else
116
+    #define  enable_y() WRITE(Y_ENABLE_PIN, Y_ENABLE_ON)
117
+    #define disable_y() WRITE(Y_ENABLE_PIN,!Y_ENABLE_ON)
118
+  #endif
114 119
 #else
115 120
   #define enable_y() ;
116 121
   #define disable_y() ;

+ 93
- 7
Marlin/Marlin_main.cpp 查看文件

@@ -44,6 +44,11 @@
44 44
 #include "language.h"
45 45
 #include "pins_arduino.h"
46 46
 
47
+#ifdef BLINKM
48
+#include "BlinkM.h"
49
+#include "Wire.h" 
50
+#endif
51
+
47 52
 #if NUM_SERVOS > 0
48 53
 #include "Servo.h"
49 54
 #endif
@@ -118,6 +123,7 @@
118 123
 // M128 - EtoP Open (BariCUDA EtoP = electricity to air pressure transducer by jmil)
119 124
 // M129 - EtoP Closed (BariCUDA EtoP = electricity to air pressure transducer by jmil)
120 125
 // M140 - Set bed target temp
126
+// M150 - Set BlinkM Colour Output R: Red<0-255> U(!): Green<0-255> B: Blue<0-255> over i2c, G for green does not work.
121 127
 // M190 - Sxxx Wait for bed current temp to reach target temp. Waits only when heating
122 128
 //        Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling
123 129
 // M200 - Set filament diameter
@@ -935,19 +941,28 @@ static void homeaxis(int axis) {
935 941
       axis_home_dir = x_home_dir(active_extruder);
936 942
 #endif
937 943
 
944
+    current_position[axis] = 0;
945
+    plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
946
+	
938 947
     // Engage Servo endstop if enabled
939 948
     #ifdef SERVO_ENDSTOPS
940
-#if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
941
-    if (axis==Z_AXIS) engage_z_probe();
942
-	else
943
-#endif
949
+      #if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
950
+        if (axis==Z_AXIS) {
951
+          #if defined (Z_RAISE_BEFORE_HOMING) && (Z_RAISE_BEFORE_HOMING > 0)
952
+            destination[axis] = Z_RAISE_BEFORE_HOMING * axis_home_dir * (-1);    // Set destination away from bed
953
+            feedrate = max_feedrate[axis];
954
+            plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder);
955
+            st_synchronize();
956
+          #endif
957
+          engage_z_probe();
958
+        }
959
+	    else
960
+      #endif
944 961
       if (servo_endstops[axis] > -1) {
945 962
         servos[servo_endstops[axis]].write(servo_endstop_angles[axis * 2]);
946 963
       }
947 964
     #endif
948 965
 
949
-    current_position[axis] = 0;
950
-    plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
951 966
     destination[axis] = 1.5 * max_length(axis) * axis_home_dir;
952 967
     feedrate = homing_feedrate[axis];
953 968
     plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
@@ -1213,6 +1228,9 @@ void process_commands()
1213 1228
           current_position[Z_AXIS]=code_value()+add_homeing[2];
1214 1229
         }
1215 1230
       }
1231
+      #ifdef ENABLE_AUTO_BED_LEVELING
1232
+         current_position[Z_AXIS] -= Z_PROBE_OFFSET_FROM_EXTRUDER;  //Add Z_Probe offset (the distance is negative)
1233
+      #endif
1216 1234
       plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1217 1235
 #endif // else DELTA
1218 1236
 
@@ -1607,6 +1625,23 @@ void process_commands()
1607 1625
         SERIAL_PROTOCOLPGM(" B@:");
1608 1626
         SERIAL_PROTOCOL(getHeaterPower(-1));
1609 1627
 
1628
+        #ifdef SHOW_TEMP_ADC_VALUES
1629
+          #if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1
1630
+            SERIAL_PROTOCOLPGM("    ADC B:");
1631
+            SERIAL_PROTOCOL_F(degBed(),1);
1632
+            SERIAL_PROTOCOLPGM("C->");
1633
+            SERIAL_PROTOCOL_F(rawBedTemp()/OVERSAMPLENR,0);
1634
+          #endif
1635
+          for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) {
1636
+            SERIAL_PROTOCOLPGM("  T");
1637
+            SERIAL_PROTOCOL(cur_extruder);
1638
+            SERIAL_PROTOCOLPGM(":");
1639
+            SERIAL_PROTOCOL_F(degHotend(cur_extruder),1);
1640
+            SERIAL_PROTOCOLPGM("C->");
1641
+            SERIAL_PROTOCOL_F(rawHotendTemp(cur_extruder)/OVERSAMPLENR,0);
1642
+          }
1643
+        #endif
1644
+		
1610 1645
         SERIAL_PROTOCOLLN("");
1611 1646
       return;
1612 1647
       break;
@@ -1943,6 +1978,21 @@ void process_commands()
1943 1978
       #endif
1944 1979
       break;
1945 1980
       //TODO: update for all axis, use for loop
1981
+    #ifdef BLINKM  
1982
+    case 150: // M150
1983
+      {
1984
+        byte red;
1985
+        byte grn;
1986
+        byte blu;
1987
+        
1988
+        if(code_seen('R')) red = code_value();
1989
+        if(code_seen('U')) grn = code_value();
1990
+        if(code_seen('B')) blu = code_value();
1991
+        
1992
+        SendColors(red,grn,blu);        
1993
+      }
1994
+      break;
1995
+    #endif //BLINKM
1946 1996
     case 201: // M201
1947 1997
       for(int8_t i=0; i < NUM_AXIS; i++)
1948 1998
       {
@@ -2925,6 +2975,39 @@ void controllerFan()
2925 2975
 }
2926 2976
 #endif
2927 2977
 
2978
+#ifdef TEMP_STAT_LEDS
2979
+static bool blue_led = false;
2980
+static bool red_led = false;
2981
+static uint32_t stat_update = 0;
2982
+
2983
+void handle_status_leds(void) {
2984
+  float max_temp = 0.0;
2985
+  if(millis() > stat_update) {
2986
+    stat_update += 500; // Update every 0.5s
2987
+    for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) {
2988
+       max_temp = max(max_temp, degHotend(cur_extruder));
2989
+       max_temp = max(max_temp, degTargetHotend(cur_extruder));
2990
+    }
2991
+    #if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1
2992
+      max_temp = max(max_temp, degTargetBed());
2993
+      max_temp = max(max_temp, degBed());
2994
+    #endif
2995
+    if((max_temp > 55.0) && (red_led == false)) {
2996
+      digitalWrite(STAT_LED_RED, 1);
2997
+      digitalWrite(STAT_LED_BLUE, 0);
2998
+      red_led = true;
2999
+      blue_led = false;
3000
+    }
3001
+    if((max_temp < 54.0) && (blue_led == false)) {
3002
+      digitalWrite(STAT_LED_RED, 0);
3003
+      digitalWrite(STAT_LED_BLUE, 1);
3004
+      red_led = false;
3005
+      blue_led = true;
3006
+    }
3007
+  }
3008
+}
3009
+#endif
3010
+
2928 3011
 void manage_inactivity()
2929 3012
 {
2930 3013
   if( (millis() - previous_millis_cmd) >  max_inactive_time )
@@ -2978,7 +3061,10 @@ void manage_inactivity()
2978 3061
       memcpy(destination,current_position,sizeof(destination));
2979 3062
       prepare_move(); 
2980 3063
     }
2981
-  #endif  
3064
+  #endif
3065
+  #ifdef TEMP_STAT_LEDS
3066
+      handle_status_leds();
3067
+  #endif
2982 3068
   check_axes_activity();
2983 3069
 }
2984 3070
 

+ 7
- 0
Marlin/pins.h 查看文件

@@ -544,6 +544,13 @@
544 544
     #endif
545 545
   #endif
546 546
 
547
+  #ifdef TEMP_STAT_LEDS
548
+    #if MOTHERBOARD == 67
549
+      #define STAT_LED_RED       6
550
+      #define STAT_LED_BLUE     11
551
+    #endif
552
+  #endif
553
+  
547 554
   #ifdef ULTRA_LCD
548 555
 
549 556
     #ifdef NEWPANEL

+ 32
- 0
Marlin/stepper.cpp 查看文件

@@ -383,10 +383,20 @@ ISR(TIMER1_COMPA_vect)
383 383
     }
384 384
     if((out_bits & (1<<Y_AXIS))!=0){
385 385
       WRITE(Y_DIR_PIN, INVERT_Y_DIR);
386
+	  
387
+	  #ifdef Y_DUAL_STEPPER_DRIVERS
388
+	    WRITE(Y2_DIR_PIN, !(INVERT_Y_DIR == INVERT_Y2_VS_Y_DIR));
389
+	  #endif
390
+	  
386 391
       count_direction[Y_AXIS]=-1;
387 392
     }
388 393
     else{
389 394
       WRITE(Y_DIR_PIN, !INVERT_Y_DIR);
395
+	  
396
+	  #ifdef Y_DUAL_STEPPER_DRIVERS
397
+	    WRITE(Y2_DIR_PIN, (INVERT_Y_DIR == INVERT_Y2_VS_Y_DIR));
398
+	  #endif
399
+	  
390 400
       count_direction[Y_AXIS]=1;
391 401
     }
392 402
 
@@ -582,9 +592,18 @@ ISR(TIMER1_COMPA_vect)
582 592
         counter_y += current_block->steps_y;
583 593
         if (counter_y > 0) {
584 594
           WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
595
+		  
596
+		  #ifdef Y_DUAL_STEPPER_DRIVERS
597
+			WRITE(Y2_STEP_PIN, !INVERT_Y_STEP_PIN);
598
+		  #endif
599
+		  
585 600
           counter_y -= current_block->step_event_count;
586 601
           count_position[Y_AXIS]+=count_direction[Y_AXIS];
587 602
           WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
603
+		  
604
+		  #ifdef Y_DUAL_STEPPER_DRIVERS
605
+			WRITE(Y2_STEP_PIN, INVERT_Y_STEP_PIN);
606
+		  #endif
588 607
         }
589 608
 
590 609
       counter_z += current_block->steps_z;
@@ -756,6 +775,10 @@ void st_init()
756 775
   #endif
757 776
   #if defined(Y_DIR_PIN) && Y_DIR_PIN > -1
758 777
     SET_OUTPUT(Y_DIR_PIN);
778
+		
779
+	#if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_DIR_PIN) && (Y2_DIR_PIN > -1)
780
+	  SET_OUTPUT(Y2_DIR_PIN);
781
+	#endif
759 782
   #endif
760 783
   #if defined(Z_DIR_PIN) && Z_DIR_PIN > -1
761 784
     SET_OUTPUT(Z_DIR_PIN);
@@ -787,6 +810,11 @@ void st_init()
787 810
   #if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1
788 811
     SET_OUTPUT(Y_ENABLE_PIN);
789 812
     if(!Y_ENABLE_ON) WRITE(Y_ENABLE_PIN,HIGH);
813
+	
814
+	#if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_ENABLE_PIN) && (Y2_ENABLE_PIN > -1)
815
+	  SET_OUTPUT(Y2_ENABLE_PIN);
816
+	  if(!Y_ENABLE_ON) WRITE(Y2_ENABLE_PIN,HIGH);
817
+	#endif
790 818
   #endif
791 819
   #if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1
792 820
     SET_OUTPUT(Z_ENABLE_PIN);
@@ -869,6 +897,10 @@ void st_init()
869 897
   #if defined(Y_STEP_PIN) && (Y_STEP_PIN > -1)
870 898
     SET_OUTPUT(Y_STEP_PIN);
871 899
     WRITE(Y_STEP_PIN,INVERT_Y_STEP_PIN);
900
+    #if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_STEP_PIN) && (Y2_STEP_PIN > -1)
901
+      SET_OUTPUT(Y2_STEP_PIN);
902
+      WRITE(Y2_STEP_PIN,INVERT_Y_STEP_PIN);
903
+    #endif
872 904
     disable_y();
873 905
   #endif
874 906
   #if defined(Z_STEP_PIN) && (Z_STEP_PIN > -1)

+ 14
- 0
Marlin/temperature.h 查看文件

@@ -35,6 +35,10 @@ void manage_heater(); //it is critical that this is called periodically.
35 35
 // do not use these routines and variables outside of temperature.cpp
36 36
 extern int target_temperature[EXTRUDERS];  
37 37
 extern float current_temperature[EXTRUDERS];
38
+#ifdef SHOW_TEMP_ADC_VALUES
39
+  extern int current_temperature_raw[EXTRUDERS];
40
+  extern int current_temperature_bed_raw;
41
+#endif
38 42
 extern int target_temperature_bed;
39 43
 extern float current_temperature_bed;
40 44
 #ifdef TEMP_SENSOR_1_AS_REDUNDANT
@@ -66,6 +70,16 @@ FORCE_INLINE float degHotend(uint8_t extruder) {
66 70
   return current_temperature[extruder];
67 71
 };
68 72
 
73
+#ifdef SHOW_TEMP_ADC_VALUES
74
+  FORCE_INLINE float rawHotendTemp(uint8_t extruder) {  
75
+    return current_temperature_raw[extruder];
76
+  };
77
+
78
+  FORCE_INLINE float rawBedTemp() {  
79
+    return current_temperature_bed_raw;
80
+  };
81
+#endif
82
+
69 83
 FORCE_INLINE float degBed() {
70 84
   return current_temperature_bed;
71 85
 };

+ 1
- 2
Marlin/ultralcd.cpp 查看文件

@@ -104,6 +104,7 @@ static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned l
104 104
     if (encoderPosition > 0x8000) encoderPosition = 0; \
105 105
     if (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM < currentMenuViewOffset) currentMenuViewOffset = encoderPosition / ENCODER_STEPS_PER_MENU_ITEM;\
106 106
     uint8_t _lineNr = currentMenuViewOffset, _menuItemNr; \
107
+    bool wasClicked = LCD_CLICKED;\
107 108
     for(uint8_t _drawLineNr = 0; _drawLineNr < LCD_HEIGHT; _drawLineNr++, _lineNr++) { \
108 109
         _menuItemNr = 0;
109 110
 #define MENU_ITEM(type, label, args...) do { \
@@ -142,7 +143,6 @@ uint8_t currentMenuViewOffset;              /* scroll offset in the current menu
142 143
 uint32_t blocking_enc;
143 144
 uint8_t lastEncoderBits;
144 145
 uint32_t encoderPosition;
145
-bool wasClicked;
146 146
 #if (SDCARDDETECT > 0)
147 147
 bool lcd_oldcardstatus;
148 148
 #endif
@@ -1042,7 +1042,6 @@ void lcd_update()
1042 1042
     
1043 1043
     if (lcd_next_update_millis < millis())
1044 1044
     {
1045
-      wasClicked = LCD_CLICKED;
1046 1045
 #ifdef ULTIPANEL
1047 1046
 		#ifdef REPRAPWORLD_KEYPAD
1048 1047
         	if (REPRAPWORLD_KEYPAD_MOVE_Z_UP) {

+ 761
- 750
Marlin/ultralcd_implementation_hitachi_HD44780.h
文件差異過大導致無法顯示
查看文件


Loading…
取消
儲存