Move BLTouch options to adv config (#14131)

Plus other BLTouch and menu enhancements.
This commit is contained in:
InsanityAutomation
2019-06-10 18:46:42 -04:00
committed by Scott Lahteine
parent 0ca2073625
commit b7eeb5b13b
180 changed files with 5277 additions and 6291 deletions

View File

@ -933,6 +933,9 @@
#ifndef MSG_BLTOUCH_MODE_ECHO
#define MSG_BLTOUCH_MODE_ECHO _UxGT("Report Drain")
#endif
#ifndef MSG_BLTOUCH_MODE_CHANGE
#define MSG_BLTOUCH_MODE_CHANGE _UxGT("DANGER: Bad settings can cause damage! Proceed anyway?")
#endif
#ifndef MSG_MANUAL_DEPLOY
#define MSG_MANUAL_DEPLOY _UxGT("Deploy Z-Probe")
#endif

View File

@ -199,11 +199,19 @@ static void lcd_factory_settings() {
MENU_ITEM(function, MSG_BLTOUCH_STOW, bltouch._stow);
MENU_ITEM(function, MSG_BLTOUCH_SW_MODE, bltouch._set_SW_mode);
#if ENABLED(BLTOUCH_LCD_VOLTAGE_MENU)
MENU_ITEM(function, MSG_BLTOUCH_5V_MODE, bltouch._set_5V_mode);
MENU_ITEM(function, MSG_BLTOUCH_OD_MODE, bltouch._set_OD_mode);
MENU_ITEM(submenu, MSG_BLTOUCH_5V_MODE, []{
do_select_screen(PSTR(MSG_BLTOUCH_5V_MODE), PSTR(MSG_BUTTON_CANCEL), bltouch._set_5V_mode, ui.goto_previous_screen, PSTR(MSG_BLTOUCH_MODE_CHANGE));
});
MENU_ITEM(submenu, MSG_BLTOUCH_OD_MODE, []{
do_select_screen(PSTR(MSG_BLTOUCH_OD_MODE), PSTR(MSG_BUTTON_CANCEL), bltouch._set_OD_mode, ui.goto_previous_screen, PSTR(MSG_BLTOUCH_MODE_CHANGE));
});
MENU_ITEM(function, MSG_BLTOUCH_MODE_STORE, bltouch._mode_store);
MENU_ITEM(function, MSG_BLTOUCH_MODE_STORE_5V, bltouch.mode_conv_5V);
MENU_ITEM(function, MSG_BLTOUCH_MODE_STORE_OD, bltouch.mode_conv_OD);
MENU_ITEM(submenu, MSG_BLTOUCH_MODE_STORE_5V, []{
do_select_screen(PSTR(MSG_BLTOUCH_MODE_STORE_5V), PSTR(MSG_BUTTON_CANCEL), bltouch.mode_conv_5V, ui.goto_previous_screen, PSTR(MSG_BLTOUCH_MODE_CHANGE));
});
MENU_ITEM(submenu, MSG_BLTOUCH_MODE_STORE_OD, []{
do_select_screen(PSTR(MSG_BLTOUCH_MODE_STORE_OD), PSTR(MSG_BUTTON_CANCEL), bltouch.mode_conv_OD, ui.goto_previous_screen, PSTR(MSG_BLTOUCH_MODE_CHANGE));
});
MENU_ITEM(function, MSG_BLTOUCH_MODE_ECHO, bltouch_report);
#endif
END_MENU();

View File

@ -196,10 +196,39 @@ millis_t next_button_update_ms;
#endif
void _wrap_string(uint8_t &x, uint8_t &y, const char * const string, read_byte_cb_t cb_read_byte) {
void _wrap_string(uint8_t &x, uint8_t &y, const char * const string, read_byte_cb_t cb_read_byte, bool wordwrap/*=false*/) {
SETCURSOR(x, y);
if (string) {
uint8_t *p = (uint8_t*)string;
if (!string) return;
uint8_t *p = (uint8_t*)string;
if (wordwrap) {
uint8_t *wrd = p, c = 0;
for (;;) {
wchar_t ch;
p = get_utf8_value_cb(p, cb_read_byte, &ch);
const bool eol = !ch;
if (eol || ch == ' ' || ch == '-' || ch == '+' || ch == '.') {
if (!c && ch == ' ') continue; // collapse extra spaces
if (x + c > LCD_WIDTH && c < (LCD_WIDTH) * 3 / 4) { // should it wrap?
x = 0; y++; // move x to string len (plus space)
SETCURSOR(0, y); // simulate carriage return
}
c += !eol; // +1 so the space will be printed
x += c; // advance x to new position
while (c--) { // character countdown
wrd = get_utf8_value_cb(wrd, cb_read_byte, &ch); // get characters again
lcd_put_wchar(ch); // word (plus space) to the LCD
}
if (eol) break; // all done
wrd = nullptr; // set up for next word
}
else {
if (!wrd) wrd = p; // starting a new word?
c++; // count word characters
}
}
}
else {
for (;;) {
wchar_t ch;
p = get_utf8_value_cb(p, cb_read_byte, &ch);
@ -221,7 +250,7 @@ millis_t next_button_update_ms;
x = (LCD_WIDTH - plen - slen) / 2;
y = LCD_HEIGHT > 3 ? 1 : 0;
}
wrap_string_P(x, y, pref);
wrap_string_P(x, y, pref, true);
if (string) {
if (x) { x = 0; y++; } // Move to the start of the next line
wrap_string(x, y, string);

View File

@ -74,9 +74,9 @@
#include "fontutils.h"
void _wrap_string(uint8_t &x, uint8_t &y, const char * const string, read_byte_cb_t cb_read_byte);
inline void wrap_string_P(uint8_t &x, uint8_t &y, PGM_P const pstr) { _wrap_string(x, y, pstr, read_byte_rom); }
inline void wrap_string(uint8_t &x, uint8_t &y, const char * const string) { _wrap_string(x, y, string, read_byte_ram); }
void _wrap_string(uint8_t &x, uint8_t &y, const char * const string, read_byte_cb_t cb_read_byte, const bool wordwrap=false);
inline void wrap_string_P(uint8_t &x, uint8_t &y, PGM_P const pstr, const bool wordwrap=false) { _wrap_string(x, y, pstr, read_byte_rom, wordwrap); }
inline void wrap_string(uint8_t &x, uint8_t &y, const char * const string, const bool wordwrap=false) { _wrap_string(x, y, string, read_byte_ram, wordwrap); }
#if ENABLED(SDSUPPORT)
#include "../sd/cardreader.h"