0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Raspberry Pi Pico用 2.66インチ e-Paper

0
Last updated at Posted at 2026-04-05

概要

買ってて忘れてたので、使ってみた。
Raspberry pi pico2をつけて試してみる。

ここに製品の情報は詳しく載っている。

サンプルを試す

前提として、
https://github.com/raspberrypi/pico-sdk.git
をgit cloneして、PICO_SDK_PATHの環境変数にそのパスを設定していること。

前述のWikiのDownload Demo codesを試す。

cd ~
git clone https://github.com/waveshare/Pico_ePaper_Code.git
cd ~/Pico_ePaper_Code

ここにあるReadmeEN.txtの通りに、main.cの

EPD_2in66b_test();  

を有効にすること。あと最後に

EPD_2IN66B_Clear(); 
DEV_Module_Exit();

をコールして画面をクリアするほうが良いと思う。

関数の変更ができたら以下でビルドする。

$ mkdir build
$ cd build
$ cmake ..
$ make -j4

できたepd.uf2をRaspberry pi2のBOOTSEL押したまま起動してコピーして、デモを書き込む。
すると、商品ページの表示やその他のデモが一通り表示される。
結構点滅してなかなか表示されないので、根気よく待つこと。

表示を変える

#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include "EPD_2in66b.h"
#include "EPD_Test.h"   //Examples


void draw_screen(UBYTE *BlackImage);

int main(void)
{
  DEV_Module_Init();
  printf("test start \n");
  EPD_2IN66B_Init();
  EPD_2IN66B_Clear();
  DEV_Delay_ms(500);

  UBYTE *BlackImage, *RedImage;
  UWORD Imagesize = ((EPD_2IN66B_WIDTH % 8 == 0)? (EPD_2IN66B_WIDTH / 8 ): (EPD_2IN66B_WIDTH / 8 + 1)) * EPD_2IN66B_HEIGHT;
  if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
    printf("Failed to apply for black memory...\r\n");
    return -1;
  }
  if((RedImage = (UBYTE *)malloc(Imagesize)) == NULL) {
    printf("Failed to apply for red memory...\r\n");
    return -1;
  }
  printf("Paint_NewImage\r\n");
  Paint_NewImage(BlackImage, EPD_2IN66B_WIDTH, EPD_2IN66B_HEIGHT, 270, WHITE);
  //Paint_Clear(WHITE);
  Paint_NewImage(RedImage, EPD_2IN66B_WIDTH, EPD_2IN66B_HEIGHT, 270, WHITE);
  //Paint_Clear(WHITE);

  draw_screen(BlackImage);

  /* 赤は未使用ならクリアだけ */
  Paint_SelectImage(RedImage);
  Paint_Clear(WHITE);

  EPD_2IN66B_Display(BlackImage, RedImage);

  DEV_Delay_ms(10000);

  EPD_2IN66B_Clear();
  
  free(BlackImage);
  BlackImage = NULL;
  free(RedImage);
  RedImage = NULL;
	
  DEV_Delay_ms(2000);//important, at least 2s
  // close 5V
  printf("close 5V, Module enters 0 power consumption ...\r\n");
  DEV_Module_Exit();

  
  return 0;
  
}

void draw_screen(UBYTE *BlackImage)
{
    char line1[64];
    char line2[64];

    /* 時刻取得(簡易:uptimeベースでもOK) */
    time_t t = time(NULL);
    struct tm *tm_info = localtime(&t);

    /* 曜日 */
    const char *wday[] = {"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};

    /* 1行目:日時 */
    snprintf(line1, sizeof(line1),
        "%04d/%02d/%02d (%s) %02d:%02d:%02d",
        tm_info->tm_year + 1900,
        tm_info->tm_mon + 1,
        tm_info->tm_mday,
        wday[tm_info->tm_wday],
        tm_info->tm_hour,
        tm_info->tm_min,
        tm_info->tm_sec
    );

    /* 2行目:固定文字 */
    snprintf(line2, sizeof(line2),
        "Hankyu-Densya:on-site");

    /* 描画開始 */
    Paint_SelectImage(BlackImage);
    Paint_Clear(WHITE);

    /* フォントに応じて座標調整 */
    Paint_DrawString_EN(10, 30, line1, &Font16, WHITE, BLACK);
    Paint_DrawString_EN(10, 80, line2, &Font16, WHITE, BLACK);
}

これをmain.cにして、さっきと同じようにビルドする。
CMakeLists.txtに

include_directories(./lib/e-Paper)  

を追加して、#include "EPD_2in66b.h"がみつかるようにすること。

これでできたuf2を書くと、
image.png

こんな感じで表示できた。

次回はUARTかI2Cで外からトリガーを与えて、表示を変えてみる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?