본문 바로가기

RaspberryPi/RaspberryPi PicoW

Raspberry Pi PicoW - HDMI 출력 테스트

 

Raspberry Pi Pico는 정말 저렴하고 성능도 나쁘지 않은 소형 마이크로컨트롤러 이다. 비디오 출력 인터페이스가 내장되어 있지는 않지만  HDMI 비디오 출력을 추가할 수 있다. 정말 못하는것이 없는 물건인것 같다.

 

하드웨어 HDMI 기능은 없지만 Raspberry Pi Pico의 PIO 기능을 이용해서 고속의 출력제어를 할수 있다. Luke Wren 라는 분이  라이브러리로 잘 만들어서 배포하고 있다.

 

 

물론 RAM용량과 속도의 한계로 제한 사항이 있다. STM32F439 EVM - HDMI 출력 테스트 에서 처럼 고해상도 고프레임 출력은 기대 하기 힘들다. 16비트 RGB 출력을 한다면 320x240 정도의 출력 수준으로 생각하면 좋을것 같다.

간단한 문구 출력이나. 해상도가 낮은 HDMI모니터에 이미지 출력 용도로 사용하면 좋을것 같다.

 

Raspberry Pi Pico 확장 테스트 보드에는 HDMI 커넥터가 있어서 쉽게 HDMI 출력 테스트를 해 볼 수 있다.

HDMI 출력 회로는 아래와 같다.

 

 


HDMI출력을 위한 PIO핀 설정은 dvi_serialiser_cfg 구조체에서 할 수 있다.

static const struct dvi_serialiser_cfg pico_exp_cfg = {
	.pio = DVI_DEFAULT_PIO_INST,
	.sm_tmds = {0, 1, 2},
	.pins_tmds = {10, 12, 14},
	.pins_clk = 8,
	.invert_diffpairs = true
};

 

 

HDMI로 이미지 파일을 출력하고 스위치 입력에 따라 화면을 회전시키는 간단한 예제를 작성해 테스트 해 보았다.

#include <PicoDVI.h>                  
#include <Fonts/FreeSansBold18pt7b.h> 
#include "img_rp2040exp.h"

#define SW1_PIN   1

static const struct dvi_serialiser_cfg pico_exp_cfg = {
	.pio = DVI_DEFAULT_PIO_INST,
	.sm_tmds = {0, 1, 2},
	.pins_tmds = {10, 12, 14},
	.pins_clk = 8,
	.invert_diffpairs = true
};

void setup() { // Runs once on startup
  pinMode(SW1_PIN, INPUT_PULLUP);
  Serial.begin(115200);
  if (!display.begin()) { // Blink LED if insufficient RAM
    pinMode(LED_BUILTIN, OUTPUT);
    for (;;) digitalWrite(LED_BUILTIN, (millis() / 500) & 1);
  }
  display.setRotation(1);
      show_bitmap((unsigned short *)img_bmp);
}

uint8_t rotate = 0; // Current screen orientation (0-3)
#define IMAGE_WIDTH     320
#define IMAGE_HIGHT     240

void show_bitmap(unsigned short *img_buf) {
  display.fillScreen(0);

  int x, y;
  int id = 0;
  for(x=0;x<IMAGE_HIGHT;x++)
  {
    for(y=0;y<IMAGE_WIDTH;y++)
    {
      display.drawPixel(x, y, img_buf[id++]);
    }
  }
}

int flag = 0;
void loop() {
  if(!digitalRead(SW1_PIN))
  {
    flag ^= 1;

	if (++rotate > 3) rotate = 0;
    Serial.print("r:");
    Serial.println(rotate);    
    display.setRotation(rotate);
    
    show_bitmap((unsigned short *)img_bmp2);
    delay(300);
  }  
}

 

PicoW HDMI BMP이미지 출력 테스트

 

PicoW HDMI 폰트 출력 테스트

반응형