Closed Bricklou closed 2 years ago
Describe the bug I'm trying to use the library on my Raspberry Pi, but for some reason I get the following error:
Failed to write to the i2c bus: Bad file descriptor.
To Reproduce Steps to reproduce the behavior:
// src/main.cpp #include <iostream> #include <lcdgfx.h> #include <lcdgfx_gui.h> #include <cstdint>
int main() { DisplaySSD1306_128x64_I2C display(-1);
display.clear();
}
```cmake // CMakeLists.txt cmake_minimum_required(VERSION 3.17) project(screen_monitor VERSION 1.0.0 LANGUAGES C CXX ) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20 -Wall -Wextra -fPIC -rdynamic -pthread") # ========== # lcdgfx # ========== add_subdirectory(libs/lcdgfx) # ========== # screen_monitor # ========== add_executable(${PROJECT_NAME} src/main.cpp ) target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20) set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 20 CXX_STANDARD_REQUIRED ON ) target_link_libraries(${PROJECT_NAME} PUBLIC lcdgfx) target_include_directories(${PROJECT_NAME} PUBLIC libs/lcdgfx/src ) if (CMAKE_BUILD_TYPE MATCHES "^[Rr]elease") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s -02 -0s") else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") endif()
libs/lcdgfx
Expected behavior The program should run, but throws the error instead.
Please complete the following information:
Additional context I tried to run the demo program using this link: https://github.com/lexus2k/lcdgfx/wiki/FAQ#how-to-run-demos-on-raspberry-pi and it worked perfectly fine, but not with my own code. :confused:
Hi,
What about display.begin() in your code? Please check your code carefully.
display.begin()
Oh, yes ! Looks like it was missing. Thank you :sweat_smile:
Describe the bug I'm trying to use the library on my Raspberry Pi, but for some reason I get the following error:
To Reproduce Steps to reproduce the behavior:
int main() { DisplaySSD1306_128x64_I2C display(-1);
}
libs/lcdgfx
Expected behavior The program should run, but throws the error instead.
Please complete the following information:
Additional context I tried to run the demo program using this link: https://github.com/lexus2k/lcdgfx/wiki/FAQ#how-to-run-demos-on-raspberry-pi and it worked perfectly fine, but not with my own code. :confused: