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

Cannot re-map pins except by Wire #2567

Open
EasyG0ing1 opened this issue Jan 9, 2025 · 1 comment
Open

Cannot re-map pins except by Wire #2567

EasyG0ing1 opened this issue Jan 9, 2025 · 1 comment
Labels

Comments

@EasyG0ing1
Copy link

Hello,

I'm using an RP2040 - specifically the Waveshare RP2040 Zero

This sketch does NOT work (nothing on the display):

#include <Arduino.h>
#include <U8g2lib.h>

U8G2_SSD1309_128X64_NONAME0_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, 13, 12);

void show() {
    static constexpr uint8_t x = 5;
    static constexpr uint8_t y = 30;
    const String msg = "Hello World!";
    u8g2.clearBuffer();
    u8g2.setFont(u8g2_font_6x13_tr);
    u8g2.drawStr(x,y,msg.c_str());
    u8g2.sendBuffer();
}

void setup() {
    u8g2.begin();
    show();
}

void loop() {
}

And this sketch DOES work:

#include <Arduino.h>
#include <U8g2lib.h>
#include <Wire.h>

U8G2_SSD1309_128X64_NONAME0_F_HW_I2C* u8g2;

void show() {
    static constexpr uint8_t x = 5;
    static constexpr uint8_t y = 30;
    const String msg = "Hello World!";
    u8g2->clearBuffer();
    u8g2->setFont(u8g2_font_6x13_tr);
    u8g2->drawStr(x,y,msg.c_str());
    u8g2->sendBuffer();
}

void setup() {
    Wire.setSCL(13);
    Wire.setSDA(12);
    Wire.begin();
    u8g2 = new U8G2_SSD1309_128X64_NONAME0_F_HW_I2C(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
    u8g2->begin();
    show();
}

void loop() {
}

I am wondering if you have any idea why I cannot re-map the pins through the constructor.

Thank you,

Mike

@olikraus
Copy link
Owner

olikraus commented Jan 9, 2025

Indeed remapping is not supported for the RP2050.

I don't have access to an RP2040, but indeed there had been issues in the past, maybe you can check existing issues: https://github.com/olikraus/u8g2/issues?q=is%3Aissue+RP2040

As a workaround, I suggest to use SW I2C:

U8G2_SSD1309_128X64_NONAME0_F_SW_I2C u8g2(U8G2_R0, 13, 12, /* reset=*/ U8X8_PIN_NONE);

Edit: Fixed constructor args

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants