🧑💻 Extend LCD string substitution (#24278)
This commit is contained in:
@ -4280,14 +4280,14 @@ void CrealityDWINClass::Print_Screen_Control() {
|
||||
card.startOrResumeFilePrinting();
|
||||
TERN_(POWER_LOSS_RECOVERY, recovery.prepare());
|
||||
#else
|
||||
char cmnd[20];
|
||||
char cmd[20];
|
||||
#if HAS_HEATED_BED
|
||||
cmnd[sprintf_P(cmnd, PSTR("M140 S%i"), pausebed)] = '\0';
|
||||
gcode.process_subcommands_now(cmnd);
|
||||
sprintf_P(cmd, PSTR("M140 S%i"), pausebed);
|
||||
gcode.process_subcommands_now(cmd);
|
||||
#endif
|
||||
#if HAS_EXTRUDERS
|
||||
cmnd[sprintf_P(cmnd, PSTR("M109 S%i"), pausetemp)] = '\0';
|
||||
gcode.process_subcommands_now(cmnd);
|
||||
sprintf_P(cmd, PSTR("M109 S%i"), pausetemp);
|
||||
gcode.process_subcommands_now(cmd);
|
||||
#endif
|
||||
TERN_(HAS_FAN, thermalManager.fan_speed[0] = pausefan);
|
||||
planner.synchronize();
|
||||
|
@ -27,35 +27,35 @@
|
||||
#include "dwin_string.h"
|
||||
//#include "../../fontutils.h"
|
||||
|
||||
uint8_t DWIN_String::data[];
|
||||
char DWIN_String::data[];
|
||||
uint16_t DWIN_String::span;
|
||||
uint8_t DWIN_String::len;
|
||||
uint8_t DWIN_String::length;
|
||||
|
||||
void DWIN_String::set() {
|
||||
//*data = 0x00;
|
||||
memset(data, 0x00, sizeof(data));
|
||||
span = 0;
|
||||
len = 0;
|
||||
length = 0;
|
||||
}
|
||||
|
||||
uint8_t read_byte(uint8_t *byte) { return *byte; }
|
||||
uint8_t read_byte(const uint8_t *byte) { return *byte; }
|
||||
|
||||
/**
|
||||
* Add a string, applying substitutions for the following characters:
|
||||
*
|
||||
* $ displays the clipped C-string given by the inStr argument
|
||||
* $ displays the clipped string given by fstr or cstr
|
||||
* = displays '0'....'10' for indexes 0 - 10
|
||||
* ~ displays '1'....'11' for indexes 0 - 10
|
||||
* * displays 'E1'...'E11' for indexes 0 - 10 (By default. Uses LCD_FIRST_TOOL)
|
||||
* @ displays an axis name such as XYZUVW, or E for an extruder
|
||||
*/
|
||||
void DWIN_String::add(uint8_t *string, const int8_t index, uint8_t *inStr/*=nullptr*/) {
|
||||
void DWIN_String::add(const char *tpl, const int8_t index, const char *cstr/*=nullptr*/, FSTR_P const fstr/*=nullptr*/) {
|
||||
wchar_t wchar;
|
||||
|
||||
while (*string) {
|
||||
string = get_utf8_value_cb(string, read_byte, &wchar);
|
||||
while (*tpl) {
|
||||
tpl = get_utf8_value_cb(tpl, read_byte, &wchar);
|
||||
if (wchar > 255) wchar |= 0x0080;
|
||||
uint8_t ch = uint8_t(wchar & 0x00FF);
|
||||
const uint8_t ch = uint8_t(wchar & 0x00FF);
|
||||
|
||||
if (ch == '=' || ch == '~' || ch == '*') {
|
||||
if (index >= 0) {
|
||||
@ -65,10 +65,12 @@ void DWIN_String::add(uint8_t *string, const int8_t index, uint8_t *inStr/*=null
|
||||
add_character('0' + inum);
|
||||
}
|
||||
else
|
||||
add(index == -2 ? GET_TEXT(MSG_CHAMBER) : GET_TEXT(MSG_BED));
|
||||
add(index == -2 ? GET_TEXT_F(MSG_CHAMBER) : GET_TEXT_F(MSG_BED));
|
||||
}
|
||||
else if (ch == '$' && inStr)
|
||||
add(inStr);
|
||||
else if (ch == '$' && fstr)
|
||||
add(fstr);
|
||||
else if (ch == '$' && cstr)
|
||||
add(cstr);
|
||||
else if (ch == '@')
|
||||
add_character(axis_codes[index]);
|
||||
else
|
||||
@ -77,10 +79,10 @@ void DWIN_String::add(uint8_t *string, const int8_t index, uint8_t *inStr/*=null
|
||||
eol();
|
||||
}
|
||||
|
||||
void DWIN_String::add(uint8_t *string, uint8_t max_len) {
|
||||
void DWIN_String::add(const char *cstr, uint8_t max_len/*=MAX_STRING_LENGTH*/) {
|
||||
wchar_t wchar;
|
||||
while (*string && max_len) {
|
||||
string = get_utf8_value_cb(string, read_byte, &wchar);
|
||||
while (*cstr && max_len) {
|
||||
cstr = get_utf8_value_cb(cstr, read_byte, &wchar);
|
||||
/*
|
||||
if (wchar > 255) wchar |= 0x0080;
|
||||
uint8_t ch = uint8_t(wchar & 0x00FF);
|
||||
@ -92,7 +94,7 @@ void DWIN_String::add(uint8_t *string, uint8_t max_len) {
|
||||
eol();
|
||||
}
|
||||
|
||||
void DWIN_String::add(wchar_t character) {
|
||||
void DWIN_String::add(const wchar_t character) {
|
||||
int ret;
|
||||
size_t idx = 0;
|
||||
dwin_charmap_t pinval;
|
||||
@ -127,18 +129,18 @@ void DWIN_String::add(wchar_t character) {
|
||||
if (str[1]) add_character(str[1]);
|
||||
}
|
||||
|
||||
void DWIN_String::add_character(const uint8_t character) {
|
||||
if (len < MAX_STRING_LENGTH) {
|
||||
data[len] = character;
|
||||
len++;
|
||||
void DWIN_String::add_character(const char character) {
|
||||
if (length < MAX_STRING_LENGTH) {
|
||||
data[length] = character;
|
||||
length++;
|
||||
//span += glyph(character)->DWidth;
|
||||
}
|
||||
}
|
||||
|
||||
void DWIN_String::rtrim(const uint8_t character) {
|
||||
while (len) {
|
||||
if (data[len - 1] == 0x20 || data[len - 1] == character) {
|
||||
len--;
|
||||
void DWIN_String::rtrim(const char character) {
|
||||
while (length) {
|
||||
if (data[length - 1] == 0x20 || data[length - 1] == character) {
|
||||
length--;
|
||||
//span -= glyph(data[length])->DWidth;
|
||||
eol();
|
||||
}
|
||||
@ -147,18 +149,18 @@ void DWIN_String::rtrim(const uint8_t character) {
|
||||
}
|
||||
}
|
||||
|
||||
void DWIN_String::ltrim(const uint8_t character) {
|
||||
void DWIN_String::ltrim(const char character) {
|
||||
uint16_t i, j;
|
||||
for (i = 0; (i < len) && (data[i] == 0x20 || data[i] == character); i++) {
|
||||
for (i = 0; (i < length) && (data[i] == 0x20 || data[i] == character); i++) {
|
||||
//span -= glyph(data[i])->DWidth;
|
||||
}
|
||||
if (i == 0) return;
|
||||
for (j = 0; i < len; data[j++] = data[i++]);
|
||||
len = j;
|
||||
for (j = 0; i < length; data[j++] = data[i++]);
|
||||
length = j;
|
||||
eol();
|
||||
}
|
||||
|
||||
void DWIN_String::trim(const uint8_t character) {
|
||||
void DWIN_String::trim(const char character) {
|
||||
rtrim(character);
|
||||
ltrim(character);
|
||||
}
|
||||
|
@ -21,6 +21,8 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
// TODO: Make AVR-compatible with separate ROM / RAM string methods
|
||||
|
||||
#include "../../fontutils.h"
|
||||
#include "../../marlinui.h"
|
||||
|
||||
@ -41,14 +43,14 @@ class DWIN_String {
|
||||
//static glyph_t *glyphs[256];
|
||||
//static font_t *font_header;
|
||||
|
||||
static uint8_t data[MAX_STRING_LENGTH + 1];
|
||||
static char data[MAX_STRING_LENGTH + 1];
|
||||
static uint16_t span; // in pixels
|
||||
static uint8_t len; // in characters
|
||||
|
||||
static void add_character(const uint8_t character);
|
||||
static void eol() { data[len] = 0x00; }
|
||||
static void add_character(const char character);
|
||||
static void eol() { data[length] = 0x00; }
|
||||
|
||||
public:
|
||||
static uint8_t length; // in characters
|
||||
//static void set_font(const uint8_t *font);
|
||||
//static void add_glyphs(const uint8_t *font);
|
||||
|
||||
@ -57,34 +59,71 @@ class DWIN_String {
|
||||
//static glyph_t *glyph(uint8_t character) { return glyphs[character] ?: glyphs[0x3F]; } /* Use '?' for unknown glyphs */
|
||||
//static glyph_t *glyph(uint8_t *character) { return glyph(*character); }
|
||||
|
||||
/**
|
||||
* @brief Set the string empty
|
||||
*/
|
||||
static void set();
|
||||
//static void add(uint8_t character) { add_character(character); eol(); }
|
||||
|
||||
//static void add(const char character) { add_character(character); eol(); }
|
||||
|
||||
/**
|
||||
* @brief Append a UTF-8 character
|
||||
*
|
||||
* @param character The UTF-8 character
|
||||
*/
|
||||
static void add(wchar_t character);
|
||||
static void add(uint8_t *string, uint8_t max_len=MAX_STRING_LENGTH);
|
||||
static void add(uint8_t *string, const int8_t index, uint8_t *inStr=nullptr);
|
||||
static void set(uint8_t *string) { set(); add(string); }
|
||||
static void set(wchar_t character) { set(); add(character); }
|
||||
static void set(uint8_t *string, int8_t index, const char *inStr=nullptr) { set(); add(string, index, (uint8_t *)inStr); }
|
||||
static void set(const char *string) { set((uint8_t *)string); }
|
||||
static void set(const char *string, int8_t index, const char *inStr=nullptr) { set((uint8_t *)string, index, inStr); }
|
||||
static void add(const char *string) { add((uint8_t *)string); }
|
||||
|
||||
static void add(FSTR_P const string, uint8_t max_len=MAX_STRING_LENGTH) { add((uint8_t *)FTOP(string), max_len); }
|
||||
static void add(FSTR_P const string, int8_t index, uint8_t *inStr=nullptr) { add((uint8_t *)FTOP(string), index, inStr); }
|
||||
static void set(FSTR_P const string) { set((uint8_t *)FTOP(string)); }
|
||||
static void set(FSTR_P const string, int8_t index, const char *inStr=nullptr) { set((uint8_t *)FTOP(string), index, inStr); }
|
||||
static void add(FSTR_P const string) { add((uint8_t *)FTOP(string)); }
|
||||
/**
|
||||
* @brief Append / Set C-string
|
||||
*
|
||||
* @param cstr The string
|
||||
* @param max_len Character limit
|
||||
*/
|
||||
static void add(const char *cstr, uint8_t max_len=MAX_STRING_LENGTH);
|
||||
static void set(const char *cstr) { set(); add(cstr); }
|
||||
|
||||
static void trim(const uint8_t character=0x20);
|
||||
static void rtrim(const uint8_t character=0x20);
|
||||
static void ltrim(const uint8_t character=0x20);
|
||||
/**
|
||||
* @brief Append / Set F-string
|
||||
*
|
||||
* @param fstr The string
|
||||
* @param max_len Character limit
|
||||
*/
|
||||
static void add(FSTR_P const fstr, uint8_t max_len=MAX_STRING_LENGTH) { add(FTOP(fstr), max_len); }
|
||||
static void set(FSTR_P const fstr) { set(FTOP(fstr)); }
|
||||
|
||||
static void truncate(uint8_t maxlen) { if (len > maxlen) { len = maxlen; eol(); } }
|
||||
/**
|
||||
* @brief Append / Set C-string with optional substitution
|
||||
*
|
||||
* @param tpl A string with optional substitution
|
||||
* @param index An index
|
||||
* @param cstr An SRAM C-string to use for $ substitution
|
||||
* @param fstr A ROM F-string to use for $ substitution
|
||||
*/
|
||||
static void add(const char *tpl, const int8_t index, const char *cstr=nullptr, FSTR_P const fstr=nullptr);
|
||||
static void set(const char *tpl, const int8_t index, const char *cstr=nullptr, FSTR_P const fstr=nullptr) { set(); add(tpl, index, cstr, fstr); }
|
||||
|
||||
static uint8_t length() { return len; }
|
||||
/**
|
||||
* @brief Append / Set F-string with optional substitution
|
||||
*
|
||||
* @param ftpl A ROM F-string with optional substitution
|
||||
* @param index An index
|
||||
* @param cstr An SRAM C-string to use for $ substitution
|
||||
* @param fstr A ROM F-string to use for $ substitution
|
||||
*/
|
||||
static void add(FSTR_P const ftpl, const int8_t index, const char *cstr=nullptr, FSTR_P const fstr=nullptr) { add(FTOP(ftpl), index, cstr, fstr); }
|
||||
static void set(FSTR_P const ftpl, const int8_t index, const char *cstr=nullptr, FSTR_P const fstr=nullptr) { set(); add(ftpl, index, cstr, fstr); }
|
||||
|
||||
// Common string ops
|
||||
static void trim(const char character=' ');
|
||||
static void rtrim(const char character=' ');
|
||||
static void ltrim(const char character=' ');
|
||||
static void truncate(const uint8_t maxlen) { if (length > maxlen) { length = maxlen; eol(); } }
|
||||
|
||||
// Accessors
|
||||
static char *string() { return data; }
|
||||
static uint16_t width() { return span; }
|
||||
static uint8_t *string() { return data; }
|
||||
static uint16_t center(uint16_t width) { return span > width ? 0 : (width - span) / 2; }
|
||||
static uint16_t center(const uint16_t width) { return span > width ? 0 : (width - span) / 2; }
|
||||
};
|
||||
|
||||
int dwin_charmap_compare(dwin_charmap_t *v1, dwin_charmap_t *v2);
|
||||
|
@ -56,20 +56,20 @@ void lcd_put_int(const int i) {
|
||||
}
|
||||
|
||||
int lcd_put_dwin_string() {
|
||||
DWIN_Draw_String(dwin_font.solid, dwin_font.index, dwin_font.fg, dwin_font.bg, cursor.x, cursor.y, (char*)dwin_string.string());
|
||||
lcd_advance_cursor(dwin_string.length());
|
||||
return dwin_string.length();
|
||||
DWIN_Draw_String(dwin_font.solid, dwin_font.index, dwin_font.fg, dwin_font.bg, cursor.x, cursor.y, dwin_string.string());
|
||||
lcd_advance_cursor(dwin_string.length);
|
||||
return dwin_string.length;
|
||||
}
|
||||
|
||||
// return < 0 on error
|
||||
// return the advanced cols
|
||||
int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length) {
|
||||
int lcd_put_wchar_max(const wchar_t c, const pixel_len_t max_length) {
|
||||
dwin_string.set(c);
|
||||
dwin_string.truncate(max_length);
|
||||
// Draw the char(s) at the cursor and advance the cursor
|
||||
DWIN_Draw_String(dwin_font.solid, dwin_font.index, dwin_font.fg, dwin_font.bg, cursor.x, cursor.y, (char*)dwin_string.string());
|
||||
lcd_advance_cursor(dwin_string.length());
|
||||
return dwin_string.length();
|
||||
DWIN_Draw_String(dwin_font.solid, dwin_font.index, dwin_font.fg, dwin_font.bg, cursor.x, cursor.y, dwin_string.string());
|
||||
lcd_advance_cursor(dwin_string.length);
|
||||
return dwin_string.length;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -83,35 +83,34 @@ int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length) {
|
||||
*
|
||||
* Draw a UTF-8 string
|
||||
*/
|
||||
static int lcd_put_u8str_max_cb(const char * utf8_str, uint8_t (*cb_read_byte)(uint8_t * str), pixel_len_t max_length) {
|
||||
uint8_t *p = (uint8_t *)utf8_str;
|
||||
static int lcd_put_u8str_max_cb(const char * utf8_str, read_byte_cb_t cb_read_byte, const pixel_len_t max_length) {
|
||||
const uint8_t *p = (uint8_t *)utf8_str;
|
||||
dwin_string.set();
|
||||
while (dwin_string.length() < max_length) {
|
||||
while (dwin_string.length < max_length) {
|
||||
wchar_t ch = 0;
|
||||
p = get_utf8_value_cb(p, cb_read_byte, &ch);
|
||||
if (!ch) break;
|
||||
dwin_string.add(ch);
|
||||
}
|
||||
DWIN_Draw_String(dwin_font.solid, dwin_font.index, dwin_font.fg, dwin_font.bg, cursor.x, cursor.y, (char*)dwin_string.string());
|
||||
lcd_advance_cursor(dwin_string.length());
|
||||
return dwin_string.length();
|
||||
DWIN_Draw_String(dwin_font.solid, dwin_font.index, dwin_font.fg, dwin_font.bg, cursor.x, cursor.y, dwin_string.string());
|
||||
lcd_advance_cursor(dwin_string.length);
|
||||
return dwin_string.length;
|
||||
}
|
||||
|
||||
int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length) {
|
||||
int lcd_put_u8str_max(const char * utf8_str, const pixel_len_t max_length) {
|
||||
return lcd_put_u8str_max_cb(utf8_str, read_byte_ram, max_length);
|
||||
}
|
||||
|
||||
int lcd_put_u8str_max_P(PGM_P utf8_pstr, pixel_len_t max_length) {
|
||||
int lcd_put_u8str_max_P(PGM_P utf8_pstr, const pixel_len_t max_length) {
|
||||
return lcd_put_u8str_max_cb(utf8_pstr, read_byte_rom, max_length);
|
||||
}
|
||||
|
||||
lcd_uint_t lcd_put_u8str_ind_P(PGM_P const pstr, const int8_t ind, PGM_P const inStr/*=nullptr*/, const lcd_uint_t maxlen/*=LCD_WIDTH*/) {
|
||||
dwin_string.set();
|
||||
dwin_string.add((uint8_t*)pstr, ind, (uint8_t*)inStr);
|
||||
lcd_uint_t lcd_put_u8str_P(PGM_P const ptpl, const int8_t ind, const char * const cstr/*=nullptr*/, FSTR_P const fstr/*=nullptr*/, const lcd_uint_t maxlen/*=LCD_WIDTH*/) {
|
||||
dwin_string.set(ptpl, ind, cstr, fstr);
|
||||
dwin_string.truncate(maxlen);
|
||||
DWIN_Draw_String(dwin_font.solid, dwin_font.index, dwin_font.fg, dwin_font.bg, cursor.x, cursor.y, (char*)dwin_string.string());
|
||||
lcd_advance_cursor(dwin_string.length());
|
||||
return dwin_string.length();
|
||||
DWIN_Draw_String(dwin_font.solid, dwin_font.index, dwin_font.fg, dwin_font.bg, cursor.x, cursor.y, dwin_string.string());
|
||||
lcd_advance_cursor(dwin_string.length);
|
||||
return dwin_string.length;
|
||||
}
|
||||
|
||||
#if ENABLED(DEBUG_LCDPRINT)
|
||||
|
@ -110,7 +110,7 @@ void MarlinUI::clear_lcd() {
|
||||
#define VERSION_Y 84
|
||||
#endif
|
||||
|
||||
DWIN_Draw_String(false, font10x20, Color_Yellow, Color_Bg_Black, INFO_CENTER - (dwin_string.length() * 10) / 2, VERSION_Y, S(dwin_string.string()));
|
||||
DWIN_Draw_String(false, font10x20, Color_Yellow, Color_Bg_Black, INFO_CENTER - (dwin_string.length * 10) / 2, VERSION_Y, S(dwin_string.string()));
|
||||
TERN_(SHOW_CUSTOM_BOOTSCREEN, safe_delay(CUSTOM_BOOTSCREEN_TIMEOUT));
|
||||
clear_lcd();
|
||||
|
||||
@ -127,7 +127,7 @@ void MarlinUI::clear_lcd() {
|
||||
DWIN_ICON_Show(BOOT_ICON, ICON_MarlinURL, INFO_CENTER - 100 / 2, 152);
|
||||
DWIN_ICON_Show(BOOT_ICON, ICON_Copyright, INFO_CENTER - 126 / 2, 200);
|
||||
#endif
|
||||
DWIN_Draw_String(false, font10x20, Color_Yellow, Color_Bg_Black, INFO_CENTER - (dwin_string.length() * 10) / 2, VERSION_Y, S(dwin_string.string()));
|
||||
DWIN_Draw_String(false, font10x20, Color_Yellow, Color_Bg_Black, INFO_CENTER - (dwin_string.length * 10) / 2, VERSION_Y, S(dwin_string.string()));
|
||||
DWIN_UpdateLCD();
|
||||
}
|
||||
|
||||
@ -284,7 +284,7 @@ void MarlinUI::draw_status_message(const bool blink) {
|
||||
else
|
||||
dwin_string.add(PSTR(" "));
|
||||
|
||||
lcd_moveto(LCD_WIDTH - dwin_string.length(), row);
|
||||
lcd_moveto(LCD_WIDTH - dwin_string.length, row);
|
||||
lcd_put_dwin_string();
|
||||
}
|
||||
|
||||
@ -311,7 +311,7 @@ void MarlinUI::draw_status_message(const bool blink) {
|
||||
|
||||
// Draw a static line of text in the same idiom as a menu item
|
||||
|
||||
void MenuItem_static::draw(const uint8_t row, FSTR_P const fstr, const uint8_t style/*=SS_DEFAULT*/, const char * const vstr/*=nullptr*/) {
|
||||
void MenuItem_static::draw(const uint8_t row, FSTR_P const ftpl, const uint8_t style/*=SS_DEFAULT*/, const char * const vstr/*=nullptr*/) {
|
||||
// Call mark_as_selected to draw a bigger selection box
|
||||
// and draw the text without a background
|
||||
if (mark_as_selected(row, (bool)(style & SS_INVERT), true)) {
|
||||
@ -320,15 +320,15 @@ void MarlinUI::draw_status_message(const bool blink) {
|
||||
dwin_font.fg = Color_White;
|
||||
|
||||
dwin_string.set();
|
||||
const int8_t plen = fstr ? utf8_strlen(fstr) : 0,
|
||||
const int8_t plen = ftpl ? utf8_strlen(ftpl) : 0,
|
||||
vlen = vstr ? utf8_strlen(vstr) : 0;
|
||||
if (style & SS_CENTER) {
|
||||
int8_t pad = (LCD_WIDTH - 1 - plen - vlen) / 2;
|
||||
while (--pad) dwin_string.add(' ');
|
||||
}
|
||||
|
||||
if (plen) dwin_string.add((uint8_t*)FTOP(fstr), itemIndex, (uint8_t*)FTOP(itemString));
|
||||
if (vlen) dwin_string.add((uint8_t*)vstr);
|
||||
if (plen) dwin_string.add(ftpl, itemIndex, itemStringC, itemStringF);
|
||||
if (vlen) dwin_string.add(vstr);
|
||||
if (style & SS_CENTER) {
|
||||
int8_t pad = (LCD_WIDTH - 1 - plen - vlen) / 2;
|
||||
while (--pad) dwin_string.add(' ');
|
||||
@ -340,15 +340,15 @@ void MarlinUI::draw_status_message(const bool blink) {
|
||||
}
|
||||
|
||||
// Draw a generic menu item
|
||||
void MenuItemBase::_draw(const bool sel, const uint8_t row, FSTR_P const fstr, const char, const char post_char) {
|
||||
void MenuItemBase::_draw(const bool sel, const uint8_t row, FSTR_P const ftpl, const char, const char post_char) {
|
||||
if (mark_as_selected(row, sel)) {
|
||||
ui.set_font(DWIN_FONT_MENU);
|
||||
dwin_font.solid = false;
|
||||
dwin_font.fg = Color_White;
|
||||
|
||||
dwin_string.set(fstr, itemIndex, FTOP(itemString));
|
||||
dwin_string.set(ftpl, itemIndex, itemStringC, itemStringF);
|
||||
|
||||
pixel_len_t n = LCD_WIDTH - 1 - dwin_string.length();
|
||||
pixel_len_t n = LCD_WIDTH - 1 - dwin_string.length;
|
||||
while (--n > 1) dwin_string.add(' ');
|
||||
|
||||
dwin_string.add(post_char);
|
||||
@ -361,7 +361,7 @@ void MarlinUI::draw_status_message(const bool blink) {
|
||||
//
|
||||
// Draw a menu item with an editable value
|
||||
//
|
||||
void MenuEditItemBase::draw(const bool sel, const uint8_t row, FSTR_P const fstr, const char * const inStr, const bool pgm) {
|
||||
void MenuEditItemBase::draw(const bool sel, const uint8_t row, FSTR_P const ftpl, const char * const inStr, const bool pgm) {
|
||||
if (mark_as_selected(row, sel)) {
|
||||
ui.set_font(DWIN_FONT_MENU);
|
||||
dwin_font.solid = false;
|
||||
@ -369,7 +369,7 @@ void MarlinUI::draw_status_message(const bool blink) {
|
||||
|
||||
const uint8_t vallen = (pgm ? utf8_strlen_P(inStr) : utf8_strlen(S(inStr)));
|
||||
|
||||
dwin_string.set(fstr, itemIndex, FTOP(itemString));
|
||||
dwin_string.set(ftpl, itemIndex, itemStringC, itemStringF);
|
||||
if (vallen) dwin_string.add(':');
|
||||
|
||||
lcd_moveto(1, row);
|
||||
@ -392,8 +392,7 @@ void MarlinUI::draw_status_message(const bool blink) {
|
||||
|
||||
const dwin_coord_t labellen = utf8_strlen(fstr), vallen = utf8_strlen(value);
|
||||
|
||||
dwin_string.set();
|
||||
dwin_string.add((uint8_t*)FTOP(fstr), itemIndex);
|
||||
dwin_string.set(FTOP(fstr), itemIndex);
|
||||
if (vallen) dwin_string.add(':'); // If a value is included, add a colon
|
||||
|
||||
// Assume the label is alpha-numeric (with a descender)
|
||||
@ -406,8 +405,7 @@ void MarlinUI::draw_status_message(const bool blink) {
|
||||
|
||||
// If a value is included, print the value in larger text below the label
|
||||
if (vallen) {
|
||||
dwin_string.set();
|
||||
dwin_string.add(value);
|
||||
dwin_string.set(value);
|
||||
|
||||
const dwin_coord_t by = (row * MENU_LINE_HEIGHT) + MENU_FONT_HEIGHT + EXTRA_ROW_HEIGHT / 2;
|
||||
DWIN_Draw_String(true, font16x32, Color_Yellow, Color_Bg_Black, (LCD_PIXEL_WIDTH - vallen * 16) / 2, by, S(dwin_string.string()));
|
||||
@ -464,8 +462,8 @@ void MarlinUI::draw_status_message(const bool blink) {
|
||||
maxlen -= 2;
|
||||
}
|
||||
|
||||
dwin_string.add((uint8_t*)ui.scrolled_filename(theCard, maxlen, row, sel), maxlen);
|
||||
uint8_t n = maxlen - dwin_string.length();
|
||||
dwin_string.add(ui.scrolled_filename(theCard, maxlen, row, sel), maxlen);
|
||||
uint8_t n = maxlen - dwin_string.length;
|
||||
while (n > 0) { dwin_string.add(' '); --n; }
|
||||
lcd_moveto(1, row);
|
||||
lcd_put_dwin_string();
|
||||
@ -548,7 +546,7 @@ void MarlinUI::draw_status_message(const bool blink) {
|
||||
dwin_string.add(i8tostr3rj(y_plot));
|
||||
dwin_string.add(")");
|
||||
lcd_moveto(
|
||||
TERN(DWIN_MARLINUI_LANDSCAPE, ((x_offset + x_map_pixels) / MENU_FONT_WIDTH) + 2, LCD_WIDTH - dwin_string.length()),
|
||||
TERN(DWIN_MARLINUI_LANDSCAPE, ((x_offset + x_map_pixels) / MENU_FONT_WIDTH) + 2, LCD_WIDTH - dwin_string.length),
|
||||
TERN(DWIN_MARLINUI_LANDSCAPE, LCD_HEIGHT - 2, ((y_offset + y_map_pixels) / MENU_LINE_HEIGHT) + 1)
|
||||
);
|
||||
lcd_put_dwin_string();
|
||||
@ -560,7 +558,7 @@ void MarlinUI::draw_status_message(const bool blink) {
|
||||
else
|
||||
dwin_string.add(PSTR(" -----"));
|
||||
lcd_moveto(
|
||||
TERN(DWIN_MARLINUI_LANDSCAPE, ((x_offset + x_map_pixels) / MENU_FONT_WIDTH) + 2, LCD_WIDTH - dwin_string.length()),
|
||||
TERN(DWIN_MARLINUI_LANDSCAPE, ((x_offset + x_map_pixels) / MENU_FONT_WIDTH) + 2, LCD_WIDTH - dwin_string.length),
|
||||
TERN(DWIN_MARLINUI_LANDSCAPE, LCD_HEIGHT - 1, ((y_offset + y_map_pixels) / MENU_LINE_HEIGHT) + 2)
|
||||
);
|
||||
lcd_put_dwin_string();
|
||||
|
@ -72,8 +72,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
|
||||
|
||||
uint8_t vallen = utf8_strlen(value);
|
||||
if (!ui.did_first_redraw) {
|
||||
dwin_string.set();
|
||||
dwin_string.add('X' + axis);
|
||||
dwin_string.set('X' + axis);
|
||||
DWIN_Draw_String(true, font16x32, Color_IconBlue, Color_Bg_Black, x + (vallen * 14 - 14) / 2, y + 2, S(dwin_string.string()));
|
||||
}
|
||||
|
||||
@ -96,8 +95,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
|
||||
#else // !DWIN_MARLINUI_PORTRAIT
|
||||
|
||||
if (!ui.did_first_redraw || ui.old_is_printing != print_job_timer.isRunning()) {
|
||||
dwin_string.set();
|
||||
dwin_string.add('X' + axis);
|
||||
dwin_string.set('X' + axis);
|
||||
DWIN_Draw_String(true, font16x32, Color_IconBlue, Color_Bg_Black, x, y, S(dwin_string.string()));
|
||||
}
|
||||
|
||||
@ -391,7 +389,7 @@ void MarlinUI::draw_status_screen() {
|
||||
time.toDigital(buffer);
|
||||
dwin_string.add(prefix);
|
||||
dwin_string.add(buffer);
|
||||
DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, (LCD_PIXEL_WIDTH - ((dwin_string.length() + 1) * 14)), 290, S(dwin_string.string()));
|
||||
DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, (LCD_PIXEL_WIDTH - ((dwin_string.length + 1) * 14)), 290, S(dwin_string.string()));
|
||||
|
||||
#else
|
||||
|
||||
@ -454,7 +452,7 @@ void MarlinUI::draw_status_screen() {
|
||||
dwin_string.add(PSTR("%"));
|
||||
DWIN_Draw_String(
|
||||
false, font16x32, Percent_Color, Color_Bg_Black,
|
||||
pb_left + (pb_width - dwin_string.length() * 16) / 2,
|
||||
pb_left + (pb_width - dwin_string.length * 16) / 2,
|
||||
pb_top + (pb_height - 32) / 2,
|
||||
S(dwin_string.string())
|
||||
);
|
||||
|
@ -3437,14 +3437,14 @@ void Draw_MaxSpeed_Menu() {
|
||||
if (!MaxSpeedMenu) MaxSpeedMenu = new MenuClass();
|
||||
if (CurrentMenu != MaxSpeedMenu) {
|
||||
CurrentMenu = MaxSpeedMenu;
|
||||
SetMenuTitle({1, 16, 28, 13}, GET_TEXT_F(MSG_MAXSPEED));
|
||||
SetMenuTitle({1, 16, 28, 13}, GET_TEXT_F(MSG_MAX_SPEED));
|
||||
MenuItemsPrepare(5);
|
||||
BACK_ITEM(Draw_Motion_Menu);
|
||||
EDIT_ITEM_F(ICON_MaxSpeedX, MSG_MAXSPEED_X, onDrawMaxSpeedX, SetMaxSpeedX, &planner.settings.max_feedrate_mm_s[X_AXIS]);
|
||||
EDIT_ITEM_F(ICON_MaxSpeedY, MSG_MAXSPEED_Y, onDrawMaxSpeedY, SetMaxSpeedY, &planner.settings.max_feedrate_mm_s[Y_AXIS]);
|
||||
EDIT_ITEM_F(ICON_MaxSpeedZ, MSG_MAXSPEED_Z, onDrawMaxSpeedZ, SetMaxSpeedZ, &planner.settings.max_feedrate_mm_s[Z_AXIS]);
|
||||
EDIT_ITEM_F(ICON_MaxSpeedX, MSG_VMAX_A, onDrawMaxSpeedX, SetMaxSpeedX, &planner.settings.max_feedrate_mm_s[X_AXIS]);
|
||||
EDIT_ITEM_F(ICON_MaxSpeedY, MSG_VMAX_B, onDrawMaxSpeedY, SetMaxSpeedY, &planner.settings.max_feedrate_mm_s[Y_AXIS]);
|
||||
EDIT_ITEM_F(ICON_MaxSpeedZ, MSG_VMAX_C, onDrawMaxSpeedZ, SetMaxSpeedZ, &planner.settings.max_feedrate_mm_s[Z_AXIS]);
|
||||
#if HAS_HOTEND
|
||||
EDIT_ITEM_F(ICON_MaxSpeedE, MSG_MAXSPEED_E, onDrawMaxSpeedE, SetMaxSpeedE, &planner.settings.max_feedrate_mm_s[E_AXIS]);
|
||||
EDIT_ITEM_F(ICON_MaxSpeedE, MSG_VMAX_E, onDrawMaxSpeedE, SetMaxSpeedE, &planner.settings.max_feedrate_mm_s[E_AXIS]);
|
||||
#endif
|
||||
}
|
||||
CurrentMenu->draw();
|
||||
|
@ -147,7 +147,7 @@ void DWIN_SRAMToPic(uint8_t picID) {
|
||||
|
||||
//--------------------------Test area -------------------------
|
||||
|
||||
//void DWIN_ReadSRAM(uint16_t addr, uint8_t length, const char * const data) {
|
||||
//void DWIN_ReadSRAM(uint16_t addr, const uint8_t length, const char * const data) {
|
||||
// size_t i = 0;
|
||||
// DWIN_Byte(i, 0x32);
|
||||
// DWIN_Byte(i, 0x5A); // 0x5A Read from SRAM - 0xA5 Read from Flash
|
||||
|
Reference in New Issue
Block a user