侧边栏壁纸
博主头像
塞塞哇 博主等级

开源创客

  • 累计撰写 38 篇文章
  • 累计创建 9 个标签
  • 累计收到 9 条评论

目 录CONTENT

文章目录

SES 2.6寸墨水屏驱动程序

塞塞蛙
2023-05-17 / 0 评论 / 0 点赞 / 844 阅读 / 0 字

SES 2.6寸墨水屏驱动程序

本文将介绍如何使用Ses2.6寸的墨水屏驱动显示三色内容。

墨水屏是博主在淘宝上捡垃圾购买的便宜拆机货点亮的效果还不错。

ses26 (2).png

价格便宜又实惠适合个人DIY和学习使用

下面将介绍如何使用Arduino代码进行驱动程序

1. 硬件环境

以 ESP32C3开发版 (合宙)

驱动板是博主自己DIY制作的

下面是使用Vscode进行构建的代码

2. 驱动代码

使用微雪示例官方驱动 : https://www.waveshare.net/wiki/E-Paper_ESP32_Driver_Board

选择驱动包是2.13寸 文件代码: EPD_2IN13BC

不过要修改代码内的尺寸为下面的

152 x 296

#ifndef __EPD_2IN13BC_H_
#define __EPD_2IN13BC_H_

#include "DEV_Config.h"

// Display resolution
#define EPD_2IN13BC_WIDTH       152
#define EPD_2IN13BC_HEIGHT      296

void EPD_2IN13BC_Init(void);
void EPD_2IN13BC_Clear(void);
void EPD_2IN13BC_Display(const UBYTE *blackimage, const UBYTE *ryimage);
void EPD_2IN13BC_Sleep(void);

#endif

main.cpp文件

#include <Arduino.h>
#include <stdlib.h>
#include "DEV_Config.h"
#include "EPD.h"
#include "GUI_Paint.h"
#include "ImageData.h"

void setup() {
    printf("EPD_2IN13BC_test Demo\r\n");
    DEV_Module_Init();

    printf("e-Paper Init and Clear...\r\n");
    EPD_2IN13BC_Init();
    EPD_2IN13BC_Clear();
    DEV_Delay_ms(500);

    // Create a new image cache named IMAGE_BW and fill it with white
    UBYTE *BlackImage, *RYImage;  // Red or Yellow
    UWORD Imagesize =
        ((EPD_2IN13BC_WIDTH % 8 == 0) ? (EPD_2IN13BC_WIDTH / 8)
                                      : (EPD_2IN13BC_WIDTH / 8 + 1)) *
        EPD_2IN13BC_HEIGHT;
    if ((BlackImage = (UBYTE*)malloc(Imagesize)) == NULL) {
        printf("Failed to apply for black memory...\r\n");
        while (1)
            ;
    }
    if ((RYImage = (UBYTE*)malloc(Imagesize)) == NULL) {
        printf("Failed to apply for red memory...\r\n");
        while (1)
            ;
    }
    printf("NewImage:BlackImage and RYImage\r\n");
    Paint_NewImage(BlackImage, EPD_2IN13BC_WIDTH, EPD_2IN13BC_HEIGHT, 270,
                   WHITE);
    Paint_NewImage(RYImage, EPD_2IN13BC_WIDTH, EPD_2IN13BC_HEIGHT, 270, WHITE);

    // Select Image
    Paint_SelectImage(BlackImage);
    Paint_Clear(WHITE);
    Paint_SelectImage(RYImage);
    Paint_Clear(WHITE);

#if 1  // show image for array
    printf("show image for array\r\n");

    EPD_2IN13BC_Display(gImage_2in66bb, gImage_2in66br);
    DEV_Delay_ms(2000);
#endif

#if 1  // Drawing on the image
    /*Horizontal screen*/
    // 1.Draw black image
    printf("Draw black image\r\n");
    Paint_SelectImage(BlackImage);
    Paint_Clear(WHITE);
    Paint_DrawPoint(5, 70, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
    Paint_DrawPoint(5, 80, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
    Paint_DrawLine(20, 70, 50, 100, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
    Paint_DrawLine(50, 70, 20, 100, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
    Paint_DrawRectangle(60, 70, 90, 100, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
    Paint_DrawCircle(125, 85, 15, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
    Paint_DrawString_CN(5, 15, "你好abc", &Font12CN, WHITE, BLACK);

    // 2.Draw red image
    printf("Draw red image\r\n");
    Paint_SelectImage(RYImage);
    Paint_Clear(WHITE);
    Paint_DrawPoint(5, 90, RED, DOT_PIXEL_3X3, DOT_STYLE_DFT);
    Paint_DrawPoint(5, 100, RED, DOT_PIXEL_4X4, DOT_STYLE_DFT);
    Paint_DrawLine(125, 70, 125, 100, RED, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
    Paint_DrawLine(110, 85, 140, 85, RED, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
    Paint_DrawRectangle(20, 70, 50, 100, RED, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
    Paint_DrawCircle(165, 85, 15, RED, DOT_PIXEL_1X1, DRAW_FILL_FULL);
    Paint_DrawString_EN(5, 0, "waveshare Electronics", &Font12, BLACK, WHITE);
    Paint_DrawNum(5, 50, 987654321, &Font16, WHITE, RED);

    printf("EPD_Display\r\n");
    EPD_2IN13BC_Display(BlackImage, RYImage);
    DEV_Delay_ms(2000);
#endif

    printf("Clear...\r\n");
    EPD_2IN13BC_Clear();

    printf("Goto Sleep...\r\n");
    EPD_2IN13BC_Sleep();
    free(BlackImage);
    free(RYImage);
    BlackImage = NULL;
    RYImage = NULL;
}

void loop() {}

运行点亮后的效果

ses26 (1).png

0
  1. 支付宝打赏

    qrcode alipay
  2. 微信打赏

    qrcode weixin

评论区