请教:我有一个墨水屏接口与程序不相符,怎么改?谢谢!-Arduino中文社区 - Powered by Discuz!

Arduino中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 1413|回复: 1

请教:我有一个墨水屏接口与程序不相符,怎么改?谢谢!

[复制链接]
发表于 2021-9-9 10:23 | 显示全部楼层 |阅读模式
/* ESP32 e-paper display
  ####################################################################################################################################
*/
#include <SPI.h>               // Built-in
#include "EPD_WaveShare.h"     // Copyright (c) 2017 by Daniel Eichhorn https://github.com/ThingPulse/minigrafx
#include "EPD_WaveShare_42.h"  // Copyright (c) 2017 by Daniel Eichhorn https://github.com/ThingPulse/minigrafx
#include "MiniGrafx.h"         // Copyright (c) 2017 by Daniel Eichhorn https://github.com/ThingPulse/minigrafx
#include "DisplayDriver.h"     // Copyright (c) 2017 by Daniel Eichhorn https://github.com/ThingPulse/minigrafx
#include "qrcode.h"            // Copyright (c) //https://github.com/ricmoo/qrcode/

#define SCREEN_WIDTH  400.0    // Set for landscape mode, don't remove the decimal place!
#define SCREEN_HEIGHT 300.0
#define BITS_PER_PIXEL 1
#define EPD_BLACK 0
#define EPD_WHITE 1
uint16_t palette[] = { 0, 1 };

// pins_arduino.h, e.g. LOLIN32
static const uint8_t EPD_BUSY = 4;
static const uint8_t EPD_SS   = 5;
static const uint8_t EPD_RST  = 16;
static const uint8_t EPD_DC   = 17;
static const uint8_t EPD_SCK  = 18;
static const uint8_t EPD_MISO = 19; // Master-In Slave-Out not used, as no data from display
static const uint8_t EPD_MOSI = 23;

EPD_WaveShare42 epd(EPD_SS, EPD_RST, EPD_DC, EPD_BUSY);
MiniGrafx gfx = MiniGrafx(&epd, BITS_PER_PIXEL, palette);

//################# LIBRARIES ##########################
String version = "1.0";       // Version of this program
//################ VARIABLES  ##########################

QRCode qrcode;

//#########################################################################################
void setup() {
  gfx.init();
  gfx.setRotation(0);
  gfx.fillBuffer(EPD_WHITE);
}

//#########################################################################################
void loop() {
  Display_QRcode(25,75,"Hello World!\n\nG6EJD");
  Display_QRcode(225,75,"http://example.com/");
  gfx.commit();
  delay(120000);
  Clear_Screen();
}

//#########################################################################################
void Display_QRcode(int offset_x, int offset_y, const char* Message){
  #define element_size 4
  // Create the QR code ~120 char maximum
  uint8_t qrcodeData[qrcode_getBufferSize(3)];
  qrcode_initText(&qrcode, qrcodeData, 3, 0, Message);
  for (int y = 0; y < qrcode.size; y++) {
    for (int x = 0; x < qrcode.size; x++) {
      if (qrcode_getModule(&qrcode, x, y)) {
        gfx.setColor(EPD_BLACK);
        gfx.fillRect(x*element_size+offset_x,y*element_size+offset_y,element_size,element_size);
      }
      else
      {
        gfx.setColor(EPD_WHITE);
        gfx.fillRect(x*element_size+offset_x,y*element_size+offset_y,element_size,element_size);
      }
    }
  }
}
//#########################################################################################
void Clear_Screen(){
  gfx.fillBuffer(EPD_WHITE);
  gfx.commit();
  delay(2000);
}




微信图片_20210908110222.jpg
微信图片_20210908110231.jpg
发表于 2021-9-9 21:26 | 显示全部楼层
目测是同时支持I2C和SPI协议的,且二者共用部分引脚
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|Archiver|手机版|Arduino中文社区

GMT+8, 2024-11-28 10:33 , Processed in 0.194846 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表