Skip to content

Commit 108f0b0

Browse files
committed
πŸ§‘β€πŸ’» LCD Code patches
1 parent 6b65665 commit 108f0b0

File tree

312 files changed

+3026
-1860
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

312 files changed

+3026
-1860
lines changed

β€ŽMarlin/src/lcd/HD44780/marlinui_HD44780.cpp

+44-26
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103

104104
#elif ENABLED(YHCB2004)
105105

106-
LCD_CLASS lcd(YHCB2004_CLK, 20, 4, YHCB2004_MOSI, YHCB2004_MISO); // CLK, cols, rows, MOSI, MISO
106+
LCD_CLASS lcd(YHCB2004_SCK_PIN, 20, 4, YHCB2004_MOSI_PIN, YHCB2004_MISO_PIN); // CLK, cols, rows, MOSI, MISO
107107

108108
#else
109109

@@ -521,7 +521,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
521521
else if (axis_should_home(axis))
522522
while (const char c = *value++) lcd_put_lchar(c <= '.' ? c : '?');
523523
else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !axis_is_trusted(axis))
524-
lcd_put_u8str(axis == Z_AXIS ? F(" ") : F(" "));
524+
lcd_put_u8str(TERN0(HAS_Z_AXIS, axis == Z_AXIS) ? F(" ") : F(" "));
525525
else
526526
lcd_put_u8str(value);
527527
}
@@ -537,7 +537,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
537537
*/
538538
FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char prefix, const bool blink) {
539539
#if HAS_HEATED_BED
540-
const bool isBed = TERN(HAS_HEATED_CHAMBER, heater_id == H_BED, heater_id < 0);
540+
const bool isBed = heater_id == H_BED;
541541
const celsius_t t1 = (isBed ? thermalManager.wholeDegBed() : thermalManager.wholeDegHotend(heater_id)),
542542
t2 = (isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater_id));
543543
#else
@@ -546,7 +546,17 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char pr
546546

547547
if (prefix >= 0) lcd_put_lchar(prefix);
548548

549-
lcd_put_u8str(t1 < 0 ? "err" : i16tostr3rj(t1));
549+
if (t1 >= 0)
550+
lcd_put_u8str(ui16tostr3rj(t1));
551+
else {
552+
#if ENABLED(SHOW_TEMPERATURE_BELOW_ZERO)
553+
char * const str = i16tostr3rj(t1);
554+
lcd_put_u8str(&str[1]);
555+
#else
556+
lcd_put_u8str(F("err"));
557+
#endif
558+
}
559+
550560
lcd_put_u8str(F("/"));
551561

552562
#if !HEATER_IDLE_HANDLER
@@ -762,9 +772,10 @@ void MarlinUI::draw_status_message(const bool blink) {
762772
#define TPOFFSET (LCD_WIDTH - 1)
763773
static uint8_t timepos = TPOFFSET - 6;
764774
static char buffer[8];
765-
static lcd_uint_t pc, pr;
766775

767776
#if ENABLED(SHOW_PROGRESS_PERCENT)
777+
static lcd_uint_t pc = 0, pr = 2;
778+
inline void setPercentPos(const lcd_uint_t c, const lcd_uint_t r) { pc = c; pr = r; }
768779
void MarlinUI::drawPercent() {
769780
const uint8_t progress = ui.get_progress_percent();
770781
if (progress) {
@@ -926,7 +937,7 @@ void MarlinUI::draw_status_screen() {
926937
#if LCD_WIDTH < 20
927938

928939
#if HAS_PRINT_PROGRESS
929-
pc = 0; pr = 2;
940+
TERN_(SHOW_PROGRESS_PERCENT, setPercentPos(0, 2));
930941
rotate_progress();
931942
#endif
932943

@@ -952,25 +963,25 @@ void MarlinUI::draw_status_screen() {
952963

953964
// Two-component mix / gradient instead of XY
954965

955-
char mixer_messages[12];
956-
const char *mix_label;
966+
char mixer_messages[15];
967+
PGM_P mix_label;
957968
#if ENABLED(GRADIENT_MIX)
958969
if (mixer.gradient.enabled) {
959970
mixer.update_mix_from_gradient();
960-
mix_label = "Gr";
971+
mix_label = PSTR("Gr");
961972
}
962973
else
963974
#endif
964975
{
965976
mixer.update_mix_from_vtool();
966-
mix_label = "Mx";
977+
mix_label = PSTR("Mx");
967978
}
968-
sprintf_P(mixer_messages, PSTR("%s %d;%d%% "), mix_label, int(mixer.mix[0]), int(mixer.mix[1]));
979+
sprintf_P(mixer_messages, PSTR(S_FMT " %d;%d%% "), mix_label, int(mixer.mix[0]), int(mixer.mix[1]));
969980
lcd_put_u8str(mixer_messages);
970981

971982
#else // !HAS_DUAL_MIXING
972983

973-
const bool show_e_total = TERN0(LCD_SHOW_E_TOTAL, printingIsActive());
984+
const bool show_e_total = TERN1(HAS_X_AXIS, TERN0(LCD_SHOW_E_TOTAL, printingIsActive()));
974985

975986
if (show_e_total) {
976987
#if ENABLED(LCD_SHOW_E_TOTAL)
@@ -981,10 +992,14 @@ void MarlinUI::draw_status_screen() {
981992
#endif
982993
}
983994
else {
984-
const xy_pos_t lpos = current_position.asLogical();
985-
_draw_axis_value(X_AXIS, ftostr4sign(lpos.x), blink);
986-
lcd_put_u8str(F(" "));
987-
_draw_axis_value(Y_AXIS, ftostr4sign(lpos.y), blink);
995+
#if HAS_X_AXIS
996+
const xy_pos_t lpos = current_position.asLogical();
997+
_draw_axis_value(X_AXIS, ftostr4sign(lpos.x), blink);
998+
#endif
999+
#if HAS_Y_AXIS
1000+
TERN_(HAS_X_AXIS, lcd_put_u8str(F(" ")));
1001+
_draw_axis_value(Y_AXIS, ftostr4sign(lpos.y), blink);
1002+
#endif
9881003
}
9891004

9901005
#endif // !HAS_DUAL_MIXING
@@ -993,11 +1008,12 @@ void MarlinUI::draw_status_screen() {
9931008

9941009
#endif // LCD_WIDTH >= 20
9951010

996-
lcd_moveto(LCD_WIDTH - 8, 1);
997-
_draw_axis_value(Z_AXIS, ftostr52sp(LOGICAL_Z_POSITION(current_position.z)), blink);
998-
999-
#if HAS_LEVELING && !HAS_HEATED_BED
1000-
lcd_put_lchar(planner.leveling_active || blink ? '_' : ' ');
1011+
#if HAS_Z_AXIS
1012+
lcd_moveto(LCD_WIDTH - 8, 1);
1013+
_draw_axis_value(Z_AXIS, ftostr52sp(LOGICAL_Z_POSITION(current_position.z)), blink);
1014+
#if HAS_LEVELING && !HAS_HEATED_BED
1015+
lcd_put_lchar(planner.leveling_active || blink ? '_' : ' ');
1016+
#endif
10011017
#endif
10021018

10031019
#endif // LCD_HEIGHT > 2
@@ -1013,7 +1029,7 @@ void MarlinUI::draw_status_screen() {
10131029
#if LCD_WIDTH >= 20
10141030

10151031
#if HAS_PRINT_PROGRESS
1016-
pc = 6; pr = 2;
1032+
TERN_(SHOW_PROGRESS_PERCENT, setPercentPos(6, 2));
10171033
rotate_progress();
10181034
#else
10191035
char c;
@@ -1059,8 +1075,10 @@ void MarlinUI::draw_status_screen() {
10591075
//
10601076
// Z Coordinate
10611077
//
1062-
lcd_moveto(LCD_WIDTH - 9, 0);
1063-
_draw_axis_value(Z_AXIS, ftostr52sp(LOGICAL_Z_POSITION(current_position.z)), blink);
1078+
#if HAS_Z_AXIS
1079+
lcd_moveto(LCD_WIDTH - 9, 0);
1080+
_draw_axis_value(Z_AXIS, ftostr52sp(LOGICAL_Z_POSITION(current_position.z)), blink);
1081+
#endif
10641082

10651083
#if HAS_LEVELING && (HAS_MULTI_HOTEND || !HAS_HEATED_BED)
10661084
lcd_put_lchar(LCD_WIDTH - 1, 0, planner.leveling_active || blink ? '_' : ' ');
@@ -1094,15 +1112,15 @@ void MarlinUI::draw_status_screen() {
10941112
_draw_bed_status(blink);
10951113
#elif HAS_PRINT_PROGRESS
10961114
#define DREW_PRINT_PROGRESS 1
1097-
pc = 0; pr = 2;
1115+
TERN_(SHOW_PROGRESS_PERCENT, setPercentPos(0, 2));
10981116
rotate_progress();
10991117
#endif
11001118

11011119
//
11021120
// All progress strings
11031121
//
11041122
#if HAS_PRINT_PROGRESS && !DREW_PRINT_PROGRESS
1105-
pc = LCD_WIDTH - 9; pr = 2;
1123+
TERN_(SHOW_PROGRESS_PERCENT, setPercentPos(LCD_WIDTH - 9, 2));
11061124
rotate_progress();
11071125
#endif
11081126
#endif // LCD_INFO_SCREEN_STYLE 1

β€ŽMarlin/src/lcd/HD44780/marlinui_HD44780.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,5 @@
103103

104104
#endif
105105

106-
#include "../fontutils.h"
106+
#include "../utf8.h"
107107
#include "../lcdprint.h"

β€ŽMarlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -864,20 +864,20 @@ void MarlinUI::draw_status_screen() {
864864
#if DUAL_MIXING_EXTRUDER
865865
lcd_moveto(0, 4);
866866
// Two-component mix / gradient instead of XY
867-
char mixer_messages[12];
868-
const char *mix_label;
867+
char mixer_messages[15];
868+
PGM_P mix_label;
869869
#if ENABLED(GRADIENT_MIX)
870870
if (mixer.gradient.enabled) {
871871
mixer.update_mix_from_gradient();
872-
mix_label = "Gr";
872+
mix_label = PSTR("Gr");
873873
}
874874
else
875875
#endif
876876
{
877877
mixer.update_mix_from_vtool();
878-
mix_label = "Mx";
878+
mix_label = PSTR("Mx");
879879
}
880-
sprintf_P(mixer_messages, PSTR("%s %d;%d%% "), mix_label, int(mixer.mix[0]), int(mixer.mix[1]));
880+
sprintf_P(mixer_messages, PSTR(S_FMT " %d;%d%% "), mix_label, int(mixer.mix[0]), int(mixer.mix[1]));
881881
lcd_put_u8str(mixer_messages);
882882
#endif
883883
#endif

β€ŽMarlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.h

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ class TFTGLCD {
5757

5858
extern TFTGLCD lcd;
5959

60-
#include "../fontutils.h"
6160
#include "../lcdprint.h"
6261

6362
// Use panel encoder - free old encoder pins

β€ŽMarlin/src/lcd/dogm/HAL_LCD_com_defines.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
*/
2222
#pragma once
2323

24-
// Use this file to select the com driver for device drivers that are NOT in the U8G library
24+
/**
25+
* Assign custom or standard U8G device drivers
26+
*/
2527

2628
#include <U8glib-HAL.h>
2729

@@ -114,6 +116,7 @@
114116
#define U8G_COM_ST7920_HAL_SW_SPI u8g_com_ST7920_sw_spi_fn
115117
#endif
116118

119+
// U8G_HAL_LINKS is defined for LPC1768/9 and Native envs by -DU8G_HAL_LINKS in platform.ini
117120
#ifndef U8G_COM_HAL_SW_SPI_FN
118121
#define U8G_COM_HAL_SW_SPI_FN u8g_com_null_fn
119122
#endif

β€ŽMarlin/src/lcd/dogm/fontdata/langdata_ro.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,10 @@
77

88
#include "langdata.h"
99

10-
static const uxg_fontinfo_t g_fontinfo_ro[] PROGMEM = {};
10+
const u8g_fntpgm_uint8_t fontpage_2_131_131[31] U8G_FONT_SECTION("fontpage_2_131_131") = {
11+
0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x83,0x83,0x00,0x08,0x00,0x00,
12+
0x00,0x05,0x08,0x08,0x06,0x00,0x00,0x88,0x70,0x00,0x70,0x08,0x78,0x88,0x78};
13+
14+
static const uxg_fontinfo_t g_fontinfo_ro[] PROGMEM = {
15+
FONTDATA_ITEM(2, 131, 131, fontpage_2_131_131), // 'Δƒ' -- 'Δƒ'
16+
};

β€ŽMarlin/src/lcd/dogm/lcdprint_u8g.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "../marlinui.h"
1717
#include "../../MarlinCore.h"
1818

19-
#include "../fontutils.h"
19+
#include "../utf8.h"
2020
#include "u8g_fontutf8.h"
2121
#include "../lcdprint.h"
2222

β€ŽMarlin/src/lcd/dogm/marlinui_DOGM.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
#endif
4848

4949
#include "../lcdprint.h"
50-
#include "../fontutils.h"
50+
#include "../utf8.h"
5151
#include "../../libs/numtostr.h"
5252
#include "../marlinui.h"
5353

β€ŽMarlin/src/lcd/dogm/marlinui_DOGM.h

+14-9
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,20 @@
3636

3737
// RepRapWorld Graphical LCD
3838

39-
40-
#if !HAS_MEDIA && (LCD_PINS_D4 == SD_SCK_PIN) && (LCD_PINS_EN == SD_MOSI_PIN)
41-
#define U8G_CLASS U8GLIB_ST7920_128X64_4X_HAL
39+
#if HAS_MEDIA
40+
#ifdef __SAMD21__
41+
#define U8G_CLASS U8GLIB_ST7920_128X64_4X_HAL
42+
#else
43+
// Hardware SPI on DUE
44+
#define U8G_CLASS U8GLIB_ST7920_128X64_4X
45+
#endif
4246
#define U8G_PARAM LCD_PINS_RS
43-
#elif HAS_MEDIA && __SAMD21__
44-
45-
#define U8G_CLASS U8GLIB_ST7920_128X64_4X
47+
#elif (LCD_PINS_D4 == SD_SCK_PIN) && (LCD_PINS_EN == SD_MOSI_PIN)
48+
// Hardware SPI shared with SD Card
49+
#define U8G_CLASS U8GLIB_ST7920_128X64_4X_HAL
4650
#define U8G_PARAM LCD_PINS_RS
4751
#else
52+
// Software SPI
4853
#define U8G_CLASS U8GLIB_ST7920_128X64_4X
4954
#define U8G_PARAM LCD_PINS_D4, LCD_PINS_EN, LCD_PINS_RS
5055
#endif
@@ -63,7 +68,7 @@
6368
#else
6469
#define U8G_CLASS U8GLIB_ST7920_128X64_RRD // Adjust stripes with PAGE_HEIGHT in ultralcd_st7920_u8glib_rrd.h
6570
#endif
66-
#define U8G_PARAM LCD_PINS_D4, LCD_PINS_EN, LCD_PINS_RS // AVR version ignores these pin settings
71+
#define U8G_PARAM LCD_PINS_D4, LCD_PINS_EN, LCD_PINS_RS // AVR version ignores these pin settings
6772
// HAL version uses these pin settings
6873
#endif
6974

@@ -95,7 +100,7 @@
95100
#define SMART_RAMPS MB(RAMPS_SMART_EFB, RAMPS_SMART_EEB, RAMPS_SMART_EFF, RAMPS_SMART_EEF, RAMPS_SMART_SF)
96101
#define U8G_CLASS U8GLIB_64128N_2X_HAL // 4 stripes (HW-SPI)
97102

98-
#if (SMART_RAMPS && defined(__SAM3X8E__)) || DOGLCD_SCK != SD_SCK_PIN || DOGLCD_MOSI != SD_MOSI_PIN
103+
#if (SMART_RAMPS && defined(__SAM3X8E__)) || (defined(DOGLCD_SCK) && (DOGLCD_SCK != -1 && DOGLCD_SCK != SD_SCK_PIN)) || (defined(DOGLCD_MOSI) && (DOGLCD_MOSI != -1 && DOGLCD_MOSI != SD_MOSI_PIN))
99104
#define FORCE_SOFT_SPI // SW-SPI
100105
#endif
101106

@@ -228,7 +233,7 @@
228233
#if ENABLED(FORCE_SOFT_SPI)
229234
#define U8G_PARAM DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, DOGLCD_A0 // SW-SPI
230235
#else
231-
#define U8G_PARAM DOGLCD_CS, DOGLCD_A0 // HW-SPI
236+
#define U8G_PARAM DOGLCD_CS, DOGLCD_A0 // HW-SPI
232237
#endif
233238
#endif
234239

β€ŽMarlin/src/lcd/dogm/status/chamber.h

+24-24
Original file line numberDiff line numberDiff line change
@@ -41,32 +41,32 @@
4141
#ifdef STATUS_CHAMBER_ANIM
4242

4343
const unsigned char status_chamber_bmp[] PROGMEM = {
44-
B00011111,B11111111,B11111000,
45-
B00010000,B00000000,B00001000,
46-
B00010000,B00000000,B00001000,
47-
B00010000,B00000000,B00001000,
48-
B00010000,B00000000,B00001000,
49-
B00010000,B00000000,B00001000,
50-
B00010000,B00000000,B00001000,
51-
B00010000,B00000000,B00001000,
52-
B00010000,B00000000,B00001000,
53-
B00010000,B00000000,B00001000,
54-
B00011111,B11111111,B11111000,
55-
B00011111,B11111111,B11111000
44+
B00001111,B11111111,B11111000,
45+
B00001000,B00000000,B00001000,
46+
B00001000,B00000000,B00001000,
47+
B00001000,B00000000,B00001000,
48+
B00001000,B00000000,B00001000,
49+
B00001000,B00000000,B00001000,
50+
B00001000,B00000000,B00001000,
51+
B00001000,B00000000,B00001000,
52+
B00001000,B00000000,B00001000,
53+
B00001000,B00000000,B00001000,
54+
B00001111,B11111111,B11111000,
55+
B00001111,B11111111,B11111000
5656
};
5757
const unsigned char status_chamber_on_bmp[] PROGMEM = {
58-
B00011111,B11111111,B11111000,
59-
B00010000,B00000000,B00001000,
60-
B00010000,B10000100,B00001000,
61-
B00010000,B01000010,B00001000,
62-
B00010000,B01000010,B00001000,
63-
B00010000,B10000100,B00001000,
64-
B00010001,B00001000,B00001000,
65-
B00010001,B00001000,B00001000,
66-
B00010000,B10000100,B00001000,
67-
B00010000,B00000000,B00001000,
68-
B00011111,B11111111,B11111000,
69-
B00011111,B11111111,B11111000
58+
B00001111,B11111111,B11111000,
59+
B00001000,B00000000,B00001000,
60+
B00001000,B10000100,B00001000,
61+
B00001000,B01000010,B00001000,
62+
B00001000,B01000010,B00001000,
63+
B00001000,B10000100,B00001000,
64+
B00001001,B00001000,B00001000,
65+
B00001001,B00001000,B00001000,
66+
B00001000,B10000100,B00001000,
67+
B00001000,B00000000,B00001000,
68+
B00001111,B11111111,B11111000,
69+
B00001111,B11111111,B11111000
7070
};
7171

7272
#else

β€ŽMarlin/src/lcd/dogm/status_screen_DOGM.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@
9696
DRAWBIT_HOTEND,
9797
DRAWBIT_BED = HOTENDS,
9898
DRAWBIT_CHAMBER,
99-
DRAWBIT_CUTTER
99+
DRAWBIT_CUTTER,
100+
DRAWBIT_COUNT
100101
};
101-
IF<(DRAWBIT_CUTTER > 7), uint16_t, uint8_t>::type draw_bits;
102+
bits_t(DRAWBIT_COUNT) draw_bits;
102103
#endif
103104

104105
#if ANIM_HOTEND

0 commit comments

Comments
Β (0)