Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pico-sdk example #626

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples_for_picosdk/spi/LGFX_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ class LGFX : public lgfx::LGFX_Device
_panel_instance.config(cfg);
}

#if USE_BACKLIGHT
#ifdef USE_BACKLIGHT
{ // バックライト制御の設定を行います。(必要なければ削除)
auto cfg = _light_instance.config(); // バックライト設定用の構造体を取得します。

cfg.pin_bl = TFT_BLK // バックライトが接続されているピン番号
cfg.pin_bl = TFT_BLK; // バックライトが接続されているピン番号
cfg.invert = false; // バックライトの輝度を反転させる場合 true
cfg.freq = 44100; // バックライトのPWM周波数
cfg.pwm_channel = 6; // 使用するPWMのチャンネル番号
Expand Down
22 changes: 21 additions & 1 deletion src/lgfx/v1/platforms/rp2040/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,24 @@ namespace lgfx
};
constexpr int n_spi = std::extent<decltype(spi_dev), 0>::value;

#if defined(PICO_RP2350)
// RP2350 Dataheetの 9.4. Function Select (Table 642)を参照
// ※30以降は2350Bで使用可能
constexpr uint8_t spi0_sclk_pinlist[] = { 2, 6, 18, 22, 34, 38, UINT8_MAX };
constexpr uint8_t spi0_miso_pinlist[] = { 0, 4, 16, 20, 32, 36, UINT8_MAX };
constexpr uint8_t spi0_mosi_pinlist[] = { 3, 7, 19, 23, 35, 39, UINT8_MAX };
constexpr uint8_t spi1_sclk_pinlist[] = { 10, 14, 26, 30, 42, 46, UINT8_MAX };
constexpr uint8_t spi1_miso_pinlist[] = { 8, 12, 24, 28, 40, 44, UINT8_MAX };
constexpr uint8_t spi1_mosi_pinlist[] = { 11, 15, 27, 31, 43, 47, UINT8_MAX };
#else
// RP2040 Dataheetの 1.4.3. GPIO Functions Table 2を参照
constexpr uint8_t spi0_sclk_pinlist[] = { 2, 6, 18, 23, UINT8_MAX };
constexpr uint8_t spi0_sclk_pinlist[] = { 2, 6, 18, 22, UINT8_MAX };
constexpr uint8_t spi0_miso_pinlist[] = { 0, 4, 16, 20, UINT8_MAX };
constexpr uint8_t spi0_mosi_pinlist[] = { 3, 7, 19, 23, UINT8_MAX };
constexpr uint8_t spi1_sclk_pinlist[] = { 10, 14, 26, UINT8_MAX };
constexpr uint8_t spi1_miso_pinlist[] = { 8, 12, 24, 28, UINT8_MAX };
constexpr uint8_t spi1_mosi_pinlist[] = { 11, 15, 27, UINT8_MAX };
#endif

constexpr uint32_t PRESCALE_ERROR = UINT32_MAX;

Expand Down Expand Up @@ -506,11 +517,20 @@ namespace lgfx
};
constexpr int n_i2c = std::extent<decltype(i2c_dev), 0>::value;

#if defined(PICO_RP2350)
// RP2350 Dataheetの 9.4. Function Select (Table 642)を参照
// ※30以降は2350Bで使用可能
constexpr uint8_t i2c0_sda_pinlist[] = { 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, UINT8_MAX };
constexpr uint8_t i2c0_sck_pinlist[] = { 1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, UINT8_MAX };
constexpr uint8_t i2c1_sda_pinlist[] = { 2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, UINT8_MAX };
constexpr uint8_t i2c1_sck_pinlist[] = { 3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, UINT8_MAX };
#else
// RP2040 Dataheetの 1.4.3. GPIO Functions Table 2を参照
constexpr uint8_t i2c0_sda_pinlist[] = { 0, 4, 8, 12, 16, 20, 24, 28, UINT8_MAX };
constexpr uint8_t i2c0_sck_pinlist[] = { 1, 5, 9, 13, 17, 21, 25, 29, UINT8_MAX };
constexpr uint8_t i2c1_sda_pinlist[] = { 2, 6, 10, 14, 18, 22, 26, UINT8_MAX };
constexpr uint8_t i2c1_sck_pinlist[] = { 3, 7, 11, 15, 19, 23, 27, UINT8_MAX };
#endif

constexpr struct i2c_pinlist_str {
const uint8_t *sda_pinlist;
Expand Down
Loading