Portenta H7 보드를 사용하여 I2C 동작 테스트를 해 보았습니다.
Portenta 보드의 I2C 포트는 아래 이미지의 2개의 포트 중 아무 포트나 사용하면 됩니다.
왼쪽에 있는 포트는 아래와 같은 특별한 커넥터가 있어야 사용 할 수 있습니다.
반면에 가운데 포트는 일반적으로 많이 사용하는 점퍼선을 꽂아서 사용할 수 있습니다.
물론 점퍼를 꽂을 수 있는 커넥터가 납땜되어져 있어야 합니다.
제 경우에는 아래와 같이 헤더핀을 연결하여 브레드보드에 꽂아서 사용하고 있습니다.
OLED와 Portenta 보드를 아래 그림과 같이 I2C로 연결하였습니다.
하드웨어적으로 연결을 시켰으니 소프트웨어를 사용하기 위해 OLED용 SSD1306 라이브러리를 설치해야 합니다.
먼저 Arudino IDE를 실행한 후 라이브러리 매니저에서 adafruit ssd1306 검색어로 검색을 합니다.
검색 결과 리스트의 맨 윗쪽에 검색된 라이브러리가 있습니다. 설치합니다.
제 경우에는 이미 설치가 되어 있어서 INSTALLED 라고 나옵니다.
설치가 완료되면 제공되는 예제 중 ssd1306_128x64_i2c.ino 를 참고하여 사용자 이미지를 디스플레이하려고 합니다.
소스코드를 살펴보니 이미지를 디스플레이 하기 위해서는 아래 코드만 적용하면 될것 같습니다.
display.clearDisplay();
display.drawBitmap(
(display.width() - logo_width ) / 2,
(display.height() - logo_height) / 2,
logo_data, logo_width, logo_height, 1);
display.display();
아래는 테스트용으로 사용하기 위해 128x64 크기의 이미지를 만들어 보았습니다.
이 이미지를 바로는 사용할 수 없고 이미지를 텍스트 형태로 변화해서 소스코드에 추가해 줘야 합니다.
설치된 Adafruit_SSD1306 라이브러리 폴더안에 scripts 폴더가 있는데 그 안을 살펴보면 make_splash.py 파일이 있습니다. 이 파일은 파이선을 사용하여 이미지를 아래와 같은 바이트 배열 형태로 변환 시켜주는 파일입니다.
이 파일을 사용하여 제가 만든 이미지를 변환시켜 보았습니다.
자세히 보시면 문자로 변환되어지만 배열상에 이미지가 보입니다.
#define logo_width 128
#define logo_height 64
const uint8_t PROGMEM logo_data[] = {
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B11111111,B11110000,B00000111,B11111111,B11111111,B11111111,B11111111,B11000000,B00011111,B11111111,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B11111111,B10000000,B00000000,B11111111,B11111111,B11111111,B11111110,B00000000,B00000011,B11111111,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B11111110,B00000000,B00000000,B00011111,B11111111,B11111111,B11110000,B00000000,B00000000,B01111111,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B11110000,B00000000,B00000000,B00000111,B11111111,B11111111,B11000000,B00000000,B00000000,B00011111,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B11100000,B00000000,B00000000,B00000011,B11111111,B11111111,B10000000,B00000000,B00000000,B00001111,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B11000000,B00000000,B00000000,B00000000,B11111111,B11111110,B00000000,B00000000,B00000000,B00000011,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B00000000,B00000000,B00000000,B00000000,B01111111,B11111100,B00000000,B00000000,B00000000,B00000001,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B00000000,B00000000,B00000000,B00000000,B00111111,B11111000,B00000000,B00000000,B00000000,B00000000,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111110,B00000000,B00011111,B11111100,B00000000,B00011111,B11110000,B00000000,B01111111,B11110000,B00000000,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111100,B00000000,B01111111,B11111111,B10000000,B00001111,B11100000,B00000001,B11111111,B11111110,B00000000,B01111111,B11111111,B11111111,
B11111111,B11111111,B11111000,B00000001,B11111111,B11111111,B11000000,B00000111,B11000000,B00000111,B11111111,B11111111,B00000000,B00111111,B11111111,B11111111,
B11111111,B11111111,B11111000,B00000011,B11111111,B11111111,B11100000,B00000011,B11000000,B00001111,B11111111,B11111111,B10000000,B00111111,B11111111,B11111111,
B11111111,B11111111,B11110000,B00000111,B11111111,B11111111,B11110000,B00000011,B10000000,B00011111,B11111111,B11111111,B11000000,B00011111,B11111111,B11111111,
B11111111,B11111111,B11110000,B00001111,B11111111,B11111111,B11111000,B00000001,B00000000,B00111111,B11111111,B11111111,B11100000,B00011111,B11111111,B11111111,
B11111111,B11111111,B11100000,B00001111,B11111111,B11111111,B11111100,B00000000,B00000000,B01111111,B11111111,B11111111,B11110000,B00001111,B11111111,B11111111,
B11111111,B11111111,B11100000,B00011111,B11111111,B11111111,B11111110,B00000000,B00000000,B11111111,B11100000,B11111111,B11110000,B00001111,B11111111,B11111111,
B11111111,B11111111,B11100000,B00011111,B11111111,B11111111,B11111111,B00000000,B00000001,B11111111,B11100000,B11111111,B11111000,B00001111,B11111111,B11111111,
B11111111,B11111111,B11100000,B00111111,B11111111,B11111111,B11111111,B10000000,B00000011,B11111111,B11100000,B11111111,B11111000,B00000111,B11111111,B11111111,
B11111111,B11111111,B11000000,B00111111,B11111111,B11111111,B11111111,B10000000,B00000011,B11111111,B00000000,B00001111,B11111000,B00000111,B11111111,B11111111,
B11111111,B11111111,B11000000,B00111111,B11000000,B00000000,B11111111,B11000000,B00000111,B11111110,B00000000,B00001111,B11111000,B00000111,B11111111,B11111111,
B11111111,B11111111,B11000000,B00111111,B11000000,B00000000,B11111111,B11100000,B00001111,B11111110,B00000000,B00001111,B11111000,B00000111,B11111111,B11111111,
B11111111,B11111111,B11000000,B00111111,B11000000,B00000000,B11111111,B11100000,B00001111,B11111110,B00000000,B00001111,B11111000,B00000111,B11111111,B11111111,
B11111111,B11111111,B11000000,B00111111,B11000000,B00000000,B11111111,B11000000,B00000111,B11111110,B00000000,B00001111,B11111000,B00000111,B11111111,B11111111,
B11111111,B11111111,B11000000,B00111111,B11111111,B11111111,B11111111,B11000000,B00000011,B11111111,B11100000,B11111111,B11111000,B00000111,B11111111,B11111111,
B11111111,B11111111,B11000000,B00111111,B11111111,B11111111,B11111111,B10000000,B00000011,B11111111,B11100000,B11111111,B11111000,B00000111,B11111111,B11111111,
B11111111,B11111111,B11100000,B00111111,B11111111,B11111111,B11111111,B00000000,B00000001,B11111111,B11100000,B11111111,B11111000,B00001111,B11111111,B11111111,
B11111111,B11111111,B11100000,B00011111,B11111111,B11111111,B11111111,B00000000,B00000000,B11111111,B11100000,B11111111,B11110000,B00001111,B11111111,B11111111,
B11111111,B11111111,B11100000,B00011111,B11111111,B11111111,B11111110,B00000000,B00000000,B11111111,B11111111,B11111111,B11110000,B00001111,B11111111,B11111111,
B11111111,B11111111,B11110000,B00001111,B11111111,B11111111,B11111100,B00000000,B00000000,B01111111,B11111111,B11111111,B11100000,B00001111,B11111111,B11111111,
B11111111,B11111111,B11110000,B00000111,B11111111,B11111111,B11111000,B00000001,B00000000,B00111111,B11111111,B11111111,B11100000,B00011111,B11111111,B11111111,
B11111111,B11111111,B11110000,B00000111,B11111111,B11111111,B11110000,B00000011,B10000000,B00011111,B11111111,B11111111,B11000000,B00011111,B11111111,B11111111,
B11111111,B11111111,B11111000,B00000011,B11111111,B11111111,B11100000,B00000111,B11000000,B00001111,B11111111,B11111111,B10000000,B00111111,B11111111,B11111111,
B11111111,B11111111,B11111100,B00000000,B11111111,B11111111,B11000000,B00001111,B11100000,B00000111,B11111111,B11111111,B00000000,B00111111,B11111111,B11111111,
B11111111,B11111111,B11111100,B00000000,B00111111,B11111111,B00000000,B00001111,B11100000,B00000001,B11111111,B11111100,B00000000,B01111111,B11111111,B11111111,
B11111111,B11111111,B11111110,B00000000,B00001111,B11111100,B00000000,B00011111,B11110000,B00000000,B01111111,B11100000,B00000000,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B00000000,B00000000,B00000000,B00000000,B00111111,B11111000,B00000000,B00000000,B00000000,B00000001,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B10000000,B00000000,B00000000,B00000000,B01111111,B11111100,B00000000,B00000000,B00000000,B00000011,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B11000000,B00000000,B00000000,B00000000,B11111111,B11111110,B00000000,B00000000,B00000000,B00000111,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B11110000,B00000000,B00000000,B00000011,B11111111,B11111111,B10000000,B00000000,B00000000,B00001111,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B11111000,B00000000,B00000000,B00000111,B11111111,B11111111,B11000000,B00000000,B00000000,B00111111,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B11111110,B00000000,B00000000,B00011111,B11111111,B11111111,B11110000,B00000000,B00000000,B11111111,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B11111111,B11000000,B00000000,B11111111,B11111111,B11111111,B11111110,B00000000,B00000111,B11111111,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B11111111,B11111110,B00011111,B11111111,B11111111,B11111111,B11111111,B11110000,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111111,B11111111,B11110011,B11111111,B00111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11110001,B11111111,B11110011,B11111111,B00111111,B11111111,B11111110,B00001111,B11111111,B11110011,B11111111,B11111111,B10011111,B11111111,B00111001,B00000011,
B11110001,B11111111,B11110011,B11111111,B11111111,B11111111,B11111110,B01100111,B11111111,B11110011,B11111111,B11111111,B10011111,B11111111,B00111001,B11110011,
B11100100,B11100001,B10000011,B00110011,B00110000,B01111000,B01111110,B01100111,B00001110,B00000000,B11000011,B10000011,B00000100,B00111111,B00111001,B11100111,
B11100100,B11100111,B00110011,B00110011,B00110011,B00110011,B00111110,B01100110,B01100110,B01110011,B10011001,B10011001,B10011011,B10011111,B00111001,B11100111,
B11001110,B01100111,B00110011,B00110011,B00110011,B00110011,B00111110,B01100110,B01100110,B01110011,B10011001,B10011001,B10011111,B10011111,B00000001,B11001111,
B11001110,B01100111,B00110011,B00110011,B00110011,B00110011,B00111110,B00001110,B01100110,B01110011,B10000001,B10011001,B10011100,B00011111,B00111001,B11001111,
B11000000,B01100111,B00110011,B00110011,B00110011,B00110011,B00111110,B01111110,B01100110,B01110011,B10011111,B10011001,B10011001,B10011111,B00111001,B11001111,
B10011111,B00100111,B00110011,B00110011,B00110011,B00110011,B00111110,B01111110,B01100110,B01110011,B10011101,B10011001,B10011001,B10011111,B00111001,B10011111,
B10011111,B00100111,B10000011,B10000011,B00110011,B00111000,B01111110,B01111111,B00001110,B01111000,B11000011,B10011001,B11000100,B00011111,B00111001,B10011111,
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
};
제공된 예제 소스와 위 2개의 소스 코드를 참고하여 테스트용 예제 파일을 작성 후 업로드를 해 보았습니다.
I2C가 정상적으로 동작되어 변환된 이미지를 잘 보여줍니다.
'Hardware > Arduino ( AVR )' 카테고리의 다른 글
[아두이노] Micro SD 카드 사용하기 (0) | 2022.02.14 |
---|---|
[Portenta H7] BLE 테스트 (0) | 2021.10.27 |
[Portenta H7] 업로드가 안되는 경우 보드 복구 방법 (0) | 2021.10.21 |
[Portenta H7] Wi-Fi Access Point로 사용하기 (0) | 2021.10.20 |
[Portenta H7] WiFi 예제 업로드시 에러가 발생될 경우 (0) | 2021.10.19 |
댓글