Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
vroland committed Sep 4, 2024
1 parent 3c1aefc commit 196ba57
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 20 deletions.
26 changes: 17 additions & 9 deletions examples/fb_mode_test/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -115,23 +116,27 @@ 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();
}

void test_2ppB() {
EpdRect area = epd_full_screen();
enum EpdDrawMode mode;
int start_column = 500;
int start_line = 100;

Expand All @@ -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);
Expand All @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions src/output_common/line_queue.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <assert.h>
#include <esp_attr.h>
#include <esp_heap_caps.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Expand Down Expand Up @@ -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);
Expand All @@ -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) {
Expand Down
13 changes: 9 additions & 4 deletions src/render.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 196ba57

Please sign in to comment.