MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
16.18k stars 19.21k forks source link

[BUG] TJC_DISPLAY flag breaks compilation #27374

Closed IngilizAdam closed 1 week ago

IngilizAdam commented 3 weeks ago

Did you test the latest bugfix-2.1.x code?

Yes, and the problem still exists.

Bug Description

Lines 33-39 in the file dwin_font.h causes compilation to fail when TJC_DISPLAY flag is active. (Also the TJC Display is not working right with my Ender-3 Max Neo after following the Special_Compilation steps, may be related to this issue.)

Bug Timeline

No response

Expected behavior

Needs definitions of the font macros for else statement.

Actual behavior

It doesn't set font macros for else statement.

The error message

Marlin/src/lcd/e3v2/common/dwin_api.cpp: In function 'uint8_t fontWidth(uint8_t)':
Marlin/src/lcd/e3v2/common/dwin_api.cpp:96:10: error: 'font6x12' was not declared in this scope; did you mean 'font8x16'?
   96 |     case font6x12 : return 6;
      |          ^~~~~~~~
      |          font8x16
Marlin/src/lcd/e3v2/common/dwin_api.cpp:102:10: error: 'font20x40' was not declared in this scope; did you mean 'font10x20'?
  102 |     case font20x40: return 20;
      |          ^~~~~~~~~
      |          font10x20
Marlin/src/lcd/e3v2/common/dwin_api.cpp:103:10: error: 'font24x48' was not declared in this scope; did you mean 'font14x28'?
  103 |     case font24x48: return 24;
      |          ^~~~~~~~~
      |          font14x28
Marlin/src/lcd/e3v2/common/dwin_api.cpp:104:10: error: 'font28x56' was not declared in this scope; did you mean 'font8x16'?
  104 |     case font28x56: return 28;
      |          ^~~~~~~~~
      |          font8x16
Marlin/src/lcd/e3v2/common/dwin_api.cpp:105:10: error: 'font32x64' was not declared in this scope; did you mean 'font12x24'?
  105 |     case font32x64: return 32;
      |          ^~~~~~~~~
      |          font12x24

Steps to Reproduce

  1. Add:
    #define DWIN_LCD_PROUI
    #define TJC_DISPLAY

    lines to the Configuration.h file.

  2. Build
  3. Compilation Error

Version of Marlin Firmware

2.1.3

Printer model

Ender-3 Max Neo

Electronics

Stock

LCD/Controller

TJC Display

Other add-ons

No response

Bed Leveling

None

Your Slicer

None

Host Software

None

Don't forget to include

Additional information & file uploads

Configuration.zip

I have tried compiling with removing the #if DISABLED(TJC_DISPLAY) statement. It compiled but the screen is not working right. I uploaded a photo of the result.

ellensp commented 3 weeks ago

This fixes that error

diff --git a/Marlin/src/lcd/e3v2/common/dwin_api.cpp b/Marlin/src/lcd/e3v2/common/dwin_api.cpp
index 1688b24230..4a93d304ca 100644
--- a/Marlin/src/lcd/e3v2/common/dwin_api.cpp
+++ b/Marlin/src/lcd/e3v2/common/dwin_api.cpp
@@ -93,16 +93,18 @@ bool dwinHandshake() {
 // Get font character width
 uint8_t fontWidth(uint8_t cfont) {
   switch (cfont) {
-    case font6x12 : return 6;
+    #if DISABLED(TJC_DISPLAY)
+      case font6x12 : return 6;
+      case font20x40: return 20;
+      case font24x48: return 24;
+      case font28x56: return 28;
+      case font32x64: return 32;
+    #endif
     case font8x16 : return 8;
     case font10x20: return 10;
     case font12x24: return 12;
     case font14x28: return 14;
     case font16x32: return 16;
-    case font20x40: return 20;
-    case font24x48: return 24;
-    case font28x56: return 28;
-    case font32x64: return 32;
     default: return 0;
   }
 }
@@ -110,16 +112,18 @@ uint8_t fontWidth(uint8_t cfont) {
 // Get font character height
 uint8_t fontHeight(uint8_t cfont) {
   switch (cfont) {
-    case font6x12 : return 12;
+    #if DISABLED(TJC_DISPLAY)
+      case font6x12 : return 12;
+      case font20x40: return 40;
+      case font24x48: return 48;
+      case font28x56: return 56;
+      case font32x64: return 64;
+    #endif
     case font8x16 : return 16;
     case font10x20: return 20;
     case font12x24: return 24;
     case font14x28: return 28;
     case font16x32: return 32;
-    case font20x40: return 40;
-    case font24x48: return 48;
-    case font28x56: return 56;
-    case font32x64: return 64;
     default: return 0;
   }
 }

Basically in https://github.com/MarlinFirmware/Marlin/pull/26003 the following fonts are removed from TJC_DISPLAYs (probably as it doesn't support them)

define font6x12 0x00

define font20x40 0x06

define font24x48 0x07

define font28x56 0x08

define font32x64 0x09

ellensp commented 3 weeks ago

I've created a PR to fix this compile error.

IngilizAdam commented 3 weeks ago

This solved the compilation issue however the screen issue is still happening. Maybe the TJC_UPDATE needs an update for the Ender-3 Max Neo. Or my configuration files are missing some statements?

20240829_131454