Skip to content

Commit e6a569a

Browse files
committed
shared-module/aurora_epaper/aurora_framebuffer.c: More comments
1 parent 633f1a6 commit e6a569a

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

shared-module/aurora_epaper/aurora_framebuffer.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ void common_hal_aurora_epaper_framebuffer_power_finish(aurora_epaper_framebuffer
308308
common_hal_aurora_epaper_framebuffer_draw_line(self, (uint8_t *)self->bufinfo.buf, i, AURORA_EPAPER_NONE_PIXEL, AURORA_EPAPER_NONE_PIXEL, border);
309309
}
310310

311+
// Send special no-scan line
311312
border = 0xAA;
312313
common_hal_aurora_epaper_framebuffer_draw_line(self, (uint8_t *)self->bufinfo.buf, -4, AURORA_EPAPER_NONE_PIXEL, AURORA_EPAPER_NONE_PIXEL, border);
313314

@@ -346,6 +347,7 @@ void common_hal_aurora_epaper_framebuffer_swapbuffers(aurora_epaper_framebuffer_
346347
return;
347348
}
348349

350+
// Spec states baud rate can be 20kHz, but my testing showed this is optimistic
349351
common_hal_busio_spi_configure(self->bus, 15000000, 0, 0, 8);
350352

351353
if (!common_hal_aurora_epaper_framebuffer_power_on(self)) {
@@ -361,6 +363,7 @@ void common_hal_aurora_epaper_framebuffer_swapbuffers(aurora_epaper_framebuffer_
361363
border = 0xFF;
362364
}
363365

366+
// Find out how many frames need to be sent to match frametime
364367
do {
365368
// Stage 1: Compensate
366369
common_hal_aurora_epaper_framebuffer_draw_frame(self, (uint8_t *)self->pframe.buf, AURORA_EPAPER_BLACK_PIXEL, AURORA_EPAPER_WHITE_PIXEL, border, 1);
@@ -411,14 +414,15 @@ void common_hal_aurora_epaper_framebuffer_draw_line(aurora_epaper_framebuffer_ob
411414

412415
if (self->type == SMALL_1_44 || self->type == MEDIUM_2 || self->type == LARGE_2_7) {
413416

417+
// 3 bit to 4 bit lookup table
414418
#define DO_MAP(mapping, input) \
415419
(((mapping) >> (((input) & 5) << 2)) & 0xF)
416420

417421
uint32_t evenMap =
418422
(whiteMap << 2 | whiteMap) << 0 |
419-
(whiteMap << 2 | blackMap) << 4 |
420-
(blackMap << 2 | whiteMap) << 16 |
421-
(blackMap << 2 | blackMap) << 20;
423+
(whiteMap << 2 | blackMap) << 4 |
424+
(blackMap << 2 | whiteMap) << 16 |
425+
(blackMap << 2 | blackMap) << 20;
422426

423427
int stride = common_hal_aurora_epaper_framebuffer_get_row_stride(self);
424428

@@ -444,9 +448,9 @@ void common_hal_aurora_epaper_framebuffer_draw_line(aurora_epaper_framebuffer_ob
444448

445449
uint32_t oddMap =
446450
(whiteMap << 2 | whiteMap) << 0 |
447-
(whiteMap << 2 | blackMap) << 16 |
448-
(blackMap << 2 | whiteMap) << 4 |
449-
(blackMap << 2 | blackMap) << 20;
451+
(whiteMap << 2 | blackMap) << 16 |
452+
(blackMap << 2 | whiteMap) << 4 |
453+
(blackMap << 2 | blackMap) << 20;
450454

451455
// Odd bytes
452456
for (int x = 0; x < stride; x++) {
@@ -467,14 +471,15 @@ void common_hal_aurora_epaper_framebuffer_draw_line(aurora_epaper_framebuffer_ob
467471
// This code is untested
468472
else if (self->type == SMALL_1_9 || self->type == LARGE_2_6) {
469473

474+
// 2 bit to 4 bit lookup table
470475
#define DO_MAP(mapping, input) \
471476
(((mapping) >> (((input) & 0x3) << 2)) & 0xF)
472477

473478
uint32_t pixelMap =
474479
(whiteMap << 2 | whiteMap) << 0 |
475-
(whiteMap << 2 | blackMap) << 4 |
476-
(blackMap << 2 | whiteMap) << 8 |
477-
(blackMap << 2 | blackMap) << 12;
480+
(whiteMap << 2 | blackMap) << 4 |
481+
(blackMap << 2 | whiteMap) << 8 |
482+
(blackMap << 2 | blackMap) << 12;
478483

479484
int stride = common_hal_aurora_epaper_framebuffer_get_row_stride(self);
480485

0 commit comments

Comments
 (0)