m5stack / M5GFX

Graphics library for M5Stack series
MIT License
154 stars 47 forks source link

Compilation fails with IDF 5.0.1 #50

Open andrzejroszkowski opened 1 year ago

andrzejroszkowski commented 1 year ago

IDF: 5.0.1 OS: Windows 11 VS Code: 1.77.3 Espressif IDF VS Code Extension: v.1.6.1

Create sample project based on IDF C++ template (like "blink"), add "components" directory, anc checkout M5GFX and M5Unified modules, then try to use M5:

#include <cstdlib>
#include <thread>
#include "esp_log.h"
#include "gpio_cxx.hpp"
#include "M5Unified.hpp"

using namespace idf;
using namespace std;

extern "C" void app_main(void)
{
    try
    {
        GPIOInput gpio(GPIONum(26));
        gpio.set_pull_mode(GPIOPullMode::PULLUP());

        auto cfg = M5.config();
        M5.begin(cfg);
        M5.Lcd.setRotation(3);
        M5.Lcd.fillScreen(BLACK);
        M5.Lcd.setCursor(0, 0, 4);
        M5.Lcd.println("PIR TEST");

        while (true)
        {
            auto level = gpio.get_level();
            M5.Lcd.setCursor(110, 55, 6);
            M5.Lcd.println(level == GPIOLevel::HIGH ? "1":"0");
        }
    }
    catch (GPIOException &e)
    {
        printf("GPIO exception occurred: %s\n", esp_err_to_name(e.error));
        printf("stopping.\n");
    }
}

Compiler warns about deprecated API, but along those error is reported:

error: format '%lu' expects argument of type 'long unsigned int', but argument 6 has type 'int' [-Werror=format=]

Adding to CMakeLists.txt as a last line in M5GFX solves problem (although it may require better solution) target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-format)

Application @ https://github.com/andrzejroszkowski/m5gfx-sample

build-log.txt

bhuvanchandra commented 1 year ago

+1

lovyan03 commented 1 year ago

Hello, @andrzejroszkowski Thank you for pointing this out. I will check and make adjustments...