first commit

This commit is contained in:
KacperLa 2026-01-15 10:21:39 -05:00
commit 9005e49d82
3071 changed files with 1941927 additions and 0 deletions

View file

@ -0,0 +1,356 @@
/**
* @filename : epd5in79.h
* @brief : Header file for e-paper library epd5in83.cpp
* @author : MyMX from Waveshare
*
* Copyright (C) Waveshare 2024/03/06
*
* 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 "epd5in79.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;
};
int Epd::Init(void) {
if (IfInit() != 0) {
return -1;
}
Reset();
ReadBusy(); //waiting for the electronic paper IC to release the idle signal
SendCommand(0x12); //POWER ON
ReadBusy(); //waiting for the electronic paper IC to release the idle signal
SendCommand(0x11);
SendData(0x01);
SendCommand(0x44); // Set Ram X- address Start / End position
SendData(0x00); // XStart, POR = 00h
SendData(0x31); //400/8-1
SendCommand(0x45); // Set Ram Y- address Start / End position
SendData(0x0f);
SendData(0x01); //300-1
SendData(0x00); // YEnd L
SendData(0x00); // YEnd H
SendCommand(0x4e);
SendData(0x00);
SendCommand(0x4f);
SendData(0x0f);
SendData(0x01);
ReadBusy();
SendCommand(0x91);
SendData(0x00);
SendCommand(0xC4); // Set Ram X- address Start / End position
SendData(0x31); // XStart, POR = 00h
SendData(0x00); //400/8-1
SendCommand(0xC5); // Set Ram Y- address Start / End position
SendData(0x0f);
SendData(0x01); //300-1
SendData(0x00); // YEnd L
SendData(0x00); // YEnd H
SendCommand(0xCE);
SendData(0x31);
SendCommand(0xCF);
SendData(0x0f);
SendData(0x01);
ReadBusy();
return 0;
}
int Epd::Init_Fast(void) {
if (IfInit() != 0) {
return -1;
}
Reset();
ReadBusy(); //waiting for the electronic paper IC to release the idle signal
SendCommand(0x12); //POWER ON
ReadBusy(); //waiting for the electronic paper IC to release the idle signal
SendCommand(0x18); //Read built-in temperature sensor
SendData(0x80);
SendCommand(0x22); // Load temperature value
SendData(0xB1);
SendCommand(0x20);
ReadBusy();
SendCommand(0x1A); // Write to temperature register
SendData(0x64);
SendData(0x00);
SendCommand(0x22); // Load temperature value
SendData(0x91);
SendCommand(0x20);
ReadBusy();
SendCommand(0x11);
SendData(0x01);
SendCommand(0x44); // Set Ram X- address Start / End position
SendData(0x00); // XStart, POR = 00h
SendData(0x31); //400/8-1
SendCommand(0x45); // Set Ram Y- address Start / End position
SendData(0x0f);
SendData(0x01); //300-1
SendData(0x00); // YEnd L
SendData(0x00); // YEnd H
SendCommand(0x4e);
SendData(0x00);
SendCommand(0x4f);
SendData(0x0f);
SendData(0x01);
ReadBusy();
SendCommand(0x91);
SendData(0x00);
SendCommand(0xC4); // Set Ram X- address Start / End position
SendData(0x31); // XStart, POR = 00h
SendData(0x00); //400/8-1
SendCommand(0xC5); // Set Ram Y- address Start / End position
SendData(0x0f);
SendData(0x01); //300-1
SendData(0x00); // YEnd L
SendData(0x00); // YEnd H
SendCommand(0xCe);
SendData(0x31);
SendCommand(0xCf);
SendData(0x0f);
SendData(0x01);
ReadBusy();
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);
}
/**
* @brief: Wait until the busy_pin goes HIGH
*/
void Epd::ReadBusy(void) {
while(DigitalRead(busy_pin) == 1) { //0: busy, 1: idle
DelayMs(100);
}
}
/**
* @brief: module reset.
* often used to awaken the module in deep sleep,
* see Epd::Sleep();
*/
void Epd::Reset(void) {
DigitalWrite(reset_pin, LOW); //module reset
DelayMs(200);
DigitalWrite(reset_pin, HIGH);
DelayMs(200);
}
/******************************************************************************
function : Turn On Display
parameter:
******************************************************************************/
void Epd::TurnOnDisplay(void)
{
SendCommand(0x22); //Display Update Control
SendData(0xF7);
SendCommand(0x20); //Activate Display Update Sequence
ReadBusy();
}
void Epd::TurnOnDisplay_Fast(void)
{
SendCommand(0x22); //Display Update Control
SendData(0xC7);
SendCommand(0x20); //Activate Display Update Sequence
ReadBusy();
}
void Epd::TurnOnDisplay_Part(void)
{
SendCommand(0x22); //Display Update Control
SendData(0xFF);
SendCommand(0x20); //Activate Display Update Sequence
ReadBusy();
}
void Epd::TurnOnDisplay_4GRAY(void)
{
SendCommand(0x22);
SendData(0xCF);
SendCommand(0x20);
ReadBusy();
}
void Epd::Display(const unsigned char* frame_buffer) {
int Width, Width1, Height;
Width =(width % 16 == 0)?(width / 16 ):(width / 16 + 1);
Width1 =(width % 8 == 0)?(width / 8 ):(width / 8 + 1);
Height = height;
// M part 396*272
SendCommand(0x24);
for (int j = 0; j < Height; j++) {
for (int i = 0; i < Width; i++) {
SendData(pgm_read_byte(&(frame_buffer[j * Width1 + i])));
}
}
SendCommand(0X26);
for (int j = 0; j < Height; j++) {
for (int i = 0; i < Width; i++) {
SendData(0x00);
}
}
// S part 396*272
SendCommand(0xA4);
for (int j = 0; j < Height; j++) {
for (int i = 0; i < Width; i++) {
SendData(pgm_read_byte(&(frame_buffer[j * Width1 + i + Width - 1])));
}
}
SendCommand(0XA6);
for (int j = 0; j < Height; j++) {
for (int i = 0; i < Width; i++) {
SendData(0x00);
}
}
TurnOnDisplay();
}
void Epd::Display_Fast(const unsigned char* frame_buffer) {
int Width, Width1, Height;
Width =(width % 16 == 0)?(width / 16 ):(width / 16 + 1);
Width1 =(width % 8 == 0)?(width / 8 ):(width / 8 + 1);
Height = height;
// M part 396*272
SendCommand(0x24);
for (int j = 0; j < Height; j++) {
for (int i = 0; i < Width; i++) {
SendData(frame_buffer[j * Width1 + i]);
}
}
SendCommand(0X26);
for (int j = 0; j < Height; j++) {
for (int i = 0; i < Width; i++) {
SendData(0x00);
}
}
// S part 396*272
SendCommand(0xA4);
for (int j = 0; j < Height; j++) {
for (int i = 0; i < Width; i++) {
SendData(frame_buffer[j * Width1 + i + Width - 1]);
}
}
SendCommand(0XA6);
for (int j = 0; j < Height; j++) {
for (int i = 0; i < Width; i++) {
SendData(0x00);
}
}
TurnOnDisplay_Fast();
}
void Epd::Clear(void) {
SendCommand(0x24);
// M part 396*272
SendCommand(0x24);
for(int i=0; i<13600; i++)
{
SendData(0xFF);
}
SendCommand(0X26);
for(int i=0; i<13600; i++)
{
SendData(0x00);
}
// S part 396*272
SendCommand(0xA4);
for(int i=0; i<13600; i++)
{
SendData(0xFF);
}
SendCommand(0XA6);
for(int i=0; i<13600; i++)
{
SendData(0x00);
}
TurnOnDisplay();
}
void Epd::Sleep(void) {
SendCommand(0X10);
SendData(0x01);
}
/* END OF FILE */

View file

@ -0,0 +1,65 @@
/**
* @filename : epd5in79.h
* @brief : Header file for e-paper library epd5in83.cpp
* @author : MyMX from Waveshare
*
* Copyright (C) Waveshare 2024/03/06
*
* 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 EPD5IN79_H
#define EPD5IN79_H
#include "epdif.h"
// Display resolution
#define EPD_WIDTH 792
#define EPD_HEIGHT 272
class Epd : EpdIf {
public:
Epd();
~Epd();
int Init(void);
int Init_Fast(void);
void ReadBusy(void);
void Reset(void);
void TurnOnDisplay(void);
void TurnOnDisplay_Fast(void);
void TurnOnDisplay_Part(void);
void TurnOnDisplay_4GRAY(void);
void Display(const unsigned char* frame_buffer);
void Display_Fast(const unsigned char* frame_buffer);
void Clear(void);
void SendCommand(unsigned char command);
void SendData(unsigned char data);
void Sleep(void);
private:
unsigned int reset_pin;
unsigned int dc_pin;
unsigned int cs_pin;
unsigned int busy_pin;
unsigned long width;
unsigned long height;
};
#endif /* EPD5IN83_H */
/* END OF FILE */

View file

@ -0,0 +1,52 @@
/**
* @filename : epd5in79-demo.ino
* @brief : 5.79inch e-paper display demo
* @author : MyMX from Waveshare
*
* Copyright (C) Waveshare 2024/03/06
*
* 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 "epd5in79.h"
#include "imagedata.h"
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Epd epd;
if (epd.Init() != 0) {
Serial.println("e-Paper init failed");
return;
}
Serial.print("e-Paper Clear\r\n ");
epd.Clear();
Serial.print("e-Paper Display\r\n ");
epd.Display(IMAGE_DATA);
Serial.print("e-Paper Clear\r\n ");
epd.Clear();
}
void loop() {
// put your main code here, to run repeatedly:
}

View file

@ -0,0 +1,68 @@
/**
* @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 2024/03/06
*
* 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);
pinMode(PWR_PIN, OUTPUT);
DigitalWrite(PWR_PIN, 1);
SPI.begin();
SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE0));
return 0;
}

View file

@ -0,0 +1,52 @@
/**
* @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 2024/03/06
*
* 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
#define PWR_PIN 6
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 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.
*/
extern const unsigned char IMAGE_DATA[];
/* FILE END */