From 196ba5742e3cd804dc17b125fdbcc13923548e9d Mon Sep 17 00:00:00 2001 From: Valentin Roland Date: Wed, 4 Sep 2024 09:49:20 +0200 Subject: [PATCH] wip --- examples/fb_mode_test/main/main.c | 26 +++++++++++++++++--------- src/output_common/line_queue.c | 14 +++++++------- src/render.c | 13 +++++++++---- 3 files changed, 33 insertions(+), 20 deletions(-) diff --git a/examples/fb_mode_test/main/main.c b/examples/fb_mode_test/main/main.c index 4bcf0686..7be93f54 100644 --- a/examples/fb_mode_test/main/main.c +++ b/examples/fb_mode_test/main/main.c @@ -99,6 +99,7 @@ void draw_2bpp_triangles(int start_line, int start_column, uint8_t color) { void test_8ppB() { EpdRect area = epd_full_screen(); + enum EpdDrawMode mode; // bytes in a line in 8ppB mode int line_bytes = epd_width() / 8; @@ -115,16 +116,19 @@ void test_8ppB() { uint8_t* line_address = framebuffer + (line_bytes * (start_line + line)); memset(line_address + black_start_column / 8, 0, 32); } - - // draw white triangles on the black background - draw_8bpp_triangles(start_line, black_start_column + 16); - + // update the display. In the first update, white pixels are no-opps, // in the second update, black pixels are no-ops. - enum EpdDrawMode mode; epd_poweron(); mode = MODE_PACKING_8PPB | MODE_DU | PREVIOUSLY_WHITE; checkError(epd_draw_base(area, framebuffer, area, mode, 25, NULL, NULL, &epdiy_ED047TC2)); + epd_poweroff(); + + // draw white triangles on the black background + draw_8bpp_triangles(start_line, black_start_column + 16); + + + epd_poweron(); mode = MODE_PACKING_8PPB | MODE_DU | PREVIOUSLY_BLACK; checkError(epd_draw_base(area, framebuffer, area, mode, 25, NULL, NULL, &epdiy_ED047TC2)); epd_poweroff(); @@ -132,6 +136,7 @@ void test_8ppB() { void test_2ppB() { EpdRect area = epd_full_screen(); + enum EpdDrawMode mode; int start_column = 500; int start_line = 100; @@ -144,9 +149,6 @@ void test_2ppB() { EpdRect black_area = { .x = black_start_column, .y = 100, .width = 256, .height = 300 }; epd_fill_rect(black_area, 0, framebuffer); - // draw white triangles on the black background - draw_2bpp_triangles(start_line, black_start_column + 16, 255); - // Do not overdraw the 8ppB image uint8_t* drawn_columns = malloc(epd_width() / 2); assert(drawn_columns != NULL); @@ -155,12 +157,18 @@ void test_2ppB() { // update the display. In the first update, white pixels are no-opps, // in the second update, black pixels are no-ops. - enum EpdDrawMode mode; epd_poweron(); mode = MODE_PACKING_2PPB | MODE_DU | PREVIOUSLY_WHITE; checkError( epd_draw_base(area, framebuffer, area, mode, 25, NULL, drawn_columns, &epdiy_ED047TC2) ); + epd_poweroff(); + + // draw white triangles on the black background + draw_2bpp_triangles(start_line, black_start_column + 16, 255); + + + epd_poweron(); mode = MODE_PACKING_2PPB | MODE_DU | PREVIOUSLY_BLACK; checkError( epd_draw_base(area, framebuffer, area, mode, 25, NULL, drawn_columns, &epdiy_ED047TC2) diff --git a/src/output_common/line_queue.c b/src/output_common/line_queue.c index 4e203576..84834614 100644 --- a/src/output_common/line_queue.c +++ b/src/output_common/line_queue.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -66,13 +67,6 @@ uint8_t* IRAM_ATTR lq_current(LineQueue_t* queue) { void IRAM_ATTR lq_commit(LineQueue_t* queue) { int current = atomic_load_explicit(&queue->current, memory_order_acquire); - - if (current == queue->size - 1) { - queue->current = 0; - } else { - atomic_fetch_add(&queue->current, 1); - } - #ifdef RENDER_METHOD_LCD void epd_apply_line_mask_VE(uint8_t * line, const uint8_t* mask, int mask_len); epd_apply_line_mask_VE(queue->bufs[current], queue->mask_buffer, queue->mask_buffer_len); @@ -81,6 +75,12 @@ void IRAM_ATTR lq_commit(LineQueue_t* queue) { ((uint32_t*)(queue->bufs[current]))[i] &= ((uint32_t*)(queue->mask_buffer))[i]; } #endif + + if (current == queue->size - 1) { + queue->current = 0; + } else { + atomic_fetch_add(&queue->current, 1); + } } int IRAM_ATTR lq_read(LineQueue_t* queue, uint8_t* dst) { diff --git a/src/render.c b/src/render.c index 3aeeadb9..af80e79b 100644 --- a/src/render.c +++ b/src/render.c @@ -198,15 +198,20 @@ enum EpdDrawError IRAM_ATTR epd_draw_base( if (waveform_phases != NULL && waveform_phases->phase_times != NULL) { render_context.phase_times = waveform_phases->phase_times; } - -#ifdef RENDER_METHOD_I2S - i2s_do_update(&render_context); -#elif defined(RENDER_METHOD_LCD) + for (int i = 0; i < NUM_RENDER_THREADS; i++) { LineQueue_t* queue = &render_context.line_queues[i]; _epd_populate_line_mask(queue->mask_buffer, drawn_columns, queue->mask_buffer_len); + + + for (int i = 0; i < queue->mask_buffer_len / 4; i++) { + printf("%X\n", ((uint32_t*)(queue->mask_buffer))[i]); + } } +#ifdef RENDER_METHOD_I2S + i2s_do_update(&render_context); +#elif defined(RENDER_METHOD_LCD) lcd_do_update(&render_context); #endif