Selaa lähdekoodia

Merge pull request #407 from buildrob101/Marlin_v1

Combine and converge other I2C LCD branches (PANELOLU2, VIKI & PCF8575)
ErikZalm 12 vuotta sitten
vanhempi
commit
1a18a487f9
7 muutettua tiedostoa jossa 1081 lisäystä ja 907 poistoa
  1. 63
    23
      Marlin/Configuration.h
  2. 11
    5
      Marlin/Marlin.pde
  3. 89
    84
      Marlin/Marlin_main.cpp
  4. 50
    159
      Marlin/pins.h
  5. 117
    83
      Marlin/ultralcd.cpp
  6. 3
    38
      Marlin/ultralcd.h
  7. 748
    515
      Marlin/ultralcd_implementation_hitachi_HD44780.h

+ 63
- 23
Marlin/Configuration.h Näytä tiedosto

@@ -90,7 +90,7 @@
90 90
 #define TEMP_SENSOR_BED 0
91 91
 
92 92
 // Actual temperature must be close to target for this long before M109 returns success
93
-#define TEMP_RESIDENCY_TIME 10	// (seconds)
93
+#define TEMP_RESIDENCY_TIME 10  // (seconds)
94 94
 #define TEMP_HYSTERESIS 3       // (degC) range of +/- temperatures considered "close" to the target one
95 95
 #define TEMP_WINDOW     1       // (degC) Window around target to start the recidency timer x degC early.
96 96
 
@@ -315,9 +315,18 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
315 315
 // please keep turned on if you can.
316 316
 //#define EEPROM_CHITCHAT
317 317
 
318
+// Preheat Constants
319
+#define PLA_PREHEAT_HOTEND_TEMP 180 
320
+#define PLA_PREHEAT_HPB_TEMP 70
321
+#define PLA_PREHEAT_FAN_SPEED 255   // Insert Value between 0 and 255
322
+
323
+#define ABS_PREHEAT_HOTEND_TEMP 240
324
+#define ABS_PREHEAT_HPB_TEMP 100
325
+#define ABS_PREHEAT_FAN_SPEED 255   // Insert Value between 0 and 255
326
+
318 327
 //LCD and SD support
319 328
 //#define ULTRA_LCD  //general lcd support, also 16x2
320
-//#define DOGLCD	// Support for SPI LCD 128x64 (Controller ST7565R graphic Display Family)
329
+//#define DOGLCD  // Support for SPI LCD 128x64 (Controller ST7565R graphic Display Family)
321 330
 //#define SDSUPPORT // Enable SD Card Support in Hardware Console
322 331
 //#define SDSLOW // Use slower SD transfer mode (not normally needed - uncomment if you're getting volume init error)
323 332
 
@@ -360,36 +369,67 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
360 369
   #define ULTIPANEL
361 370
 #endif
362 371
 
363
-// Preheat Constants
364
-#define PLA_PREHEAT_HOTEND_TEMP 180
365
-#define PLA_PREHEAT_HPB_TEMP 70
366
-#define PLA_PREHEAT_FAN_SPEED 255		// Insert Value between 0 and 255
372
+//I2C PANELS
367 373
 
368
-#define ABS_PREHEAT_HOTEND_TEMP 240
369
-#define ABS_PREHEAT_HPB_TEMP 100
370
-#define ABS_PREHEAT_FAN_SPEED 255		// Insert Value between 0 and 255
374
+//#define LCD_I2C_SAINSMART_YWROBOT
375
+#ifdef LCD_I2C_SAINSMART_YWROBOT
376
+  // This uses the LiquidCrystal_I2C library ( https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home )
377
+  // Make sure it is placed in the Arduino libraries directory.
378
+  #define LCD_I2C_TYPE_PCF8575
379
+  #define LCD_I2C_ADDRESS 0x27   // I2C Address of the port expander
380
+  #define NEWPANEL
381
+  #define ULTIPANEL 
382
+#endif
371 383
 
384
+// PANELOLU2 LCD with status LEDs, separate encoder and click inputs
385
+//#define LCD_I2C_PANELOLU2
386
+#ifdef LCD_I2C_PANELOLU2
387
+  // This uses the LiquidTWI2 library v1.2.3 or later ( https://github.com/lincomatic/LiquidTWI2 )
388
+  // Make sure the LiquidTWI2 directory is placed in the Arduino or Sketchbook libraries subdirectory.
389
+  // (v1.2.3 no longer requires you to define PANELOLU in the LiquidTWI2.h library header file)
390
+  // Note: The PANELOLU2 encoder click input can either be directly connected to a pin 
391
+  //       (if BTN_ENC defined to != -1) or read through I2C (when BTN_ENC == -1). 
392
+  #define LCD_I2C_TYPE_MCP23017
393
+  #define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander
394
+  #define LCD_USE_I2C_BUZZER //comment out to disable buzzer on LCD
395
+  #define NEWPANEL
396
+  #define ULTIPANEL 
397
+#endif
398
+
399
+// Panucatt VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs
400
+//#define LCD_I2C_VIKI
401
+#ifdef LCD_I2C_VIKI
402
+  // This uses the LiquidTWI2 library v1.2.3 or later ( https://github.com/lincomatic/LiquidTWI2 )
403
+  // Make sure the LiquidTWI2 directory is placed in the Arduino or Sketchbook libraries subdirectory.
404
+  // Note: The pause/stop/resume LCD button pin should be connected to the Arduino
405
+  //       BTN_ENC pin (or set BTN_ENC to -1 if not used)
406
+  #define LCD_I2C_TYPE_MCP23017 
407
+  #define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander
408
+  #define LCD_USE_I2C_BUZZER //comment out to disable buzzer on LCD (requires LiquidTWI2 v1.2.3 or later)
409
+  #define NEWPANEL
410
+  #define ULTIPANEL 
411
+#endif
372 412
 
373 413
 #ifdef ULTIPANEL
374 414
 //  #define NEWPANEL  //enable this if you have a click-encoder panel
375 415
   #define SDSUPPORT
376 416
   #define ULTRA_LCD
377
-	#ifdef DOGLCD	// Change number of lines to match the DOG graphic display
378
-		#define LCD_WIDTH 20
379
-		#define LCD_HEIGHT 5
380
-	#else
381
-		#define LCD_WIDTH 20
382
-		#define LCD_HEIGHT 4
383
-	#endif
417
+  #ifdef DOGLCD // Change number of lines to match the DOG graphic display
418
+    #define LCD_WIDTH 20
419
+    #define LCD_HEIGHT 5
420
+  #else
421
+    #define LCD_WIDTH 20
422
+    #define LCD_HEIGHT 4
423
+  #endif
384 424
 #else //no panel but just lcd
385 425
   #ifdef ULTRA_LCD
386
-	#ifdef DOGLCD	// Change number of lines to match the 128x64 graphics display
387
-		#define LCD_WIDTH 20
388
-		#define LCD_HEIGHT 5
389
-	#else
390
-		#define LCD_WIDTH 16
391
-		#define LCD_HEIGHT 2
392
-	#endif
426
+  #ifdef DOGLCD // Change number of lines to match the 128x64 graphics display
427
+    #define LCD_WIDTH 20
428
+    #define LCD_HEIGHT 5
429
+  #else
430
+    #define LCD_WIDTH 16
431
+    #define LCD_HEIGHT 2
432
+  #endif
393 433
   #endif
394 434
 #endif
395 435
 

+ 11
- 5
Marlin/Marlin.pde Näytä tiedosto

@@ -34,11 +34,17 @@
34 34
 #include "pins.h"
35 35
 
36 36
 #ifdef ULTRA_LCD
37
-	#ifdef DOGLCD
38
-		#include <U8glib.h> // library for graphics LCD by Oli Kraus (https://code.google.com/p/u8glib/)
39
-	#else
40
-		#include <LiquidCrystal.h> // library for character LCD
41
-	#endif
37
+  #if defined(LCD_I2C_TYPE_PCF8575)
38
+    #include <Wire.h>
39
+    #include <LiquidCrystal_I2C.h>
40
+  #elif defined(LCD_I2C_TYPE_MCP23017) || defined(LCD_I2C_TYPE_MCP23008)
41
+    #include <Wire.h>
42
+    #include <LiquidTWI2.h>
43
+  #elif defined(DOGLCD)
44
+    #include <U8glib.h> // library for graphics LCD by Oli Kraus (https://code.google.com/p/u8glib/)
45
+  #else
46
+    #include <LiquidCrystal.h> // library for character LCD
47
+  #endif
42 48
 #endif
43 49
 
44 50
 #if DIGIPOTSS_PIN > -1

+ 89
- 84
Marlin/Marlin_main.cpp Näytä tiedosto

@@ -40,11 +40,11 @@
40 40
 #include "language.h"
41 41
 #include "pins_arduino.h"
42 42
 
43
-#if (defined NUM_SERVOS) && (NUM_SERVOS > 0)
43
+#if NUM_SERVOS > 0
44 44
 #include "Servo.h"
45 45
 #endif
46 46
 
47
-#if DIGIPOTSS_PIN > -1
47
+#if DIGIPOTSS_PIN > 0
48 48
 #include <SPI.h>
49 49
 #endif
50 50
 
@@ -102,7 +102,7 @@
102 102
 // M85  - Set inactivity shutdown timer with parameter S<seconds>. To disable set zero (default)
103 103
 // M92  - Set axis_steps_per_unit - same syntax as G92
104 104
 // M114 - Output current position to serial port
105
-// M115	- Capabilities string
105
+// M115 - Capabilities string
106 106
 // M117 - display message
107 107
 // M119 - Output Endstop status to serial port
108 108
 // M126 - Solenoid Air Valve Open (BariCUDA support by jmil)
@@ -230,7 +230,7 @@ static uint8_t tmp_extruder;
230 230
 
231 231
 bool Stopped=false;
232 232
 
233
-#if (defined NUM_SERVOS) && (NUM_SERVOS > 0)
233
+#if NUM_SERVOS > 0
234 234
   Servo servos[NUM_SERVOS];
235 235
 #endif
236 236
 
@@ -309,7 +309,7 @@ void setup_killpin()
309 309
 void setup_photpin()
310 310
 {
311 311
   #ifdef PHOTOGRAPH_PIN
312
-    #if (PHOTOGRAPH_PIN > -1)
312
+    #if (PHOTOGRAPH_PIN > 0)
313 313
     SET_OUTPUT(PHOTOGRAPH_PIN);
314 314
     WRITE(PHOTOGRAPH_PIN, LOW);
315 315
     #endif
@@ -324,7 +324,7 @@ void setup_powerhold()
324 324
       WRITE(SUICIDE_PIN, HIGH);
325 325
    #endif
326 326
  #endif
327
- #if (PS_ON_PIN > -1)
327
+ #if (PS_ON_PIN > 0)
328 328
    SET_OUTPUT(PS_ON_PIN);
329 329
    WRITE(PS_ON_PIN, PS_ON_AWAKE);
330 330
  #endif
@@ -333,7 +333,7 @@ void setup_powerhold()
333 333
 void suicide()
334 334
 {
335 335
  #ifdef SUICIDE_PIN
336
-    #if (SUICIDE_PIN> -1)
336
+    #if (SUICIDE_PIN > 0)
337 337
       SET_OUTPUT(SUICIDE_PIN);
338 338
       WRITE(SUICIDE_PIN, LOW);
339 339
     #endif
@@ -342,16 +342,16 @@ void suicide()
342 342
 
343 343
 void servo_init()
344 344
 {
345
-  #if (NUM_SERVOS >= 1) && defined (SERVO0_PIN) && (SERVO0_PIN > -1)
345
+  #if (NUM_SERVOS >= 1) && (SERVO0_PIN > 0)
346 346
     servos[0].attach(SERVO0_PIN);
347 347
   #endif
348
-  #if (NUM_SERVOS >= 2) && defined (SERVO1_PIN) && (SERVO1_PIN > -1)
348
+  #if (NUM_SERVOS >= 2) && (SERVO1_PIN > 0)
349 349
     servos[1].attach(SERVO1_PIN);
350 350
   #endif
351
-  #if (NUM_SERVOS >= 3) && defined (SERVO2_PIN) && (SERVO2_PIN > -1)
351
+  #if (NUM_SERVOS >= 3) && (SERVO2_PIN > 0)
352 352
     servos[2].attach(SERVO2_PIN);
353 353
   #endif
354
-  #if (NUM_SERVOS >= 4) && defined (SERVO3_PIN) && (SERVO3_PIN > -1)
354
+  #if (NUM_SERVOS >= 4) && (SERVO3_PIN > 0)
355 355
     servos[3].attach(SERVO3_PIN);
356 356
   #endif
357 357
   #if (NUM_SERVOS >= 5)
@@ -433,9 +433,9 @@ void loop()
433 433
     #ifdef SDSUPPORT
434 434
       if(card.saving)
435 435
       {
436
-	if(strstr_P(cmdbuffer[bufindr], PSTR("M29")) == NULL)
437
-	{
438
-	  card.write_command(cmdbuffer[bufindr]);
436
+        if(strstr_P(cmdbuffer[bufindr], PSTR("M29")) == NULL)
437
+        {
438
+          card.write_command(cmdbuffer[bufindr]);
439 439
           if(card.logging)
440 440
           {
441 441
             process_commands();
@@ -444,16 +444,16 @@ void loop()
444 444
           {
445 445
             SERIAL_PROTOCOLLNPGM(MSG_OK);
446 446
           }
447
-	}
448
-	else
449
-	{
450
-	  card.closefile();
451
-	  SERIAL_PROTOCOLLNPGM(MSG_FILE_SAVED);
452
-	}
447
+        }
448
+        else
449
+        {
450
+          card.closefile();
451
+          SERIAL_PROTOCOLLNPGM(MSG_FILE_SAVED);
452
+        }
453 453
       }
454 454
       else
455 455
       {
456
-	process_commands();
456
+        process_commands();
457 457
       }
458 458
     #else
459 459
       process_commands();
@@ -548,10 +548,10 @@ void get_command()
548 548
           case 2:
549 549
           case 3:
550 550
             if(Stopped == false) { // If printer is stopped by an error the G[0-3] codes are ignored.
551
-	      #ifdef SDSUPPORT
551
+          #ifdef SDSUPPORT
552 552
               if(card.saving)
553 553
                 break;
554
-	      #endif //SDSUPPORT
554
+          #endif //SDSUPPORT
555 555
               SERIAL_PROTOCOLLNPGM(MSG_OK);
556 556
             }
557 557
             else {
@@ -645,17 +645,17 @@ bool code_seen(char code)
645 645
   return (strchr_pointer != NULL);  //Return True if a character was found
646 646
 }
647 647
 
648
-#define DEFINE_PGM_READ_ANY(type, reader)		\
649
-    static inline type pgm_read_any(const type *p)	\
650
-	{ return pgm_read_##reader##_near(p); }
648
+#define DEFINE_PGM_READ_ANY(type, reader)       \
649
+    static inline type pgm_read_any(const type *p)  \
650
+    { return pgm_read_##reader##_near(p); }
651 651
 
652 652
 DEFINE_PGM_READ_ANY(float,       float);
653 653
 DEFINE_PGM_READ_ANY(signed char, byte);
654 654
 
655
-#define XYZ_CONSTS_FROM_CONFIG(type, array, CONFIG)	\
656
-static const PROGMEM type array##_P[3] =		\
657
-    { X_##CONFIG, Y_##CONFIG, Z_##CONFIG };		\
658
-static inline type array(int axis)			\
655
+#define XYZ_CONSTS_FROM_CONFIG(type, array, CONFIG) \
656
+static const PROGMEM type array##_P[3] =        \
657
+    { X_##CONFIG, Y_##CONFIG, Z_##CONFIG };     \
658
+static inline type array(int axis)          \
659 659
     { return pgm_read_any(&array##_P[axis]); }
660 660
 
661 661
 XYZ_CONSTS_FROM_CONFIG(float, base_min_pos,    MIN_POS);
@@ -673,7 +673,7 @@ static void axis_is_at_home(int axis) {
673 673
 
674 674
 static void homeaxis(int axis) {
675 675
 #define HOMEAXIS_DO(LETTER) \
676
-  ((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1))
676
+  ((LETTER##_MIN_PIN > 0 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > 0 && LETTER##_HOME_DIR==1))
677 677
 
678 678
   if (axis==X_AXIS ? HOMEAXIS_DO(X) :
679 679
       axis==Y_AXIS ? HOMEAXIS_DO(Y) :
@@ -911,13 +911,13 @@ void process_commands()
911 911
       previous_millis_cmd = millis();
912 912
       if (codenum > 0){
913 913
         codenum += millis();  // keep track of when we started waiting
914
-        while(millis()  < codenum && !LCD_CLICKED){
914
+        while(millis()  < codenum && !lcd_clicked()){
915 915
           manage_heater();
916 916
           manage_inactivity();
917 917
           lcd_update();
918 918
         }
919 919
       }else{
920
-        while(!LCD_CLICKED){
920
+        while(!lcd_clicked()){
921 921
           manage_heater();
922 922
           manage_inactivity();
923 923
           lcd_update();
@@ -987,17 +987,17 @@ void process_commands()
987 987
       //card,saving = false;
988 988
       break;
989 989
     case 30: //M30 <filename> Delete File
990
-	if (card.cardOK){
991
-		card.closefile();
992
-		starpos = (strchr(strchr_pointer + 4,'*'));
993
-                if(starpos != NULL){
994
-                char* npos = strchr(cmdbuffer[bufindr], 'N');
995
-                strchr_pointer = strchr(npos,' ') + 1;
996
-                *(starpos-1) = '\0';
997
-         }
998
-	 card.removeFile(strchr_pointer + 4);
999
-	}
1000
-	break;
990
+      if (card.cardOK){
991
+        card.closefile();
992
+        starpos = (strchr(strchr_pointer + 4,'*'));
993
+        if(starpos != NULL){
994
+          char* npos = strchr(cmdbuffer[bufindr], 'N');
995
+          strchr_pointer = strchr(npos,' ') + 1;
996
+          *(starpos-1) = '\0';
997
+        }
998
+        card.removeFile(strchr_pointer + 4);
999
+      }
1000
+      break;
1001 1001
     case 928: //M928 - Start SD write
1002 1002
       starpos = (strchr(strchr_pointer + 5,'*'));
1003 1003
       if(starpos != NULL){
@@ -1062,12 +1062,12 @@ void process_commands()
1062 1062
       if(setTargetedHotend(105)){
1063 1063
         break;
1064 1064
       }
1065
-      #if (TEMP_0_PIN > -1)
1065
+      #if (TEMP_0_PIN > 0)
1066 1066
         SERIAL_PROTOCOLPGM("ok T:");
1067 1067
         SERIAL_PROTOCOL_F(degHotend(tmp_extruder),1);
1068 1068
         SERIAL_PROTOCOLPGM(" /");
1069 1069
         SERIAL_PROTOCOL_F(degTargetHotend(tmp_extruder),1);
1070
-        #if TEMP_BED_PIN > -1
1070
+        #if TEMP_BED_PIN > 0
1071 1071
           SERIAL_PROTOCOLPGM(" B:");
1072 1072
           SERIAL_PROTOCOL_F(degBed(),1);
1073 1073
           SERIAL_PROTOCOLPGM(" /");
@@ -1165,7 +1165,7 @@ void process_commands()
1165 1165
       }
1166 1166
       break;
1167 1167
     case 190: // M190 - Wait for bed heater to reach target.
1168
-    #if TEMP_BED_PIN > -1
1168
+    #if TEMP_BED_PIN > 0
1169 1169
         LCD_MESSAGEPGM(MSG_BED_HEATING);
1170 1170
         if (code_seen('S')) setTargetBed(code_value());
1171 1171
         codenum = millis();
@@ -1192,7 +1192,7 @@ void process_commands()
1192 1192
     #endif
1193 1193
         break;
1194 1194
 
1195
-    #if FAN_PIN > -1
1195
+    #if FAN_PIN > 0
1196 1196
       case 106: //M106 Fan On
1197 1197
         if (code_seen('S')){
1198 1198
            fanSpeed=constrain(code_value(),0,255);
@@ -1206,8 +1206,8 @@ void process_commands()
1206 1206
         break;
1207 1207
     #endif //FAN_PIN
1208 1208
     #ifdef BARICUDA
1209
-	// PWM for HEATER_1_PIN
1210
-      #if HEATER_1_PIN > -1
1209
+      // PWM for HEATER_1_PIN
1210
+      #if HEATER_1_PIN > 0
1211 1211
         case 126: //M126 valve open
1212 1212
           if (code_seen('S')){
1213 1213
              ValvePressure=constrain(code_value(),0,255);
@@ -1221,8 +1221,8 @@ void process_commands()
1221 1221
           break;
1222 1222
       #endif //HEATER_1_PIN
1223 1223
 
1224
-  	// PWM for HEATER_2_PIN
1225
-      #if HEATER_2_PIN > -1
1224
+      // PWM for HEATER_2_PIN
1225
+      #if HEATER_2_PIN > 0
1226 1226
         case 128: //M128 valve open
1227 1227
           if (code_seen('S')){
1228 1228
              EtoPPressure=constrain(code_value(),0,255);
@@ -1237,7 +1237,7 @@ void process_commands()
1237 1237
       #endif //HEATER_2_PIN
1238 1238
     #endif
1239 1239
 
1240
-    #if (PS_ON_PIN > -1)
1240
+    #if (PS_ON_PIN > 0)
1241 1241
       case 80: // M80 - ATX Power On
1242 1242
         SET_OUTPUT(PS_ON_PIN); //GND
1243 1243
         WRITE(PS_ON_PIN, PS_ON_AWAKE);
@@ -1246,14 +1246,14 @@ void process_commands()
1246 1246
 
1247 1247
       case 81: // M81 - ATX Power Off
1248 1248
 
1249
-      #if defined SUICIDE_PIN && SUICIDE_PIN > -1
1249
+      #if defined SUICIDE_PIN && SUICIDE_PIN > 0
1250 1250
         st_synchronize();
1251 1251
         suicide();
1252
-      #elif (PS_ON_PIN > -1)
1252
+      #elif (PS_ON_PIN > 0)
1253 1253
         SET_OUTPUT(PS_ON_PIN);
1254 1254
         WRITE(PS_ON_PIN, PS_ON_ASLEEP);
1255 1255
       #endif
1256
-		break;
1256
+        break;
1257 1257
 
1258 1258
     case 82:
1259 1259
       axis_relative_modes[3] = false;
@@ -1354,27 +1354,27 @@ void process_commands()
1354 1354
       break;
1355 1355
     case 119: // M119
1356 1356
     SERIAL_PROTOCOLLN(MSG_M119_REPORT);
1357
-      #if (X_MIN_PIN > -1)
1357
+      #if (X_MIN_PIN > 0)
1358 1358
         SERIAL_PROTOCOLPGM(MSG_X_MIN);
1359 1359
         SERIAL_PROTOCOLLN(((READ(X_MIN_PIN)^X_ENDSTOPS_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
1360 1360
       #endif
1361
-      #if (X_MAX_PIN > -1)
1361
+      #if (X_MAX_PIN > 0)
1362 1362
         SERIAL_PROTOCOLPGM(MSG_X_MAX);
1363 1363
         SERIAL_PROTOCOLLN(((READ(X_MAX_PIN)^X_ENDSTOPS_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
1364 1364
       #endif
1365
-      #if (Y_MIN_PIN > -1)
1365
+      #if (Y_MIN_PIN > 0)
1366 1366
         SERIAL_PROTOCOLPGM(MSG_Y_MIN);
1367 1367
         SERIAL_PROTOCOLLN(((READ(Y_MIN_PIN)^Y_ENDSTOPS_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
1368 1368
       #endif
1369
-      #if (Y_MAX_PIN > -1)
1369
+      #if (Y_MAX_PIN > 0)
1370 1370
         SERIAL_PROTOCOLPGM(MSG_Y_MAX);
1371 1371
         SERIAL_PROTOCOLLN(((READ(Y_MAX_PIN)^Y_ENDSTOPS_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
1372 1372
       #endif
1373
-      #if (Z_MIN_PIN > -1)
1373
+      #if (Z_MIN_PIN > 0)
1374 1374
         SERIAL_PROTOCOLPGM(MSG_Z_MIN);
1375 1375
         SERIAL_PROTOCOLLN(((READ(Z_MIN_PIN)^Z_ENDSTOPS_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
1376 1376
       #endif
1377
-      #if (Z_MAX_PIN > -1)
1377
+      #if (Z_MAX_PIN > 0)
1378 1378
         SERIAL_PROTOCOLPGM(MSG_Z_MAX);
1379 1379
         SERIAL_PROTOCOLLN(((READ(Z_MAX_PIN)^Z_ENDSTOPS_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
1380 1380
       #endif
@@ -1389,7 +1389,7 @@ void process_commands()
1389 1389
         }
1390 1390
       }
1391 1391
       // steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner)
1392
-	  reset_acceleration_rates();
1392
+      reset_acceleration_rates();
1393 1393
       break;
1394 1394
     #if 0 // Not used for Sprinter/grbl gen6
1395 1395
     case 202: // M202
@@ -1513,8 +1513,8 @@ void process_commands()
1513 1513
       }
1514 1514
     }
1515 1515
     break;
1516
-
1517
-    #if (defined NUM_SERVOS) && (NUM_SERVOS > 0)
1516
+    
1517
+    #if NUM_SERVOS > 0
1518 1518
     case 280: // M280 - set servo position absolute. P: servo index, S: angle or microseconds
1519 1519
       {
1520 1520
         int servo_index = -1;
@@ -1545,16 +1545,20 @@ void process_commands()
1545 1545
       break;
1546 1546
     #endif // NUM_SERVOS > 0
1547 1547
 
1548
-    #if defined(LARGE_FLASH) && LARGE_FLASH == true && defined(BEEPER) && BEEPER > -1
1548
+    #if LARGE_FLASH == true && ( BEEPER > 0 || defined(ULTRALCD) )
1549 1549
     case 300: // M300
1550 1550
     {
1551
-      int beepS = 1;
1551
+      int beepS = 400;
1552 1552
       int beepP = 1000;
1553 1553
       if(code_seen('S')) beepS = code_value();
1554 1554
       if(code_seen('P')) beepP = code_value();
1555
-      tone(BEEPER, beepS);
1556
-      delay(beepP);
1557
-      noTone(BEEPER);
1555
+      #if BEEPER > 0
1556
+        tone(BEEPER, beepS);
1557
+        delay(beepP);
1558
+        noTone(BEEPER);
1559
+      #elif defined(ULTRALCD)
1560
+        lcd_buzz(beepS, beepP);
1561
+      #endif
1558 1562
     }
1559 1563
     break;
1560 1564
     #endif // M300
@@ -1572,7 +1576,7 @@ void process_commands()
1572 1576
 
1573 1577
         updatePID();
1574 1578
         SERIAL_PROTOCOL(MSG_OK);
1575
-		SERIAL_PROTOCOL(" p:");
1579
+        SERIAL_PROTOCOL(" p:");
1576 1580
         SERIAL_PROTOCOL(Kp);
1577 1581
         SERIAL_PROTOCOL(" i:");
1578 1582
         SERIAL_PROTOCOL(unscalePID_i(Ki));
@@ -1596,7 +1600,7 @@ void process_commands()
1596 1600
 
1597 1601
         updatePID();
1598 1602
         SERIAL_PROTOCOL(MSG_OK);
1599
-		SERIAL_PROTOCOL(" p:");
1603
+        SERIAL_PROTOCOL(" p:");
1600 1604
         SERIAL_PROTOCOL(bedKp);
1601 1605
         SERIAL_PROTOCOL(" i:");
1602 1606
         SERIAL_PROTOCOL(unscalePID_i(bedKi));
@@ -1609,7 +1613,7 @@ void process_commands()
1609 1613
     case 240: // M240  Triggers a camera by emulating a Canon RC-1 : http://www.doc-diy.net/photo/rc-1_hacked/
1610 1614
      {
1611 1615
       #ifdef PHOTOGRAPH_PIN
1612
-        #if (PHOTOGRAPH_PIN > -1)
1616
+        #if (PHOTOGRAPH_PIN > 0)
1613 1617
         const uint8_t NUM_PULSES=16;
1614 1618
         const float PULSE_LENGTH=0.01524;
1615 1619
         for(int i=0; i < NUM_PULSES; i++) {
@@ -1641,8 +1645,8 @@ void process_commands()
1641 1645
       int e=0;
1642 1646
       int c=5;
1643 1647
       if (code_seen('E')) e=code_value();
1644
-			if (e<0)
1645
-				temp=70;
1648
+        if (e<0)
1649
+          temp=70;
1646 1650
       if (code_seen('S')) temp=code_value();
1647 1651
       if (code_seen('C')) c=code_value();
1648 1652
       PID_autotune(temp, e, c);
@@ -1765,23 +1769,24 @@ void process_commands()
1765 1769
         delay(100);
1766 1770
         LCD_ALERTMESSAGEPGM(MSG_FILAMENTCHANGE);
1767 1771
         uint8_t cnt=0;
1768
-        while(!LCD_CLICKED){
1772
+        while(!lcd_clicked()){
1769 1773
           cnt++;
1770 1774
           manage_heater();
1771 1775
           manage_inactivity();
1772 1776
           lcd_update();
1773
-
1774
-          #if BEEPER > -1
1775 1777
           if(cnt==0)
1776 1778
           {
1779
+          #if BEEPER > 0
1777 1780
             SET_OUTPUT(BEEPER);
1778 1781
 
1779 1782
             WRITE(BEEPER,HIGH);
1780 1783
             delay(3);
1781 1784
             WRITE(BEEPER,LOW);
1782 1785
             delay(3);
1783
-          }
1786
+          #else 
1787
+            lcd_buzz(1000/6,100);
1784 1788
           #endif
1789
+          }
1785 1790
         }
1786 1791
 
1787 1792
         //return to normal
@@ -1806,7 +1811,7 @@ void process_commands()
1806 1811
     #endif //FILAMENTCHANGEENABLE
1807 1812
     case 907: // M907 Set digital trimpot motor current using axis codes.
1808 1813
     {
1809
-      #if DIGIPOTSS_PIN > -1
1814
+      #if DIGIPOTSS_PIN > 0
1810 1815
         for(int i=0;i<NUM_AXIS;i++) if(code_seen(axis_codes[i])) digipot_current(i,code_value());
1811 1816
         if(code_seen('B')) digipot_current(4,code_value());
1812 1817
         if(code_seen('S')) for(int i=0;i<=4;i++) digipot_current(i,code_value());
@@ -1815,7 +1820,7 @@ void process_commands()
1815 1820
     break;
1816 1821
     case 908: // M908 Control digital trimpot directly.
1817 1822
     {
1818
-      #if DIGIPOTSS_PIN > -1
1823
+      #if DIGIPOTSS_PIN > 0
1819 1824
         uint8_t channel,current;
1820 1825
         if(code_seen('P')) channel=code_value();
1821 1826
         if(code_seen('S')) current=code_value();
@@ -1825,7 +1830,7 @@ void process_commands()
1825 1830
     break;
1826 1831
     case 350: // M350 Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers.
1827 1832
     {
1828
-      #if X_MS1_PIN > -1
1833
+      #if X_MS1_PIN > 0
1829 1834
         if(code_seen('S')) for(int i=0;i<=4;i++) microstep_mode(i,code_value());
1830 1835
         for(int i=0;i<NUM_AXIS;i++) if(code_seen(axis_codes[i])) microstep_mode(i,(uint8_t)code_value());
1831 1836
         if(code_seen('B')) microstep_mode(4,code_value());
@@ -1835,7 +1840,7 @@ void process_commands()
1835 1840
     break;
1836 1841
     case 351: // M351 Toggle MS1 MS2 pins directly, S# determines MS1 or MS2, X# sets the pin high/low.
1837 1842
     {
1838
-      #if X_MS1_PIN > -1
1843
+      #if X_MS1_PIN > 0
1839 1844
       if(code_seen('S')) switch((int)code_value())
1840 1845
       {
1841 1846
         case 1:
@@ -2173,7 +2178,7 @@ void kill()
2173 2178
   disable_e1();
2174 2179
   disable_e2();
2175 2180
 
2176
-  if(PS_ON_PIN > -1) pinMode(PS_ON_PIN,INPUT);
2181
+  if(PS_ON_PIN > 0) pinMode(PS_ON_PIN,INPUT);
2177 2182
   SERIAL_ERROR_START;
2178 2183
   SERIAL_ERRORLNPGM(MSG_ERR_KILLED);
2179 2184
   LCD_ALERTMESSAGEPGM(MSG_KILLED);

+ 50
- 159
Marlin/pins.h Näytä tiedosto

@@ -14,7 +14,7 @@
14 14
 #define DIGIPOTSS_PIN -1
15 15
 
16 16
 #if MOTHERBOARD == 99
17
-#define	KNOWN_BOARD 1
17
+#define KNOWN_BOARD 1
18 18
 
19 19
 #define X_STEP_PIN          2
20 20
 #define X_DIR_PIN           3
@@ -228,7 +228,7 @@
228 228
 
229 229
 //x axis pins
230 230
     #define X_STEP_PIN      21                  //different from stanard GEN7
231
-    #define X_DIR_PIN       20				    //different from stanard GEN7
231
+    #define X_DIR_PIN       20            //different from stanard GEN7
232 232
     #define X_ENABLE_PIN    24
233 233
     #define X_STOP_PIN      0
234 234
 
@@ -274,11 +274,11 @@
274 274
     //#define RX_ENABLE_PIN       13
275 275
 
276 276
     #define BEEPER -1
277
-	#define SDCARDDETECT -1
278
-    #define SUICIDE_PIN -1						//has to be defined; otherwise Power_off doesn't work
277
+    #define SDCARDDETECT -1
278
+    #define SUICIDE_PIN -1    //has to be defined; otherwise Power_off doesn't work
279 279
 
280 280
     #define KILL_PIN -1
281
-	//Pins for 4bit LCD Support
281
+    //Pins for 4bit LCD Support
282 282
     #define LCD_PINS_RS 18
283 283
     #define LCD_PINS_ENABLE 17
284 284
     #define LCD_PINS_D4 16
@@ -291,14 +291,6 @@
291 291
     #define BTN_EN2 10
292 292
     #define BTN_ENC 12  //the click
293 293
 
294
-    #define BLEN_C 2
295
-    #define BLEN_B 1
296
-    #define BLEN_A 0
297
-
298
-    #define encrot0 0
299
-    #define encrot1 2
300
-    #define encrot2 3
301
-    #define encrot3 1
302 294
 #endif
303 295
 
304 296
 /****************************************************************************************
@@ -391,17 +383,7 @@
391 383
 #ifdef ULTRA_LCD
392 384
 
393 385
   #ifdef NEWPANEL
394
-     //encoder rotation values
395
-    #define encrot0 0
396
-    #define encrot1 2
397
-    #define encrot2 3
398
-    #define encrot3 1
399
-
400
-    #define BLEN_A 0
401
-    #define BLEN_B 1
402
-    #define BLEN_C 2
403
-
404
-    #define LCD_PINS_RS 16
386
+    #define LCD_PINS_RS 16 
405 387
     #define LCD_PINS_ENABLE 17
406 388
     #define LCD_PINS_D4 23
407 389
     #define LCD_PINS_D5 25
@@ -418,7 +400,7 @@
418 400
       #define SDCARDDETECT 49
419 401
     #else
420 402
       //arduino pin which triggers an piezzo beeper
421
-      #define BEEPER 33	 // Beeper on AUX-4
403
+      #define BEEPER 33  // Beeper on AUX-4
422 404
 
423 405
       //buttons are directly attached using AUX-2
424 406
       #ifdef REPRAPWORLD_KEYPAD
@@ -428,16 +410,7 @@
428 410
         #define SHIFT_OUT 40 // shift register
429 411
         #define SHIFT_CLK 44 // shift register
430 412
         #define SHIFT_LD 42 // shift register
431
-        // define register bit values, don't change it
432
-        #define BLEN_REPRAPWORLD_KEYPAD_F3 0
433
-        #define BLEN_REPRAPWORLD_KEYPAD_F2 1
434
-        #define BLEN_REPRAPWORLD_KEYPAD_F1 2
435
-        #define BLEN_REPRAPWORLD_KEYPAD_UP 3
436
-        #define BLEN_REPRAPWORLD_KEYPAD_RIGHT 4
437
-        #define BLEN_REPRAPWORLD_KEYPAD_MIDDLE 5
438
-        #define BLEN_REPRAPWORLD_KEYPAD_DOWN 6
439
-        #define BLEN_REPRAPWORLD_KEYPAD_LEFT 7
440
-	  #else
413
+      #else
441 414
         #define BTN_EN1 37
442 415
         #define BTN_EN2 35
443 416
         #define BTN_ENC 31  //the click
@@ -452,10 +425,10 @@
452 425
 
453 426
   #else //old style panel with shift register
454 427
     //arduino pin witch triggers an piezzo beeper
455
-    #define BEEPER 33		No Beeper added
428
+    #define BEEPER 33   // No Beeper added 
456 429
 
457 430
     //buttons are attached to a shift register
458
-	// Not wired this yet
431
+  // Not wired this yet
459 432
     //#define SHIFT_CLK 38
460 433
     //#define SHIFT_LD 42
461 434
     //#define SHIFT_OUT 40
@@ -467,26 +440,7 @@
467 440
     #define LCD_PINS_D5 25
468 441
     #define LCD_PINS_D6 27
469 442
     #define LCD_PINS_D7 29
470
-
471
-    //encoder rotation values
472
-    #define encrot0 0
473
-    #define encrot1 2
474
-    #define encrot2 3
475
-    #define encrot3 1
476
-
477
-
478
-    //bits in the shift register that carry the buttons for:
479
-    // left up center down right red
480
-    #define BL_LE 7
481
-    #define BL_UP 6
482
-    #define BL_MI 5
483
-    #define BL_DW 4
484
-    #define BL_RI 3
485
-    #define BL_ST 2
486
-
487
-    #define BLEN_B 1
488
-    #define BLEN_A 0
489
-  #endif
443
+  #endif 
490 444
 #endif //ULTRA_LCD
491 445
 
492 446
 #else // RAMPS_V_1_1 or RAMPS_V_1_2 as default (MOTHERBOARD == 3)
@@ -659,8 +613,8 @@
659 613
     #define DEBUG_PIN        0
660 614
 
661 615
     //our RS485 pins
662
-    #define TX_ENABLE_PIN	12
663
-    #define RX_ENABLE_PIN	13
616
+    #define TX_ENABLE_PIN 12
617
+    #define RX_ENABLE_PIN 13
664 618
 
665 619
 
666 620
 #endif
@@ -759,43 +713,32 @@
759 713
      //we have no buzzer installed
760 714
      #define BEEPER -1
761 715
      //LCD Pins
762
-	 	 #ifdef DOGLCD
763
-			 // Pins for DOGM SPI LCD Support
764
-			 #define DOGLCD_A0	30
765
-			 #define DOGLCD_CS	29
766
-			 // GLCD features
767
-			 #define LCD_CONTRAST 1
768
-			 // Uncomment screen orientation
769
-		     // #define LCD_SCREEN_ROT_0
770
-		     // #define LCD_SCREEN_ROT_90
771
-			 #define LCD_SCREEN_ROT_180
772
-		     // #define LCD_SCREEN_ROT_270
773
-			 #else // standard Hitachi LCD controller
774
-			 #define LCD_PINS_RS        4
775
-			 #define LCD_PINS_ENABLE    17
776
-			 #define LCD_PINS_D4        30
777
-			 #define LCD_PINS_D5        29
778
-			 #define LCD_PINS_D6        28
779
-			 #define LCD_PINS_D7        27
780
-         #endif
716
+     #ifdef DOGLCD
717
+       // Pins for DOGM SPI LCD Support
718
+       #define DOGLCD_A0  30
719
+       #define DOGLCD_CS  29
720
+       // GLCD features
721
+       #define LCD_CONTRAST 1
722
+       // Uncomment screen orientation
723
+         // #define LCD_SCREEN_ROT_0
724
+         // #define LCD_SCREEN_ROT_90
725
+       #define LCD_SCREEN_ROT_180
726
+         // #define LCD_SCREEN_ROT_270
727
+       #else // standard Hitachi LCD controller
728
+       #define LCD_PINS_RS        4
729
+       #define LCD_PINS_ENABLE    17
730
+       #define LCD_PINS_D4        30
731
+       #define LCD_PINS_D5        29
732
+       #define LCD_PINS_D6        28
733
+       #define LCD_PINS_D7        27
734
+     #endif
781 735
      //The encoder and click button
782
-     #define BTN_EN1 11  //must be a hardware interrupt pin
783
-     #define BTN_EN2 10 //must be hardware interrupt pin
736
+     #define BTN_EN1 11  
737
+     #define BTN_EN2 10 
784 738
      #define BTN_ENC 16  //the switch
785 739
      //not connected to a pin
786
-     #define SDCARDDETECT -1
787
-
788
-     //from the same bit in the RAMPS Newpanel define
789
-     //encoder rotation values
790
-     #define encrot0 0
791
-     #define encrot1 2
792
-     #define encrot2 3
793
-     #define encrot3 1
794
-
795
-     #define BLEN_C 2
796
-     #define BLEN_B 1
797
-     #define BLEN_A 0
798
-
740
+     #define SDCARDDETECT -1    
741
+    
799 742
    #endif //Newpanel
800 743
  #endif //Ultipanel
801 744
 
@@ -879,18 +822,9 @@
879 822
     #define BTN_EN1 40
880 823
     #define BTN_EN2 42
881 824
     #define BTN_ENC 19  //the click
882
-
883
-    #define BLEN_C 2
884
-    #define BLEN_B 1
885
-    #define BLEN_A 0
886
-
825
+    
887 826
     #define SDCARDDETECT 38
888
-
889
-      //encoder rotation values
890
-    #define encrot0 0
891
-    #define encrot1 2
892
-    #define encrot2 3
893
-    #define encrot3 1
827
+    
894 828
   #else //old style panel with shift register
895 829
     //arduino pin witch triggers an piezzo beeper
896 830
     #define BEEPER 18
@@ -907,34 +841,9 @@
907 841
     #define LCD_PINS_D5 21
908 842
     #define LCD_PINS_D6 20
909 843
     #define LCD_PINS_D7 19
910
-
911
-    //encoder rotation values
912
-    #ifndef ULTIMAKERCONTROLLER
913
-     #define encrot0 0
914
-     #define encrot1 2
915
-     #define encrot2 3
916
-     #define encrot3 1
917
-    #else
918
-     #define encrot0 0
919
-     #define encrot1 1
920
-     #define encrot2 3
921
-     #define encrot3 2
922
-
923
-    #endif
924
-
844
+  
925 845
     #define SDCARDDETECT -1
926
-    //bits in the shift register that carry the buttons for:
927
-    // left up center down right red
928
-    #define BL_LE 7
929
-    #define BL_UP 6
930
-    #define BL_MI 5
931
-    #define BL_DW 4
932
-    #define BL_RI 3
933
-    #define BL_ST 2
934
-
935
-    #define BLEN_B 1
936
-    #define BLEN_A 0
937
-  #endif
846
+  #endif 
938 847
 #endif //ULTRA_LCD
939 848
 
940 849
 #endif
@@ -1122,14 +1031,6 @@
1122 1031
 #define BTN_EN1            11
1123 1032
 #define BTN_EN2            12
1124 1033
 #define BTN_ENC            43
1125
-//encoder rotation values
1126
-#define BLEN_C 2
1127
-#define BLEN_B 1
1128
-#define BLEN_A 0
1129
-#define encrot0 0
1130
-#define encrot1 2
1131
-#define encrot2 3
1132
-#define encrot3 1
1133 1034
 
1134 1035
 #endif //MOTHERBOARD==80
1135 1036
 
@@ -1434,12 +1335,12 @@
1434 1335
 #define E0_ENABLE_PIN       10
1435 1336
 
1436 1337
 /* future proofing */
1437
-#define __FS	20
1438
-#define __FD	19
1439
-#define __GS	18
1440
-#define __GD	13
1338
+#define __FS  20
1339
+#define __FD  19
1340
+#define __GS  18
1341
+#define __GD  13
1441 1342
 
1442
-#define UNUSED_PWM           14	/* PWM on LEFT connector */
1343
+#define UNUSED_PWM           14 /* PWM on LEFT connector */
1443 1344
 
1444 1345
 #define E1_STEP_PIN         -1 // 21
1445 1346
 #define E1_DIR_PIN          -1 // 20
@@ -1468,8 +1369,8 @@
1468 1369
 #define HEATER_BED_PIN      4
1469 1370
 #define TEMP_BED_PIN        2 // 1,2 or I2C
1470 1371
 
1471
-#define I2C_SCL				16
1472
-#define I2C_SDA				17
1372
+#define I2C_SCL       16
1373
+#define I2C_SDA       17
1473 1374
 
1474 1375
 #endif
1475 1376
 
@@ -1617,7 +1518,7 @@
1617 1518
 #define HEATER_BED_PIN     10   // BED
1618 1519
 #define TEMP_BED_PIN       14   // ANALOG NUMBERING
1619 1520
 
1620
-#define BEEPER 33			// Beeper on AUX-4
1521
+#define BEEPER 33     // Beeper on AUX-4
1621 1522
 
1622 1523
 
1623 1524
 #ifdef ULTRA_LCD
@@ -1636,18 +1537,8 @@
1636 1537
     #define BTN_EN1 59
1637 1538
     #define BTN_EN2 64
1638 1539
     #define BTN_ENC 43  //the click
1639
-
1640
-    #define BLEN_C 2
1641
-    #define BLEN_B 1
1642
-    #define BLEN_A 0
1643
-
1644
-    #define SDCARDDETECT -1		// Ramps does not use this port
1645
-
1646
-      //encoder rotation values
1647
-    #define encrot0 0
1648
-    #define encrot1 2
1649
-    #define encrot2 3
1650
-    #define encrot3 1
1540
+    
1541
+    #define SDCARDDETECT -1   // Ramps does not use this port
1651 1542
 #endif
1652 1543
 #endif //ULTRA_LCD
1653 1544
 

+ 117
- 83
Marlin/ultralcd.cpp Näytä tiedosto

@@ -76,7 +76,11 @@ 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
+#if !defined(LCD_I2C_VIKI)
80
+  #define ENCODER_STEPS_PER_MENU_ITEM 5
81
+#else
82
+  #define ENCODER_STEPS_PER_MENU_ITEM 2 // VIKI LCD rotary encoder uses a different number of steps per rotation
83
+#endif
80 84
 
81 85
 /* Helper macros for menus */
82 86
 #define START_MENU() do { \
@@ -112,15 +116,18 @@ static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned l
112 116
     } } while(0)
113 117
 
114 118
 /** Used variables to keep track of the menu */
119
+#ifndef REPRAPWORLD_KEYPAD
115 120
 volatile uint8_t buttons;//Contains the bits of the currently pressed buttons.
116
-volatile uint8_t buttons_reprapworld_keypad; // to store the reprapworld_keypad shiftregister values
121
+#else
122
+volatile uint16_t buttons;//Contains the bits of the currently pressed buttons (extended).
123
+#endif
117 124
 
118 125
 uint8_t currentMenuViewOffset;              /* scroll offset in the current menu */
119 126
 uint32_t blocking_enc;
120 127
 uint8_t lastEncoderBits;
121 128
 int8_t encoderDiff; /* encoderDiff is updated from interrupt context and added to encoderPosition every LCD update */
122 129
 uint32_t encoderPosition;
123
-#if (SDCARDDETECT > -1)
130
+#if (SDCARDDETECT > 0)
124 131
 bool lcd_oldcardstatus;
125 132
 #endif
126 133
 #endif//ULTIPANEL
@@ -222,14 +229,14 @@ static void lcd_main_menu()
222 229
         }else{
223 230
             MENU_ITEM(submenu, MSG_CARD_MENU, lcd_sdcard_menu);
224 231
 #if SDCARDDETECT < 1
225
-			MENU_ITEM(gcode, MSG_CNG_SDCARD, PSTR("M21"));	// SD-card changed by user
226
-#endif			
232
+            MENU_ITEM(gcode, MSG_CNG_SDCARD, PSTR("M21"));  // SD-card changed by user
233
+#endif
227 234
         }
228 235
     }else{
229 236
         MENU_ITEM(submenu, MSG_NO_CARD, lcd_sdcard_menu);
230
-#if SDCARDDETECT < 1		
231
-		MENU_ITEM(gcode, MSG_INIT_SDCARD, PSTR("M21"));	// Manually initialize the SD-card via user interface
232
-#endif		
237
+#if SDCARDDETECT < 1
238
+        MENU_ITEM(gcode, MSG_INIT_SDCARD, PSTR("M21")); // Manually initialize the SD-card via user interface
239
+#endif
233 240
     }
234 241
 #endif
235 242
     END_MENU();
@@ -252,7 +259,7 @@ void lcd_preheat_pla()
252 259
     setTargetBed(plaPreheatHPBTemp);
253 260
     fanSpeed = plaPreheatFanSpeed;
254 261
     lcd_return_to_status();
255
-	setWatch();	// heater sanity check timer
262
+    setWatch(); // heater sanity check timer
256 263
 }
257 264
 
258 265
 void lcd_preheat_abs()
@@ -263,16 +270,16 @@ void lcd_preheat_abs()
263 270
     setTargetBed(absPreheatHPBTemp);
264 271
     fanSpeed = absPreheatFanSpeed;
265 272
     lcd_return_to_status();
266
-	setWatch();	// heater sanity check timer
273
+    setWatch(); // heater sanity check timer
267 274
 }
268 275
 
269 276
 static void lcd_cooldown()
270 277
 {
271
-	setTargetHotend0(0);
272
-	setTargetHotend1(0);
273
-	setTargetHotend2(0);
274
-	setTargetBed(0);
275
-	lcd_return_to_status();
278
+    setTargetHotend0(0);
279
+    setTargetHotend1(0);
280
+    setTargetHotend2(0);
281
+    setTargetBed(0);
282
+    lcd_return_to_status();
276 283
 }
277 284
 
278 285
 static void lcd_tune_menu()
@@ -471,10 +478,10 @@ static void lcd_control_menu()
471 478
 
472 479
 static void lcd_control_temperature_menu()
473 480
 {
474
-	// set up temp variables - undo the default scaling
475
-	raw_Ki = unscalePID_i(Ki);
476
-	raw_Kd = unscalePID_d(Kd);
477
-	
481
+    // set up temp variables - undo the default scaling
482
+    raw_Ki = unscalePID_i(Ki);
483
+    raw_Kd = unscalePID_d(Kd);
484
+
478 485
     START_MENU();
479 486
     MENU_ITEM(back, MSG_CONTROL, lcd_control_menu);
480 487
     MENU_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15);
@@ -496,7 +503,7 @@ static void lcd_control_temperature_menu()
496 503
 #endif
497 504
 #ifdef PIDTEMP
498 505
     MENU_ITEM_EDIT(float52, MSG_PID_P, &Kp, 1, 9990);
499
-	// i is typically a small value so allows values below 1
506
+    // i is typically a small value so allows values below 1
500 507
     MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I, &raw_Ki, 0.01, 9990, copy_and_scalePID_i);
501 508
     MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D, &raw_Kd, 1, 9990, copy_and_scalePID_d);
502 509
 # ifdef PID_ADD_EXTRUSION_RATE
@@ -700,21 +707,21 @@ menu_edit_type(float, float52, ftostr52, 100)
700 707
 menu_edit_type(unsigned long, long5, ftostr5, 0.01)
701 708
 
702 709
 #ifdef REPRAPWORLD_KEYPAD
703
-	static void reprapworld_keypad_move_y_down() {
710
+    static void reprapworld_keypad_move_y_down() {
704 711
         encoderPosition = 1;
705 712
         move_menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP;
706
-		lcd_move_y();
707
-	}
708
-	static void reprapworld_keypad_move_y_up() {
709
-		encoderPosition = -1;
710
-		move_menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP;
711
-    	lcd_move_y();
712
-	}
713
-	static void reprapworld_keypad_move_home() {
714
-		//enquecommand_P((PSTR("G28"))); // move all axis home
715
-		// TODO gregor: move all axis home, i have currently only one axis on my prusa i3
716
-		enquecommand_P((PSTR("G28 Y")));
717
-	}
713
+        lcd_move_y();
714
+    }
715
+    static void reprapworld_keypad_move_y_up() {
716
+        encoderPosition = -1;
717
+        move_menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP;
718
+        lcd_move_y();
719
+    }
720
+    static void reprapworld_keypad_move_home() {
721
+        //enquecommand_P((PSTR("G28"))); // move all axis home
722
+        // TODO gregor: move all axis home, i have currently only one axis on my prusa i3
723
+        enquecommand_P((PSTR("G28 Y")));
724
+    }
718 725
 #endif
719 726
 
720 727
 /** End of menus **/
@@ -775,18 +782,20 @@ void lcd_init()
775 782
 #ifdef NEWPANEL
776 783
     pinMode(BTN_EN1,INPUT);
777 784
     pinMode(BTN_EN2,INPUT); 
778
-    pinMode(BTN_ENC,INPUT); 
779 785
     pinMode(SDCARDDETECT,INPUT);
780 786
     WRITE(BTN_EN1,HIGH);
781 787
     WRITE(BTN_EN2,HIGH);
788
+  #if BTN_ENC > 0
789
+    pinMode(BTN_ENC,INPUT); 
782 790
     WRITE(BTN_ENC,HIGH);
783
-    #ifdef REPRAPWORLD_KEYPAD
784
-      pinMode(SHIFT_CLK,OUTPUT);
785
-      pinMode(SHIFT_LD,OUTPUT);
786
-      pinMode(SHIFT_OUT,INPUT);
787
-      WRITE(SHIFT_OUT,HIGH);
788
-      WRITE(SHIFT_LD,HIGH);
789
-    #endif
791
+  #endif    
792
+  #ifdef REPRAPWORLD_KEYPAD
793
+    pinMode(SHIFT_CLK,OUTPUT);
794
+    pinMode(SHIFT_LD,OUTPUT);
795
+    pinMode(SHIFT_OUT,INPUT);
796
+    WRITE(SHIFT_OUT,HIGH);
797
+    WRITE(SHIFT_LD,HIGH);
798
+  #endif
790 799
 #else
791 800
     pinMode(SHIFT_CLK,OUTPUT);
792 801
     pinMode(SHIFT_LD,OUTPUT);
@@ -796,12 +805,14 @@ void lcd_init()
796 805
     WRITE(SHIFT_LD,HIGH); 
797 806
     WRITE(SHIFT_EN,LOW);
798 807
 #endif//!NEWPANEL
799
-#if (SDCARDDETECT > -1)
808
+#if (SDCARDDETECT > 0)
800 809
     WRITE(SDCARDDETECT, HIGH);
801 810
     lcd_oldcardstatus = IS_SD_INSERTED;
802
-#endif//(SDCARDDETECT > -1)
811
+#endif//(SDCARDDETECT > 0)
803 812
     lcd_buttons_update();
813
+#ifdef ULTIPANEL    
804 814
     encoderDiff = 0;
815
+#endif    
805 816
 }
806 817
 
807 818
 void lcd_update()
@@ -810,7 +821,11 @@ void lcd_update()
810 821
     
811 822
     lcd_buttons_update();
812 823
     
813
-    #if (SDCARDDETECT > -1)
824
+    #ifdef LCD_HAS_SLOW_BUTTONS
825
+    buttons |= lcd_implementation_read_slow_buttons(); // buttons which take too long to read in interrupt context
826
+    #endif
827
+    
828
+    #if (SDCARDDETECT > 0)
814 829
     if((IS_SD_INSERTED != lcd_oldcardstatus))
815 830
     {
816 831
         lcdDrawUpdate = 2;
@@ -833,17 +848,17 @@ void lcd_update()
833 848
     if (lcd_next_update_millis < millis())
834 849
     {
835 850
 #ifdef ULTIPANEL
836
-		#ifdef REPRAPWORLD_KEYPAD
837
-        	if (REPRAPWORLD_KEYPAD_MOVE_Y_DOWN) {
838
-        		reprapworld_keypad_move_y_down();
839
-        	}
840
-        	if (REPRAPWORLD_KEYPAD_MOVE_Y_UP) {
841
-        		reprapworld_keypad_move_y_up();
842
-        	}
843
-        	if (REPRAPWORLD_KEYPAD_MOVE_HOME) {
844
-        		reprapworld_keypad_move_home();
845
-        	}
846
-		#endif
851
+        #ifdef REPRAPWORLD_KEYPAD
852
+        if (REPRAPWORLD_KEYPAD_MOVE_Y_DOWN) {
853
+            reprapworld_keypad_move_y_down();
854
+        }
855
+        if (REPRAPWORLD_KEYPAD_MOVE_Y_UP) {
856
+            reprapworld_keypad_move_y_up();
857
+        }
858
+        if (REPRAPWORLD_KEYPAD_MOVE_HOME) {
859
+            reprapworld_keypad_move_home();
860
+        }
861
+        #endif
847 862
         if (encoderDiff)
848 863
         {
849 864
             lcdDrawUpdate = 1;
@@ -856,21 +871,26 @@ void lcd_update()
856 871
 #endif//ULTIPANEL
857 872
 
858 873
 #ifdef DOGLCD        // Changes due to different driver architecture of the DOGM display
859
-		blink++;	   // Variable for fan animation and alive dot
860
-		u8g.firstPage();
861
-		do {
862
-				u8g.setFont(u8g_font_6x10_marlin);
863
-				u8g.setPrintPos(125,0);
864
-				if (blink % 2) u8g.setColorIndex(1); else u8g.setColorIndex(0); // Set color for the alive dot
865
-				u8g.drawPixel(127,63);	// draw alive dot
866
-				u8g.setColorIndex(1);	// black on white
867
-				(*currentMenu)();
868
-				if (!lcdDrawUpdate)  break; // Terminate display update, when nothing new to draw. This must be done before the last dogm.next()
869
-		   } while( u8g.nextPage() );
874
+        blink++;     // Variable for fan animation and alive dot
875
+        u8g.firstPage();
876
+        do 
877
+        {
878
+            u8g.setFont(u8g_font_6x10_marlin);
879
+            u8g.setPrintPos(125,0);
880
+            if (blink % 2) u8g.setColorIndex(1); else u8g.setColorIndex(0); // Set color for the alive dot
881
+            u8g.drawPixel(127,63); // draw alive dot
882
+            u8g.setColorIndex(1); // black on white
883
+            (*currentMenu)();
884
+            if (!lcdDrawUpdate)  break; // Terminate display update, when nothing new to draw. This must be done before the last dogm.next()
885
+        } while( u8g.nextPage() );
870 886
 #else        
871 887
         (*currentMenu)();
872 888
 #endif
873 889
 
890
+#ifdef LCD_HAS_STATUS_INDICATORS
891
+        lcd_implementation_update_indicators();
892
+#endif
893
+
874 894
 #ifdef ULTIPANEL
875 895
         if(timeoutToStatus < millis() && currentMenu != lcd_status_screen)
876 896
         {
@@ -921,23 +941,25 @@ void lcd_buttons_update()
921 941
     uint8_t newbutton=0;
922 942
     if(READ(BTN_EN1)==0)  newbutton|=EN_A;
923 943
     if(READ(BTN_EN2)==0)  newbutton|=EN_B;
944
+  #if BTN_ENC > 0
924 945
     if((blocking_enc<millis()) && (READ(BTN_ENC)==0))
925 946
         newbutton |= EN_C;
947
+  #endif      
948
+  #ifdef REPRAPWORLD_KEYPAD
949
+    // for the reprapworld_keypad
950
+    uint8_t newbutton_reprapworld_keypad=0;
951
+    WRITE(SHIFT_LD,LOW);
952
+    WRITE(SHIFT_LD,HIGH);
953
+    for(int8_t i=0;i<8;i++) {
954
+        newbutton_reprapworld_keypad = newbutton_reprapworld_keypad>>1;
955
+        if(READ(SHIFT_OUT))
956
+            newbutton_reprapworld_keypad|=(1<<7);
957
+        WRITE(SHIFT_CLK,HIGH);
958
+        WRITE(SHIFT_CLK,LOW);
959
+    }
960
+    newbutton |= ((~newbutton_reprapworld_keypad) << REPRAPWORLD_BTN_OFFSET); //invert it, because a pressed switch produces a logical 0
961
+  #endif
926 962
     buttons = newbutton;
927
-    #ifdef REPRAPWORLD_KEYPAD
928
-      // for the reprapworld_keypad
929
-      uint8_t newbutton_reprapworld_keypad=0;
930
-      WRITE(SHIFT_LD,LOW);
931
-      WRITE(SHIFT_LD,HIGH);
932
-      for(int8_t i=0;i<8;i++) {
933
-          newbutton_reprapworld_keypad = newbutton_reprapworld_keypad>>1;
934
-          if(READ(SHIFT_OUT))
935
-              newbutton_reprapworld_keypad|=(1<<7);
936
-          WRITE(SHIFT_CLK,HIGH);
937
-          WRITE(SHIFT_CLK,LOW);
938
-      }
939
-      buttons_reprapworld_keypad=~newbutton_reprapworld_keypad; //invert it, because a pressed switch produces a logical 0
940
-	#endif
941 963
 #else   //read it from the shift register
942 964
     uint8_t newbutton=0;
943 965
     WRITE(SHIFT_LD,LOW);
@@ -992,6 +1014,18 @@ void lcd_buttons_update()
992 1014
     }
993 1015
     lastEncoderBits = enc;
994 1016
 }
1017
+
1018
+void lcd_buzz(long duration, uint16_t freq)
1019
+{ 
1020
+#ifdef LCD_USE_I2C_BUZZER
1021
+  lcd.buzz(duration,freq);
1022
+#endif   
1023
+}
1024
+
1025
+bool lcd_clicked() 
1026
+{ 
1027
+  return LCD_CLICKED;
1028
+}
995 1029
 #endif//ULTIPANEL
996 1030
 
997 1031
 /********************************/
@@ -1193,7 +1227,7 @@ void copy_and_scalePID_i()
1193 1227
 {
1194 1228
   Ki = scalePID_i(raw_Ki);
1195 1229
   updatePID();
1196
-}	
1230
+}
1197 1231
 
1198 1232
 // Callback for after editing PID d value
1199 1233
 // grab the pid d value out of the temp variable; scale it; then update the PID driver
@@ -1201,6 +1235,6 @@ void copy_and_scalePID_d()
1201 1235
 {
1202 1236
   Kd = scalePID_d(raw_Kd);
1203 1237
   updatePID();
1204
-}	
1205
-	
1238
+}
1239
+
1206 1240
 #endif //ULTRA_LCD

+ 3
- 38
Marlin/ultralcd.h Näytä tiedosto

@@ -22,10 +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
-  #ifdef REPRAPWORLD_KEYPAD
27
-    extern volatile uint8_t buttons_reprapworld_keypad; // to store the keypad shiftregister values
28
-  #endif
29 25
   #else
30 26
   FORCE_INLINE void lcd_buttons_update() {}
31 27
   #endif
@@ -38,40 +34,8 @@
38 34
   extern int absPreheatHPBTemp;
39 35
   extern int absPreheatFanSpeed;
40 36
     
41
-  #ifdef NEWPANEL
42
-    #define EN_C (1<<BLEN_C)
43
-    #define EN_B (1<<BLEN_B)
44
-    #define EN_A (1<<BLEN_A)
45
-
46
-    #define LCD_CLICKED (buttons&EN_C)
47
-    #ifdef REPRAPWORLD_KEYPAD
48
-  	  #define EN_REPRAPWORLD_KEYPAD_F3 (1<<BLEN_REPRAPWORLD_KEYPAD_F3)
49
-  	  #define EN_REPRAPWORLD_KEYPAD_F2 (1<<BLEN_REPRAPWORLD_KEYPAD_F2)
50
-  	  #define EN_REPRAPWORLD_KEYPAD_F1 (1<<BLEN_REPRAPWORLD_KEYPAD_F1)
51
-  	  #define EN_REPRAPWORLD_KEYPAD_UP (1<<BLEN_REPRAPWORLD_KEYPAD_UP)
52
-  	  #define EN_REPRAPWORLD_KEYPAD_RIGHT (1<<BLEN_REPRAPWORLD_KEYPAD_RIGHT)
53
-  	  #define EN_REPRAPWORLD_KEYPAD_MIDDLE (1<<BLEN_REPRAPWORLD_KEYPAD_MIDDLE)
54
-  	  #define EN_REPRAPWORLD_KEYPAD_DOWN (1<<BLEN_REPRAPWORLD_KEYPAD_DOWN)
55
-  	  #define EN_REPRAPWORLD_KEYPAD_LEFT (1<<BLEN_REPRAPWORLD_KEYPAD_LEFT)
56
-
57
-  	  #define LCD_CLICKED ((buttons&EN_C) || (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_F1))
58
-  	  #define REPRAPWORLD_KEYPAD_MOVE_Y_DOWN (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_DOWN)
59
-  	  #define REPRAPWORLD_KEYPAD_MOVE_Y_UP (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_UP)
60
-  	  #define REPRAPWORLD_KEYPAD_MOVE_HOME (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_MIDDLE)
61
-    #endif //REPRAPWORLD_KEYPAD
62
-  #else
63
-    //atomatic, do not change
64
-    #define B_LE (1<<BL_LE)
65
-    #define B_UP (1<<BL_UP)
66
-    #define B_MI (1<<BL_MI)
67
-    #define B_DW (1<<BL_DW)
68
-    #define B_RI (1<<BL_RI)
69
-    #define B_ST (1<<BL_ST)
70
-    #define EN_B (1<<BLEN_B)
71
-    #define EN_A (1<<BLEN_A)
72
-    
73
-    #define LCD_CLICKED ((buttons&B_MI)||(buttons&B_ST))
74
-  #endif//NEWPANEL
37
+  void lcd_buzz(long duration,uint16_t freq);
38
+  bool lcd_clicked();
75 39
 
76 40
 #else //no lcd
77 41
   FORCE_INLINE void lcd_update() {}
@@ -79,6 +43,7 @@
79 43
   FORCE_INLINE void lcd_setstatus(const char* message) {}
80 44
   FORCE_INLINE void lcd_buttons_update() {}
81 45
   FORCE_INLINE void lcd_reset_alert_level() {}
46
+  FORCE_INLINE void lcd_buzz(long duration,uint16_t freq) {}
82 47
 
83 48
   #define LCD_MESSAGEPGM(x) 
84 49
   #define LCD_ALERTMESSAGEPGM(x) 

+ 748
- 515
Marlin/ultralcd_implementation_hitachi_HD44780.h
File diff suppressed because it is too large
Näytä tiedosto


Loading…
Peruuta
Tallenna