Selaa lähdekoodia

Move SD Card Menu to its own file

Scott Lahteine 6 vuotta sitten
vanhempi
commit
43cf913048
3 muutettua tiedostoa jossa 137 lisäystä ja 122 poistoa
  1. 0
    117
      Marlin/src/lcd/menu/menu.cpp
  2. 0
    5
      Marlin/src/lcd/menu/menu.h
  3. 137
    0
      Marlin/src/lcd/menu/menu_sdcard.cpp

+ 0
- 117
Marlin/src/lcd/menu/menu.cpp Näytä tiedosto

@@ -118,30 +118,6 @@ void menu_action_submenu(screenFunc_t func) { lcd_save_previous_screen(); lcd_go
118 118
 void menu_action_gcode(PGM_P pgcode) { enqueue_and_echo_commands_P(pgcode); }
119 119
 void menu_action_function(screenFunc_t func) { (*func)(); }
120 120
 
121
-#if ENABLED(SDSUPPORT)
122
-
123
-  void menu_action_sdfile(CardReader &theCard) {
124
-    #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
125
-      last_sdfile_encoderPosition = encoderPosition;  // Save which file was selected for later use
126
-    #endif
127
-    card.openAndPrintFile(theCard.filename);
128
-    lcd_return_to_status();
129
-    lcd_reset_status();
130
-  }
131
-
132
-  void menu_action_sddirectory(CardReader &theCard) {
133
-    card.chdir(theCard.filename);
134
-    encoderTopLine = 0;
135
-    encoderPosition = 2 * ENCODER_STEPS_PER_MENU_ITEM;
136
-    screen_changed = true;
137
-    #if HAS_GRAPHICAL_LCD
138
-      drawing_screen = false;
139
-    #endif
140
-    lcd_refresh();
141
-  }
142
-
143
-#endif // SDSUPPORT
144
-
145 121
 ////////////////////////////////////////////
146 122
 /////////// Menu Editing Actions ///////////
147 123
 ////////////////////////////////////////////
@@ -505,97 +481,4 @@ void _lcd_draw_homing() {
505 481
   void _lcd_toggle_bed_leveling() { set_bed_leveling_enabled(!planner.leveling_active); }
506 482
 #endif
507 483
 
508
-#if ENABLED(SDSUPPORT)
509
-
510
-  #if !PIN_EXISTS(SD_DETECT)
511
-    void lcd_sd_refresh() {
512
-      card.initsd();
513
-      encoderTopLine = 0;
514
-    }
515
-  #endif
516
-
517
-  void lcd_sd_updir() {
518
-    encoderPosition = card.updir() ? ENCODER_STEPS_PER_MENU_ITEM : 0;
519
-    encoderTopLine = 0;
520
-    screen_changed = true;
521
-    lcd_refresh();
522
-  }
523
-
524
-  /**
525
-   *
526
-   * "Print from SD" submenu
527
-   *
528
-   */
529
-
530
-  #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
531
-    uint32_t last_sdfile_encoderPosition = 0xFFFF;
532
-
533
-    void lcd_reselect_last_file() {
534
-      if (last_sdfile_encoderPosition == 0xFFFF) return;
535
-      #if HAS_GRAPHICAL_LCD
536
-        // Some of this is a hack to force the screen update to work.
537
-        // TODO: Fix the real issue that causes this!
538
-        lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
539
-        lcd_synchronize();
540
-        safe_delay(50);
541
-        lcd_synchronize();
542
-        lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
543
-        drawing_screen = screen_changed = true;
544
-      #endif
545
-
546
-      lcd_goto_screen(menu_sdcard, last_sdfile_encoderPosition);
547
-      defer_return_to_status = true;
548
-      last_sdfile_encoderPosition = 0xFFFF;
549
-
550
-      #if HAS_GRAPHICAL_LCD
551
-        lcd_update();
552
-      #endif
553
-    }
554
-  #endif
555
-
556
-  void menu_sdcard() {
557
-    ENCODER_DIRECTION_MENUS();
558
-
559
-    const uint16_t fileCnt = card.get_num_Files();
560
-
561
-    START_MENU();
562
-    MENU_BACK(MSG_MAIN);
563
-    card.getWorkDirName();
564
-    if (card.filename[0] == '/') {
565
-      #if !PIN_EXISTS(SD_DETECT)
566
-        MENU_ITEM(function, LCD_STR_REFRESH MSG_REFRESH, lcd_sd_refresh);
567
-      #endif
568
-    }
569
-    else {
570
-      MENU_ITEM(function, LCD_STR_FOLDER "..", lcd_sd_updir);
571
-    }
572
-
573
-    for (uint16_t i = 0; i < fileCnt; i++) {
574
-      if (_menuLineNr == _thisItemNr) {
575
-        const uint16_t nr =
576
-          #if ENABLED(SDCARD_RATHERRECENTFIRST) && DISABLED(SDCARD_SORT_ALPHA)
577
-            fileCnt - 1 -
578
-          #endif
579
-        i;
580
-
581
-        #if ENABLED(SDCARD_SORT_ALPHA)
582
-          card.getfilename_sorted(nr);
583
-        #else
584
-          card.getfilename(nr);
585
-        #endif
586
-
587
-        if (card.filenameIsDir)
588
-          MENU_ITEM(sddirectory, MSG_CARD_MENU, card);
589
-        else
590
-          MENU_ITEM(sdfile, MSG_CARD_MENU, card);
591
-      }
592
-      else {
593
-        MENU_ITEM_DUMMY();
594
-      }
595
-    }
596
-    END_MENU();
597
-  }
598
-
599
-#endif // SDSUPPORT
600
-
601 484
 #endif // ULTIPANEL

+ 0
- 5
Marlin/src/lcd/menu/menu.h Näytä tiedosto

@@ -130,11 +130,6 @@ void menu_action_submenu(screenFunc_t data);
130 130
 void menu_action_function(menuAction_t data);
131 131
 void menu_action_gcode(const char* pgcode);
132 132
 
133
-#if ENABLED(SDSUPPORT)
134
-  void menu_action_sdfile(CardReader &theCard);
135
-  void menu_action_sddirectory(CardReader &theCard);
136
-#endif
137
-
138 133
 ////////////////////////////////////////////
139 134
 /////////// Menu Editing Actions ///////////
140 135
 ////////////////////////////////////////////

+ 137
- 0
Marlin/src/lcd/menu/menu_sdcard.cpp Näytä tiedosto

@@ -0,0 +1,137 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+//
24
+// SD Card Menu
25
+//
26
+
27
+#include "../../inc/MarlinConfigPre.h"
28
+
29
+#if HAS_LCD_MENU && ENABLED(SDSUPPORT)
30
+
31
+#include "menu.h"
32
+#include "../../sd/cardreader.h"
33
+
34
+#if !PIN_EXISTS(SD_DETECT)
35
+  void lcd_sd_refresh() {
36
+    card.initsd();
37
+    encoderTopLine = 0;
38
+  }
39
+#endif
40
+
41
+void lcd_sd_updir() {
42
+  encoderPosition = card.updir() ? ENCODER_STEPS_PER_MENU_ITEM : 0;
43
+  encoderTopLine = 0;
44
+  screen_changed = true;
45
+  lcd_refresh();
46
+}
47
+
48
+#if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
49
+  uint32_t last_sdfile_encoderPosition = 0xFFFF;
50
+
51
+  void lcd_reselect_last_file() {
52
+    if (last_sdfile_encoderPosition == 0xFFFF) return;
53
+    #if HAS_GRAPHICAL_LCD
54
+      // Some of this is a hack to force the screen update to work.
55
+      // TODO: Fix the real issue that causes this!
56
+      lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
57
+      lcd_synchronize();
58
+      safe_delay(50);
59
+      lcd_synchronize();
60
+      lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
61
+      drawing_screen = screen_changed = true;
62
+    #endif
63
+
64
+    lcd_goto_screen(menu_sdcard, last_sdfile_encoderPosition);
65
+    defer_return_to_status = true;
66
+    last_sdfile_encoderPosition = 0xFFFF;
67
+
68
+    #if HAS_GRAPHICAL_LCD
69
+      lcd_update();
70
+    #endif
71
+  }
72
+#endif
73
+
74
+void menu_action_sdfile(CardReader &theCard) {
75
+  #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
76
+    last_sdfile_encoderPosition = encoderPosition;  // Save which file was selected for later use
77
+  #endif
78
+  card.openAndPrintFile(theCard.filename);
79
+  lcd_return_to_status();
80
+  lcd_reset_status();
81
+}
82
+
83
+void menu_action_sddirectory(CardReader &theCard) {
84
+  card.chdir(theCard.filename);
85
+  encoderTopLine = 0;
86
+  encoderPosition = 2 * ENCODER_STEPS_PER_MENU_ITEM;
87
+  screen_changed = true;
88
+  #if HAS_GRAPHICAL_LCD
89
+    drawing_screen = false;
90
+  #endif
91
+  lcd_refresh();
92
+}
93
+
94
+void menu_sdcard() {
95
+  ENCODER_DIRECTION_MENUS();
96
+
97
+  const uint16_t fileCnt = card.get_num_Files();
98
+
99
+  START_MENU();
100
+  MENU_BACK(MSG_MAIN);
101
+  card.getWorkDirName();
102
+  if (card.filename[0] == '/') {
103
+    #if !PIN_EXISTS(SD_DETECT)
104
+      MENU_ITEM(function, LCD_STR_REFRESH MSG_REFRESH, lcd_sd_refresh);
105
+    #endif
106
+  }
107
+  else {
108
+    MENU_ITEM(function, LCD_STR_FOLDER "..", lcd_sd_updir);
109
+  }
110
+
111
+  for (uint16_t i = 0; i < fileCnt; i++) {
112
+    if (_menuLineNr == _thisItemNr) {
113
+      const uint16_t nr =
114
+        #if ENABLED(SDCARD_RATHERRECENTFIRST) && DISABLED(SDCARD_SORT_ALPHA)
115
+          fileCnt - 1 -
116
+        #endif
117
+      i;
118
+
119
+      #if ENABLED(SDCARD_SORT_ALPHA)
120
+        card.getfilename_sorted(nr);
121
+      #else
122
+        card.getfilename(nr);
123
+      #endif
124
+
125
+      if (card.filenameIsDir)
126
+        MENU_ITEM(sddirectory, MSG_CARD_MENU, card);
127
+      else
128
+        MENU_ITEM(sdfile, MSG_CARD_MENU, card);
129
+    }
130
+    else {
131
+      MENU_ITEM_DUMMY();
132
+    }
133
+  }
134
+  END_MENU();
135
+}
136
+
137
+#endif // HAS_LCD_MENU && SDSUPPORT

Loading…
Peruuta
Tallenna