-
-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
5,013 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,12 @@ | ||
# CMakeLists for ESP-IDF | ||
# Espressif ESP* based boards | ||
if (DEFINED ESP_PLATFORM) | ||
include(boards.cmake/esp-idf.cmake) | ||
|
||
set(COMPONENT_ADD_INCLUDEDIRS | ||
src | ||
) | ||
file(GLOB SRCS | ||
src/lgfx/Fonts/efont/*.c | ||
src/lgfx/Fonts/IPA/*.c | ||
src/lgfx/utility/*.c | ||
src/lgfx/v1/*.cpp | ||
src/lgfx/v1/misc/*.cpp | ||
src/lgfx/v1/panel/*.cpp | ||
src/lgfx/v1/platforms/arduino_default/*.cpp | ||
src/lgfx/v1/platforms/esp32/*.cpp | ||
src/lgfx/v1/platforms/esp32c3/*.cpp | ||
src/lgfx/v1/platforms/esp32s2/*.cpp | ||
src/lgfx/v1/platforms/esp32s3/*.cpp | ||
src/lgfx/v1/touch/*.cpp | ||
) | ||
# Raspberry Pi RP* based boards | ||
elseif ((DEFINED PICO_PLATFORM) OR (DEFINED PICO_BOARD)) | ||
include(boards.cmake/pico-sdk.cmake) | ||
|
||
set(COMPONENT_SRCS ${SRCS}) | ||
|
||
if (IDF_VERSION_MAJOR GREATER_EQUAL 5) | ||
set(COMPONENT_REQUIRES nvs_flash efuse esp_lcd driver esp_timer) | ||
elseif ((IDF_VERSION_MAJOR EQUAL 4) AND (IDF_VERSION_MINOR GREATER 3) OR IDF_VERSION_MAJOR GREATER 4) | ||
set(COMPONENT_REQUIRES nvs_flash efuse esp_lcd) | ||
# Cannot determine boards type | ||
else() | ||
set(COMPONENT_REQUIRES nvs_flash efuse) | ||
message("Error: No platform specified") | ||
endif() | ||
|
||
|
||
### If you use arduino-esp32 components, please activate next comment line. | ||
# list(APPEND COMPONENT_REQUIRES arduino-esp32) | ||
|
||
|
||
message(STATUS "LovyanGFX use components = ${COMPONENT_REQUIRES}") | ||
|
||
register_component() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# CMakeLists for ESP-IDF | ||
|
||
set(COMPONENT_ADD_INCLUDEDIRS | ||
src | ||
) | ||
file(GLOB SRCS | ||
src/lgfx/Fonts/efont/*.c | ||
src/lgfx/Fonts/IPA/*.c | ||
src/lgfx/utility/*.c | ||
src/lgfx/v1/*.cpp | ||
src/lgfx/v1/misc/*.cpp | ||
src/lgfx/v1/panel/*.cpp | ||
src/lgfx/v1/platforms/arduino_default/*.cpp | ||
src/lgfx/v1/platforms/esp32/*.cpp | ||
src/lgfx/v1/platforms/esp32c3/*.cpp | ||
src/lgfx/v1/platforms/esp32s2/*.cpp | ||
src/lgfx/v1/platforms/esp32s3/*.cpp | ||
src/lgfx/v1/touch/*.cpp | ||
) | ||
|
||
set(COMPONENT_SRCS ${SRCS}) | ||
|
||
if (IDF_VERSION_MAJOR GREATER_EQUAL 5) | ||
set(COMPONENT_REQUIRES nvs_flash efuse esp_lcd driver esp_timer) | ||
elseif ((IDF_VERSION_MAJOR EQUAL 4) AND (IDF_VERSION_MINOR GREATER 3) OR IDF_VERSION_MAJOR GREATER 4) | ||
set(COMPONENT_REQUIRES nvs_flash efuse esp_lcd) | ||
else() | ||
set(COMPONENT_REQUIRES nvs_flash efuse) | ||
endif() | ||
|
||
|
||
### If you use arduino-esp32 components, please activate next comment line. | ||
# list(APPEND COMPONENT_REQUIRES arduino-esp32) | ||
|
||
|
||
message(STATUS "LovyanGFX use components = ${COMPONENT_REQUIRES}") | ||
|
||
register_component() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# CMakeLists for PICO SDK | ||
|
||
include(${PICO_SDK_PATH}/external/pico_sdk_import.cmake) | ||
|
||
pico_sdk_init() | ||
|
||
add_compile_definitions( | ||
USE_PICO_SDK=1 | ||
) | ||
|
||
# pico_add_library() | ||
add_library(LovyanGFX_headers INTERFACE) | ||
add_library(LovyanGFX INTERFACE) | ||
|
||
target_include_directories( | ||
LovyanGFX_headers INTERFACE | ||
src | ||
) | ||
|
||
#add_compile_definitions | ||
target_compile_definitions(LovyanGFX INTERFACE | ||
USE_PICO_SDK | ||
) | ||
|
||
file(GLOB SRCS | ||
src/lgfx/Fonts/efont/*.c | ||
src/lgfx/Fonts/IPA/*.c | ||
src/lgfx/utility/*.c | ||
src/lgfx/v1/*.cpp | ||
src/lgfx/v1/misc/*.cpp | ||
src/lgfx/v1/panel/*.cpp | ||
src/lgfx/v1/platforms/arduino_default/*.cpp | ||
src/lgfx/v1/platforms/rp2040/*.cpp | ||
src/lgfx/v1/touch/*.cpp | ||
) | ||
target_sources(LovyanGFX INTERFACE ${SRCS}) | ||
target_link_libraries(LovyanGFX INTERFACE | ||
LovyanGFX_headers | ||
pico_stdlib | ||
pico_float | ||
pico_double | ||
hardware_dma | ||
hardware_gpio | ||
hardware_spi | ||
hardware_i2c | ||
hardware_pwm | ||
) | ||
|
||
pico_enable_stdio_usb(LovyanGFX 0) | ||
pico_enable_stdio_uart(LovyanGFX 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# | ||
# Usage: | ||
# | ||
# 1. Copy this directory outside "LovyanGFX" directory | ||
# | ||
# 2. Set variables below (in environment variables or CMakeLists.txt) | ||
# PICO_SDK_PATH | ||
# PICO_PLATFORM (rp2040,rp2350-arm-s) | ||
# PICO_BOARD (optional, "pico", "pico2",...) | ||
# | ||
# 3. Copy "LovyanGFX" directory to this directory) | ||
# | ||
# 4. mkdir and cd build directory | ||
# | ||
# 5. run cmake | ||
# | ||
|
||
set (PROJ_NAME i2c_test) | ||
|
||
cmake_minimum_required(VERSION 3.13) | ||
|
||
if (NOT (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/LovyanGFX)) | ||
message(FATAL_ERROR "Please copy \"LovyanGFX\" directory to \"${CMAKE_CURRENT_SOURCE_DIR}\".") | ||
endif() | ||
|
||
|
||
include(../pico_sdk_import.cmake) | ||
include(../pico_extras_import_optional.cmake) | ||
|
||
project(${PROJ_NAME} | ||
C | ||
CXX | ||
ASM | ||
) | ||
|
||
set(CMAKE_C_STNDARD 11) | ||
set(CMAKE_CXX_STANDARD 17) | ||
|
||
pico_sdk_init() | ||
|
||
add_subdirectory( | ||
LovyanGFX | ||
) | ||
|
||
add_executable(${PROJ_NAME} | ||
main.cpp | ||
) | ||
|
||
target_include_directories(${PROJ_NAME} PRIVATE | ||
. | ||
) | ||
|
||
pico_enable_stdio_usb(${PROJ_NAME} 0) | ||
pico_enable_stdio_uart(${PROJ_NAME} 1) | ||
|
||
pico_add_extra_outputs(${PROJ_NAME}) | ||
|
||
target_link_libraries(${PROJ_NAME} | ||
pico_stdlib | ||
LovyanGFX | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include <LovyanGFX.hpp> | ||
|
||
// SSD1306 (128x64) の接続設定例 | ||
#define TFT_SDA 12 | ||
#define TFT_SCL 13 | ||
#define I2C_PORT 0 | ||
#define I2C_ADDR 0x3c | ||
|
||
class LGFX : public lgfx::LGFX_Device | ||
{ | ||
lgfx::Panel_SSD1306 _panel_instance; | ||
lgfx::Bus_I2C _bus_instance; // I2Cバスのインスタンス | ||
public: | ||
LGFX(void) | ||
{ | ||
{ // バス制御の設定を行います。 | ||
auto cfg = _bus_instance.config(); // バス設定用の構造体を取得します。 | ||
|
||
// I2Cバスの設定 | ||
cfg.i2c_port = I2C_PORT; // 使用するI2Cポートを選択 (0 or 1) | ||
cfg.freq_write = 400000; // 送信時のクロック | ||
cfg.freq_read = 400000; // 受信時のクロック | ||
cfg.pin_sda = TFT_SDA; // SDAを接続しているピン番号 | ||
cfg.pin_scl = TFT_SCL; // SCLを接続しているピン番号 | ||
cfg.i2c_addr = I2C_ADDR; // I2Cデバイスのアドレス | ||
|
||
_bus_instance.config(cfg); // 設定値をバスに反映します。 | ||
_panel_instance.setBus(&_bus_instance); // バスをパネルにセットします。 | ||
} | ||
|
||
{ // 表示パネル制御の設定を行います。 | ||
auto cfg = _panel_instance.config(); // 表示パネル設定用の構造体を取得します。 | ||
|
||
cfg.pin_cs = -1; // CSが接続されているピン番号 (-1 = disable) | ||
cfg.pin_rst = -1; // RSTが接続されているピン番号 (-1 = disable) | ||
cfg.pin_busy = -1; // BUSYが接続されているピン番号 (-1 = disable) | ||
|
||
cfg.panel_width = 128; // 実際に表示可能な幅 | ||
cfg.panel_height = 64; // 実際に表示可能な高さ | ||
//cfg.offset_x = 0; // パネルのX方向オフセット量 | ||
//cfg.offset_y = 0; // パネルのY方向オフセット量 | ||
|
||
// cfg.offset_rotation = 4; // 回転方向の値のオフセット 0~7 (4~7は上下反転) | ||
// cfg.invert = true; // パネルの明暗が反転してしまう場合 trueに設定 | ||
// cfg.rgb_order = true; // パネルの赤と青が入れ替わってしまう場合 trueに設定 | ||
|
||
_panel_instance.config(cfg); | ||
} | ||
|
||
setPanel(&_panel_instance); // 使用するパネルをセットします。 | ||
} | ||
}; |
Oops, something went wrong.