<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Kitchen Sink Example</title> | |
</head> | |
<body lang="en"> | |
<p>This paragraph WILL NOT be styled by CSS or changed by javascript.</p> | |
<p id="secondpara">This paragraph will be styled by CSS using its <b>id</b>attribute using CSS selector.</p> | |
<p class="thirdpara">This paragraph will be styled by CSS using its <b>class</b>attribute using CSS selector.</p> | |
<p id="willchange">This paragraph will be changed by javascript</p> |
p { | |
color: green | |
} |
#include <Arduino.h> | |
#include <SPI.h> | |
// Pin definitions matching your diagram.json | |
#define BUSY_PIN 4 // esp:D4 -> epd1:BUSY | |
#define RESET_PIN 21 // esp:D21 -> epd1:RST | |
#define DC_PIN 22 // esp:D22 -> epd1:DC | |
#define CS_PIN 5 // esp:D5 -> epd1:CS | |
#define MOSI_PIN 23 // esp:D23 -> epd1:DIN | |
#define SCK_PIN 18 // esp:D18 -> epd1:CLK |
#include <Arduino.h> | |
#include <SPI.h> | |
#define BUSY_PIN 4 | |
#define RESET_PIN 21 | |
#define DC_PIN 22 | |
// Display dimensions | |
#define EPD_WIDTH 128 | |
#define EPD_HEIGHT 296 |
unsigned char ucDataBlock[1983] = { | |
// Offset 0x00000000 to 0x000007BE | |
0x12, 0x01, 0x27, 0x01, 0x00, 0x11, 0x03, 0x44, 0x00, 0x0F, 0x45, 0x00, | |
0x00, 0x27, 0x01, 0x21, 0x00, 0x80, 0x4E, 0x00, 0x4F, 0x00, 0x00, 0x24, | |
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | |
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | |
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | |
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | |
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | |
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
Tiny hardware detail check first: you’re using the ESP32 with Arduino framework, and you want to send raw bytes over SPI. You have a DC pin (Data/Command pin) that determines whether the bytes should be understood as command or data by the peripheral. Conventionally, DC=0 → command and DC=1 → data. Correct?
Here’s a neat, reusable way to implement your two functions:
#include <SPI.h>
#define DC_PIN 21 // Change to your actual DC pin number
#define CS_PIN 5 // Chip select, change to your wiring
For the Waveshare 2.9" e-paper display v2, after initialization, you'll need to send several commands to turn on a pixel at position (0,0). Here's the sequence of raw bytes:
0x44, 0x00, 0x0F // Command 0x44, X start=0, X end=15 (128 pixels / 8 = 16 bytes)
0x45, 0x00, 0x00, 0x27, 0x01 // Command 0x45, Y start=0x0000, Y end=0x0127 (295 pixels)
https://files.waveshare.com/upload/7/79/2.9inch-e-paper-v2-specification.pdf
Sending raw SPI data to an e-paper display requires a precise sequence of commands and data bytes. Below is a detailed breakdown of the raw byte stream needed to draw a 5x5 black square at the (0,0) coordinate on a Waveshare 2.9-inch V2 e-paper display.
Communication with the display via SPI involves these key signals:
- CS (Chip Select): Must be pulled low to start an SPI transaction.