Add 7.3inch e-Paper (F) programs for stm32 and arduino.

This commit is contained in:
SSYYL 2022-10-22 15:25:33 +08:00
parent b578b5047f
commit 469a2551a0
23 changed files with 26164 additions and 1154 deletions

View file

@ -0,0 +1,300 @@
/*****************************************************************************
* | File : EPD_7in3f.c
* | Author : Waveshare team
* | Function : 7.3inch e-Paper (F)
* | Info :
*----------------
* | This version: V1.0
* | Date : 2022-10-21
* | Info :
* -----------------------------------------------------------------------------
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documnetation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
******************************************************************************/
#include <stdlib.h>
#include "epd7in3f.h"
#include "imagedata.h"
Epd::~Epd() {
};
Epd::Epd() {
reset_pin = RST_PIN;
dc_pin = DC_PIN;
cs_pin = CS_PIN;
busy_pin = BUSY_PIN;
width = EPD_WIDTH;
height = EPD_HEIGHT;
};
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
int Epd::Init(void) {
if (IfInit() != 0) {
return -1;
}
Reset();
DelayMs(20);
EPD_7IN3F_BusyHigh();
SendCommand(0xAA); // CMDH
SendData(0x49);
SendData(0x55);
SendData(0x20);
SendData(0x08);
SendData(0x09);
SendData(0x18);
SendCommand(0x01);
SendData(0x3F);
SendData(0x00);
SendData(0x32);
SendData(0x2A);
SendData(0x0E);
SendData(0x2A);
SendCommand(0x00);
SendData(0x5F);
SendData(0x69);
SendCommand(0x03);
SendData(0x00);
SendData(0x54);
SendData(0x00);
SendData(0x44);
SendCommand(0x05);
SendData(0x40);
SendData(0x1F);
SendData(0x1F);
SendData(0x2C);
SendCommand(0x06);
SendData(0x6F);
SendData(0x1F);
SendData(0x16);
SendData(0x25);
SendCommand(0x08);
SendData(0x6F);
SendData(0x1F);
SendData(0x1F);
SendData(0x22);
SendCommand(0x13); // IPC
SendData(0x00);
SendData(0x04);
SendCommand(0x30);
SendData(0x02);
SendCommand(0x41); // TSE
SendData(0x00);
SendCommand(0x50);
SendData(0x3F);
SendCommand(0x60);
SendData(0x02);
SendData(0x00);
SendCommand(0x61);
SendData(0x03);
SendData(0x20);
SendData(0x01);
SendData(0xE0);
SendCommand(0x82);
SendData(0x1E);
SendCommand(0x84);
SendData(0x00);
SendCommand(0x86); // AGID
SendData(0x00);
SendCommand(0xE3);
SendData(0x2F);
SendCommand(0xE0); // CCSET
SendData(0x00);
SendCommand(0xE6); // TSSET
SendData(0x00);
return 0;
}
/**
* @brief: basic function for sending commands
*/
void Epd::SendCommand(unsigned char command) {
DigitalWrite(dc_pin, LOW);
SpiTransfer(command);
}
/**
* @brief: basic function for sending data
*/
void Epd::SendData(unsigned char data) {
DigitalWrite(dc_pin, HIGH);
SpiTransfer(data);
}
void Epd::EPD_7IN3F_BusyHigh(void)// If BUSYN=0 then waiting
{
while(!DigitalRead(BUSY_PIN)) {
DelayMs(1);
}
}
/**
* @brief: module reset.
* often used to awaken the module in deep sleep,
* see Epd::Sleep();
*/
void Epd::Reset(void) {
DigitalWrite(reset_pin, HIGH);
DelayMs(20);
DigitalWrite(reset_pin, LOW); //module reset
DelayMs(1);
DigitalWrite(reset_pin, HIGH);
DelayMs(20);
}
void Epd::TurnOnDisplay(void) {
SendCommand(0x04); // POWER_ON
EPD_7IN3F_BusyHigh();
SendCommand(0x12); // DISPLAY_REFRESH
SendData(0x00);
EPD_7IN3F_BusyHigh();
SendCommand(0x02); // POWER_OFF
SendData(0x00);
EPD_7IN3F_BusyHigh();
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void Epd::EPD_7IN3F_Display(const UBYTE *image) {
unsigned long i,j;
SendCommand(0x10);
for(i=0; i<height; i++) {
for(j=0; j<width/2; j++) {
SendData(image[j + width*i]);
}
}
TurnOnDisplay();
}
/******************************************************************************
function : Sends the part image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void Epd::EPD_7IN3F_Display_part(const UBYTE *image, UWORD xstart, UWORD ystart,
UWORD image_width, UWORD image_heigh)
{
unsigned long i,j;
SendCommand(0x10);
for(i=0; i<height; i++) {
for(j=0; j< width/2; j++) {
if(i<image_heigh+ystart && i>=ystart && j<(image_width+xstart)/2 && j>=xstart/2) {
SendData(pgm_read_byte(&image[(j-xstart/2) + (image_width/2*(i-ystart))]));
}
else {
SendData(0x11);
}
}
}
TurnOnDisplay();
}
/******************************************************************************
function : show 7 kind of color block
parameter:
******************************************************************************/
void Epd::EPD_7IN3F_Show7Block(void)
{
unsigned long i, j, k;
unsigned char const Color_seven[8] =
{EPD_7IN3F_BLACK, EPD_7IN3F_BLUE, EPD_7IN3F_GREEN, EPD_7IN3F_ORANGE,
EPD_7IN3F_RED, EPD_7IN3F_YELLOW, EPD_7IN3F_WHITE, EPD_7IN3F_WHITE};
SendCommand(0x10);
for(i=0; i<240; i++) {
for(k = 0 ; k < 4; k ++) {
for(j = 0 ; j < 100; j ++) {
SendData((Color_seven[k]<<4) |Color_seven[k]);
}
}
}
for(i=0; i<240; i++) {
for(k = 4 ; k < 8; k ++) {
for(j = 0 ; j < 100; j ++) {
SendData((Color_seven[k]<<4) |Color_seven[k]);
}
}
}
TurnOnDisplay();
}
/******************************************************************************
function :
Clear screen
******************************************************************************/
void Epd::Clear(UBYTE color) {
SendCommand(0x10);
for(int i=0; i<width/2; i++) {
for(int j=0; j<height; j++) {
SendData((color<<4)|color);
}
}
TurnOnDisplay();
}
/**
* @brief: After this command is transmitted, the chip would enter the
* deep-sleep mode to save power.
* The deep sleep mode would return to standby by hardware reset.
* The only one parameter is a check code, the command would be
* You can use EPD_Reset() to awaken
*/
void Epd::Sleep(void) {
SendCommand(0x07);
SendData(0xA5);
DelayMs(10);
DigitalWrite(RST_PIN, 0); // Reset
}
/* END OF FILE */

View file

@ -0,0 +1,85 @@
/*****************************************************************************
* | File : EPD_7in3f.h
* | Author : Waveshare team
* | Function : 7.3inch e-paper F
* | Info :
*----------------
* | This version: V1.0
* | Date : 2022-10-21
* | Info :
* -----------------------------------------------------------------------------
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documnetation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
******************************************************************************/
#ifndef __EPD_7IN3F_H__
#define __EPD_7IN3F_H__
#include "epdif.h"
// Display resolution
#define EPD_WIDTH 800
#define EPD_HEIGHT 480
#define UWORD unsigned int
#define UBYTE unsigned char
#define UDOUBLE unsigned long
/**********************************
Color Index
**********************************/
#define EPD_7IN3F_BLACK 0x0 /// 000
#define EPD_7IN3F_WHITE 0x1 /// 001
#define EPD_7IN3F_GREEN 0x2 /// 010
#define EPD_7IN3F_BLUE 0x3 /// 011
#define EPD_7IN3F_RED 0x4 /// 100
#define EPD_7IN3F_YELLOW 0x5 /// 101
#define EPD_7IN3F_ORANGE 0x6 /// 110
#define EPD_7IN3F_CLEAN 0x7 /// 111 unavailable Afterimage
class Epd : EpdIf {
public:
Epd();
~Epd();
int Init(void);
void EPD_7IN3F_BusyHigh(void);
void TurnOnDisplay(void);
void Reset(void);
void EPD_7IN3F_Display(const UBYTE *image);
void EPD_7IN3F_Display_part(const UBYTE *image, UWORD xstart, UWORD ystart,
UWORD image_width, UWORD image_heigh);
void EPD_7IN3F_Show7Block(void);
void SendCommand(unsigned char command);
void SendData(unsigned char data);
void Sleep(void);
void Clear(UBYTE color);
private:
unsigned int reset_pin;
unsigned int dc_pin;
unsigned int cs_pin;
unsigned int busy_pin;
unsigned long width;
unsigned long height;
};
#endif /* EPD5IN83B_HD_H */
/* END OF FILE */

View file

@ -0,0 +1,57 @@
/**
@filename : EPD_7in3f.ino
@brief : EPD_7in3 e-paper F display demo
@author : Waveshare
Copyright (C) Waveshare 10 21 2022
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documnetation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <SPI.h>
#include "imagedata.h"
#include "epd7in3f.h"
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Epd epd;
if (epd.Init() != 0) {
Serial.print("e-Paper init failed");
return;
}
Serial.print("e-Paper Clear\r\n ");
epd.Clear(EPD_7IN3F_WHITE);
Serial.print("Show pic\r\n ");
epd.EPD_7IN3F_Display_part(gImage_7in3f, 250, 150, 300, 180);
delay(2000);
Serial.print("draw 7 color block\r\n ");
epd.EPD_7IN3F_Show7Block();
delay(2000);
epd.Sleep();
}
void loop() {
// put your main code here, to run repeatedly:
}

View file

@ -0,0 +1,65 @@
/**
* @filename : epdif.cpp
* @brief : Implements EPD interface functions
* Users have to implement all the functions in epdif.cpp
* @author : Yehui from Waveshare
*
* Copyright (C) Waveshare August 10 2017
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documnetation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "epdif.h"
#include <spi.h>
EpdIf::EpdIf() {
};
EpdIf::~EpdIf() {
};
void EpdIf::DigitalWrite(int pin, int value) {
digitalWrite(pin, value);
}
int EpdIf::DigitalRead(int pin) {
return digitalRead(pin);
}
void EpdIf::DelayMs(unsigned int delaytime) {
delay(delaytime);
}
void EpdIf::SpiTransfer(unsigned char data) {
digitalWrite(CS_PIN, LOW);
SPI.transfer(data);
digitalWrite(CS_PIN, HIGH);
}
int EpdIf::IfInit(void) {
pinMode(CS_PIN, OUTPUT);
pinMode(RST_PIN, OUTPUT);
pinMode(DC_PIN, OUTPUT);
pinMode(BUSY_PIN, INPUT);
SPI.begin();
SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE0));
return 0;
}

51
Arduino/epd7in3f/epdif.h Normal file
View file

@ -0,0 +1,51 @@
/**
* @filename : epdif.h
* @brief : Header file of epdif.cpp providing EPD interface functions
* Users have to implement all the functions in epdif.cpp
* @author : Yehui from Waveshare
*
* Copyright (C) Waveshare August 10 2017
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documnetation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef EPDIF_H
#define EPDIF_H
#include <arduino.h>
// Pin definition
#define RST_PIN 8
#define DC_PIN 9
#define CS_PIN 10
#define BUSY_PIN 7
class EpdIf {
public:
EpdIf(void);
~EpdIf(void);
static int IfInit(void);
static void DigitalWrite(int pin, int value);
static int DigitalRead(int pin);
static void DelayMs(unsigned int delaytime);
static void SpiTransfer(unsigned char data);
};
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,28 @@
/**
* @filename : imagedata.h
* @brief : head file for imagedata.cpp
*
* Copyright (C) Waveshare July 8 2020
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documnetation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
extern const unsigned char gImage_7in3f[];
/* FILE END */