1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-27 05:48:43 +00:00

Refactor LCD menus

This commit is contained in:
Scott Lahteine 2018-10-23 16:00:34 -05:00
parent ac5f2762b7
commit 2bf18950ab
25 changed files with 5720 additions and 5442 deletions

View File

@ -264,7 +264,7 @@
// LCD Menu Messages
#define LANGUAGE_DATA_INCL_(M) STRINGIFY_(../lcd/dogm/language_data_##M.h)
#define LANGUAGE_DATA_INCL_(M) STRINGIFY_(language_data_##M.h)
#define LANGUAGE_DATA_INCL(M) LANGUAGE_DATA_INCL_(M)
#define INCLUDE_LANGUAGE_DATA LANGUAGE_DATA_INCL(LCD_LANGUAGE)

View File

@ -628,7 +628,7 @@
LEAVE:
#if ENABLED(NEWPANEL)
#if ENABLED(ULTIPANEL)
lcd_reset_alert_level();
lcd_quick_feedback(true);
lcd_reset_status();

View File

@ -210,7 +210,6 @@ void GcodeSuite::G28(const bool always_home_all) {
// Cancel the active G29 session
#if ENABLED(PROBE_MANUALLY)
extern bool g29_in_progress;
g29_in_progress = false;
#endif

View File

@ -298,7 +298,13 @@
#define ULTIPANEL
#endif
#if ENABLED(DOGLCD) // Change number of lines to match the DOG graphic display
#if ENABLED(NO_LCD_MENUS)
#undef ULTIPANEL
#endif
#define HAS_GRAPHICAL_LCD ENABLED(DOGLCD)
#if HAS_GRAPHICAL_LCD
#ifndef LCD_WIDTH
#ifdef LCD_WIDTH_OVERRIDE
#define LCD_WIDTH LCD_WIDTH_OVERRIDE
@ -311,10 +317,6 @@
#endif
#endif
#if ENABLED(NO_LCD_MENUS)
#undef ULTIPANEL
#endif
#if ENABLED(ULTIPANEL)
#define NEWPANEL // Disable this if you actually have no click-encoder panel
#define ULTRA_LCD
@ -333,7 +335,14 @@
#endif
#endif
#if ENABLED(DOGLCD)
// Aliases for LCD features
#define HAS_SPI_LCD ENABLED(ULTRA_LCD)
#define HAS_CHARACTER_LCD (ENABLED(ULTRA_LCD) && DISABLED(DOGLCD))
#define HAS_DIGITAL_ENCODER (HAS_SPI_LCD && ENABLED(NEWPANEL))
#define HAS_LCD_MENU ENABLED(ULTIPANEL)
#define HAS_DEBUG_MENU (HAS_LCD_MENU && ENABLED(LCD_PROGRESS_BAR_TEST))
#if HAS_GRAPHICAL_LCD
/* Custom characters defined in font Marlin_symbols.fon which was merged to ISO10646-0-3.bdf */
// \x00 intentionally skipped to avoid problems in strings
#define LCD_STR_REFRESH "\x01"
@ -369,7 +378,7 @@
/**
* Default LCD contrast for dogm-like LCD displays
*/
#if ENABLED(DOGLCD)
#if HAS_GRAPHICAL_LCD
#define HAS_LCD_CONTRAST ( \
ENABLED(MAKRPANEL) \
@ -394,14 +403,12 @@
#endif
// Boot screens
#if DISABLED(ULTRA_LCD)
#if !HAS_SPI_LCD
#undef SHOW_BOOTSCREEN
#elif !defined(BOOTSCREEN_TIMEOUT)
#define BOOTSCREEN_TIMEOUT 2500
#endif
#define HAS_DEBUG_MENU (ENABLED(ULTIPANEL) && ENABLED(LCD_PROGRESS_BAR_TEST))
/**
* Extruders have some combination of stepper motors and hotends
* so we separate these concepts into the defines:

View File

@ -12,17 +12,16 @@
* Western(English), Cyrillic(Russian), Kana(Japanese) charsets.
*/
#include "../inc/MarlinConfigPre.h"
#include "../inc/MarlinConfig.h"
#include "../../inc/MarlinConfigPre.h"
#if ENABLED(ULTRA_LCD)
#include "ultralcd.h"
#include "../Marlin.h"
#if ENABLED(ULTRA_LCD) && DISABLED(DOGLCD)
#include "../ultralcd.h"
#include "../../Marlin.h"
#if DISABLED(DOGLCD)
#include <string.h>
#include "fontutils.h"
#include "lcdprint.h"
#include "../fontutils.h"
#include "../lcdprint.h"
#include "ultralcd_common_HD44780.h"
#ifndef LCD_CLASS
@ -1040,5 +1039,4 @@ int lcd_put_u8str_max_P(PGM_P utf8_str_P, pixel_len_t max_length) {
return lcd_put_u8str_max_cb(utf8_str_P, read_byte_rom, max_length);
}
#endif // DOGLCD
#endif // ULTRA_LCD
#endif // ULTRA_LCD && !DOGLCD

View File

@ -19,23 +19,21 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ULTRALCD_COMMON_HD44780_H
#define ULTRALCD_COMMON_HD44780_H
#pragma once
/**
* Implementation of the LCD display routines for a Hitachi HD44780 display.
* These are the most common LCD character displays.
*/
#include "../inc/MarlinConfig.h"
#include "../../inc/MarlinConfig.h"
#if LCD_HEIGHT > 3
#include "../libs/duration_t.h"
#include "../../libs/duration_t.h"
#endif
#if ENABLED(AUTO_BED_LEVELING_UBL)
#include "../feature/bedlevel/ubl/ubl.h"
#include "../../feature/bedlevel/ubl/ubl.h"
#if ENABLED(ULTIPANEL)
#define ULTRA_X_PIXELS_PER_CHAR 5
@ -183,17 +181,9 @@ extern volatile uint8_t buttons; //an extended version of the last checked butt
#endif
#include "fontutils.h"
#include "lcdprint.h"
#include "../fontutils.h"
#include "../lcdprint.h"
#if ENABLED(LCD_PROGRESS_BAR)
#define LCD_STR_PROGRESS "\x03\x04\x05"
#endif
enum HD44780CharSet : char {
CHARSET_MENU,
CHARSET_INFO,
CHARSET_BOOT
};
#endif // ULTRALCD_COMMON_HD44780_H

View File

@ -69,8 +69,8 @@
LCD_CLASS lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5, LCD_PINS_D6, LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7
#endif
#include "fontutils.h"
#include "lcdprint.h"
#include "../fontutils.h"
#include "../lcdprint.h"
#if ENABLED(LCD_PROGRESS_BAR)
static millis_t progress_bar_ms = 0; // Start millis of the current progress bar cycle
@ -90,7 +90,7 @@ static void createChar_P(const char c, const byte * const ptr) {
lcd.createChar(c, temp);
}
static void lcd_set_custom_characters(
void lcd_set_custom_characters(
#if ENABLED(LCD_PROGRESS_BAR) || ENABLED(SHOW_BOOTSCREEN)
const uint8_t screen_charset=CHARSET_INFO
#endif
@ -308,7 +308,7 @@ static void lcd_set_custom_characters(
}
static void lcd_implementation_init(
void lcd_implementation_init(
#if ENABLED(LCD_PROGRESS_BAR)
const uint8_t screen_charset=CHARSET_INFO
#endif
@ -744,7 +744,7 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
* |01234567890123456789|
*/
static void lcd_impl_status_screen_0() {
void lcd_impl_status_screen_0() {
const bool blink = lcd_blink();
// ========== Line 1 ==========
@ -969,7 +969,7 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
#if ENABLED(ADVANCED_PAUSE_FEATURE)
static void lcd_implementation_hotend_status(const uint8_t row, const uint8_t extruder=active_extruder) {
void lcd_implementation_hotend_status(const uint8_t row, const uint8_t extruder) {
if (row < LCD_HEIGHT) {
lcd_moveto(LCD_WIDTH - 9, row);
_draw_heater_status(extruder, LCD_STR_THERMOMETER[0], lcd_blink());
@ -978,7 +978,7 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
#endif // ADVANCED_PAUSE_FEATURE
static void lcd_implementation_drawmenu_static(const uint8_t row, PGM_P pstr, const bool center=true, const bool invert=false, const char *valstr=NULL) {
void lcd_implementation_drawmenu_static(const uint8_t row, PGM_P pstr, const bool center/*=true*/, const bool invert/*=false*/, const char *valstr/*=NULL*/) {
UNUSED(invert);
int8_t n = LCD_WIDTH;
lcd_moveto(0, row);
@ -991,7 +991,7 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
for (; n > 0; --n) lcd_put_wchar(' ');
}
static void lcd_implementation_drawmenu_generic(const bool sel, const uint8_t row, PGM_P pstr, const char pre_char, const char post_char) {
void lcd_implementation_drawmenu_generic(const bool sel, const uint8_t row, PGM_P pstr, const char pre_char, const char post_char) {
uint8_t n = LCD_WIDTH - 2;
lcd_moveto(0, row);
lcd_put_wchar(sel ? pre_char : ' ');
@ -1000,7 +1000,7 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
lcd_put_wchar(post_char);
}
static void lcd_implementation_drawmenu_setting_edit_generic(const bool sel, const uint8_t row, PGM_P pstr, const char pre_char, const char* const data) {
void lcd_implementation_drawmenu_setting_edit_generic(const bool sel, const uint8_t row, PGM_P pstr, const char pre_char, const char* const data) {
uint8_t n = LCD_WIDTH - 2 - utf8_strlen(data);
lcd_moveto(0, row);
lcd_put_wchar(sel ? pre_char : ' ');
@ -1009,7 +1009,7 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
while (n--) lcd_put_wchar(' ');
lcd_put_u8str(data);
}
static void lcd_implementation_drawmenu_setting_edit_generic_P(const bool sel, const uint8_t row, PGM_P pstr, const char pre_char, const char* const data) {
void lcd_implementation_drawmenu_setting_edit_generic_P(const bool sel, const uint8_t row, PGM_P pstr, const char pre_char, const char* const data) {
uint8_t n = LCD_WIDTH - 2 - utf8_strlen_P(data);
lcd_moveto(0, row);
lcd_put_wchar(sel ? pre_char : ' ');
@ -1019,10 +1019,7 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
lcd_put_u8str_P(data);
}
#define DRAWMENU_SETTING_EDIT_GENERIC(_src) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', _src)
#define DRAW_BOOL_SETTING(sel, row, pstr, data) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, '>', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
void lcd_implementation_drawedit(PGM_P pstr, const char* const value=NULL) {
void lcd_implementation_drawedit(PGM_P pstr, const char* const value/*=NULL*/) {
lcd_moveto(1, 1);
lcd_put_u8str_P(pstr);
if (value != NULL) {
@ -1071,25 +1068,18 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
lcd_put_wchar(post_char);
}
static void lcd_implementation_drawmenu_sdfile(const bool sel, const uint8_t row, PGM_P pstr, CardReader &theCard) {
void lcd_implementation_drawmenu_sdfile(const bool sel, const uint8_t row, PGM_P pstr, CardReader &theCard) {
lcd_implementation_drawmenu_sd(sel, row, pstr, theCard, 2, ' ');
}
static void lcd_implementation_drawmenu_sddirectory(const bool sel, const uint8_t row, PGM_P pstr, CardReader &theCard) {
void lcd_implementation_drawmenu_sddirectory(const bool sel, const uint8_t row, PGM_P pstr, CardReader &theCard) {
lcd_implementation_drawmenu_sd(sel, row, pstr, theCard, 2, LCD_STR_FOLDER[0]);
}
#endif // SDSUPPORT
#define lcd_implementation_drawmenu_back(sel, row, pstr, dummy) lcd_implementation_drawmenu_generic(sel, row, pstr, LCD_UPLEVEL_CHAR, LCD_UPLEVEL_CHAR)
#define lcd_implementation_drawmenu_submenu(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
#define lcd_implementation_drawmenu_gcode(sel, row, pstr, gcode) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
#define lcd_implementation_drawmenu_function(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
#if ENABLED(LCD_HAS_SLOW_BUTTONS)
extern millis_t next_button_update_ms;
static uint8_t lcd_implementation_read_slow_buttons() {
#if ENABLED(LCD_I2C_TYPE_MCP23017)
// Reading these buttons this is likely to be too slow to call inside interrupt context

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
// use this file to create the public interface for device drivers that are NOT in the U8G library
@ -36,7 +36,6 @@ class U8GLIB_64128N_2X_HAL : public U8GLIB
{ }
};
extern u8g_dev_t u8g_dev_st7920_128x64_HAL_4x_sw_spi;
extern u8g_dev_t u8g_dev_st7920_128x64_HAL_4x_hw_spi;
class U8GLIB_ST7920_128X64_4X_HAL : public U8GLIB
@ -50,7 +49,6 @@ class U8GLIB_ST7920_128X64_4X_HAL : public U8GLIB
{ }
};
// AVR version uses ultralcd_st7920_u8glib_rrd_AVR.cpp, HAL version uses u8g_dev_st7920_128x64_HAL.cpp
extern u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi;
class U8GLIB_ST7920_128X64_RRD : public U8GLIB
@ -61,7 +59,6 @@ class U8GLIB_ST7920_128X64_RRD : public U8GLIB
{ }
};
extern u8g_dev_t u8g_dev_sh1106_128x64_2x_i2c_2_wire;
class U8GLIB_SH1106_128X64_2X_I2C_2_WIRE : public U8GLIB {
public:
@ -70,8 +67,6 @@ class U8GLIB_SH1106_128X64_2X_I2C_2_WIRE : public U8GLIB {
{ }
};
extern u8g_dev_t u8g_dev_ssd1306_128x64_2x_i2c_2_wire;
class U8GLIB_SSD1306_128X64_2X_I2C_2_WIRE : public U8GLIB {
public:

View File

@ -7,7 +7,7 @@
* @copyright GPL/BSD
*/
#include "../inc/MarlinConfigPre.h"
#include "../../inc/MarlinConfigPre.h"
#if ENABLED(DOGLCD)
@ -16,12 +16,12 @@ extern U8GLIB *pu8g;
#define _lcd_write(a) pu8g->print(a)
#define _lcd_setcursor(col, row) pu8g->setPrintPos((col), (row));
#include "ultralcd.h"
#include "../Marlin.h"
#include "../ultralcd.h"
#include "../../Marlin.h"
#include "fontutils.h"
#include "../fontutils.h"
#include "u8g_fontutf8.h"
#include "lcdprint.h"
#include "../lcdprint.h"
int lcd_glyph_height(void) {
return u8g_GetFontBBXHeight(pu8g->getU8g());

View File

@ -198,7 +198,7 @@ inline void lcd_implementation_status_message(const bool blink) {
#endif
}
static void lcd_impl_status_screen_0() {
void lcd_impl_status_screen_0() {
const bool blink = lcd_blink();

View File

@ -947,7 +947,7 @@ void ST7920_Lite_Status_Screen::clear_text_buffer() {
ncs();
}
static void lcd_impl_status_screen_0() {
void lcd_impl_status_screen_0() {
ST7920_Lite_Status_Screen::update(false);
}

View File

@ -7,12 +7,12 @@
* @copyright GPL/BSD
*/
#include "../inc/MarlinConfigPre.h"
#include "../../inc/MarlinConfigPre.h"
#if ENABLED(DOGLCD)
#include <string.h>
#include "fontutils.h"
#include "../fontutils.h"
#include "u8g_fontutf8.h"
////////////////////////////////////////////////////////////

View File

@ -6,11 +6,10 @@
* @date 2015-02-19
* @copyright GPL/BSD
*/
#ifndef _UXG_FONTUTF8_H
#define _UXG_FONTUTF8_H 1
#pragma once
#include <U8glib.h>
#include "fontutils.h"
#include "../fontutils.h"
// the macro to indicate a UTF-8 string
// You should to save the C/C++ source in UTF-8 encoding!
@ -25,16 +24,14 @@ typedef struct _uxg_fontinfo_t {
const u8g_fntpgm_uint8_t *fntdata;
} uxg_fontinfo_t;
int uxg_SetUtf8Fonts (const uxg_fontinfo_t * fntinfo, int number); // fntinfo is type of PROGMEM
int uxg_SetUtf8Fonts(const uxg_fontinfo_t * fntinfo, int number); // fntinfo is type of PROGMEM
unsigned int uxg_DrawWchar (u8g_t *pu8g, unsigned int x, unsigned int y, wchar_t ch, pixel_len_t max_length);
unsigned int uxg_DrawWchar(u8g_t *pu8g, unsigned int x, unsigned int y, wchar_t ch, pixel_len_t max_length);
unsigned int uxg_DrawUtf8Str (u8g_t *pu8g, unsigned int x, unsigned int y, const char *utf8_msg, pixel_len_t max_length);
unsigned int uxg_DrawUtf8StrP (u8g_t *pu8g, unsigned int x, unsigned int y, PGM_P utf8_msg, pixel_len_t max_length);
unsigned int uxg_DrawUtf8Str(u8g_t *pu8g, unsigned int x, unsigned int y, const char *utf8_msg, pixel_len_t max_length);
unsigned int uxg_DrawUtf8StrP(u8g_t *pu8g, unsigned int x, unsigned int y, PGM_P utf8_msg, pixel_len_t max_length);
int uxg_GetUtf8StrPixelWidth(u8g_t *pu8g, const char *utf8_msg);
int uxg_GetUtf8StrPixelWidthP(u8g_t *pu8g, PGM_P utf8_msg);
#define uxg_GetFont(puxg) ((puxg)->font)
#endif // _UXG_FONTUTF8_H

View File

@ -36,37 +36,29 @@
#ifndef ULTRALCD_IMPL_DOGM_H
#define ULTRALCD_IMPL_DOGM_H
#include "../inc/MarlinConfig.h"
#include "../../inc/MarlinConfig.h"
/**
* Implementation of the LCD display routines for a DOGM128 graphic display.
* These are common LCD 128x64 pixel graphic displays.
*/
#include "ultralcd.h"
#include "../ultralcd.h"
/*
#if ENABLED(U8GLIB_ST7565_64128N)
#include "dogm/ultralcd_st7565_u8glib_VIKI.h"
#elif ENABLED(U8GLIB_ST7920)
#include "dogm/ultralcd_st7920_u8glib_rrd.h"
#endif
*/
#include "dogm/dogm_bitmaps.h"
#include "dogm_bitmaps.h"
#if ENABLED(SDSUPPORT)
#include "../libs/duration_t.h"
#include "../../libs/duration_t.h"
#endif
#include <U8glib.h>
#include "fontutils.h"
#include "../fontutils.h"
#include "u8g_fontutf8.h"
#include "dogm/HAL_LCD_class_defines.h"
#include "HAL_LCD_class_defines.h"
#if ENABLED(AUTO_BED_LEVELING_UBL)
#include "../feature/bedlevel/ubl/ubl.h"
#include "../../feature/bedlevel/ubl/ubl.h"
#endif
// Only Western languages support big / small fonts
@ -76,7 +68,7 @@
#endif
#if ENABLED(USE_SMALL_INFOFONT)
#include "dogm/dogm_font_data_6x9_marlin.h"
#include "dogm_font_data_6x9_marlin.h"
#define FONT_STATUSMENU_NAME u8g_font_6x9
#define INFO_FONT_HEIGHT 7
#else
@ -89,7 +81,7 @@
#include LANGUAGE_DATA_INCL(LCD_LANGUAGE)
#include "dogm/dogm_font_data_ISO10646_1.h"
#include "dogm_font_data_ISO10646_1.h"
#define FONT_MENU_NAME ISO10646_1_5x7
//#define FONT_STATUSMENU_NAME FONT_MENU_NAME
@ -199,7 +191,7 @@ U8GLIB *pu8g = &u8g;
#define LCD_PIXEL_HEIGHT 64
#endif
#include "lcdprint.h"
#include "../lcdprint.h"
int16_t lcd_contrast; // Initialized by settings.load()
static char currentfont = 0;
@ -302,13 +294,13 @@ static void lcd_setFont(const char font_nr) {
#endif // SHOW_BOOTSCREEN
#if ENABLED(LIGHTWEIGHT_UI)
#include "dogm/status_screen_lite_ST7920.h"
#include "status_screen_lite_ST7920.h"
#else
#include "dogm/status_screen_DOGM.h"
#include "status_screen_DOGM.h"
#endif
// Initialize or re-initialize the LCD
static void lcd_implementation_init() {
void lcd_implementation_init() {
#if PIN_EXISTS(LCD_BACKLIGHT) // Enable LCD backlight
OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH);
@ -374,7 +366,7 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
#if ENABLED(ADVANCED_PAUSE_FEATURE)
static void lcd_implementation_hotend_status(const uint8_t row, const uint8_t extruder=active_extruder) {
void lcd_implementation_hotend_status(const uint8_t row, const uint8_t extruder) {
row_y1 = row * row_height + 1;
row_y2 = row_y1 + row_height - 1;
@ -394,7 +386,7 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
#endif // ADVANCED_PAUSE_FEATURE
// Set the colors for a menu item based on whether it is selected
static bool lcd_implementation_mark_as_selected(const uint8_t row, const bool isSelected) {
static bool mark_as_selected(const uint8_t row, const bool isSelected) {
row_y1 = row * row_height + 1;
row_y2 = row_y1 + row_height - 1;
@ -423,9 +415,9 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
}
// Draw a static line of text in the same idiom as a menu item
static void lcd_implementation_drawmenu_static(const uint8_t row, PGM_P pstr, const bool center=true, const bool invert=false, const char* valstr=NULL) {
void lcd_implementation_drawmenu_static(const uint8_t row, PGM_P pstr, const bool center/*=true*/, const bool invert/*=false*/, const char* valstr/*=NULL*/) {
if (lcd_implementation_mark_as_selected(row, invert)) {
if (mark_as_selected(row, invert)) {
uint8_t n = LCD_PIXEL_WIDTH - (DOG_CHAR_WIDTH) * (START_COL); // pixel width of string allowed
@ -443,10 +435,10 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
}
// Draw a generic menu item
static void lcd_implementation_drawmenu_generic(const bool isSelected, const uint8_t row, PGM_P pstr, const char pre_char, const char post_char) {
void lcd_implementation_drawmenu_generic(const bool isSelected, const uint8_t row, PGM_P pstr, const char pre_char, const char post_char) {
UNUSED(pre_char);
if (lcd_implementation_mark_as_selected(row, isSelected)) {
if (mark_as_selected(row, isSelected)) {
uint8_t n = LCD_WIDTH - (START_COL) - 2;
n *= DOG_CHAR_WIDTH;
n -= lcd_put_u8str_max_P(pstr, n);
@ -457,15 +449,9 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
}
}
// Macros for specific types of menu items
#define lcd_implementation_drawmenu_back(sel, row, pstr, dummy) lcd_implementation_drawmenu_generic(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
#define lcd_implementation_drawmenu_submenu(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
#define lcd_implementation_drawmenu_gcode(sel, row, pstr, gcode) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
#define lcd_implementation_drawmenu_function(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
// Draw a menu item with an editable value
static void _drawmenu_setting_edit_generic(const bool isSelected, const uint8_t row, PGM_P pstr, const char* const data, const bool pgm) {
if (lcd_implementation_mark_as_selected(row, isSelected)) {
void _drawmenu_setting_edit_generic(const bool isSelected, const uint8_t row, PGM_P pstr, const char* const data, const bool pgm) {
if (mark_as_selected(row, isSelected)) {
const uint8_t vallen = (pgm ? utf8_strlen_P(data) : utf8_strlen((char*)data));
uint8_t n = LCD_WIDTH - (START_COL) - 2 - vallen;
n *= DOG_CHAR_WIDTH;
@ -477,14 +463,7 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
}
}
// Macros for edit items
#define lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, data) _drawmenu_setting_edit_generic(sel, row, pstr, data, false)
#define lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, data) _drawmenu_setting_edit_generic(sel, row, pstr, data, true)
#define DRAWMENU_SETTING_EDIT_GENERIC(_src) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, _src)
#define DRAW_BOOL_SETTING(sel, row, pstr, data) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
void lcd_implementation_drawedit(PGM_P const pstr, const char* const value=NULL) {
void lcd_implementation_drawedit(PGM_P const pstr, const char* const value/*=NULL*/) {
const uint8_t labellen = utf8_strlen_P(pstr),
vallen = utf8_strlen(value);
@ -536,10 +515,10 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
#if ENABLED(SDSUPPORT)
static void _drawmenu_sd(const bool isSelected, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir) {
void _drawmenu_sd(const bool isSelected, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir) {
UNUSED(pstr);
lcd_implementation_mark_as_selected(row, isSelected);
mark_as_selected(row, isSelected);
if (!PAGE_CONTAINS(row_y1, row_y2)) return;
@ -572,9 +551,6 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
while (n - DOG_CHAR_WIDTH > 0) { n -= lcd_put_wchar(' '); }
}
#define lcd_implementation_drawmenu_sdfile(sel, row, pstr, theCard) _drawmenu_sd(sel, row, pstr, theCard, false)
#define lcd_implementation_drawmenu_sddirectory(sel, row, pstr, theCard) _drawmenu_sd(sel, row, pstr, theCard, true)
#endif // SDSUPPORT
#if ENABLED(AUTO_BED_LEVELING_UBL)
@ -666,6 +642,44 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
#endif // AUTO_BED_LEVELING_UBL
#if ENABLED(BABYSTEP_ZPROBE_GFX_OVERLAY) || ENABLED(MESH_EDIT_GFX_OVERLAY)
void _lcd_zoffset_overlay_gfx(const float zvalue) {
// Determine whether the user is raising or lowering the nozzle.
static int8_t dir;
static float old_zvalue;
if (zvalue != old_zvalue) {
dir = zvalue ? zvalue < old_zvalue ? -1 : 1 : 0;
old_zvalue = zvalue;
}
#if ENABLED(OVERLAY_GFX_REVERSE)
const unsigned char *rot_up = ccw_bmp, *rot_down = cw_bmp;
#else
const unsigned char *rot_up = cw_bmp, *rot_down = ccw_bmp;
#endif
#if ENABLED(USE_BIG_EDIT_FONT)
const int left = 0, right = 45, nozzle = 95;
#else
const int left = 5, right = 90, nozzle = 60;
#endif
// Draw a representation of the nozzle
if (PAGE_CONTAINS(3, 16)) u8g.drawBitmapP(nozzle + 6, 4 - dir, 2, 12, nozzle_bmp);
if (PAGE_CONTAINS(20, 20)) u8g.drawBitmapP(nozzle + 0, 20, 3, 1, offset_bedline_bmp);
// Draw cw/ccw indicator and up/down arrows.
if (PAGE_CONTAINS(47, 62)) {
u8g.drawBitmapP(left + 0, 47, 3, 16, rot_down);
u8g.drawBitmapP(right + 0, 47, 3, 16, rot_up);
u8g.drawBitmapP(right + 20, 48 - dir, 2, 13, up_arrow_bmp);
u8g.drawBitmapP(left + 20, 49 - dir, 2, 13, down_arrow_bmp);
}
}
#endif // BABYSTEP_ZPROBE_GFX_OVERLAY || MESH_EDIT_GFX_OVERLAY
#endif // ULTIPANEL
#endif // __ULTRALCD_IMPL_DOGM_H

View File

@ -6,8 +6,7 @@
* @date 2016-08-19
* @copyright GPL/BSD
*/
#ifndef _FONT_UTILS_H
#define _FONT_UTILS_H
#pragma once
#include <stdlib.h>
#include <Arduino.h>
@ -45,5 +44,3 @@ uint8_t* get_utf8_value_cb(uint8_t *pstart, read_byte_cb_t cb_read_byte, wchar_t
/* Returns lenght of string in CHARACTERS, NOT BYTES */
uint8_t utf8_strlen(const char *pstart);
uint8_t utf8_strlen_P(PGM_P pstart);
#endif // _FONT_UTILS_H

View File

@ -229,7 +229,7 @@
#define MSG_E6STEPS _UxGT("挤出机6步数/mm") //"E6steps/mm"
#define MSG_TEMPERATURE _UxGT("温度") //"Temperature"
#define MSG_MOTION _UxGT("运动") //"Motion"
#define MSG_FILAMENT _UxGT("丝料测容") //"Filament" lcd_control_volumetric_menu
#define MSG_FILAMENT _UxGT("丝料测容") //"Filament" menu_advanced_filament
#define MSG_VOLUMETRIC_ENABLED _UxGT("测容积mm³") //"E in mm3" volumetric_enabled
#define MSG_FILAMENT_DIAM _UxGT("丝料直径") //"Fil. Dia."
#define MSG_FILAMENT_UNLOAD _UxGT("卸载 mm") // "Unload mm"

View File

@ -229,7 +229,7 @@
#define MSG_E6STEPS _UxGT("擠出機6步數/mm") //"E6steps/mm"
#define MSG_TEMPERATURE _UxGT("溫度") //"Temperature"
#define MSG_MOTION _UxGT("運作") //"Motion"
#define MSG_FILAMENT _UxGT("絲料測容") //"Filament" lcd_control_volumetric_menu
#define MSG_FILAMENT _UxGT("絲料測容") //"Filament" menu_control_volumetric
#define MSG_VOLUMETRIC_ENABLED _UxGT("測容積mm³") //"E in mm3" volumetric_enabled
#define MSG_FILAMENT_DIAM _UxGT("絲料直徑") //"Fil. Dia."
#define MSG_FILAMENT_UNLOAD _UxGT("卸載 mm") // "Unload mm"

View File

@ -11,10 +11,12 @@
#include "fontutils.h"
#if DISABLED(DOGLCD)
#define _UxGT(a) a
#include "../inc/MarlinConfigPre.h"
#if HAS_GRAPHICAL_LCD
#include "dogm/u8g_fontutf8.h"
#else
#include "u8g_fontutf8.h"
#define _UxGT(a) a
#endif
#define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80u)

4660
Marlin/src/lcd/menu/menu.cpp Normal file

File diff suppressed because it is too large Load Diff

396
Marlin/src/lcd/menu/menu.h Normal file
View File

@ -0,0 +1,396 @@
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "../ultralcd.h"
#include "../../inc/MarlinConfig.h"
extern uint32_t encoderPosition;
extern int8_t encoderLine, encoderTopLine, screen_items;
extern millis_t lastEncoderMovementMillis;
extern bool screen_changed;
constexpr int16_t heater_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP);
void scroll_screen(const uint8_t limit, const bool is_menu);
bool use_click();
bool printer_busy();
void lcd_completion_feedback(const bool good=true);
void lcd_goto_previous_menu();
void lcd_goto_previous_menu_no_defer();
////////////////////////////////////////////
///////// Menu Item Draw Functions /////////
////////////////////////////////////////////
#if ENABLED(SDSUPPORT)
class CardReader;
#endif
void lcd_implementation_drawmenu_generic(const bool isSelected, const uint8_t row, const char* pstr, const char pre_char, const char post_char);
void lcd_implementation_drawmenu_static(const uint8_t row, const char* pstr, const bool center=true, const bool invert=false, const char *valstr=NULL);
void lcd_implementation_drawedit(const char* const pstr, const char* const value=NULL);
#if ENABLED(ADVANCED_PAUSE_FEATURE)
void lcd_implementation_hotend_status(const uint8_t row, const uint8_t extruder);
#endif
#if HAS_GRAPHICAL_LCD
void _drawmenu_setting_edit_generic(const bool isSelected, const uint8_t row, const char* pstr, const char* const data, const bool pgm);
#define lcd_implementation_drawmenu_back(sel, row, pstr, dummy) lcd_implementation_drawmenu_generic(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
#define lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, data) _drawmenu_setting_edit_generic(sel, row, pstr, data, false)
#define lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, data) _drawmenu_setting_edit_generic(sel, row, pstr, data, true)
#define DRAWMENU_SETTING_EDIT_GENERIC(SRC) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, SRC)
#define DRAW_BOOL_SETTING(sel, row, pstr, data) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
#if ENABLED(SDSUPPORT)
void _drawmenu_sd(const bool isSelected, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir);
#define lcd_implementation_drawmenu_sdfile(sel, row, pstr, theCard) _drawmenu_sd(sel, row, pstr, theCard, false)
#define lcd_implementation_drawmenu_sddirectory(sel, row, pstr, theCard) _drawmenu_sd(sel, row, pstr, theCard, true)
#endif
#if ENABLED(BABYSTEP_ZPROBE_GFX_OVERLAY) || ENABLED(MESH_EDIT_GFX_OVERLAY)
void _lcd_zoffset_overlay_gfx(const float zvalue);
#endif
#else
#define lcd_implementation_drawmenu_back(sel, row, pstr, dummy) lcd_implementation_drawmenu_generic(sel, row, pstr, LCD_UPLEVEL_CHAR, LCD_UPLEVEL_CHAR)
void lcd_implementation_drawmenu_setting_edit_generic(const bool sel, const uint8_t row, const char* pstr, const char pre_char, const char* const data);
void lcd_implementation_drawmenu_setting_edit_generic_P(const bool sel, const uint8_t row, const char* pstr, const char pre_char, const char* const data);
#define DRAWMENU_SETTING_EDIT_GENERIC(SRC) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', SRC)
#define DRAW_BOOL_SETTING(sel, row, pstr, data) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, '>', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
#if ENABLED(SDSUPPORT)
void lcd_implementation_drawmenu_sdfile(const bool sel, const uint8_t row, PGM_P pstr, CardReader &theCard);
void lcd_implementation_drawmenu_sddirectory(const bool sel, const uint8_t row, PGM_P pstr, CardReader &theCard);
#endif
#endif
#define lcd_implementation_drawmenu_submenu(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
#define lcd_implementation_drawmenu_gcode(sel, row, pstr, gcode) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
#define lcd_implementation_drawmenu_function(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
#if ENABLED(AUTO_BED_LEVELING_UBL)
void lcd_implementation_ubl_plot(const uint8_t x, const uint8_t inverted_y);
#endif
////////////////////////////////////////////
/////// Edit Setting Draw Functions ////////
////////////////////////////////////////////
#define DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(TYPE, NAME, STRFUNC) \
FORCE_INLINE void lcd_implementation_drawmenu_setting_edit_ ## NAME (const bool sel, const uint8_t row, PGM_P pstr, PGM_P pstr2, TYPE * const data, ...) { \
UNUSED(pstr2); \
DRAWMENU_SETTING_EDIT_GENERIC(STRFUNC(*(data))); \
} \
FORCE_INLINE void lcd_implementation_drawmenu_setting_edit_callback_ ## NAME (const bool sel, const uint8_t row, PGM_P pstr, PGM_P pstr2, TYPE * const data, ...) { \
UNUSED(pstr2); \
DRAWMENU_SETTING_EDIT_GENERIC(STRFUNC(*(data))); \
} \
FORCE_INLINE void lcd_implementation_drawmenu_setting_edit_accessor_ ## NAME (const bool sel, const uint8_t row, PGM_P pstr, PGM_P pstr2, TYPE (*pget)(), void (*pset)(TYPE), ...) { \
UNUSED(pstr2); UNUSED(pset); \
DRAWMENU_SETTING_EDIT_GENERIC(STRFUNC(pget())); \
} \
typedef void NAME##_void
DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(int16_t, int3, itostr3);
DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(int16_t, int4, itostr4sign);
DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(uint8_t, int8, i8tostr3);
DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float3, ftostr3);
DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float52, ftostr52);
DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float43, ftostr43sign);
DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float5, ftostr5rj);
DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float51, ftostr51sign);
DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float52sign, ftostr52sign);
DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float62, ftostr62rj);
DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(uint32_t, long5, ftostr5rj);
#define lcd_implementation_drawmenu_setting_edit_bool(sel, row, pstr, pstr2, data) DRAW_BOOL_SETTING(sel, row, pstr, data)
#define lcd_implementation_drawmenu_setting_edit_callback_bool(sel, row, pstr, pstr2, data, callback) DRAW_BOOL_SETTING(sel, row, pstr, data)
#define lcd_implementation_drawmenu_setting_edit_accessor_bool(sel, row, pstr, pstr2, pget, pset) DRAW_BOOL_SETTING(sel, row, pstr, data)
////////////////////////////////////////////
/////////////// Menu Actions ///////////////
////////////////////////////////////////////
#define menu_action_back(dummy) _menu_action_back()
void _menu_action_back();
void menu_action_submenu(screenFunc_t data);
void menu_action_function(menuAction_t data);
void menu_action_gcode(const char* pgcode);
#if ENABLED(SDSUPPORT)
void menu_action_sdfile(CardReader &theCard);
void menu_action_sddirectory(CardReader &theCard);
#endif
////////////////////////////////////////////
/////////// Menu Editing Actions ///////////
////////////////////////////////////////////
#define DECLARE_MENU_EDIT_TYPE(TYPE, NAME) \
bool _menu_edit_ ## NAME(); \
void menu_edit_ ## NAME(); \
void menu_edit_callback_ ## NAME(); \
void _menu_action_setting_edit_ ## NAME(PGM_P const pstr, TYPE* const ptr, const TYPE minValue, const TYPE maxValue); \
void menu_action_setting_edit_callback_ ## NAME(PGM_P const pstr, TYPE * const ptr, const TYPE minValue, const TYPE maxValue, const screenFunc_t callback=NULL, const bool live=false); \
FORCE_INLINE void menu_action_setting_edit_ ## NAME(PGM_P const pstr, TYPE * const ptr, const TYPE minValue, const TYPE maxValue) { \
menu_action_setting_edit_callback_ ## NAME(pstr, ptr, minValue, maxValue); \
} \
typedef void NAME##_void
DECLARE_MENU_EDIT_TYPE(int16_t, int3);
DECLARE_MENU_EDIT_TYPE(int16_t, int4);
DECLARE_MENU_EDIT_TYPE(uint8_t, int8);
DECLARE_MENU_EDIT_TYPE(float, float3);
DECLARE_MENU_EDIT_TYPE(float, float52);
DECLARE_MENU_EDIT_TYPE(float, float43);
DECLARE_MENU_EDIT_TYPE(float, float5);
DECLARE_MENU_EDIT_TYPE(float, float51);
DECLARE_MENU_EDIT_TYPE(float, float52sign);
DECLARE_MENU_EDIT_TYPE(float, float62);
DECLARE_MENU_EDIT_TYPE(uint32_t, long5);
void menu_action_setting_edit_bool(PGM_P pstr, bool* ptr);
void menu_action_setting_edit_callback_bool(PGM_P pstr, bool* ptr, screenFunc_t callbackFunc);
////////////////////////////////////////////
//////////// Menu System Macros ////////////
////////////////////////////////////////////
/**
* SCREEN_OR_MENU_LOOP generates init code for a screen or menu
*
* encoderTopLine is the top menu line to display
* _lcdLineNr is the index of the LCD line (e.g., 0-3)
* _menuLineNr is the menu item to draw and process
* _thisItemNr is the index of each MENU_ITEM or STATIC_ITEM
*/
#define SCREEN_OR_MENU_LOOP() \
int8_t _menuLineNr = encoderTopLine, _thisItemNr; \
for (int8_t _lcdLineNr = 0; _lcdLineNr < menu_bottom; _lcdLineNr++, _menuLineNr++) { \
_thisItemNr = 0
/**
* START_SCREEN Opening code for a screen having only static items.
* Do simplified scrolling of the entire screen.
*
* START_MENU Opening code for a screen with menu items.
* Scroll as-needed to keep the selected line in view.
*/
#define START_SCREEN() \
scroll_screen(menu_bottom, false); \
bool _skipStatic = false; \
SCREEN_OR_MENU_LOOP()
#define START_MENU() \
scroll_screen(1, true); \
bool _skipStatic = true; \
SCREEN_OR_MENU_LOOP()
#define END_SCREEN() \
} \
screen_items = _thisItemNr
#define END_MENU() \
} \
screen_items = _thisItemNr; \
UNUSED(_skipStatic)
/**
* REVERSE_MENU_DIRECTION
*
* To reverse the menu direction we need a general way to reverse
* the direction of the encoder everywhere. So encoderDirection is
* added to allow the encoder to go the other way.
*
* This behavior is limited to scrolling Menus and SD card listings,
* and is disabled in other contexts.
*/
#if ENABLED(REVERSE_MENU_DIRECTION)
extern int8_t encoderDirection;
#define ENCODER_DIRECTION_NORMAL() (encoderDirection = 1)
#define ENCODER_DIRECTION_MENUS() (encoderDirection = -1)
#else
#define ENCODER_DIRECTION_NORMAL() NOOP
#define ENCODER_DIRECTION_MENUS() NOOP
#endif
#if ENABLED(ENCODER_RATE_MULTIPLIER)
extern bool encoderRateMultiplierEnabled;
#define ENCODER_RATE_MULTIPLY(F) (encoderRateMultiplierEnabled = F)
//#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value
/**
* MENU_MULTIPLIER_ITEM generates drawing and handling code for a multiplier menu item
*/
#define MENU_MULTIPLIER_ITEM(TYPE, LABEL, ...) do { \
_MENU_ITEM_PART_1(TYPE, ## __VA_ARGS__); \
encoderRateMultiplierEnabled = true; \
lastEncoderMovementMillis = 0; \
_MENU_ITEM_PART_2(TYPE, PSTR(LABEL), ## __VA_ARGS__); \
}while(0)
#else // !ENCODER_RATE_MULTIPLIER
#define ENCODER_RATE_MULTIPLY(F) NOOP
#endif // !ENCODER_RATE_MULTIPLIER
/**
* MENU_ITEM generates draw & handler code for a menu item, potentially calling:
*
* lcd_implementation_drawmenu_[type](sel, row, label, arg3...)
* menu_action_[type](arg3...)
*
* Examples:
* MENU_ITEM(back, MSG_WATCH, 0 [dummy parameter] )
* or
* MENU_BACK(MSG_WATCH)
* lcd_implementation_drawmenu_back(sel, row, PSTR(MSG_WATCH))
* menu_action_back()
*
* MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_sdcard_pause)
* lcd_implementation_drawmenu_function(sel, row, PSTR(MSG_PAUSE_PRINT), lcd_sdcard_pause)
* menu_action_function(lcd_sdcard_pause)
*
* MENU_ITEM_EDIT(int3, MSG_SPEED, &feedrate_percentage, 10, 999)
* MENU_ITEM(setting_edit_int3, MSG_SPEED, PSTR(MSG_SPEED), &feedrate_percentage, 10, 999)
* lcd_implementation_drawmenu_setting_edit_int3(sel, row, PSTR(MSG_SPEED), PSTR(MSG_SPEED), &feedrate_percentage, 10, 999)
* menu_action_setting_edit_int3(PSTR(MSG_SPEED), &feedrate_percentage, 10, 999)
*
*/
#define _MENU_ITEM_PART_1(TYPE, ...) \
if (_menuLineNr == _thisItemNr) { \
if (encoderLine == _thisItemNr && lcd_clicked) { \
lcd_clicked = false
#define _MENU_ITEM_PART_2(TYPE, PLABEL, ...) \
menu_action_ ## TYPE(__VA_ARGS__); \
if (screen_changed) return; \
} \
if (lcdDrawUpdate) \
lcd_implementation_drawmenu_ ## TYPE(encoderLine == _thisItemNr, _lcdLineNr, PLABEL, ## __VA_ARGS__); \
} \
++_thisItemNr
#define MENU_ITEM_P(TYPE, PLABEL, ...) do { \
_skipStatic = false; \
_MENU_ITEM_PART_1(TYPE, ## __VA_ARGS__); \
_MENU_ITEM_PART_2(TYPE, PLABEL, ## __VA_ARGS__); \
}while(0)
#define MENU_ITEM(TYPE, LABEL, ...) MENU_ITEM_P(TYPE, PSTR(LABEL), ## __VA_ARGS__)
#define MENU_ITEM_ADDON_START(X) \
if (lcdDrawUpdate && _menuLineNr == _thisItemNr - 1) { \
SETCURSOR(X, _lcdLineNr)
#define MENU_ITEM_ADDON_END() } (0)
#define MENU_BACK(LABEL) MENU_ITEM(back, LABEL, 0)
// Used to print static text with no visible cursor.
// Parameters: label [, bool center [, bool invert [, char *value] ] ]
#define STATIC_ITEM_P(LABEL, ...) do{ \
if (_menuLineNr == _thisItemNr) { \
if (_skipStatic && encoderLine <= _thisItemNr) { \
encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; \
++encoderLine; \
} \
if (lcdDrawUpdate) \
lcd_implementation_drawmenu_static(_lcdLineNr, LABEL, ## __VA_ARGS__); \
} \
++_thisItemNr; } while(0)
#define STATIC_ITEM(LABEL, ...) STATIC_ITEM_P(PSTR(LABEL), ## __VA_ARGS__)
#define MENU_ITEM_DUMMY() do { _thisItemNr++; }while(0)
#define MENU_ITEM_EDIT(TYPE, LABEL, ...) MENU_ITEM(_CAT(setting_edit_,TYPE), LABEL, PSTR(LABEL), ## __VA_ARGS__)
#define MENU_ITEM_EDIT_CALLBACK(TYPE, LABEL, ...) MENU_ITEM(_CAT(setting_edit_callback_,TYPE), LABEL, PSTR(LABEL), ## __VA_ARGS__)
#if ENABLED(ENCODER_RATE_MULTIPLIER)
#define MENU_MULTIPLIER_ITEM_EDIT(TYPE, LABEL, ...) MENU_MULTIPLIER_ITEM(_CAT(setting_edit_,TYPE), LABEL, PSTR(LABEL), ## __VA_ARGS__)
#define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(TYPE, LABEL, ...) MENU_MULTIPLIER_ITEM(_CAT(setting_edit_callback_,TYPE), LABEL, PSTR(LABEL), ## __VA_ARGS__)
#else // !ENCODER_RATE_MULTIPLIER
#define MENU_MULTIPLIER_ITEM_EDIT(TYPE, LABEL, ...) MENU_ITEM(_CAT(setting_edit_,TYPE), LABEL, PSTR(LABEL), ## __VA_ARGS__)
#define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(TYPE, LABEL, ...) MENU_ITEM(_CAT(setting_edit_callback_,TYPE), LABEL, PSTR(LABEL), ## __VA_ARGS__)
#endif // !ENCODER_RATE_MULTIPLIER
////////////////////////////////////////////
/////////////// Menu Screens ///////////////
////////////////////////////////////////////
void menu_main();
void menu_move();
#if ENABLED(SDSUPPORT)
void menu_sdcard();
#endif
// First Fan Speed title in "Tune" and "Control>Temperature" menus
#if FAN_COUNT > 0 && HAS_FAN0
#if FAN_COUNT > 1
#define FAN_SPEED_1_SUFFIX " 1"
#else
#define FAN_SPEED_1_SUFFIX ""
#endif
#endif
////////////////////////////////////////////
//////// Menu Item Helper Functions ////////
////////////////////////////////////////////
void lcd_move_z();
void lcd_synchronize(PGM_P const msg=NULL);
void line_to_z(const float &z);
void _lcd_draw_homing();
void watch_temp_callback_E0();
void watch_temp_callback_E1();
void watch_temp_callback_E2();
void watch_temp_callback_E3();
void watch_temp_callback_E4();
void watch_temp_callback_E5();
void watch_temp_callback_bed();
#if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(PID_AUTOTUNE_MENU) || ENABLED(ADVANCED_PAUSE_FEATURE)
void lcd_enqueue_command(const char * const cmd);
void lcd_enqueue_commands_P(PGM_P const cmd);
#endif
#if ENABLED(LEVEL_BED_CORNERS)
void _lcd_level_bed_corners();
#endif
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
extern float lcd_z_fade_height;
void _lcd_set_z_fade_height();
#endif
#if ENABLED(LCD_BED_LEVELING) || (HAS_LEVELING && DISABLED(SLIM_LCD_MENUS))
void _lcd_toggle_bed_leveling();
#endif
#if ENABLED(BABYSTEPPING)
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
void lcd_babystep_zoffset();
#else
void lcd_babystep_z();
#endif
#endif
#if ENABLED(EEPROM_SETTINGS)
void lcd_store_settings();
void lcd_load_settings();
#endif

File diff suppressed because it is too large Load Diff

View File

@ -19,12 +19,21 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ULTRALCD_H
#define ULTRALCD_H
#pragma once
#include "../inc/MarlinConfig.h"
#if ENABLED(DOGLCD)
extern bool first_page;
#else
constexpr bool first_page = true;
enum HD44780CharSet : uint8_t {
CHARSET_MENU,
CHARSET_INFO,
CHARSET_BOOT
};
#endif
#if ENABLED(ULTRA_LCD) || ENABLED(MALYAN_LCD) || ENABLED(EXTENSIBLE_UI)
void lcd_init();
bool lcd_detected();
@ -71,6 +80,8 @@
#if HAS_BUZZER
void lcd_buzz(const long duration, const uint16_t freq);
#else
inline void lcd_buzz(const long duration, const uint16_t freq) { UNUSED(duration); UNUSED(freq); }
#endif
void lcd_quick_feedback(const bool clear_buttons); // Audible feedback for a button click - could also be visual
@ -108,13 +119,14 @@
#define BUTTON_EXISTS(BN) (defined(BTN_## BN) && BTN_## BN >= 0)
#define BUTTON_PRESSED(BN) !READ(BTN_## BN)
#if ENABLED(ULTIPANEL) // LCD with a click-wheel input
#if HAS_LCD_MENU
extern bool defer_return_to_status;
// Function pointer to menu functions.
typedef void (*screenFunc_t)();
typedef void (*menuAction_t)();
extern screenFunc_t currentScreen;
void lcd_goto_screen(screenFunc_t screen, const uint32_t encoder=0);
extern bool lcd_clicked, defer_return_to_status;
extern int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2];
extern uint8_t lcd_preheat_fan_speed[2];
@ -131,9 +143,13 @@
constexpr bool lcd_wait_for_move = false;
#endif
void lcd_goto_screen(screenFunc_t screen, const uint32_t encoder=0);
void lcd_completion_feedback(const bool good=true);
// Manual Movement
constexpr float manual_feedrate_mm_m[XYZE] = MANUAL_FEEDRATE;
#if IS_KINEMATIC
extern bool processing_manual_move;
#else
constexpr bool processing_manual_move = false;
#endif
#if ENABLED(ADVANCED_PAUSE_FEATURE)
void lcd_advanced_pause_show_message(const AdvancedPauseMessage message,
@ -273,6 +289,10 @@
#endif
#if ENABLED(LCD_HAS_SLOW_BUTTONS)
extern volatile uint8_t slow_buttons;
#endif
#if ENABLED(REPRAPWORLD_KEYPAD)
#ifdef EN_C
#define LCD_CLICKED ((buttons & EN_C) || REPRAPWORLD_KEYPAD_MOVE_MENU)
@ -297,5 +317,6 @@
void lcd_reselect_last_file();
#endif
#endif // ULTRALCD_H
// LCD implementations
void lcd_implementation_clear();
void lcd_implementation_init();

View File

@ -19,9 +19,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#ifndef __DURATION_T__
#define __DURATION_T__
#include <Arduino.h>
struct duration_t {
/**
@ -163,5 +163,3 @@ struct duration_t {
}
}
};
#endif // __DURATION_T__

View File

@ -108,7 +108,7 @@ XYZ_DEFS(signed char, home_dir, HOME_DIR);
extern bool soft_endstops_enabled;
void clamp_to_software_endstops(float target[XYZ]);
#else
#define soft_endstops_enabled false
constexpr bool soft_endstops_enabled = false;
#define clamp_to_software_endstops(x) NOOP
#endif

View File

@ -30,7 +30,7 @@ opt_set TEMP_SENSOR_BED 1
opt_set POWER_SUPPLY 1
opt_set GRID_MAX_POINTS_X 16
opt_enable PIDTEMPBED FIX_MOUNTED_PROBE Z_SAFE_HOMING \
REPRAP_DISCOUNT_SMART_CONTROLLER SDSUPPORT EEPROM_SETTINGS PINS_DEBUGGING \
REPRAP_DISCOUNT_SMART_CONTROLLER SDSUPPORT LCD_PROGRESS_BAR LCD_PROGRESS_BAR_TEST EEPROM_SETTINGS PINS_DEBUGGING \
BLINKM PCA9632 RGB_LED NEOPIXEL_LED AUTO_POWER_CONTROL \
NOZZLE_PARK_FEATURE FILAMENT_RUNOUT_SENSOR FILAMENT_RUNOUT_DISTANCE_MM \
AUTO_BED_LEVELING_LINEAR Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \