lvgl_tft/epdiy_epaper.c
/* A copy from epd_copy_to_framebuffer with temporary lenght prediction */
A copy from epd_copy_to_framebuffer with temporary lenght prediction
A copy from epd_copy_to_framebuffer with temporary lenght prediction
void buf_copy_to_framebuffer(EpdRect image_area, const uint8_t *image_data) {
  assert(framebuffer != NULL);
  for (uint32_t i = 0; i < image_area.width * image_area.height; i++) {
    uint8_t val = (i % 2) ? (image_data[i / 2] & 0xF0) >> 4
                                    : image_data[i / 2] & 0x0F;
    int xx = image_area.x + i % image_area.width;
    if (xx < 0 || xx >= EPD_WIDTH) {
      continue;
    }
    int yy = image_area.y + i / image_area.width;
    if (yy < 0 || yy >= EPD_HEIGHT) {
      continue;
    }
    uint8_t *buf_ptr = &framebuffer[yy * EPD_WIDTH / 2 + xx / 2];
    if (xx % 2) {
      *buf_ptr = (*buf_ptr & 0x0F) | (val << 4);
    } else {
      *buf_ptr = (*buf_ptr & 0xF0) | val;
    }
  }
}
void buf_copy_to_framebuffer ( EpdRect image_area , const uint8_t * image_data ) { assert ( framebuffer != NULL ) ; for ( uint32_t i = 0 ; i < image_area . width * image_area . height ; i ++ ) { uint8_t val = ( i % 2 ) ? ( image_data [ i / 2 ] & 0xF0 ) >> 4 : image_data [ i / 2 ] & 0x0F ; int xx = image_area . x + i % image_area . width ; if ( xx < 0 || xx >= EPD_WIDTH ) { continue ; } int yy = image_area . y + i / image_area . width ; if ( yy < 0 || yy >= EPD_HEIGHT ) { continue ; } uint8_t * buf_ptr = & framebuffer [ yy * EPD_WIDTH / 2 + xx / 2 ] ; if ( xx % 2 ) { * buf_ptr = ( * buf_ptr & 0x0F ) | ( val << 4 ) ; } else { * buf_ptr = ( * buf_ptr & 0xF0 ) | val ; } } }
A copy from epd_copy_to_framebuffer with temporary lenght prediction
A copy from epd_copy_to_framebuffer with temporary lenght prediction