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.24k stars 19.22k forks source link

[BUG] ultralcd_HD44780.cpp calling private function #19861

Closed TijsP closed 4 years ago

TijsP commented 4 years ago

Bug Description

When selecting RA_CONTROL_PANEL as your LCD screen, an error gets thrown upon build.

.pio\libdeps\mega2560\LiquidCrystal/LiquidCrystal_I2C.h:186:9: error: 'int LiquidCrystal_I2C::init()' is private
    int  init();
         ^
Marlin\src\lcd\HD44780\ultralcd_HD44780.cpp:357:14: error: within this context
     lcd.init();
              ^

It seems like RA_CONTROL_PANEL defines LCD_I2C_TYPE_PCA8574 in Conditionals_LCD.h, which leads to lcd.init() being called in ultralcd_HD44780.cpp even though lcd.init() is a private function. My best bet would be that instead of init(), begin() should be called instead.

My Configurations

Configuration.zip

Steps to Reproduce

  1. Define RA_CONTROL_PANEL in Configuration.h
  2. Build Marlin

Expected behavior: A successful build

Actual behavior: A failed build

Additional information

While this is likely an error every build target will get, I did try building for multiple boards (mega1280, mega2560, sanguino1284p and STM32F103RC), all of which resulted in the same error

Edit Turns out that this issue was caused by the fact that LiquidCrystal.h was included instead of LiquidCrystal_I2C.h See the reply by ellensp for the solution

ellensp commented 4 years ago

Removed Red hearing. Issue is not in marlin code, but wrong library included in platformio.

TijsP commented 4 years ago

To answer your second question first: I took a quick look at the datasheet of the PCA8574, and it doesn't look like it has a backlight feature

I replaced the lines like you suggested, and while it does upload successfully, the LCD isn't behaving properly. The first and third line are filled with black squares and the second and fourth are complete blank. I'll take a further look myself later this day, I'm a bit short on time right now. Still, help/some pointers would be greatly appreciated

ellensp commented 4 years ago

That was a red herring...

The error message you saw was because marlin is including the wrong library If you force it to use the correct library, the code compiles as it was.

Please test this In platformio.ini change the mega2560 env: to this

[env:mega2560]
platform            = atmelavr
extends             = common_avr8
board               = megaatmega2560
lib_ignore          = LiquidCrystal
lib_deps            = ${common.lib_deps}
  LiquidCrystal_I2C

If this works I will work out how to make it include correct library automatically as it should Edit Have worked out how, if this should work.

ellensp commented 4 years ago

how to do this automatically In platformio.ini find the line USES_LIQUIDCRYSTAL = LiquidCrystal@1.5.0 add this line under it USES_LIQUIDCRYSTAL_I2C = LiquidCrystal_I2C@1.1.4

In Marlin/buildroot/share/PlatformIO/scripts/common-dependencies.h find #elif ANY(HAS_MARLINUI_HD44780, LCD_I2C_TYPE_PCF8575, LCD_I2C_TYPE_PCA8574, SR_LCD_2W_NL, LCM1602) change to

#elif ENABLED(LCD_I2C_TYPE_PCA8574)
  #define USES_LIQUIDCRYSTAL_I2C
#elif ANY(HAS_MARLINUI_HD44780, LCD_I2C_TYPE_PCF8575, SR_LCD_2W_NL , LCM1602)
TijsP commented 4 years ago

That works perfectly! I'm new to PlatformIO and VScode, so i definitely wouldn't have thought to check that. Thanks so much for your help!

ellensp commented 4 years ago

Ill turn this in a PR so its fixed for all.

github-actions[bot] commented 3 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.