Skip to content

Commit 96bfce2

Browse files
committed
tweak for PaperS3
1 parent d41b919 commit 96bfce2

File tree

4 files changed

+99
-104
lines changed

4 files changed

+99
-104
lines changed

src/lgfx/v1/platforms/esp32/Bus_EPD.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ bool Bus_EPD::powerControl(bool flg_on)
106106
return true;
107107
}
108108

109-
void Bus_EPD::writeBytes(const uint8_t *data, uint32_t length)
109+
void Bus_EPD::writeScanLine(const uint8_t *data, uint32_t length)
110110
{
111111
wait();
112112
_bus_busy = true;

src/lgfx/v1/platforms/esp32/Bus_EPD.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class Bus_EPD : public Bus_NULL
8787
void config(const config_t& cfg) { _config = cfg; };
8888
const config_t& config(void) { return _config; };
8989

90-
void writeBytes(const uint8_t *data, uint32_t length);
90+
void writeScanLine(const uint8_t *data, uint32_t length);
9191

9292
void beginTransaction(void) override;
9393
void endTransaction(void) override;

src/lgfx/v1/platforms/esp32/Panel_EPD.cpp

Lines changed: 96 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -72,88 +72,70 @@ namespace lgfx
7272
//----------------------------------------------------------------------------
7373

7474
static constexpr int8_t Bayer[16] = {-30, 2, -22, 10, 18, -14, 26, -6, -18, 14, -26, 6, 30, -2, 22, -10};
75+
// static constexpr int8_t Bayer[16] = { 0, };
7576

7677
#define LUT_MAKE(d0,d1,d2,d3,d4,d5,d6,d7,d8,d9,da,db,dc,dd,de,df) (uint32_t)((d0<< 0)|(d1<< 2)|(d2<< 4)|(d3<< 6)|(d4<< 8)|(d5<<10)|(d6<<12)|(d7<<14)|(d8<<16)|(d9<<18)|(da<<20)|(db<<22)|(dc<<24)|(dd<<26)|(de<<28)|(df<<30))
7778

7879
// LUTの横軸は色の濃さ。左端が 黒、右端が白の16段階のグレースケール。
7980
// LUTの縦軸は時間軸。上から順に下に向かって処理が進んでいく。
80-
// 値の意味は 0 == neutral / 1 == to black / 2 == to white / 3 == no operation
81+
// 値の意味は 0 == no operation / 1 == to black / 2 == to white / 3 == end of data
8182
static constexpr const uint32_t lut_quality[] = {
82-
LUT_MAKE(2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1),
83-
LUT_MAKE(2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1),
84-
LUT_MAKE(2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1),
85-
LUT_MAKE(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2),
86-
LUT_MAKE(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2),
87-
LUT_MAKE(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2),
88-
LUT_MAKE(2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1),
89-
LUT_MAKE(2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1),
90-
LUT_MAKE(2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1),
91-
LUT_MAKE(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2),
92-
LUT_MAKE(2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1),
93-
LUT_MAKE(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2),
94-
LUT_MAKE(2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1),
95-
LUT_MAKE(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
96-
LUT_MAKE(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
97-
LUT_MAKE(0,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LUT_MAKE(1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 2, 2, 2, 2, 2, 2),
126+
LUT_MAKE(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0),
127+
LUT_MAKE(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 2, 2, 2, 0),
148128
LUT_MAKE(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
149129
LUT_MAKE(3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3),
150130
};
151131

152132
static constexpr const uint32_t lut_fast[] = {
153-
LUT_MAKE(2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1),
154-
LUT_MAKE(2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1),
155133
LUT_MAKE(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2),
156134
LUT_MAKE(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2),
135+
LUT_MAKE(2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1),
136+
LUT_MAKE(2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1),
137+
LUT_MAKE(2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1),
138+
LUT_MAKE(2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1),
157139
LUT_MAKE(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2),
158140
LUT_MAKE(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2),
159141
LUT_MAKE(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2),
@@ -167,8 +149,8 @@ namespace lgfx
167149
};
168150

169151
static constexpr const uint32_t lut_fastest[] = {
170-
LUT_MAKE(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2),
171-
LUT_MAKE(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2),
152+
LUT_MAKE(2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1),
153+
LUT_MAKE(2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1),
172154
LUT_MAKE(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2),
173155
LUT_MAKE(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2),
174156
LUT_MAKE(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2),
@@ -298,7 +280,7 @@ namespace lgfx
298280
}
299281
}
300282

301-
_update_queue_handle = xQueueCreate(16, sizeof(update_data_t));
283+
_update_queue_handle = xQueueCreate(4, sizeof(update_data_t));
302284
auto task_priority = _config_detail.task_priority;
303285
auto task_pinned_core = _config_detail.task_pinned_core;
304286
if (task_pinned_core >= portNUM_PROCESSORS)
@@ -321,11 +303,19 @@ namespace lgfx
321303

322304
void Panel_EPD::waitDisplay(void)
323305
{
324-
while (_display_busy) {
325-
vTaskDelay(1);
326-
}
306+
while (_display_busy) { vTaskDelay(1); }
327307
}
328308

309+
bool Panel_EPD::displayBusy(void)
310+
{
311+
// キュー _update_queue_handle に余裕があるか調べる
312+
if (_update_queue_handle && uxQueueSpacesAvailable(_update_queue_handle) == 0) {
313+
return true;
314+
}
315+
return false;
316+
};
317+
318+
329319
void Panel_EPD::setInvert(bool invert)
330320
{
331321
// unimplemented
@@ -531,8 +521,10 @@ namespace lgfx
531521
upd.mode = _epd_mode;
532522

533523
cacheWriteBack(&_buf[y * _cfg.memory_width >> 1], h * _cfg.memory_width >> 1);
524+
vTaskDelay(1);
534525
bool res = xQueueSend(_update_queue_handle, &upd, 128 / portTICK_PERIOD_MS) == pdTRUE;
535526
vTaskDelay(1);
527+
// printf("\nres: %d, xs: %d, xe: %d, ys: %d, ye: %d\n", res, xs, xe, ys, ye);
536528
if (res)
537529
{
538530
_range_mod.top = INT16_MAX;
@@ -555,17 +547,19 @@ namespace lgfx
555547

556548
bus->powerControl(true);
557549

558-
uint32_t nodata_counter = 0;
550+
uint32_t remain = 0;
559551

560552
for (;;) {
561-
me->_display_busy = nodata_counter;
562-
TickType_t wait_tick = nodata_counter ? 0 : portMAX_DELAY;
553+
vTaskDelay(1);
554+
me->_display_busy = (remain != 0);
555+
TickType_t wait_tick = remain ? 0 : portMAX_DELAY;
563556
if (xQueueReceive(me->_update_queue_handle, &new_data, wait_tick)) {
564557
me->_display_busy = true;
558+
uint32_t retry = 4;
565559
do {
566560
auto lut_remain = me->_lut_remain_table[new_data.mode];
567-
if (nodata_counter < lut_remain) {
568-
nodata_counter = lut_remain;
561+
if (remain < lut_remain) {
562+
remain = lut_remain;
569563
}
570564
// 範囲内のピクセルをすべて操作し変化分を反映する
571565
size_t idx = (new_data.x + new_data.y * data_len) >> 1;
@@ -574,34 +568,38 @@ namespace lgfx
574568
size_t h = new_data.h;
575569
size_t w = (((new_data.x & 1) + new_data.w) >> 1) + 1;
576570
uint_fast16_t lut_offset = me->_lut_offset_table[new_data.mode] << 8;
577-
bool force = new_data.mode == epd_mode_t::epd_quality || new_data.mode == epd_mode_t::epd_text;
571+
uint_fast16_t lut_last = lut_offset + ((me->_lut_remain_table[new_data.mode]) << 8);
572+
if (new_data.mode != epd_mode_t::epd_fastest) { lut_last -= 256; }
573+
// printf("\n new_data: x:%d y:%d w:%d h:%d \n", new_data.x, new_data.y, new_data.w, new_data.h);
578574
do {
579-
auto s = src;
580-
auto d = dst;
575+
auto s = src - 1;
576+
auto d = dst - 1;
581577
src += data_len >> 1;
582578
dst += data_len >> 1;
583-
for (int i = 0; i < w; ++i) {
584-
auto dval = *d;
585-
auto sval = *s;
586-
if (force || (dval & 0xFF) != sval)
587-
{
588-
*d = sval + lut_offset;
579+
{
580+
for (int i = 0; i < w; ++i) {
581+
auto dval = d[1];
582+
auto sval = s[1];
583+
d++;
584+
s++;
585+
if ((dval >= lut_last) || (dval < lut_offset) || ((dval & 0xFF) != sval))
586+
{
587+
*d = sval + lut_offset;
588+
}
589589
}
590-
s++;
591-
d++;
592590
}
593591
} while (--h);
594-
// printf("\n new_data: x:%d y:%d w:%d h:%d \n", new_data.x, new_data.y, new_data.w, new_data.h);
592+
if (--retry == 0) {
593+
break;
594+
}
595595
} while (xQueueReceive(me->_update_queue_handle, &new_data, 0));
596-
} else {
597-
vTaskDelay(1);
598596
}
599-
if (nodata_counter == 0) {
597+
if (remain == 0) {
600598
bus->powerControl(false);
601599
continue;
602600
}
603-
--nodata_counter;
604-
// 待機中にスリープ操作されている可能性があるので、ここで電源ON
601+
--remain;
602+
605603
bus->powerControl(true);
606604

607605
auto lut = me->_lut_2pixel;
@@ -612,9 +610,9 @@ namespace lgfx
612610
{
613611
auto sb = &me->_step_framebuf[y * data_len >> 1];
614612
auto dst = dma_buf;
615-
auto sb0 = sb[0];
616-
auto sb1 = sb[1];
617-
while (w--) {
613+
do {
614+
auto sb0 = sb[0];
615+
auto sb1 = sb[1];
618616
auto fb0 = lut[sb0];
619617
auto fb1 = lut[sb1];
620618
if (fb0 != 0x0F) {
@@ -625,17 +623,15 @@ namespace lgfx
625623
}
626624
dst[0] = (fb0 << 4) + fb1;
627625
sb += 2;
628-
sb0 = sb[0];
629-
sb1 = sb[1];
630-
dst++;
631-
}
626+
dst += 1;
627+
} while (--w);
632628
}
633629
if (y == 0) {
634630
bus->beginTransaction();
635631
} else {
636632
bus->scanlineDone();
637633
}
638-
bus->writeBytes(dma_buf, write_len);
634+
bus->writeScanLine(dma_buf, write_len);
639635
}
640636

641637
bus->scanlineDone();

src/lgfx/v1/platforms/esp32/Panel_EPD.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ Original Source:
2424
#include <freertos/FreeRTOS.h>
2525
#include <freertos/task.h>
2626
#include <freertos/queue.h>
27-
#include <vector>
2827

2928
#include "lgfx/v1/panel/Panel_HasBuffer.hpp"
3029
#include "lgfx/v1/misc/range.hpp"
@@ -67,7 +66,7 @@ namespace lgfx
6766
bool init(bool use_reset) override;
6867

6968
void waitDisplay(void) override;
70-
bool displayBusy(void) override { return _display_busy; };
69+
bool displayBusy(void) override;
7170
color_depth_t setColorDepth(color_depth_t depth) override;
7271

7372
void setInvert(bool invert) override;

0 commit comments

Comments
 (0)