Browse Source

Merge pull request #676 from IVI053/Marlin_v1

Minor improvements for encoder configuration, LCD entry for PSU controll and thermistor pins on RAMPS
ErikZalm 10 years ago
parent
commit
46d2443c7d
3 changed files with 140 additions and 131 deletions
  1. 14
    13
      Marlin/Configuration.h
  2. 95
    91
      Marlin/Marlin_main.cpp
  3. 31
    27
      Marlin/ultralcd.cpp

+ 14
- 13
Marlin/Configuration.h View File

@@ -8,9 +8,9 @@
8 8
 //===========================================================================
9 9
 //============================= DELTA Printer ===============================
10 10
 //===========================================================================
11
-// For a Delta printer rplace the configuration files wilth the files in the 
11
+// For a Delta printer rplace the configuration files wilth the files in the
12 12
 // example_configurations/delta directory.
13
-// 
13
+//
14 14
 
15 15
 // User-specified version info of this build to display in [Pronterface, etc] terminal window during
16 16
 // startup. Implementation of an idea by Prof Braino to inform user that any changes made to this
@@ -37,7 +37,7 @@
37 37
 // 12 = Gen7 v1.3
38 38
 // 13 = Gen7 v1.4
39 39
 // 2  = Cheaptronic v1.0
40
-// 20 = Sethi 3D_1 
40
+// 20 = Sethi 3D_1
41 41
 // 3  = MEGA/RAMPS up to 1.2 = 3
42 42
 // 33 = RAMPS 1.3 / 1.4 (Power outputs: Extruder, Fan, Bed)
43 43
 // 34 = RAMPS 1.3 / 1.4 (Power outputs: Extruder0, Extruder1, Bed)
@@ -336,9 +336,9 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
336 336
 
337 337
   #define Z_RAISE_BEFORE_HOMING 4       // (in mm) Raise Z before homing (G28) for Probe Clearance.
338 338
                                         // Be sure you have this distance over your Z_MAX_POS in case
339
-    
339
+
340 340
   #define XY_TRAVEL_SPEED 8000         // X and Y axis travel speed between probes, in mm/min
341
-  
341
+
342 342
   #define Z_RAISE_BEFORE_PROBING 15    //How much the extruder will be raised before traveling to the first probing point.
343 343
   #define Z_RAISE_BETWEEN_PROBINGS 5  //How much the extruder will be raised when traveling from between next probing points
344 344
 
@@ -347,26 +347,26 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
347 347
   //The value is the delay to turn the servo off after powered on - depends on the servo speed; 300ms is good value, but you can try lower it.
348 348
   // You MUST HAVE the SERVO_ENDSTOPS defined to use here a value higher than zero otherwise your code will not compile.
349 349
 
350
-//  #define PROBE_SERVO_DEACTIVATION_DELAY 300  
350
+//  #define PROBE_SERVO_DEACTIVATION_DELAY 300
351 351
 
352 352
 
353
-//If you have enabled the Bed Auto Levelling and are using the same Z Probe for Z Homing, 
353
+//If you have enabled the Bed Auto Levelling and are using the same Z Probe for Z Homing,
354 354
 //it is highly recommended you let this Z_SAFE_HOMING enabled!!!
355 355
 
356
-  #define Z_SAFE_HOMING   // This feature is meant to avoid Z homing with probe outside the bed area. 
356
+  #define Z_SAFE_HOMING   // This feature is meant to avoid Z homing with probe outside the bed area.
357 357
                           // When defined, it will:
358 358
                           // - Allow Z homing only after X and Y homing AND stepper drivers still enabled
359 359
                           // - If stepper drivers timeout, it will need X and Y homing again before Z homing
360 360
                           // - Position the probe in a defined XY point before Z Homing when homing all axis (G28)
361 361
                           // - Block Z homing only when the probe is outside bed area.
362
-  
362
+
363 363
   #ifdef Z_SAFE_HOMING
364
-    
364
+
365 365
     #define Z_SAFE_HOMING_X_POINT (X_MAX_LENGTH/2)    // X point for Z homing when homing all axis (G28)
366 366
     #define Z_SAFE_HOMING_Y_POINT (Y_MAX_LENGTH/2)    // Y point for Z homing when homing all axis (G28)
367
-    
367
+
368 368
   #endif
369
-  
369
+
370 370
 #endif
371 371
 
372 372
 
@@ -435,6 +435,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
435 435
 //#define SDSUPPORT // Enable SD Card Support in Hardware Console
436 436
 //#define SDSLOW // Use slower SD transfer mode (not normally needed - uncomment if you're getting volume init error)
437 437
 //#define ENCODER_PULSES_PER_STEP 1 // Increase if you have a high resolution encoder
438
+//#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
438 439
 //#define ULTIMAKERCONTROLLER //as available from the ultimaker online store.
439 440
 //#define ULTIPANEL  //the ultipanel as on thingiverse
440 441
 
@@ -541,7 +542,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
541 542
 // Shift register panels
542 543
 // ---------------------
543 544
 // 2 wire Non-latching LCD SR from:
544
-// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection 
545
+// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection
545 546
 //#define SR_LCD
546 547
 #ifdef SR_LCD
547 548
    #define SR_LCD_2W_NL    // Non latching 2 wire shiftregister

+ 95
- 91
Marlin/Marlin_main.cpp View File

@@ -47,7 +47,7 @@
47 47
 
48 48
 #ifdef BLINKM
49 49
 #include "BlinkM.h"
50
-#include "Wire.h" 
50
+#include "Wire.h"
51 51
 #endif
52 52
 
53 53
 #if NUM_SERVOS > 0
@@ -96,7 +96,7 @@
96 96
 // M29  - Stop SD write
97 97
 // M30  - Delete file from SD (M30 filename.g)
98 98
 // M31  - Output time since last M109 or SD card start to serial
99
-// M32  - Select file and start SD print (Can be used _while_ printing from SD card files): 
99
+// M32  - Select file and start SD print (Can be used _while_ printing from SD card files):
100 100
 //        syntax "M32 /path/filename#", or "M32 S<startpos bytes> !filename#"
101 101
 //        Call gcode file : "M32 P !filename#" and return to caller file after finishing (simiarl to #include).
102 102
 //        The '#' is necessary when calling from within sd files, as it stops buffer prereading
@@ -226,7 +226,11 @@ int EtoPPressure=0;
226 226
 #endif
227 227
 
228 228
 #ifdef ULTIPANEL
229
-	bool powersupply = true;
229
+  #ifdef PS_DEFAULT_OFF
230
+    bool powersupply = false;
231
+  #else
232
+	  bool powersupply = true;
233
+  #endif
230 234
 #endif
231 235
 
232 236
 #ifdef DELTA
@@ -415,7 +419,7 @@ void servo_init()
415 419
 
416 420
   #if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
417 421
   delay(PROBE_SERVO_DEACTIVATION_DELAY);
418
-  servos[servo_endstops[Z_AXIS]].detach();  
422
+  servos[servo_endstops[Z_AXIS]].detach();
419 423
   #endif
420 424
 }
421 425
 
@@ -636,17 +640,17 @@ void get_command()
636 640
   if(!card.sdprinting || serial_count!=0){
637 641
     return;
638 642
   }
639
-  
643
+
640 644
   //'#' stops reading from sd to the buffer prematurely, so procedural macro calls are possible
641
-  // if it occures, stop_buffering is triggered and the buffer is ran dry. 
645
+  // if it occures, stop_buffering is triggered and the buffer is ran dry.
642 646
   // this character _can_ occure in serial com, due to checksums. however, no checksums are used in sd printing
643
-  
647
+
644 648
   static bool stop_buffering=false;
645 649
   if(buflen==0) stop_buffering=false;
646
-  
647
-  while( !card.eof()  && buflen < BUFSIZE && !stop_buffering) { 
650
+
651
+  while( !card.eof()  && buflen < BUFSIZE && !stop_buffering) {
648 652
     int16_t n=card.get();
649
-    serial_char = (char)n; 
653
+    serial_char = (char)n;
650 654
     if(serial_char == '\n' ||
651 655
        serial_char == '\r' ||
652 656
        (serial_char == '#' && comment_mode == false) ||
@@ -671,7 +675,7 @@ void get_command()
671 675
       }
672 676
       if(serial_char=='#')
673 677
         stop_buffering=true;
674
-      
678
+
675 679
       if(!serial_count)
676 680
       {
677 681
         comment_mode = false; //for new command
@@ -743,13 +747,13 @@ XYZ_CONSTS_FROM_CONFIG(signed char, home_dir,  HOME_DIR);
743 747
   #endif
744 748
   #if X_HOME_DIR != -1 || X2_HOME_DIR != 1
745 749
     #error "Please use canonical x-carriage assignment" // the x-carriages are defined by their homing directions
746
-  #endif  
750
+  #endif
747 751
 
748 752
 #define DXC_FULL_CONTROL_MODE 0
749 753
 #define DXC_AUTO_PARK_MODE    1
750 754
 #define DXC_DUPLICATION_MODE  2
751 755
 static int dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
752
- 
756
+
753 757
 static float x_home_pos(int extruder) {
754 758
   if (extruder == 0)
755 759
     return base_home_pos(X_AXIS) + add_homeing[X_AXIS];
@@ -767,12 +771,12 @@ static int x_home_dir(int extruder) {
767 771
 
768 772
 static float inactive_extruder_x_pos = X2_MAX_POS; // used in mode 0 & 1
769 773
 static bool active_extruder_parked = false; // used in mode 1 & 2
770
-static float raised_parked_position[NUM_AXIS]; // used in mode 1 
771
-static unsigned long delayed_move_time = 0; // used in mode 1 
774
+static float raised_parked_position[NUM_AXIS]; // used in mode 1
775
+static unsigned long delayed_move_time = 0; // used in mode 1
772 776
 static float duplicate_extruder_x_offset = DEFAULT_DUPLICATION_X_OFFSET; // used in mode 2
773 777
 static float duplicate_extruder_temp_offset = 0; // used in mode 2
774 778
 bool extruder_duplication_enabled = false; // used in mode 2
775
-#endif //DUAL_X_CARRIAGE    
779
+#endif //DUAL_X_CARRIAGE
776 780
 
777 781
 static void axis_is_at_home(int axis) {
778 782
 #ifdef DUAL_X_CARRIAGE
@@ -785,8 +789,8 @@ static void axis_is_at_home(int axis) {
785 789
     }
786 790
     else if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && active_extruder == 0) {
787 791
       current_position[X_AXIS] = base_home_pos(X_AXIS) + add_homeing[X_AXIS];
788
-      min_pos[X_AXIS] =          base_min_pos(X_AXIS) + add_homeing[X_AXIS]; 
789
-      max_pos[X_AXIS] =          min(base_max_pos(X_AXIS) + add_homeing[X_AXIS], 
792
+      min_pos[X_AXIS] =          base_min_pos(X_AXIS) + add_homeing[X_AXIS];
793
+      max_pos[X_AXIS] =          min(base_max_pos(X_AXIS) + add_homeing[X_AXIS],
790 794
                                   max(extruder_offset[X_AXIS][1], X2_MAX_POS) - duplicate_extruder_x_offset);
791 795
       return;
792 796
     }
@@ -853,7 +857,7 @@ static void run_z_probe() {
853 857
     st_synchronize();
854 858
 
855 859
     // move back down slowly to find bed
856
-    feedrate = homing_feedrate[Z_AXIS]/4; 
860
+    feedrate = homing_feedrate[Z_AXIS]/4;
857 861
     zPosition -= home_retract_mm(Z_AXIS) * 2;
858 862
     plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
859 863
     st_synchronize();
@@ -950,7 +954,7 @@ static void homeaxis(int axis) {
950 954
 
951 955
     current_position[axis] = 0;
952 956
     plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
953
-	
957
+
954 958
 
955 959
     // Engage Servo endstop if enabled
956 960
     #ifdef SERVO_ENDSTOPS
@@ -1008,7 +1012,7 @@ static void homeaxis(int axis) {
1008 1012
 #if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
1009 1013
     if (axis==Z_AXIS) retract_z_probe();
1010 1014
 #endif
1011
-    
1015
+
1012 1016
   }
1013 1017
 }
1014 1018
 #define HOMEAXIS(LETTER) homeaxis(LETTER##_AXIS)
@@ -1082,7 +1086,7 @@ void process_commands()
1082 1086
         destination[Y_AXIS]=current_position[Y_AXIS];
1083 1087
         destination[Z_AXIS]=current_position[Z_AXIS];
1084 1088
         current_position[Z_AXIS]+=retract_zlift;
1085
-        destination[E_AXIS]=current_position[E_AXIS]+retract_length+retract_recover_length; 
1089
+        destination[E_AXIS]=current_position[E_AXIS]+retract_length+retract_recover_length;
1086 1090
         feedrate=retract_recover_feedrate;
1087 1091
         retracted=false;
1088 1092
         prepare_move();
@@ -1196,10 +1200,10 @@ void process_commands()
1196 1200
         // reset state used by the different modes
1197 1201
         memcpy(raised_parked_position, current_position, sizeof(raised_parked_position));
1198 1202
         delayed_move_time = 0;
1199
-        active_extruder_parked = true; 
1200
-      #else      
1203
+        active_extruder_parked = true;
1204
+      #else
1201 1205
         HOMEAXIS(X);
1202
-      #endif         
1206
+      #endif
1203 1207
       }
1204 1208
 
1205 1209
       if((home_all_axis) || (code_seen(axis_codes[Y_AXIS]))) {
@@ -1218,7 +1222,7 @@ void process_commands()
1218 1222
           current_position[Y_AXIS]=code_value()+add_homeing[1];
1219 1223
         }
1220 1224
       }
1221
-      
1225
+
1222 1226
       #if Z_HOME_DIR < 0                      // If homing towards BED do Z last
1223 1227
         #ifndef Z_SAFE_HOMING
1224 1228
           if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
@@ -1230,14 +1234,14 @@ void process_commands()
1230 1234
             #endif
1231 1235
             HOMEAXIS(Z);
1232 1236
           }
1233
-        #else                      // Z Safe mode activated. 
1237
+        #else                      // Z Safe mode activated.
1234 1238
           if(home_all_axis) {
1235 1239
             destination[X_AXIS] = round(Z_SAFE_HOMING_X_POINT - X_PROBE_OFFSET_FROM_EXTRUDER);
1236 1240
             destination[Y_AXIS] = round(Z_SAFE_HOMING_Y_POINT - Y_PROBE_OFFSET_FROM_EXTRUDER);
1237 1241
             destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1);    // Set destination away from bed
1238 1242
             feedrate = XY_TRAVEL_SPEED;
1239 1243
             current_position[Z_AXIS] = 0;
1240
-			
1244
+
1241 1245
             plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1242 1246
             plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder);
1243 1247
             st_synchronize();
@@ -1255,7 +1259,7 @@ void process_commands()
1255 1259
               && (current_position[Y_AXIS]+Y_PROBE_OFFSET_FROM_EXTRUDER <= Y_MAX_POS)) {
1256 1260
 
1257 1261
               current_position[Z_AXIS] = 0;
1258
-              plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);			  
1262
+              plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1259 1263
               destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1);    // Set destination away from bed
1260 1264
               feedrate = max_feedrate[Z_AXIS];
1261 1265
               plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder);
@@ -1275,8 +1279,8 @@ void process_commands()
1275 1279
         #endif
1276 1280
       #endif
1277 1281
 
1278
-      
1279
-     
1282
+
1283
+
1280 1284
       if(code_seen(axis_codes[Z_AXIS])) {
1281 1285
         if(code_value_long() != 0) {
1282 1286
           current_position[Z_AXIS]=code_value()+add_homeing[2];
@@ -1347,7 +1351,7 @@ void process_commands()
1347 1351
             run_z_probe();
1348 1352
             float z_at_xLeft_yFront = current_position[Z_AXIS];
1349 1353
             retract_z_probe();
1350
-            
1354
+
1351 1355
             SERIAL_PROTOCOLPGM("Bed x: ");
1352 1356
             SERIAL_PROTOCOL(LEFT_PROBE_BED_POSITION);
1353 1357
             SERIAL_PROTOCOLPGM(" y: ");
@@ -1365,7 +1369,7 @@ void process_commands()
1365 1369
             run_z_probe();
1366 1370
             float z_at_xRight_yFront = current_position[Z_AXIS];
1367 1371
             retract_z_probe(); // Retract Z Servo endstop if available
1368
-            
1372
+
1369 1373
             SERIAL_PROTOCOLPGM("Bed x: ");
1370 1374
             SERIAL_PROTOCOL(RIGHT_PROBE_BED_POSITION);
1371 1375
             SERIAL_PROTOCOLPGM(" y: ");
@@ -1378,10 +1382,10 @@ void process_commands()
1378 1382
 
1379 1383
             set_bed_level_equation(z_at_xLeft_yFront, z_at_xRight_yFront, z_at_xLeft_yBack);
1380 1384
 
1381
-            st_synchronize();            
1385
+            st_synchronize();
1382 1386
 
1383 1387
             // The following code correct the Z height difference from z-probe position and hotend tip position.
1384
-            // The Z height on homing is measured by Z-Probe, but the probe is quite far from the hotend. 
1388
+            // The Z height on homing is measured by Z-Probe, but the probe is quite far from the hotend.
1385 1389
             // When the bed is uneven, this height must be corrected.
1386 1390
             real_z = float(st_get_position(Z_AXIS))/axis_steps_per_unit[Z_AXIS];  //get the real Z (since the auto bed leveling is already correcting the plane)
1387 1391
             x_tmp = current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER;
@@ -1393,11 +1397,11 @@ void process_commands()
1393 1397
             plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1394 1398
         }
1395 1399
         break;
1396
-        
1400
+
1397 1401
     case 30: // G30 Single Z Probe
1398 1402
         {
1399 1403
             engage_z_probe(); // Engage Z Servo endstop if available
1400
-            
1404
+
1401 1405
             st_synchronize();
1402 1406
             // TODO: make sure the bed_level_rotation_matrix is identity or the planner will get set incorectly
1403 1407
             setup_for_endstop_move();
@@ -1548,14 +1552,14 @@ void process_commands()
1548 1552
         card.removeFile(strchr_pointer + 4);
1549 1553
       }
1550 1554
       break;
1551
-    case 32: //M32 - Select file and start SD print 
1555
+    case 32: //M32 - Select file and start SD print
1552 1556
     {
1553 1557
       if(card.sdprinting) {
1554 1558
         st_synchronize();
1555 1559
 
1556 1560
       }
1557
-      starpos = (strchr(strchr_pointer + 4,'*')); 
1558
-      
1561
+      starpos = (strchr(strchr_pointer + 4,'*'));
1562
+
1559 1563
       char* namestartpos = (strchr(strchr_pointer + 4,'!'));   //find ! to indicate filename string start.
1560 1564
       if(namestartpos==NULL)
1561 1565
       {
@@ -1563,16 +1567,16 @@ void process_commands()
1563 1567
       }
1564 1568
       else
1565 1569
         namestartpos++; //to skip the '!'
1566
-        
1570
+
1567 1571
       if(starpos!=NULL)
1568 1572
         *(starpos-1)='\0';
1569
-            
1573
+
1570 1574
       bool call_procedure=(code_seen('P'));
1571
-      
1572
-      if(strchr_pointer>namestartpos) 
1575
+
1576
+      if(strchr_pointer>namestartpos)
1573 1577
         call_procedure=false;  //false alert, 'P' found within filename
1574
-      
1575
-      if( card.cardOK ) 
1578
+
1579
+      if( card.cardOK )
1576 1580
       {
1577 1581
         card.openFile(namestartpos,true,!call_procedure);
1578 1582
         if(code_seen('S'))
@@ -1645,7 +1649,7 @@ void process_commands()
1645 1649
 #ifdef DUAL_X_CARRIAGE
1646 1650
       if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && tmp_extruder == 0)
1647 1651
         setTargetHotend1(code_value() == 0.0 ? 0.0 : code_value() + duplicate_extruder_temp_offset);
1648
-#endif          
1652
+#endif
1649 1653
       setWatch();
1650 1654
       break;
1651 1655
     case 140: // M140 set bed temp
@@ -1701,7 +1705,7 @@ void process_commands()
1701 1705
             SERIAL_PROTOCOL_F(rawHotendTemp(cur_extruder)/OVERSAMPLENR,0);
1702 1706
           }
1703 1707
         #endif
1704
-		
1708
+
1705 1709
         SERIAL_PROTOCOLLN("");
1706 1710
       return;
1707 1711
       break;
@@ -1719,14 +1723,14 @@ void process_commands()
1719 1723
 #ifdef DUAL_X_CARRIAGE
1720 1724
         if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && tmp_extruder == 0)
1721 1725
           setTargetHotend1(code_value() == 0.0 ? 0.0 : code_value() + duplicate_extruder_temp_offset);
1722
-#endif          
1726
+#endif
1723 1727
         CooldownNoWait = true;
1724 1728
       } else if (code_seen('R')) {
1725 1729
         setTargetHotend(code_value(), tmp_extruder);
1726 1730
 #ifdef DUAL_X_CARRIAGE
1727 1731
         if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && tmp_extruder == 0)
1728 1732
           setTargetHotend1(code_value() == 0.0 ? 0.0 : code_value() + duplicate_extruder_temp_offset);
1729
-#endif          
1733
+#endif
1730 1734
         CooldownNoWait = false;
1731 1735
       }
1732 1736
       #ifdef AUTOTEMP
@@ -1890,7 +1894,7 @@ void process_commands()
1890 1894
             SET_OUTPUT(SUICIDE_PIN);
1891 1895
             WRITE(SUICIDE_PIN, HIGH);
1892 1896
         #endif
1893
-        
1897
+
1894 1898
         #ifdef ULTIPANEL
1895 1899
           powersupply = true;
1896 1900
           LCD_MESSAGEPGM(WELCOME_MSG);
@@ -2047,18 +2051,18 @@ void process_commands()
2047 2051
       #endif
2048 2052
       break;
2049 2053
       //TODO: update for all axis, use for loop
2050
-    #ifdef BLINKM  
2054
+    #ifdef BLINKM
2051 2055
     case 150: // M150
2052 2056
       {
2053 2057
         byte red;
2054 2058
         byte grn;
2055 2059
         byte blu;
2056
-        
2060
+
2057 2061
         if(code_seen('R')) red = code_value();
2058 2062
         if(code_seen('U')) grn = code_value();
2059 2063
         if(code_seen('B')) blu = code_value();
2060
-        
2061
-        SendColors(red,grn,blu);        
2064
+
2065
+        SendColors(red,grn,blu);
2062 2066
       }
2063 2067
       break;
2064 2068
     #endif //BLINKM
@@ -2180,7 +2184,7 @@ void process_commands()
2180 2184
       {
2181 2185
         extruder_offset[Z_AXIS][tmp_extruder] = code_value();
2182 2186
       }
2183
-      #endif       
2187
+      #endif
2184 2188
       SERIAL_ECHO_START;
2185 2189
       SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
2186 2190
       for(tmp_extruder = 0; tmp_extruder < EXTRUDERS; tmp_extruder++)
@@ -2213,17 +2217,17 @@ void process_commands()
2213 2217
       }
2214 2218
     }
2215 2219
     break;
2216
-	
2220
+
2217 2221
 	case 226: // M226 P<pin number> S<pin state>- Wait until the specified pin reaches the state required
2218 2222
 	{
2219 2223
       if(code_seen('P')){
2220 2224
         int pin_number = code_value(); // pin number
2221 2225
         int pin_state = -1; // required pin state - default is inverted
2222
-        
2226
+
2223 2227
         if(code_seen('S')) pin_state = code_value(); // required pin state
2224
-      
2228
+
2225 2229
         if(pin_state >= -1 && pin_state <= 1){
2226
-        
2230
+
2227 2231
           for(int8_t i = 0; i < (int8_t)sizeof(sensitive_pins); i++)
2228 2232
           {
2229 2233
             if (sensitive_pins[i] == pin_number)
@@ -2232,28 +2236,28 @@ void process_commands()
2232 2236
               break;
2233 2237
             }
2234 2238
           }
2235
-        
2239
+
2236 2240
           if (pin_number > -1)
2237 2241
           {
2238 2242
             st_synchronize();
2239
-            
2243
+
2240 2244
             pinMode(pin_number, INPUT);
2241
-            
2245
+
2242 2246
             int target;
2243 2247
             switch(pin_state){
2244 2248
             case 1:
2245 2249
               target = HIGH;
2246 2250
               break;
2247
-            
2251
+
2248 2252
             case 0:
2249 2253
               target = LOW;
2250 2254
               break;
2251
-            
2255
+
2252 2256
             case -1:
2253 2257
               target = !digitalRead(pin_number);
2254 2258
               break;
2255 2259
             }
2256
-            
2260
+
2257 2261
             while(digitalRead(pin_number) != target){
2258 2262
               manage_heater();
2259 2263
               manage_inactivity();
@@ -2263,7 +2267,7 @@ void process_commands()
2263 2267
         }
2264 2268
       }
2265 2269
     }
2266
-    break;	
2270
+    break;
2267 2271
 
2268 2272
     #if NUM_SERVOS > 0
2269 2273
     case 280: // M280 - set servo position absolute. P: servo index, S: angle or microseconds
@@ -2439,13 +2443,13 @@ void process_commands()
2439 2443
         engage_z_probe();    // Engage Z Servo endstop if available
2440 2444
     }
2441 2445
     break;
2442
-    
2446
+
2443 2447
     case 402:
2444 2448
     {
2445 2449
         retract_z_probe();    // Retract Z Servo endstop if enabled
2446 2450
     }
2447 2451
     break;
2448
-#endif    
2452
+#endif
2449 2453
     case 500: // M500 Store settings in EEPROM
2450 2454
     {
2451 2455
         Config_StoreSettings();
@@ -2603,14 +2607,14 @@ void process_commands()
2603 2607
               //    M605 S0: Full control mode. The slicer has full control over x-carriage movement
2604 2608
               //    M605 S1: Auto-park mode. The inactive head will auto park/unpark without slicer involvement
2605 2609
               //    M605 S2 [Xnnn] [Rmmm]: Duplication mode. The second extruder will duplicate the first with nnn
2606
-              //                         millimeters x-offset and an optional differential hotend temperature of 
2610
+              //                         millimeters x-offset and an optional differential hotend temperature of
2607 2611
               //                         mmm degrees. E.g., with "M605 S2 X100 R2" the second extruder will duplicate
2608 2612
               //                         the first with a spacing of 100mm in the x direction and 2 degrees hotter.
2609 2613
               //
2610 2614
               //    Note: the X axis should be homed after changing dual x-carriage mode.
2611 2615
     {
2612 2616
         st_synchronize();
2613
-        
2617
+
2614 2618
         if (code_seen('S'))
2615 2619
           dual_x_carriage_mode = code_value();
2616 2620
 
@@ -2621,7 +2625,7 @@ void process_commands()
2621 2625
 
2622 2626
           if (code_seen('R'))
2623 2627
             duplicate_extruder_temp_offset = code_value();
2624
-            
2628
+
2625 2629
           SERIAL_ECHO_START;
2626 2630
           SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
2627 2631
           SERIAL_ECHO(" ");
@@ -2637,13 +2641,13 @@ void process_commands()
2637 2641
         {
2638 2642
           dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
2639 2643
         }
2640
-        
2644
+
2641 2645
         active_extruder_parked = false;
2642 2646
         extruder_duplication_enabled = false;
2643 2647
         delayed_move_time = 0;
2644 2648
     }
2645 2649
     break;
2646
-    #endif //DUAL_X_CARRIAGE         
2650
+    #endif //DUAL_X_CARRIAGE
2647 2651
 
2648 2652
     case 907: // M907 Set digital trimpot motor current using axis codes.
2649 2653
     {
@@ -2724,19 +2728,19 @@ void process_commands()
2724 2728
         // Save current position to return to after applying extruder offset
2725 2729
         memcpy(destination, current_position, sizeof(destination));
2726 2730
       #ifdef DUAL_X_CARRIAGE
2727
-        if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE && Stopped == false && 
2731
+        if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE && Stopped == false &&
2728 2732
             (delayed_move_time != 0 || current_position[X_AXIS] != x_home_pos(active_extruder)))
2729 2733
         {
2730 2734
           // Park old head: 1) raise 2) move to park position 3) lower
2731
-          plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + TOOLCHANGE_PARK_ZLIFT, 
2735
+          plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + TOOLCHANGE_PARK_ZLIFT,
2732 2736
                 current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder);
2733
-          plan_buffer_line(x_home_pos(active_extruder), current_position[Y_AXIS], current_position[Z_AXIS] + TOOLCHANGE_PARK_ZLIFT, 
2737
+          plan_buffer_line(x_home_pos(active_extruder), current_position[Y_AXIS], current_position[Z_AXIS] + TOOLCHANGE_PARK_ZLIFT,
2734 2738
                 current_position[E_AXIS], max_feedrate[X_AXIS], active_extruder);
2735
-          plan_buffer_line(x_home_pos(active_extruder), current_position[Y_AXIS], current_position[Z_AXIS], 
2739
+          plan_buffer_line(x_home_pos(active_extruder), current_position[Y_AXIS], current_position[Z_AXIS],
2736 2740
                 current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder);
2737 2741
           st_synchronize();
2738 2742
         }
2739
-        
2743
+
2740 2744
         // apply Y & Z extruder offset (x offset is already used in determining home pos)
2741 2745
         current_position[Y_AXIS] = current_position[Y_AXIS] -
2742 2746
                      extruder_offset[Y_AXIS][active_extruder] +
@@ -2744,7 +2748,7 @@ void process_commands()
2744 2748
         current_position[Z_AXIS] = current_position[Z_AXIS] -
2745 2749
                      extruder_offset[Z_AXIS][active_extruder] +
2746 2750
                      extruder_offset[Z_AXIS][tmp_extruder];
2747
-                     
2751
+
2748 2752
         active_extruder = tmp_extruder;
2749 2753
 
2750 2754
         // This function resets the max/min values - the current position may be overwritten below.
@@ -2752,18 +2756,18 @@ void process_commands()
2752 2756
 
2753 2757
         if (dual_x_carriage_mode == DXC_FULL_CONTROL_MODE)
2754 2758
         {
2755
-          current_position[X_AXIS] = inactive_extruder_x_pos; 
2759
+          current_position[X_AXIS] = inactive_extruder_x_pos;
2756 2760
           inactive_extruder_x_pos = destination[X_AXIS];
2757 2761
         }
2758 2762
         else if (dual_x_carriage_mode == DXC_DUPLICATION_MODE)
2759 2763
         {
2760 2764
           active_extruder_parked = (active_extruder == 0); // this triggers the second extruder to move into the duplication position
2761 2765
           if (active_extruder == 0 || active_extruder_parked)
2762
-            current_position[X_AXIS] = inactive_extruder_x_pos; 
2766
+            current_position[X_AXIS] = inactive_extruder_x_pos;
2763 2767
           else
2764
-            current_position[X_AXIS] = destination[X_AXIS] + duplicate_extruder_x_offset; 
2768
+            current_position[X_AXIS] = destination[X_AXIS] + duplicate_extruder_x_offset;
2765 2769
           inactive_extruder_x_pos = destination[X_AXIS];
2766
-          extruder_duplication_enabled = false; 
2770
+          extruder_duplication_enabled = false;
2767 2771
         }
2768 2772
         else
2769 2773
         {
@@ -2773,7 +2777,7 @@ void process_commands()
2773 2777
           active_extruder_parked = true;
2774 2778
           delayed_move_time = 0;
2775 2779
         }
2776
-      #else    
2780
+      #else
2777 2781
         // Offset extruder (only by XY)
2778 2782
         int i;
2779 2783
         for(i = 0; i < 2; i++) {
@@ -2986,13 +2990,13 @@ void prepare_move()
2986 2990
     {
2987 2991
       // move duplicate extruder into correct duplication position.
2988 2992
       plan_set_position(inactive_extruder_x_pos, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
2989
-      plan_buffer_line(current_position[X_AXIS] + duplicate_extruder_x_offset, current_position[Y_AXIS], current_position[Z_AXIS], 
2993
+      plan_buffer_line(current_position[X_AXIS] + duplicate_extruder_x_offset, current_position[Y_AXIS], current_position[Z_AXIS],
2990 2994
           current_position[E_AXIS], max_feedrate[X_AXIS], 1);
2991 2995
       plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
2992 2996
       st_synchronize();
2993 2997
       extruder_duplication_enabled = true;
2994 2998
       active_extruder_parked = false;
2995
-    }  
2999
+    }
2996 3000
     else if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE) // handle unparking of head
2997 3001
     {
2998 3002
       if (current_position[E_AXIS] == destination[E_AXIS])
@@ -3001,7 +3005,7 @@ void prepare_move()
3001 3005
         // be used as start of first non-travel move)
3002 3006
         if (delayed_move_time != 0xFFFFFFFFUL)
3003 3007
         {
3004
-          memcpy(current_position, destination, sizeof(current_position)); 
3008
+          memcpy(current_position, destination, sizeof(current_position));
3005 3009
           if (destination[Z_AXIS] > raised_parked_position[Z_AXIS])
3006 3010
             raised_parked_position[Z_AXIS] = destination[Z_AXIS];
3007 3011
           delayed_move_time = millis();
@@ -3011,9 +3015,9 @@ void prepare_move()
3011 3015
       delayed_move_time = 0;
3012 3016
       // unpark extruder: 1) raise, 2) move into starting XY position, 3) lower
3013 3017
       plan_buffer_line(raised_parked_position[X_AXIS], raised_parked_position[Y_AXIS], raised_parked_position[Z_AXIS],    current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder);
3014
-      plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], raised_parked_position[Z_AXIS], 
3018
+      plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], raised_parked_position[Z_AXIS],
3015 3019
           current_position[E_AXIS], min(max_feedrate[X_AXIS],max_feedrate[Y_AXIS]), active_extruder);
3016
-      plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], 
3020
+      plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS],
3017 3021
           current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder);
3018 3022
       active_extruder_parked = false;
3019 3023
     }
@@ -3179,7 +3183,7 @@ void manage_inactivity()
3179 3183
       // travel moves have been received so enact them
3180 3184
       delayed_move_time = 0xFFFFFFFFUL; // force moves to be done
3181 3185
       memcpy(destination,current_position,sizeof(destination));
3182
-      prepare_move(); 
3186
+      prepare_move();
3183 3187
     }
3184 3188
   #endif
3185 3189
   #ifdef TEMP_STAT_LEDS

+ 31
- 27
Marlin/ultralcd.cpp View File

@@ -90,12 +90,16 @@ static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned l
90 90
 #define ENCODER_FEEDRATE_DEADZONE 10
91 91
 
92 92
 #if !defined(LCD_I2C_VIKI)
93
-  #define ENCODER_STEPS_PER_MENU_ITEM 5
93
+  #ifndef ENCODER_STEPS_PER_MENU_ITEM
94
+    #define ENCODER_STEPS_PER_MENU_ITEM 5
95
+  #endif
94 96
   #ifndef ENCODER_PULSES_PER_STEP
95 97
     #define ENCODER_PULSES_PER_STEP 1
96 98
   #endif
97 99
 #else
98
-  #define ENCODER_STEPS_PER_MENU_ITEM 2 // VIKI LCD rotary encoder uses a different number of steps per rotation
100
+  #ifndef ENCODER_STEPS_PER_MENU_ITEM
101
+    #define ENCODER_STEPS_PER_MENU_ITEM 2 // VIKI LCD rotary encoder uses a different number of steps per rotation
102
+  #endif
99 103
   #ifndef ENCODER_PULSES_PER_STEP
100 104
     #define ENCODER_PULSES_PER_STEP 1
101 105
   #endif
@@ -207,7 +211,7 @@ static void lcd_status_screen()
207 211
     else if (feedmultiply == 100 && int(encoderPosition) < -ENCODER_FEEDRATE_DEADZONE)
208 212
     {
209 213
         feedmultiply += int(encoderPosition) + ENCODER_FEEDRATE_DEADZONE;
210
-        encoderPosition = 0;	
214
+        encoderPosition = 0;
211 215
     }
212 216
     else if (feedmultiply != 100)
213 217
     {
@@ -407,7 +411,7 @@ static void lcd_tune_menu()
407 411
 #endif
408 412
     MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255);
409 413
     MENU_ITEM_EDIT(int3, MSG_FLOW, &extrudemultiply, 10, 999);
410
-    
414
+
411 415
 #ifdef BABYSTEPPING
412 416
     #ifdef BABYSTEP_XY
413 417
       MENU_ITEM(submenu, "Babystep X", lcd_babystep_x);
@@ -719,7 +723,7 @@ static void lcd_control_motion_menu()
719 723
     MENU_ITEM_EDIT(float52, MSG_XSTEPS, &axis_steps_per_unit[X_AXIS], 5, 9999);
720 724
     MENU_ITEM_EDIT(float52, MSG_YSTEPS, &axis_steps_per_unit[Y_AXIS], 5, 9999);
721 725
     MENU_ITEM_EDIT(float51, MSG_ZSTEPS, &axis_steps_per_unit[Z_AXIS], 5, 9999);
722
-    MENU_ITEM_EDIT(float51, MSG_ESTEPS, &axis_steps_per_unit[E_AXIS], 5, 9999);    
726
+    MENU_ITEM_EDIT(float51, MSG_ESTEPS, &axis_steps_per_unit[E_AXIS], 5, 9999);
723 727
 #ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
724 728
     MENU_ITEM_EDIT(bool, "Endstop abort", &abort_on_endstop_hit);
725 729
 #endif
@@ -781,7 +785,7 @@ static void lcd_sd_updir()
781 785
 
782 786
 void lcd_sdcard_menu()
783 787
 {
784
-    if (lcdDrawUpdate == 0 && LCD_CLICKED == 0) 
788
+    if (lcdDrawUpdate == 0 && LCD_CLICKED == 0)
785 789
         return;	// nothing to do (so don't thrash the SD card)
786 790
     uint16_t fileCnt = card.getnrfilenames();
787 791
     START_MENU();
@@ -795,7 +799,7 @@ void lcd_sdcard_menu()
795 799
     }else{
796 800
         MENU_ITEM(function, LCD_STR_FOLDER "..", lcd_sd_updir);
797 801
     }
798
-    
802
+
799 803
     for(uint16_t i=0;i<fileCnt;i++)
800 804
     {
801 805
         if (_menuItemNr == _lineNr)
@@ -982,14 +986,14 @@ void lcd_init()
982 986
 
983 987
 #ifdef NEWPANEL
984 988
     pinMode(BTN_EN1,INPUT);
985
-    pinMode(BTN_EN2,INPUT); 
989
+    pinMode(BTN_EN2,INPUT);
986 990
     pinMode(SDCARDDETECT,INPUT);
987 991
     WRITE(BTN_EN1,HIGH);
988 992
     WRITE(BTN_EN2,HIGH);
989 993
   #if BTN_ENC > 0
990
-    pinMode(BTN_ENC,INPUT); 
994
+    pinMode(BTN_ENC,INPUT);
991 995
     WRITE(BTN_ENC,HIGH);
992
-  #endif    
996
+  #endif
993 997
   #ifdef REPRAPWORLD_KEYPAD
994 998
     pinMode(SHIFT_CLK,OUTPUT);
995 999
     pinMode(SHIFT_LD,OUTPUT);
@@ -1007,9 +1011,9 @@ void lcd_init()
1007 1011
      pinMode(SHIFT_EN,OUTPUT);
1008 1012
      pinMode(SHIFT_OUT,INPUT);
1009 1013
      WRITE(SHIFT_OUT,HIGH);
1010
-     WRITE(SHIFT_LD,HIGH); 
1014
+     WRITE(SHIFT_LD,HIGH);
1011 1015
      WRITE(SHIFT_EN,LOW);
1012
-   #endif // SR_LCD_2W_NL    
1016
+   #endif // SR_LCD_2W_NL
1013 1017
 #endif//!NEWPANEL
1014 1018
 
1015 1019
 #if (SDCARDDETECT > 0)
@@ -1020,28 +1024,28 @@ void lcd_init()
1020 1024
     slow_buttons = 0;
1021 1025
     #endif
1022 1026
     lcd_buttons_update();
1023
-#ifdef ULTIPANEL    
1027
+#ifdef ULTIPANEL
1024 1028
     encoderDiff = 0;
1025
-#endif    
1029
+#endif
1026 1030
 }
1027 1031
 
1028 1032
 void lcd_update()
1029 1033
 {
1030 1034
     static unsigned long timeoutToStatus = 0;
1031
-    
1035
+
1032 1036
     #ifdef LCD_HAS_SLOW_BUTTONS
1033 1037
     slow_buttons = lcd_implementation_read_slow_buttons(); // buttons which take too long to read in interrupt context
1034 1038
     #endif
1035
-    
1039
+
1036 1040
     lcd_buttons_update();
1037
-    
1041
+
1038 1042
     #if (SDCARDDETECT > 0)
1039 1043
     if((IS_SD_INSERTED != lcd_oldcardstatus))
1040 1044
     {
1041 1045
         lcdDrawUpdate = 2;
1042 1046
         lcd_oldcardstatus = IS_SD_INSERTED;
1043 1047
         lcd_implementation_init(); // to maybe revive the lcd if static electricty killed it.
1044
-        
1048
+
1045 1049
         if(lcd_oldcardstatus)
1046 1050
         {
1047 1051
             card.initsd();
@@ -1054,7 +1058,7 @@ void lcd_update()
1054 1058
         }
1055 1059
     }
1056 1060
     #endif//CARDINSERTED
1057
-    
1061
+
1058 1062
     if (lcd_next_update_millis < millis())
1059 1063
     {
1060 1064
 #ifdef ULTIPANEL
@@ -1095,7 +1099,7 @@ void lcd_update()
1095 1099
 #ifdef DOGLCD        // Changes due to different driver architecture of the DOGM display
1096 1100
         blink++;     // Variable for fan animation and alive dot
1097 1101
         u8g.firstPage();
1098
-        do 
1102
+        do
1099 1103
         {
1100 1104
             u8g.setFont(u8g_font_6x10_marlin);
1101 1105
             u8g.setPrintPos(125,0);
@@ -1105,7 +1109,7 @@ void lcd_update()
1105 1109
             (*currentMenu)();
1106 1110
             if (!lcdDrawUpdate)  break; // Terminate display update, when nothing new to draw. This must be done before the last dogm.next()
1107 1111
         } while( u8g.nextPage() );
1108
-#else        
1112
+#else
1109 1113
         (*currentMenu)();
1110 1114
 #endif
1111 1115
 
@@ -1159,7 +1163,7 @@ void lcd_reset_alert_level()
1159 1163
 void lcd_setcontrast(uint8_t value)
1160 1164
 {
1161 1165
     lcd_contrast = value & 63;
1162
-    u8g.setContrast(lcd_contrast);	
1166
+    u8g.setContrast(lcd_contrast);
1163 1167
 }
1164 1168
 #endif
1165 1169
 
@@ -1199,7 +1203,7 @@ void lcd_buttons_update()
1199 1203
     WRITE(SHIFT_LD,HIGH);
1200 1204
     unsigned char tmp_buttons=0;
1201 1205
     for(int8_t i=0;i<8;i++)
1202
-    { 
1206
+    {
1203 1207
         newbutton = newbutton>>1;
1204 1208
         if(READ(SHIFT_OUT))
1205 1209
             newbutton|=(1<<7);
@@ -1249,14 +1253,14 @@ void lcd_buttons_update()
1249 1253
 }
1250 1254
 
1251 1255
 void lcd_buzz(long duration, uint16_t freq)
1252
-{ 
1256
+{
1253 1257
 #ifdef LCD_USE_I2C_BUZZER
1254 1258
   lcd.buzz(duration,freq);
1255
-#endif   
1259
+#endif
1256 1260
 }
1257 1261
 
1258
-bool lcd_clicked() 
1259
-{ 
1262
+bool lcd_clicked()
1263
+{
1260 1264
   return LCD_CLICKED;
1261 1265
 }
1262 1266
 #endif//ULTIPANEL

Loading…
Cancel
Save