lovyan03 / LovyanGFX

SPI LCD graphics library for ESP32 (ESP-IDF/ArduinoESP32) / ESP8266 (ArduinoESP8266) / SAMD51(Seeed ArduinoSAMD51)
Other
1.12k stars 200 forks source link

src_bits is used uninitialised #380

Closed ammaree closed 1 year ago

ammaree commented 1 year ago

Environment

Problem Description

Code fails to compile with 2 errors

Expected Behavior

Code should compile successfully

Actual Behavior

/Users/andremaree/DevSpace/z-repo/lovyan/src/lgfx/v1/misc/pixelcopy.cpp: In constructor 'lgfx::v1::pixelcopy_t::pixelcopy_t(const void*, lgfx::v1::color_depth_t, lgfx::v1::color_depth_t, bool, const void*, uint32_t)': /Users/andremaree/DevSpace/z-repo/lovyan/src/lgfx/v1/misc/pixelcopy.cpp:39:25: error: member 'lgfx::v1::pixelcopy_t::<anonymous>' is used uninitialized [-Werror=uninitialized] 39 | , src_mask ( (1 << src_bits) - 1 ) | ^~~~~~~~ /Users/andremaree/DevSpace/z-repo/lovyan/src/lgfx/v1/misc/pixelcopy.cpp:40:25: error: member 'lgfx::v1::pixelcopy_t::<anonymous>' is used uninitialized [-Werror=uninitialized] 40 | , dst_mask ( (1 << dst_bits) - 1 ) | ^~~~~~~~

Steps to reproduce

I suspect the cause is somewhere in my device definition and solution simple, hopefully someone can point me in the right direction.

Code to reproduce this issue

tobozo commented 1 year ago

hi,

Code fails to compile with 2 errors

what code ? please provide a snippet of the code that caused this, we can't guess it from an error message :wink:

ammaree commented 1 year ago

I am not sure what part of the code to supply. I am integrating the basic support (so far just the initialisation code) for the devkit into a large application.

#define LGFX_MAKERFABS_TFT_TOUCH_PARALLEL16
#define SD_SUPPORTED

#include <LovyanGFX.hpp>
#if (cmakePLTFRM == HW_MF3P16)
    #include <driver/i2c.h>
#endif

void vGuiInit(void) {
    lcd.init();
    lcd.clear();
    if (lcd.width() < lcd.height())
        lcd.setRotation(lcd.getRotation() ^ 1);
    lcd.cp437(true);
    lcd.setColorDepth(8);
}

void vGuiRefresh(void) {
    lcd.clear(0x0000);
    lcd.setColor(255,255,255);
    lcd.setCursor(0,0);
    lcd.print(pReqBuf ? pReqBuf : DispBuf);
    pReqBuf = NULL;
}

If you can give me a pointer of the section/area to look or copy here, much appreciated.

tobozo commented 1 year ago

mayb you can try this:

#define LGFX_USE_V1
#include <SD.h> // will tell LGFX to enable filesystem draw functions
#include <LovyanGFX.hpp>
#include <lgfx_user/LGFX_ESP32S2_MakerabsParallelTFTwithTouch.hpp>

static LGFX lcd;

also make sure this is the only place you where include LovyanGFX in your project.

the extra #include <SD.h> will tell LGFX to enable filesystem draw functions, you can ignore that if you're not using the SD, but it applies to SPIFFS and LittleFS too

lovyan03 commented 1 year ago

I changed the code because it is tedious to explain.

ammaree commented 1 year ago

@tobozo Thanks for your help, appreciated

@lovyan03 Thanks for fixing, works perfectly. Most probably the explanation would not have made much sense to me, Im not a C++ expert...