Skip to content

Commit

Permalink
consistent error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
vroland committed Sep 14, 2023
1 parent 9c14e1c commit b3a8ffa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/output_lcd/render_lcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,19 @@ void IRAM_ATTR lcd_calculate_frame(RenderContext_t *ctx, int thread_id) {
LineQueue_t *lq = &ctx->line_queues[thread_id];
int l = 0;

lut_func_t input_calc_func = get_lut_function(ctx);

// if there is an error, start the frame but don't feed data.
if (ctx->error) {
memset(ctx->line_threads, 0, ctx->lines_total);
epd_lcd_line_source_cb((line_cb_func_t)&retrieve_line_isr, ctx);
epd_lcd_start_frame();
ESP_LOGW("epd_lcd", "draw frame draw initiated, but an error flag is set: %X", ctx->error);
return;
}

assert(input_calc_func != NULL);

// line must be able to hold 2-pixel-per-byte or 1-pixel-per-byte data
memset(input_line, 0x00, ctx->display_width);

Expand All @@ -139,8 +144,6 @@ void IRAM_ATTR lcd_calculate_frame(RenderContext_t *ctx, int thread_id) {
const uint8_t *ptr_start;
get_buffer_params(ctx, &bytes_per_line, &ptr_start, &min_y, &max_y, &_ppB);

lut_func_t input_calc_func = get_lut_function(ctx);

assert(area.width == ctx->display_width && area.x == 0 && !ctx->error);

// index of the line that triggers the frame output when processed
Expand Down
6 changes: 5 additions & 1 deletion src/render.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <stdalign.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <esp_log.h>
#include <esp_types.h>
Expand Down Expand Up @@ -85,6 +86,9 @@ static inline int rounded_display_height() {
enum EpdDrawError IRAM_ATTR epd_draw_base(
EpdRect area, const uint8_t *data, EpdRect crop_to, enum EpdDrawMode mode,
int temperature, const bool *drawn_lines, const EpdWaveform *waveform) {
if (waveform == NULL) {
return EPD_DRAW_NO_PHASES_AVAILABLE;
}
int waveform_range = waveform_temp_range_index(waveform, temperature);
if (waveform_range < 0) {
return EPD_DRAW_NO_PHASES_AVAILABLE;
Expand Down Expand Up @@ -259,7 +263,7 @@ void epd_renderer_init(enum EpdInitOptions options) {
render_context.feed_line_buffers[i] = (uint8_t *)heap_caps_malloc(render_context.display_width, MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL);
assert(render_context.feed_line_buffers[i] != NULL);
RTOS_ERROR_CHECK(xTaskCreatePinnedToCore(
render_thread, "epd_prep", 1 << 10, (void *)i,
render_thread, "epd_prep", 1 << 11, (void *)i,
configMAX_PRIORITIES, &render_context.feed_tasks[i], i));
if (render_context.line_queues[i].buf == NULL) {
ESP_LOGE("epd", "could not allocate line queue!");
Expand Down

0 comments on commit b3a8ffa

Please sign in to comment.