🧑‍💻 Apply F() to some LCD / TFT strings

Followup to #24228
This commit is contained in:
Scott Lahteine
2022-06-13 20:43:23 -05:00
parent c605c1ebb5
commit 78a3ea0ed4
20 changed files with 160 additions and 109 deletions

View File

@@ -271,19 +271,25 @@ void MarlinUI::draw_status_screen() {
else {
tft.add_text(200, 3, COLOR_AXIS_HOMED , "X");
const bool nhx = axis_should_home(X_AXIS);
tft_string.set(blink && nhx ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x)));
if (blink && nhx)
tft_string.set('?');
else
tft_string.set(ftostr4sign(LOGICAL_X_POSITION(current_position.x)));
tft.add_text(300 - tft_string.width(), 3, nhx ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
tft.add_text(500, 3, COLOR_AXIS_HOMED , "Y");
const bool nhy = axis_should_home(Y_AXIS);
tft_string.set(blink && nhy ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y)));
if (blink && nhy)
tft_string.set('?');
else
tft_string.set(ftostr4sign(LOGICAL_Y_POSITION(current_position.y)));
tft.add_text(600 - tft_string.width(), 3, nhy ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
}
tft.add_text(800, 3, COLOR_AXIS_HOMED , "Z");
uint16_t offset = 32;
const bool nhz = axis_should_home(Z_AXIS);
if (blink && nhz)
tft_string.set("?");
tft_string.set('?');
else {
const float z = LOGICAL_Z_POSITION(current_position.z);
tft_string.set(ftostr52sp((int16_t)z));
@@ -479,7 +485,7 @@ void MenuItem_confirm::draw_select_screen(FSTR_P const yes, FSTR_P const no, con
tft_string.add(' ');
tft_string.add(i16tostr3rj(thermalManager.wholeDegHotend(extruder)));
tft_string.add(LCD_STR_DEGREE);
tft_string.add(" / ");
tft_string.add(F(" / "));
tft_string.add(i16tostr3rj(thermalManager.degTargetHotend(extruder)));
tft_string.add(LCD_STR_DEGREE);
tft_string.trim();
@@ -607,19 +613,19 @@ static void quick_feedback() {
#define CUR_STEP_VALUE_WIDTH 104
static void drawCurStepValue() {
tft_string.set(ftostr52sp(motionAxisState.currentStepSize));
tft_string.add("mm");
tft_string.add(F("mm"));
tft.canvas(motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y, CUR_STEP_VALUE_WIDTH, BTN_HEIGHT);
tft.set_background(COLOR_BACKGROUND);
tft.add_text(tft_string.center(CUR_STEP_VALUE_WIDTH), 0, COLOR_AXIS_HOMED, tft_string);
}
static void drawCurZSelection() {
tft_string.set("Z");
tft_string.set('Z');
tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y, tft_string.width(), 34);
tft.set_background(COLOR_BACKGROUND);
tft.add_text(0, 0, Z_BTN_COLOR, tft_string);
tft.queue.sync();
tft_string.set("Offset");
tft_string.set(F("Offset"));
tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y + 34, tft_string.width(), 34);
tft.set_background(COLOR_BACKGROUND);
if (motionAxisState.z_selection == Z_SELECTION_Z_PROBE) {
@@ -630,17 +636,19 @@ static void drawCurZSelection() {
static void drawCurESelection() {
tft.canvas(motionAxisState.eNamePos.x, motionAxisState.eNamePos.y, BTN_WIDTH, BTN_HEIGHT);
tft.set_background(COLOR_BACKGROUND);
tft_string.set("E");
tft_string.set('E');
tft.add_text(0, 0, E_BTN_COLOR , tft_string);
tft.add_text(tft_string.width(), 0, E_BTN_COLOR, ui8tostr3rj(motionAxisState.e_selection));
}
static void drawMessage(const char *msg) {
static void drawMessage(PGM_P const msg) {
tft.canvas(X_MARGIN, TFT_HEIGHT - Y_MARGIN - 34, TFT_HEIGHT / 2, 34);
tft.set_background(COLOR_BACKGROUND);
tft.add_text(0, 0, COLOR_YELLOW, msg);
}
static void drawMessage(FSTR_P const fmsg) { drawMessage(FTOP(fmsg)); }
static void drawAxisValue(const AxisEnum axis) {
const float value = (
TERN_(HAS_BED_PROBE, axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE ? probe.offset.z :)
@@ -666,7 +674,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) {
#if ENABLED(PREVENT_COLD_EXTRUSION)
if (axis == E_AXIS && thermalManager.tooColdToExtrude(motionAxisState.e_selection)) {
drawMessage("Too cold");
drawMessage(F("Too cold"));
return;
}
#endif