9static constexpr const char *
const TAG =
"epaper_spi.t133a01";
15static constexpr uint8_t T133A01_BLACK = 0x0F;
16static constexpr uint8_t T133A01_WHITE = 0x00;
17static constexpr uint8_t T133A01_GREEN = 0x02;
18static constexpr uint8_t T133A01_RED = 0x06;
19static constexpr uint8_t T133A01_YELLOW = 0x0B;
20static constexpr uint8_t T133A01_BLUE = 0x0D;
23static constexpr uint8_t R00_PSR = 0x00;
24static constexpr uint8_t R01_PWR = 0x01;
25static constexpr uint8_t R02_POF = 0x02;
26static constexpr uint8_t R04_PON = 0x04;
27static constexpr uint8_t R05_BTST_N = 0x05;
28static constexpr uint8_t R06_BTST_P = 0x06;
29static constexpr uint8_t R10_DTM = 0x10;
30static constexpr uint8_t R12_DRF = 0x12;
31static constexpr uint8_t R50_CDI = 0x50;
32static constexpr uint8_t R61_TRES = 0x61;
33static constexpr uint8_t RA5_DCDC = 0xA5;
34static constexpr uint8_t RE0_CCSET = 0xE0;
35static constexpr uint8_t RE3_PWS = 0xE3;
44 switch (index & 0x0F) {
68 unsigned char max_rgb = std::max({color.
r, color.
g, color.
b});
69 unsigned char min_rgb = std::min({color.
r, color.
g, color.
b});
72 if ((max_rgb - min_rgb) < 50) {
73 if ((
static_cast<int>(color.
r) + color.
g + color.
b) > 382) {
79 bool r_on = (color.
r > 128);
80 bool g_on = (color.
g > 128);
81 bool b_on = (color.
b > 128);
83 if (r_on && g_on && !b_on)
84 return T133A01_YELLOW;
85 if (r_on && !g_on && !b_on)
87 if (!r_on && g_on && !b_on)
89 if (!r_on && !g_on && b_on)
92 if (!r_on && g_on && b_on)
116 enable_pin->digital_write(
true);
141 this->
write_command_(0x74, {0x00, 0x0C, 0x0C, 0xD9, 0xDD, 0xDD, 0x15, 0x15, 0x55},
true,
false);
145 this->
write_command_(0xF0, {0x49, 0x55, 0x13, 0x5D, 0x05, 0x10},
true,
true);
175 {(uint8_t) (this->
width_ >> 8), (uint8_t) (this->
width_ & 0xFF),
176 (uint8_t) ((this->
height_ / 2) >> 8), (uint8_t) ((this->
height_ / 2) & 0xFF)},
181 this->
write_command_(R01_PWR, {0x0F, 0x00, 0x28, 0x2C, 0x28, 0x38},
true,
false);
212 ESP_LOGV(TAG,
"Command: 0x%02X, Length: %u, CS: %d, CS1: %d",
command, (
unsigned)
length, use_cs, use_cs1);
234 this->
buffer_.
fill(pixel_color + (pixel_color << 4));
242 uint32_t byte_position = pixel_position / 2;
243 auto original = this->
buffer_[byte_position];
244 if ((pixel_position & 1) != 0) {
245 this->
buffer_[byte_position] = (original & 0xF0) | pixel_bits;
247 this->
buffer_[byte_position] = (original & 0x0F) | (pixel_bits << 4);
252 ESP_LOGV(TAG,
"Power on");
257 ESP_LOGV(TAG,
"Power off");
262 ESP_LOGV(TAG,
"Refresh screen");
268 ESP_LOGV(TAG,
"Deep sleep");
274 const uint16_t bytes_per_half_row = this->
width_ / 4;
275 const uint16_t total_rows = this->
height_;
276 const uint16_t bytes_per_row = this->
width_ / 2;
277 uint8_t line_data[400] = {};
293 if (half < total_rows) {
303 while (half < total_rows) {
304 size_t buf_offset = half * bytes_per_row;
305 for (uint16_t col = 0; col < bytes_per_half_row; col++) {
306 uint8_t b = this->
buffer_[buf_offset + col];
313 if (
millis() - start_time > MAX_TRANSFER_TIME) {
317 ESP_LOGD(TAG,
"CS phase done");
325 if (half >= total_rows && half < total_rows * 2) {
326 size_t cs1_row = half - total_rows;
337 while (half < total_rows * 2) {
338 size_t row = half - total_rows;
339 size_t buf_offset = row * bytes_per_row + bytes_per_half_row;
340 for (uint16_t col = 0; col < bytes_per_half_row; col++) {
341 uint8_t b = this->
buffer_[buf_offset + col];
348 if (
millis() - start_time > MAX_TRANSFER_TIME) {
352 ESP_LOGD(TAG,
"CS1 phase done");
363 LOG_PIN(
" CS Pin: ", this->
cs_pin_);
364 LOG_PIN(
" CS1 Pin: ", this->
cs1_pin_);
virtual void digital_write(bool value)=0
Rect get_clipping() const
Get the current the clipping rectangle.
void command(uint8_t value)
void fill(Color color) override
bool rotate_coordinates_(int &x, int &y)
Check and rotate coordinates based on the transform flags.
void dump_config() override
split_buffer::SplitBuffer buffer_
void wait_for_idle_(bool should_wait)
size_t current_data_index_
int get_width_internal() override
std::vector< GPIOPin * > enable_pins_
void fill(Color color) override
void deep_sleep() override
static uint8_t remap_color(uint8_t index)
Apply COLOR_GET remap table to translate sprite indices to hardware values.
void power_off() override
void refresh_screen(bool partial) override
static uint8_t color_to_index(Color color)
Convert Color to 4-bit T133A01 color index.
bool initialise(bool partial) override
Initialise the T133A01 display.
void draw_pixel_at(int x, int y, Color color) override
void write_command_(uint8_t command, const uint8_t *data, size_t length, bool use_cs, bool use_cs1)
Send a command (and optional data) selecting one or both controllers.
void dump_config() override
bool transfer_data() override
void write_byte(uint8_t data)
void write_array(const uint8_t *data, size_t length)
void fill(uint8_t value) const
Fill the entire buffer with a single byte value.
void HOT delay(uint32_t ms)
uint32_t IRAM_ATTR HOT millis()