Skip to content

Commit

Permalink
πŸ§‘β€πŸ’» LCD Code patches
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Feb 10, 2024
1 parent 6b65665 commit 108f0b0
Show file tree
Hide file tree
Showing 312 changed files with 3,026 additions and 1,860 deletions.
70 changes: 44 additions & 26 deletions Marlin/src/lcd/HD44780/marlinui_HD44780.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@

#elif ENABLED(YHCB2004)

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

#else

Expand Down Expand Up @@ -521,7 +521,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
else if (axis_should_home(axis))
while (const char c = *value++) lcd_put_lchar(c <= '.' ? c : '?');
else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !axis_is_trusted(axis))
lcd_put_u8str(axis == Z_AXIS ? F(" ") : F(" "));
lcd_put_u8str(TERN0(HAS_Z_AXIS, axis == Z_AXIS) ? F(" ") : F(" "));
else
lcd_put_u8str(value);
}
Expand All @@ -537,7 +537,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
*/
FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char prefix, const bool blink) {
#if HAS_HEATED_BED
const bool isBed = TERN(HAS_HEATED_CHAMBER, heater_id == H_BED, heater_id < 0);
const bool isBed = heater_id == H_BED;
const celsius_t t1 = (isBed ? thermalManager.wholeDegBed() : thermalManager.wholeDegHotend(heater_id)),
t2 = (isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater_id));
#else
Expand All @@ -546,7 +546,17 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char pr

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

lcd_put_u8str(t1 < 0 ? "err" : i16tostr3rj(t1));
if (t1 >= 0)
lcd_put_u8str(ui16tostr3rj(t1));
else {
#if ENABLED(SHOW_TEMPERATURE_BELOW_ZERO)
char * const str = i16tostr3rj(t1);
lcd_put_u8str(&str[1]);
#else
lcd_put_u8str(F("err"));
#endif
}

lcd_put_u8str(F("/"));

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

#if ENABLED(SHOW_PROGRESS_PERCENT)
static lcd_uint_t pc = 0, pr = 2;
inline void setPercentPos(const lcd_uint_t c, const lcd_uint_t r) { pc = c; pr = r; }
void MarlinUI::drawPercent() {
const uint8_t progress = ui.get_progress_percent();
if (progress) {
Expand Down Expand Up @@ -926,7 +937,7 @@ void MarlinUI::draw_status_screen() {
#if LCD_WIDTH < 20

#if HAS_PRINT_PROGRESS
pc = 0; pr = 2;
TERN_(SHOW_PROGRESS_PERCENT, setPercentPos(0, 2));
rotate_progress();
#endif

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

// Two-component mix / gradient instead of XY

char mixer_messages[12];
const char *mix_label;
char mixer_messages[15];
PGM_P mix_label;
#if ENABLED(GRADIENT_MIX)
if (mixer.gradient.enabled) {
mixer.update_mix_from_gradient();
mix_label = "Gr";
mix_label = PSTR("Gr");
}
else
#endif
{
mixer.update_mix_from_vtool();
mix_label = "Mx";
mix_label = PSTR("Mx");
}
sprintf_P(mixer_messages, PSTR("%s %d;%d%% "), mix_label, int(mixer.mix[0]), int(mixer.mix[1]));
sprintf_P(mixer_messages, PSTR(S_FMT " %d;%d%% "), mix_label, int(mixer.mix[0]), int(mixer.mix[1]));
lcd_put_u8str(mixer_messages);

#else // !HAS_DUAL_MIXING

const bool show_e_total = TERN0(LCD_SHOW_E_TOTAL, printingIsActive());
const bool show_e_total = TERN1(HAS_X_AXIS, TERN0(LCD_SHOW_E_TOTAL, printingIsActive()));

if (show_e_total) {
#if ENABLED(LCD_SHOW_E_TOTAL)
Expand All @@ -981,10 +992,14 @@ void MarlinUI::draw_status_screen() {
#endif
}
else {
const xy_pos_t lpos = current_position.asLogical();
_draw_axis_value(X_AXIS, ftostr4sign(lpos.x), blink);
lcd_put_u8str(F(" "));
_draw_axis_value(Y_AXIS, ftostr4sign(lpos.y), blink);
#if HAS_X_AXIS
const xy_pos_t lpos = current_position.asLogical();
_draw_axis_value(X_AXIS, ftostr4sign(lpos.x), blink);
#endif
#if HAS_Y_AXIS
TERN_(HAS_X_AXIS, lcd_put_u8str(F(" ")));
_draw_axis_value(Y_AXIS, ftostr4sign(lpos.y), blink);
#endif
}

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

#endif // LCD_WIDTH >= 20

lcd_moveto(LCD_WIDTH - 8, 1);
_draw_axis_value(Z_AXIS, ftostr52sp(LOGICAL_Z_POSITION(current_position.z)), blink);

#if HAS_LEVELING && !HAS_HEATED_BED
lcd_put_lchar(planner.leveling_active || blink ? '_' : ' ');
#if HAS_Z_AXIS
lcd_moveto(LCD_WIDTH - 8, 1);
_draw_axis_value(Z_AXIS, ftostr52sp(LOGICAL_Z_POSITION(current_position.z)), blink);
#if HAS_LEVELING && !HAS_HEATED_BED
lcd_put_lchar(planner.leveling_active || blink ? '_' : ' ');
#endif
#endif

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

#if HAS_PRINT_PROGRESS
pc = 6; pr = 2;
TERN_(SHOW_PROGRESS_PERCENT, setPercentPos(6, 2));
rotate_progress();
#else
char c;
Expand Down Expand Up @@ -1059,8 +1075,10 @@ void MarlinUI::draw_status_screen() {
//
// Z Coordinate
//
lcd_moveto(LCD_WIDTH - 9, 0);
_draw_axis_value(Z_AXIS, ftostr52sp(LOGICAL_Z_POSITION(current_position.z)), blink);
#if HAS_Z_AXIS
lcd_moveto(LCD_WIDTH - 9, 0);
_draw_axis_value(Z_AXIS, ftostr52sp(LOGICAL_Z_POSITION(current_position.z)), blink);
#endif

#if HAS_LEVELING && (HAS_MULTI_HOTEND || !HAS_HEATED_BED)
lcd_put_lchar(LCD_WIDTH - 1, 0, planner.leveling_active || blink ? '_' : ' ');
Expand Down Expand Up @@ -1094,15 +1112,15 @@ void MarlinUI::draw_status_screen() {
_draw_bed_status(blink);
#elif HAS_PRINT_PROGRESS
#define DREW_PRINT_PROGRESS 1
pc = 0; pr = 2;
TERN_(SHOW_PROGRESS_PERCENT, setPercentPos(0, 2));
rotate_progress();
#endif

//
// All progress strings
//
#if HAS_PRINT_PROGRESS && !DREW_PRINT_PROGRESS
pc = LCD_WIDTH - 9; pr = 2;
TERN_(SHOW_PROGRESS_PERCENT, setPercentPos(LCD_WIDTH - 9, 2));
rotate_progress();
#endif
#endif // LCD_INFO_SCREEN_STYLE 1
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/HD44780/marlinui_HD44780.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,5 @@

#endif

#include "../fontutils.h"
#include "../utf8.h"
#include "../lcdprint.h"
10 changes: 5 additions & 5 deletions Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -864,20 +864,20 @@ void MarlinUI::draw_status_screen() {
#if DUAL_MIXING_EXTRUDER
lcd_moveto(0, 4);
// Two-component mix / gradient instead of XY
char mixer_messages[12];
const char *mix_label;
char mixer_messages[15];
PGM_P mix_label;
#if ENABLED(GRADIENT_MIX)
if (mixer.gradient.enabled) {
mixer.update_mix_from_gradient();
mix_label = "Gr";
mix_label = PSTR("Gr");
}
else
#endif
{
mixer.update_mix_from_vtool();
mix_label = "Mx";
mix_label = PSTR("Mx");
}
sprintf_P(mixer_messages, PSTR("%s %d;%d%% "), mix_label, int(mixer.mix[0]), int(mixer.mix[1]));
sprintf_P(mixer_messages, PSTR(S_FMT " %d;%d%% "), mix_label, int(mixer.mix[0]), int(mixer.mix[1]));
lcd_put_u8str(mixer_messages);
#endif
#endif
Expand Down
1 change: 0 additions & 1 deletion Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class TFTGLCD {

extern TFTGLCD lcd;

#include "../fontutils.h"
#include "../lcdprint.h"

// Use panel encoder - free old encoder pins
Expand Down
5 changes: 4 additions & 1 deletion Marlin/src/lcd/dogm/HAL_LCD_com_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
*/
#pragma once

// Use this file to select the com driver for device drivers that are NOT in the U8G library
/**
* Assign custom or standard U8G device drivers
*/

#include <U8glib-HAL.h>

Expand Down Expand Up @@ -114,6 +116,7 @@
#define U8G_COM_ST7920_HAL_SW_SPI u8g_com_ST7920_sw_spi_fn
#endif

// U8G_HAL_LINKS is defined for LPC1768/9 and Native envs by -DU8G_HAL_LINKS in platform.ini
#ifndef U8G_COM_HAL_SW_SPI_FN
#define U8G_COM_HAL_SW_SPI_FN u8g_com_null_fn
#endif
Expand Down
8 changes: 7 additions & 1 deletion Marlin/src/lcd/dogm/fontdata/langdata_ro.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@

#include "langdata.h"

static const uxg_fontinfo_t g_fontinfo_ro[] PROGMEM = {};
const u8g_fntpgm_uint8_t fontpage_2_131_131[31] U8G_FONT_SECTION("fontpage_2_131_131") = {
0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x83,0x83,0x00,0x08,0x00,0x00,
0x00,0x05,0x08,0x08,0x06,0x00,0x00,0x88,0x70,0x00,0x70,0x08,0x78,0x88,0x78};

static const uxg_fontinfo_t g_fontinfo_ro[] PROGMEM = {
FONTDATA_ITEM(2, 131, 131, fontpage_2_131_131), // 'Δƒ' -- 'Δƒ'
};
2 changes: 1 addition & 1 deletion Marlin/src/lcd/dogm/lcdprint_u8g.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "../marlinui.h"
#include "../../MarlinCore.h"

#include "../fontutils.h"
#include "../utf8.h"
#include "u8g_fontutf8.h"
#include "../lcdprint.h"

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/dogm/marlinui_DOGM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#endif

#include "../lcdprint.h"
#include "../fontutils.h"
#include "../utf8.h"
#include "../../libs/numtostr.h"
#include "../marlinui.h"

Expand Down
23 changes: 14 additions & 9 deletions Marlin/src/lcd/dogm/marlinui_DOGM.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,20 @@

// RepRapWorld Graphical LCD


#if !HAS_MEDIA && (LCD_PINS_D4 == SD_SCK_PIN) && (LCD_PINS_EN == SD_MOSI_PIN)
#define U8G_CLASS U8GLIB_ST7920_128X64_4X_HAL
#if HAS_MEDIA
#ifdef __SAMD21__
#define U8G_CLASS U8GLIB_ST7920_128X64_4X_HAL
#else
// Hardware SPI on DUE
#define U8G_CLASS U8GLIB_ST7920_128X64_4X
#endif
#define U8G_PARAM LCD_PINS_RS
#elif HAS_MEDIA && __SAMD21__

#define U8G_CLASS U8GLIB_ST7920_128X64_4X
#elif (LCD_PINS_D4 == SD_SCK_PIN) && (LCD_PINS_EN == SD_MOSI_PIN)
// Hardware SPI shared with SD Card
#define U8G_CLASS U8GLIB_ST7920_128X64_4X_HAL
#define U8G_PARAM LCD_PINS_RS
#else
// Software SPI
#define U8G_CLASS U8GLIB_ST7920_128X64_4X
#define U8G_PARAM LCD_PINS_D4, LCD_PINS_EN, LCD_PINS_RS
#endif
Expand All @@ -63,7 +68,7 @@
#else
#define U8G_CLASS U8GLIB_ST7920_128X64_RRD // Adjust stripes with PAGE_HEIGHT in ultralcd_st7920_u8glib_rrd.h
#endif
#define U8G_PARAM LCD_PINS_D4, LCD_PINS_EN, LCD_PINS_RS // AVR version ignores these pin settings
#define U8G_PARAM LCD_PINS_D4, LCD_PINS_EN, LCD_PINS_RS // AVR version ignores these pin settings
// HAL version uses these pin settings
#endif

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

#if (SMART_RAMPS && defined(__SAM3X8E__)) || DOGLCD_SCK != SD_SCK_PIN || DOGLCD_MOSI != SD_MOSI_PIN
#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))
#define FORCE_SOFT_SPI // SW-SPI
#endif

Expand Down Expand Up @@ -228,7 +233,7 @@
#if ENABLED(FORCE_SOFT_SPI)
#define U8G_PARAM DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, DOGLCD_A0 // SW-SPI
#else
#define U8G_PARAM DOGLCD_CS, DOGLCD_A0 // HW-SPI
#define U8G_PARAM DOGLCD_CS, DOGLCD_A0 // HW-SPI
#endif
#endif

Expand Down
48 changes: 24 additions & 24 deletions Marlin/src/lcd/dogm/status/chamber.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,32 +41,32 @@
#ifdef STATUS_CHAMBER_ANIM

const unsigned char status_chamber_bmp[] PROGMEM = {
B00011111,B11111111,B11111000,
B00010000,B00000000,B00001000,
B00010000,B00000000,B00001000,
B00010000,B00000000,B00001000,
B00010000,B00000000,B00001000,
B00010000,B00000000,B00001000,
B00010000,B00000000,B00001000,
B00010000,B00000000,B00001000,
B00010000,B00000000,B00001000,
B00010000,B00000000,B00001000,
B00011111,B11111111,B11111000,
B00011111,B11111111,B11111000
B00001111,B11111111,B11111000,
B00001000,B00000000,B00001000,
B00001000,B00000000,B00001000,
B00001000,B00000000,B00001000,
B00001000,B00000000,B00001000,
B00001000,B00000000,B00001000,
B00001000,B00000000,B00001000,
B00001000,B00000000,B00001000,
B00001000,B00000000,B00001000,
B00001000,B00000000,B00001000,
B00001111,B11111111,B11111000,
B00001111,B11111111,B11111000
};
const unsigned char status_chamber_on_bmp[] PROGMEM = {
B00011111,B11111111,B11111000,
B00010000,B00000000,B00001000,
B00010000,B10000100,B00001000,
B00010000,B01000010,B00001000,
B00010000,B01000010,B00001000,
B00010000,B10000100,B00001000,
B00010001,B00001000,B00001000,
B00010001,B00001000,B00001000,
B00010000,B10000100,B00001000,
B00010000,B00000000,B00001000,
B00011111,B11111111,B11111000,
B00011111,B11111111,B11111000
B00001111,B11111111,B11111000,
B00001000,B00000000,B00001000,
B00001000,B10000100,B00001000,
B00001000,B01000010,B00001000,
B00001000,B01000010,B00001000,
B00001000,B10000100,B00001000,
B00001001,B00001000,B00001000,
B00001001,B00001000,B00001000,
B00001000,B10000100,B00001000,
B00001000,B00000000,B00001000,
B00001111,B11111111,B11111000,
B00001111,B11111111,B11111000
};

#else
Expand Down
5 changes: 3 additions & 2 deletions Marlin/src/lcd/dogm/status_screen_DOGM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@
DRAWBIT_HOTEND,
DRAWBIT_BED = HOTENDS,
DRAWBIT_CHAMBER,
DRAWBIT_CUTTER
DRAWBIT_CUTTER,
DRAWBIT_COUNT
};
IF<(DRAWBIT_CUTTER > 7), uint16_t, uint8_t>::type draw_bits;
bits_t(DRAWBIT_COUNT) draw_bits;
#endif

#if ANIM_HOTEND
Expand Down
Loading

0 comments on commit 108f0b0

Please sign in to comment.