Fixing Makersfab 3.5 LCD With LovyanGFX On ESP32

by Admin 50 views

Troubleshooting Your Makersfab 3.5-inch LCD with LovyanGFX on ESP32

Troubleshooting Your Makersfab 3.5-inch LCD with LovyanGFX on ESP32

Hey guys, if you're pulling your hair out trying to get your Makersfab 3.5-inch LCD working with the latest ESP32 and LovyanGFX, you're not alone! It seems like some updates have caused a few hiccups. Let's dive in and troubleshoot this issue, specifically focusing on the compilation errors and black screen problems that many users are facing. This guide will walk you through the problem, explain the error messages, and offer potential solutions. Remember, we're all in this together, and by working through this, we can hopefully get your display up and running smoothly. We'll start with understanding the problem, then move on to the code, and finally suggest solutions, making sure everything is clear and easy to follow.

Understanding the Problem: The Compilation Error

The primary issue seems to stem from a compilation error that arises when you try to build your code with the updated ESP32 and LovyanGFX libraries. The error message is quite specific: gpio_hal_iomux_func_sel' was not declared in this scope; did you mean 'gpio_hal_func_sel'? This error occurs in the Bus_RGB.cpp file within the LovyanGFX library. What's happening is that the compiler (the tool that turns your code into something the ESP32 can understand) is not recognizing gpio_hal_iomux_func_sel. This function is responsible for configuring the pins on the ESP32 to work with the LCD. The error suggests that this function might have been deprecated or renamed in the newer versions of the ESP32's core or the LovyanGFX library itself. When the compiler encounters something it doesn't recognize, it throws an error and stops the build process, preventing you from uploading the code to your ESP32 and thus preventing the LCD from displaying anything.

The user reports that certain combinations of ESP32 and LovyanGFX versions lead to different outcomes: ESP 3.1.0 and 1.2.0 worked, while ESP 3.3.0 and 1.2.0 resulted in a black screen, and ESP 3.2.0 and 1.2.0 threw errors. This indicates that the compatibility between these versions is crucial. The changes in the ESP32 core, especially concerning GPIO (General Purpose Input/Output) pin handling, are likely the root cause of these issues. These changes require the LovyanGFX library to be updated to match the new pin configuration methods. Let's analyze the provided code and identify the sections that might be causing these compatibility issues, allowing us to find a workaround or a fix.

Analyzing the Driver Code for the Makersfab 3.5-inch LCD

The provided code snippet represents the driver initialization for the Makersfab 3.5-inch LCD using the LovyanGFX library. Let's break it down to see what's going on. First, the code includes the necessary LovyanGFX library (#include <LovyanGFX.hpp>). It defines the LCD's Chip Select (CS) and Backlight (BLK) pins. A class LGFX is defined, inheriting from lgfx::LGFX_Device. Inside the LGFX class, instances for the panel (ILI9488 in this case) and the bus (Parallel16) are created. The bus configuration section sets up the parallel communication, specifying pins for WR (Write), RD (Read), RS (Register Select), and the data pins (D0-D15). The frequency of write operations is also set. Following this, the panel configuration section sets parameters like the dimensions of the display, the CS pin, and other settings. Finally, the setPanel() method links the panel to the display device.

Now, focusing on the error, the most relevant part of the code concerning the error is not directly visible in this snippet. The error originates from the Bus_RGB.cpp file, which is part of the LovyanGFX library, not the user's specific driver code. However, the driver code provided uses the library and configures the pins which can indirectly affect the compilation issues. When you are using a library, such as LovyanGFX with its various configuration settings, it might call the system's underlying function, such as gpio_hal_iomux_func_sel. The compilation issue will originate from within the library, which is not compatible with the ESP32's current software version. The configuration in the code you've provided sets up the hardware pins that the LCD will use. Any incompatibilities here would result in incorrect communication between the ESP32 and the LCD, leading to a black screen or display errors. Any code changes made to align the pin configurations, such as changes to the Bus_Parallel16 settings, could potentially resolve the compatibility issues.

Potential Solutions and Workarounds

Given the compilation error and the version-specific issues, here are some potential solutions and workarounds. First, the most straightforward approach would be to downgrade the ESP32 core to a version known to work with the LovyanGFX library you are using. The user indicated that ESP3.1.0 and LovyanGFX 1.2.0 worked. If possible, revert to this configuration in the Arduino IDE. Open the board manager (Tools > Board > Boards Manager), search for the ESP32 board, and select an older version, then compile and upload your sketch. This is often the quickest fix.

Second, check for updates to the LovyanGFX library. The library maintainers may have addressed this specific issue in a newer version. In the Arduino IDE's Library Manager (Sketch > Include Library > Manage Libraries), search for LovyanGFX and update it to the newest version. Always check the release notes of the library updates for specific fixes and improvements relevant to your LCD model and ESP32 board. If an update is available, install it and try to compile your code. This solution relies on the library developer to fix the issue.

Third, and a bit more involved, modify the Bus_RGB.cpp file within the LovyanGFX library directly. Locate the file in your Arduino libraries folder or the Arduino installation directory (it might be in a hidden folder). Open Bus_RGB.cpp. Inside this file, look for the function call that is causing the error (gpio_hal_iomux_func_sel). The error message suggests it should be gpio_hal_func_sel. You might need to change the function call and adapt the code to what the ESP32's current core expects. This involves some code-level understanding. If you're not comfortable with this, skip this step. Make a backup of the original file before editing it so that you can revert if necessary.

Another approach is to try a different bus configuration. The example is using a parallel bus. Some LCDs support SPI communication, which might be less susceptible to the GPIO pin changes causing the issue. Change the bus type in the driver code, which might involve rewriting the code slightly, but it could bypass the error. Make the necessary code modifications and update the relevant pins in the driver to match the SPI configuration. For example, you may need to define the MOSI, MISO, and CLK pins, which is dependent on your particular LCD screen and its pinout.

If you have a similar LCD screen and have successfully implemented it on your ESP32, you can also consider copying and adapting working code. Check for any online projects. Copy the necessary code, which can provide a starting point and reference for your setup. This is often useful if you have limited experience. Make sure to understand the code, pin configurations, and any LCD-specific adjustments before implementing it.

Finally, make sure your wiring is correct. Double-check all the connections between your ESP32 and the LCD. Incorrect wiring could lead to a black screen or display errors. A simple mistake could be the issue. Check all of your connections and make sure they match the driver code.

Step-by-Step Troubleshooting Guide

Let's put together a step-by-step troubleshooting guide:

  1. Identify Your Versions: Ensure you know the exact versions of your ESP32 core and LovyanGFX library.
  2. Try Downgrading (Easiest): If possible, revert to the known working version of the ESP32 core (e.g., 3.1.0) using the Arduino IDE's Board Manager. Then, try compiling your code.
  3. Update LovyanGFX: Check the Library Manager for a newer version of LovyanGFX. Update and recompile.
  4. Check Wiring: Verify all wiring connections between the ESP32 and the LCD screen. Check for any shorts, loose wires, and incorrect connections.
  5. Examine the Code: Review your code for the LCD driver, paying attention to pin assignments. Ensure they match your LCD and the ESP32's physical pinout.
  6. Analyze Error Messages: Examine the Arduino IDE's output for detailed error messages. These may offer clues about the problem.
  7. Consult Online Resources: Search online forums and communities (e.g., Arduino forums, GitHub) for solutions. Other users may have encountered and solved similar issues.
  8. Ask for Help: If you can't resolve the issue, create a new post with detailed information, including your code, the error messages, the hardware, and the versions of your software. Provide as much detail as possible to enable others to help.

By following these steps, you should be able to get your Makersfab 3.5-inch LCD working again. The key is to be methodical, try different approaches, and leverage the community's collective knowledge to solve this problem.