Subversion Repositories MK-Marlin

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 ron 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
#ifndef ULTRALCD_H
24
#define ULTRALCD_H
25
 
26
#include "MarlinConfig.h"
27
 
28
#if ENABLED(ULTRA_LCD) || ENABLED(MALYAN_LCD)
29
  void lcd_init();
30
  bool lcd_detected();
31
  void lcd_update();
32
  void lcd_setalertstatusPGM(const char* message);
33
#else
34
  inline void lcd_init() {}
35
  inline bool lcd_detected() { return true; }
36
  inline void lcd_update() {}
37
  inline void lcd_setalertstatusPGM(const char* message) { UNUSED(message); }
38
#endif
39
 
40
#if ENABLED(ULTRA_LCD)
41
 
42
  #include "Marlin.h"
43
 
44
  int16_t utf8_strlen(const char* s);
45
  int16_t utf8_strlen_P(const char* s);
46
  bool lcd_hasstatus();
47
  void lcd_setstatus(const char* message, const bool persist=false);
48
  void lcd_setstatusPGM(const char* message, const int8_t level=0);
49
  void lcd_setalertstatusPGM(const char* message);
50
  void lcd_reset_alert_level();
51
  void lcd_reset_status();
52
  void lcd_status_printf_P(const uint8_t level, const char * const fmt, ...);
53
  void lcd_kill_screen();
54
  void kill_screen(const char* lcd_msg);
55
 
56
  extern uint8_t lcdDrawUpdate;
57
  inline void lcd_refresh() { lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; }
58
 
59
  #if HAS_BUZZER
60
    void lcd_buzz(const long duration, const uint16_t freq);
61
  #endif
62
 
63
  void lcd_quick_feedback(const bool clear_buttons); // Audible feedback for a button click - could also be visual
64
 
65
  #if ENABLED(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0
66
    void dontExpireStatus();
67
  #endif
68
 
69
  #if ENABLED(LCD_SET_PROGRESS_MANUALLY)
70
    extern uint8_t progress_bar_percent;
71
  #endif
72
 
73
  #if ENABLED(ADC_KEYPAD)
74
    uint8_t get_ADC_keyValue();
75
  #endif
76
 
77
  #if ENABLED(DOGLCD)
78
    extern int16_t lcd_contrast;
79
    void set_lcd_contrast(const int16_t value);
80
  #endif
81
 
82
  #if ENABLED(SHOW_BOOTSCREEN)
83
    void lcd_bootscreen();
84
  #endif
85
 
86
  #define LCD_UPDATE_INTERVAL 100
87
  #define BUTTON_EXISTS(BN) (defined(BTN_## BN) && BTN_## BN >= 0)
88
  #define BUTTON_PRESSED(BN) !READ(BTN_## BN)
89
 
90
  #if ENABLED(ULTIPANEL) // LCD with a click-wheel input
91
 
92
    extern bool defer_return_to_status;
93
 
94
    // Function pointer to menu functions.
95
    typedef void (*screenFunc_t)();
96
    typedef void (*menuAction_t)();
97
 
98
    extern int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
99
 
100
    #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
101
      extern bool lcd_external_control;
102
    #else
103
      constexpr bool lcd_external_control = false;
104
    #endif
105
 
106
    #if ENABLED(LCD_BED_LEVELING)
107
      extern bool lcd_wait_for_move;
108
    #else
109
      constexpr bool lcd_wait_for_move = false;
110
    #endif
111
 
112
    void lcd_goto_screen(screenFunc_t screen, const uint32_t encoder=0);
113
 
114
    void lcd_completion_feedback(const bool good=true);
115
 
116
    #if ENABLED(ADVANCED_PAUSE_FEATURE)
117
      extern uint8_t active_extruder;
118
      void lcd_advanced_pause_show_message(const AdvancedPauseMessage message,
119
                                           const AdvancedPauseMode mode=ADVANCED_PAUSE_MODE_PAUSE_PRINT,
120
                                           const uint8_t extruder=active_extruder);
121
    #endif
122
 
123
    #if ENABLED(G26_MESH_VALIDATION)
124
      void lcd_chirp();
125
    #endif
126
 
127
    #if ENABLED(AUTO_BED_LEVELING_UBL)
128
      void lcd_mesh_edit_setup(const float &initial);
129
      float lcd_mesh_edit();
130
      void lcd_z_offset_edit_setup(const float &initial);
131
      float lcd_z_offset_edit();
132
    #endif
133
 
134
  #endif
135
 
136
  #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
137
    extern millis_t previous_lcd_status_ms;
138
  #endif
139
 
140
  bool lcd_blink();
141
 
142
  #if ENABLED(REPRAPWORLD_KEYPAD) // is also ULTIPANEL and NEWPANEL
143
 
144
    #define REPRAPWORLD_BTN_OFFSET 0 // bit offset into buttons for shift register values
145
 
146
    #define BLEN_REPRAPWORLD_KEYPAD_F3     0
147
    #define BLEN_REPRAPWORLD_KEYPAD_F2     1
148
    #define BLEN_REPRAPWORLD_KEYPAD_F1     2
149
    #define BLEN_REPRAPWORLD_KEYPAD_DOWN   3
150
    #define BLEN_REPRAPWORLD_KEYPAD_RIGHT  4
151
    #define BLEN_REPRAPWORLD_KEYPAD_MIDDLE 5
152
    #define BLEN_REPRAPWORLD_KEYPAD_UP     6
153
    #define BLEN_REPRAPWORLD_KEYPAD_LEFT   7
154
 
155
    #define EN_REPRAPWORLD_KEYPAD_F3      (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_F3))
156
    #define EN_REPRAPWORLD_KEYPAD_F2      (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_F2))
157
    #define EN_REPRAPWORLD_KEYPAD_F1      (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_F1))
158
    #define EN_REPRAPWORLD_KEYPAD_DOWN    (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_DOWN))
159
    #define EN_REPRAPWORLD_KEYPAD_RIGHT   (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_RIGHT))
160
    #define EN_REPRAPWORLD_KEYPAD_MIDDLE  (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_MIDDLE))
161
    #define EN_REPRAPWORLD_KEYPAD_UP      (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_UP))
162
    #define EN_REPRAPWORLD_KEYPAD_LEFT    (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_LEFT))
163
 
164
    #define REPRAPWORLD_KEYPAD_MOVE_Z_DOWN  (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_F3)
165
    #define REPRAPWORLD_KEYPAD_MOVE_Z_UP    (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_F2)
166
    #define REPRAPWORLD_KEYPAD_MOVE_Y_DOWN  (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_DOWN)
167
    #define REPRAPWORLD_KEYPAD_MOVE_X_RIGHT (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_RIGHT)
168
    #define REPRAPWORLD_KEYPAD_MOVE_Y_UP    (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_UP)
169
    #define REPRAPWORLD_KEYPAD_MOVE_X_LEFT  (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_LEFT)
170
 
171
    #if ENABLED(ADC_KEYPAD)
172
      #define KEYPAD_HOME EN_REPRAPWORLD_KEYPAD_F1
173
      #define KEYPAD_EN_C EN_REPRAPWORLD_KEYPAD_MIDDLE
174
    #else
175
      #define KEYPAD_HOME EN_REPRAPWORLD_KEYPAD_MIDDLE
176
      #define KEYPAD_EN_C EN_REPRAPWORLD_KEYPAD_F1
177
    #endif
178
    #define REPRAPWORLD_KEYPAD_MOVE_HOME    (buttons_reprapworld_keypad & KEYPAD_HOME)
179
    #define REPRAPWORLD_KEYPAD_MOVE_MENU    (buttons_reprapworld_keypad & KEYPAD_EN_C)
180
 
181
    #define REPRAPWORLD_KEYPAD_PRESSED      (buttons_reprapworld_keypad & ( \
182
                                              EN_REPRAPWORLD_KEYPAD_F3 | \
183
                                              EN_REPRAPWORLD_KEYPAD_F2 | \
184
                                              EN_REPRAPWORLD_KEYPAD_F1 | \
185
                                              EN_REPRAPWORLD_KEYPAD_DOWN | \
186
                                              EN_REPRAPWORLD_KEYPAD_RIGHT | \
187
                                              EN_REPRAPWORLD_KEYPAD_MIDDLE | \
188
                                              EN_REPRAPWORLD_KEYPAD_UP | \
189
                                              EN_REPRAPWORLD_KEYPAD_LEFT) \
190
                                            )
191
 
192
  #endif
193
 
194
  #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
195
    bool is_lcd_clicked();
196
    void wait_for_release();
197
  #endif
198
 
199
#else // MALYAN_LCD or no LCD
200
 
201
  constexpr bool lcd_wait_for_move = false;
202
 
203
  inline void lcd_refresh() {}
204
  inline bool lcd_hasstatus() { return false; }
205
  inline void lcd_setstatus(const char* const message, const bool persist=false) { UNUSED(message); UNUSED(persist); }
206
  inline void lcd_setstatusPGM(const char* const message, const int8_t level=0) { UNUSED(message); UNUSED(level); }
207
  inline void lcd_status_printf_P(const uint8_t level, const char * const fmt, ...) { UNUSED(level); UNUSED(fmt); }
208
  inline void lcd_reset_alert_level() {}
209
  inline void lcd_reset_status() {}
210
 
211
#endif // ULTRA_LCD
212
 
213
#if ENABLED(ULTIPANEL)
214
 
215
  #if ENABLED(NEWPANEL) // Uses digital switches, not a shift register
216
 
217
    // Wheel spin pins where BA is 00, 10, 11, 01 (1 bit always changes)
218
    #define BLEN_A 0
219
    #define BLEN_B 1
220
 
221
    #define EN_A _BV(BLEN_A)
222
    #define EN_B _BV(BLEN_B)
223
 
224
    #if BUTTON_EXISTS(ENC)
225
      #define BLEN_C 2
226
      #define EN_C _BV(BLEN_C)
227
    #endif
228
 
229
    #if BUTTON_EXISTS(BACK)
230
      #define BLEN_D 3
231
      #define EN_D _BV(BLEN_D)
232
      #define LCD_BACK_CLICKED (buttons & EN_D)
233
    #endif
234
 
235
  #endif // NEWPANEL
236
 
237
  extern volatile uint8_t buttons;  // The last-checked buttons in a bit array.
238
  void lcd_buttons_update();
239
 
240
#else
241
 
242
  inline void lcd_buttons_update() {}
243
 
244
#endif
245
 
246
#if ENABLED(REPRAPWORLD_KEYPAD)
247
  #ifdef EN_C
248
    #define LCD_CLICKED ((buttons & EN_C) || REPRAPWORLD_KEYPAD_MOVE_MENU)
249
  #else
250
    #define LCD_CLICKED REPRAPWORLD_KEYPAD_MOVE_MENU
251
  #endif
252
#elif defined(EN_C)
253
  #define LCD_CLICKED (buttons & EN_C)
254
#else
255
  #define LCD_CLICKED false
256
#endif
257
 
258
#define LCD_MESSAGEPGM(x)      lcd_setstatusPGM(PSTR(x))
259
#define LCD_ALERTMESSAGEPGM(x) lcd_setalertstatusPGM(PSTR(x))
260
 
261
#if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
262
  void lcd_reselect_last_file();
263
#endif
264
 
265
#endif // ULTRALCD_H