Erik van der Zalm пре 12 година
родитељ
комит
a5be0c52c6
2 измењених фајлова са 117 додато и 45 уклоњено
  1. 74
    45
      Marlin/ultralcd.cpp
  2. 43
    0
      Marlin/ultralcd.h

+ 74
- 45
Marlin/ultralcd.cpp Прегледај датотеку

@@ -8,6 +8,8 @@
8 8
 #include "stepper.h"
9 9
 #include "ConfigurationStore.h"
10 10
 
11
+int8_t encoderDiff; /* encoderDiff is updated from interrupt context and added to encoderPosition every LCD update */
12
+
11 13
 /* Configuration settings */
12 14
 int plaPreheatHotendTemp;
13 15
 int plaPreheatHPBTemp;
@@ -122,13 +124,11 @@ static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned l
122 124
 #ifndef REPRAPWORLD_KEYPAD
123 125
 volatile uint8_t buttons;//Contains the bits of the currently pressed buttons.
124 126
 #else
125
-volatile uint16_t buttons;//Contains the bits of the currently pressed buttons (extended).
127
+volatile uint8_t buttons_reprapworld_keypad; // to store the reprapworld_keypad shiftregister values
126 128
 #endif
127
-
128 129
 uint8_t currentMenuViewOffset;              /* scroll offset in the current menu */
129 130
 uint32_t blocking_enc;
130 131
 uint8_t lastEncoderBits;
131
-int8_t encoderDiff; /* encoderDiff is updated from interrupt context and added to encoderPosition every LCD update */
132 132
 uint32_t encoderPosition;
133 133
 #if (SDCARDDETECT > 0)
134 134
 bool lcd_oldcardstatus;
@@ -410,7 +410,7 @@ static void lcd_move_z()
410 410
         if (current_position[Z_AXIS] > Z_MAX_POS)
411 411
             current_position[Z_AXIS] = Z_MAX_POS;
412 412
         encoderPosition = 0;
413
-        plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 60, active_extruder);
413
+        plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[Z_AXIS]/60, active_extruder);
414 414
         lcdDrawUpdate = 1;
415 415
     }
416 416
     if (lcdDrawUpdate)
@@ -736,21 +736,39 @@ menu_edit_type(float, float52, ftostr52, 100)
736 736
 menu_edit_type(unsigned long, long5, ftostr5, 0.01)
737 737
 
738 738
 #ifdef REPRAPWORLD_KEYPAD
739
-    static void reprapworld_keypad_move_y_down() {
740
-        encoderPosition = 1;
741
-        move_menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP;
742
-        lcd_move_y();
743
-    }
744
-    static void reprapworld_keypad_move_y_up() {
745
-        encoderPosition = -1;
746
-        move_menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP;
747
-        lcd_move_y();
748
-    }
749
-    static void reprapworld_keypad_move_home() {
750
-        //enquecommand_P((PSTR("G28"))); // move all axis home
751
-        // TODO gregor: move all axis home, i have currently only one axis on my prusa i3
752
-        enquecommand_P((PSTR("G28 Y")));
753
-    }
739
+	static void reprapworld_keypad_move_z_up() {
740
+    encoderPosition = 1;
741
+    move_menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP;
742
+		lcd_move_z();
743
+  }
744
+	static void reprapworld_keypad_move_z_down() {
745
+    encoderPosition = -1;
746
+    move_menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP;
747
+		lcd_move_z();
748
+  }
749
+	static void reprapworld_keypad_move_x_left() {
750
+    encoderPosition = -1;
751
+    move_menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP;
752
+		lcd_move_x();
753
+  }
754
+	static void reprapworld_keypad_move_x_right() {
755
+    encoderPosition = 1;
756
+    move_menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP;
757
+		lcd_move_x();
758
+	}
759
+	static void reprapworld_keypad_move_y_down() {
760
+    encoderPosition = 1;
761
+    move_menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP;
762
+		lcd_move_y();
763
+	}
764
+	static void reprapworld_keypad_move_y_up() {
765
+		encoderPosition = -1;
766
+		move_menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP;
767
+    lcd_move_y();
768
+	}
769
+	static void reprapworld_keypad_move_home() {
770
+		enquecommand_P((PSTR("G28"))); // move all axis home
771
+	}
754 772
 #endif
755 773
 
756 774
 /** End of menus **/
@@ -877,17 +895,29 @@ void lcd_update()
877 895
     if (lcd_next_update_millis < millis())
878 896
     {
879 897
 #ifdef ULTIPANEL
880
-        #ifdef REPRAPWORLD_KEYPAD
881
-        if (REPRAPWORLD_KEYPAD_MOVE_Y_DOWN) {
882
-            reprapworld_keypad_move_y_down();
883
-        }
884
-        if (REPRAPWORLD_KEYPAD_MOVE_Y_UP) {
885
-            reprapworld_keypad_move_y_up();
886
-        }
887
-        if (REPRAPWORLD_KEYPAD_MOVE_HOME) {
888
-            reprapworld_keypad_move_home();
889
-        }
890
-        #endif
898
+		#ifdef REPRAPWORLD_KEYPAD
899
+        	if (REPRAPWORLD_KEYPAD_MOVE_Z_UP) {
900
+        		reprapworld_keypad_move_z_up();
901
+        	}
902
+        	if (REPRAPWORLD_KEYPAD_MOVE_Z_DOWN) {
903
+        		reprapworld_keypad_move_z_down();
904
+        	}
905
+        	if (REPRAPWORLD_KEYPAD_MOVE_X_LEFT) {
906
+        		reprapworld_keypad_move_x_left();
907
+        	}
908
+        	if (REPRAPWORLD_KEYPAD_MOVE_X_RIGHT) {
909
+        		reprapworld_keypad_move_x_right();
910
+        	}
911
+        	if (REPRAPWORLD_KEYPAD_MOVE_Y_DOWN) {
912
+        		reprapworld_keypad_move_y_down();
913
+        	}
914
+        	if (REPRAPWORLD_KEYPAD_MOVE_Y_UP) {
915
+        		reprapworld_keypad_move_y_up();
916
+        	}
917
+        	if (REPRAPWORLD_KEYPAD_MOVE_HOME) {
918
+        		reprapworld_keypad_move_home();
919
+        	}
920
+		#endif
891 921
         if (encoderDiff)
892 922
         {
893 923
             lcdDrawUpdate = 1;
@@ -973,22 +1003,21 @@ void lcd_buttons_update()
973 1003
   #if BTN_ENC > 0
974 1004
     if((blocking_enc<millis()) && (READ(BTN_ENC)==0))
975 1005
         newbutton |= EN_C;
976
-  #endif      
977
-  #ifdef REPRAPWORLD_KEYPAD
978
-    // for the reprapworld_keypad
979
-    uint8_t newbutton_reprapworld_keypad=0;
980
-    WRITE(SHIFT_LD,LOW);
981
-    WRITE(SHIFT_LD,HIGH);
982
-    for(int8_t i=0;i<8;i++) {
983
-        newbutton_reprapworld_keypad = newbutton_reprapworld_keypad>>1;
984
-        if(READ(SHIFT_OUT))
985
-            newbutton_reprapworld_keypad|=(1<<7);
986
-        WRITE(SHIFT_CLK,HIGH);
987
-        WRITE(SHIFT_CLK,LOW);
988
-    }
989
-    newbutton |= ((~newbutton_reprapworld_keypad) << REPRAPWORLD_BTN_OFFSET); //invert it, because a pressed switch produces a logical 0
990
-  #endif
991 1006
     buttons = newbutton;
1007
+    #ifdef REPRAPWORLD_KEYPAD
1008
+      // for the reprapworld_keypad
1009
+      uint8_t newbutton_reprapworld_keypad=0;
1010
+      WRITE(SHIFT_LD,LOW);
1011
+      WRITE(SHIFT_LD,HIGH);
1012
+      for(int8_t i=0;i<8;i++) {
1013
+          newbutton_reprapworld_keypad = newbutton_reprapworld_keypad>>1;
1014
+          if(READ(SHIFT_OUT))
1015
+              newbutton_reprapworld_keypad|=(1<<7);
1016
+          WRITE(SHIFT_CLK,HIGH);
1017
+          WRITE(SHIFT_CLK,LOW);
1018
+      }
1019
+      buttons_reprapworld_keypad=~newbutton_reprapworld_keypad; //invert it, because a pressed switch produces a logical 0
1020
+	#endif
992 1021
 #else   //read it from the shift register
993 1022
     uint8_t newbutton=0;
994 1023
     WRITE(SHIFT_LD,LOW);

+ 43
- 0
Marlin/ultralcd.h Прегледај датотеку

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

Loading…
Откажи
Сачувај