lv_drivers/display/fbdev.c
/**
 * Flush a buffer to the marked area
 * @param drv pointer to driver where this function belongs
 * @param area an area where to copy `color_p`
 * @param color_p an array of pixel to copy to the `area` part of the screen
 */
Flush a buffer to the marked area
@param drv pointer to driver where this function belongs
@param area an area where to copy `color_p`
@param color_p an array of pixel to copy to the `area` part of the screen
Flush a buffer to the marked area @param drv pointer to driver where this function belongs @param area an area where to copy ` color_p ` @param color_p an array of pixel to copy to the ` area ` part of the screen
void fbdev_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_p)
{
    if(fbp == NULL ||
            area->x2 < 0 ||
            area->y2 < 0 ||
            area->x1 > (int32_t)vinfo.xres - 1 ||
            area->y1 > (int32_t)vinfo.yres - 1) {
        lv_disp_flush_ready(drv);
        return;
    }
    lv_coord_t w = (area->x2 - area->x1 + 1);
#ifdef DRV_DEBUG
    lv_coord_t h = (area->y2 - area->y1 + 1);
#endif
    dbg("fbdev_flush() x %d:%d y %d:%d w %d h %d", area->x1, area->x2, area->y1, area->y2, w, h);
    int32_t act_x1 = area->x1 < 0 ? 0 : area->x1;
    int32_t act_y1 = area->y1 < 0 ? 0 : area->y1;
    int32_t act_x2 = area->x2 > (int32_t)vinfo.xres - 1 ? (int32_t)vinfo.xres - 1 : area->x2;
    int32_t act_y2 = area->y2 > (int32_t)vinfo.yres - 1 ? (int32_t)vinfo.yres - 1 : area->y2;
    long int location = 0;
    long int byte_location = 0;
    unsigned char bit_location = 0;
    if(vinfo.bits_per_pixel == 32 || vinfo.bits_per_pixel == 24) {
        uint32_t * fbp32 = (uint32_t *)fbp;
        int32_t y;
        for(y = act_y1; y <= act_y2; y++) {
            location = (act_x1 + vinfo.xoffset) + (y + vinfo.yoffset) * finfo.line_length / 4;
            memcpy(&fbp32[location], (uint32_t *)color_p, (act_x2 - act_x1 + 1) * 4);
            color_p += w;
        }
    }
    else if(vinfo.bits_per_pixel == 16) {
        uint16_t * fbp16 = (uint16_t *)fbp;
        int32_t y;
        for(y = act_y1; y <= act_y2; y++) {
            location = (act_x1 + vinfo.xoffset) + (y + vinfo.yoffset) * finfo.line_length / 2;
            memcpy(&fbp16[location], (uint32_t *)color_p, (act_x2 - act_x1 + 1) * 2);
            color_p += w;
        }
    }
    else if(vinfo.bits_per_pixel == 8) {
        uint8_t * fbp8 = (uint8_t *)fbp;
        int32_t y;
        for(y = act_y1; y <= act_y2; y++) {
            location = (act_x1 + vinfo.xoffset) + (y + vinfo.yoffset) * finfo.line_length;
            memcpy(&fbp8[location], (uint32_t *)color_p, (act_x2 - act_x1 + 1));
            color_p += w;
        }
    }
    else if(vinfo.bits_per_pixel == 1) {
        uint8_t * fbp8 = (uint8_t *)fbp;
        int32_t x;
        int32_t y;
        for(y = act_y1; y <= act_y2; y++) {
            for(x = act_x1; x <= act_x2; x++) {
                location = (x + vinfo.xoffset) + (y + vinfo.yoffset) * vinfo.xres;
                byte_location = location / 8; 
                bit_location = location % 8; 
                fbp8[byte_location] &= ~(((uint8_t)(1)) << bit_location);
                fbp8[byte_location] |= ((uint8_t)(color_p->full)) << bit_location;
                color_p++;
            }
            color_p += area->x2 - act_x2;
        }
    } else {
    }
    ioctl(fbfd, FBIOPAN_DISPLAY, &vinfo);
    lv_disp_flush_ready(drv);
}
void fbdev_flush ( lv_disp_drv_t * drv , const lv_area_t * area , lv_color_t * color_p ) { if ( fbp == NULL || area -> x2 < 0 || area -> y2 < 0 || area -> x1 > ( int32_t ) vinfo . xres - 1 || area -> y1 > ( int32_t ) vinfo . yres - 1 ) { lv_disp_flush_ready ( drv ) ; return ; } lv_coord_t w = ( area -> x2 - area -> x1 + 1 ) ; #ifdef DRV_DEBUG lv_coord_t h = ( area -> y2 - area -> y1 + 1 ) ; #endif dbg ( " " , area -> x1 , area -> x2 , area -> y1 , area -> y2 , w , h ) ; int32_t act_x1 = area -> x1 < 0 ? 0 : area -> x1 ; int32_t act_y1 = area -> y1 < 0 ? 0 : area -> y1 ; int32_t act_x2 = area -> x2 > ( int32_t ) vinfo . xres - 1 ? ( int32_t ) vinfo . xres - 1 : area -> x2 ; int32_t act_y2 = area -> y2 > ( int32_t ) vinfo . yres - 1 ? ( int32_t ) vinfo . yres - 1 : area -> y2 ; long int location = 0 ; long int byte_location = 0 ; unsigned char bit_location = 0 ; if ( vinfo . bits_per_pixel == 32 || vinfo . bits_per_pixel == 24 ) { uint32_t * fbp32 = ( uint32_t * ) fbp ; int32_t y ; for ( y = act_y1 ; y <= act_y2 ; y ++ ) { location = ( act_x1 + vinfo . xoffset ) + ( y + vinfo . yoffset ) * finfo . line_length / 4 ; memcpy ( & fbp32 [ location ] , ( uint32_t * ) color_p , ( act_x2 - act_x1 + 1 ) * 4 ) ; color_p += w ; } } else if ( vinfo . bits_per_pixel == 16 ) { uint16_t * fbp16 = ( uint16_t * ) fbp ; int32_t y ; for ( y = act_y1 ; y <= act_y2 ; y ++ ) { location = ( act_x1 + vinfo . xoffset ) + ( y + vinfo . yoffset ) * finfo . line_length / 2 ; memcpy ( & fbp16 [ location ] , ( uint32_t * ) color_p , ( act_x2 - act_x1 + 1 ) * 2 ) ; color_p += w ; } } else if ( vinfo . bits_per_pixel == 8 ) { uint8_t * fbp8 = ( uint8_t * ) fbp ; int32_t y ; for ( y = act_y1 ; y <= act_y2 ; y ++ ) { location = ( act_x1 + vinfo . xoffset ) + ( y + vinfo . yoffset ) * finfo . line_length ; memcpy ( & fbp8 [ location ] , ( uint32_t * ) color_p , ( act_x2 - act_x1 + 1 ) ) ; color_p += w ; } } else if ( vinfo . bits_per_pixel == 1 ) { uint8_t * fbp8 = ( uint8_t * ) fbp ; int32_t x ; int32_t y ; for ( y = act_y1 ; y <= act_y2 ; y ++ ) { for ( x = act_x1 ; x <= act_x2 ; x ++ ) { location = ( x + vinfo . xoffset ) + ( y + vinfo . yoffset ) * vinfo . xres ; byte_location = location / 8 ; bit_location = location % 8 ; fbp8 [ byte_location ] &= ~ ( ( ( uint8_t ) ( 1 ) ) << bit_location ) ; fbp8 [ byte_location ] |= ( ( uint8_t ) ( color_p -> full ) ) << bit_location ; color_p ++ ; } color_p += area -> x2 - act_x2 ; } } else { } ioctl ( fbfd , FBIOPAN_DISPLAY , & vinfo ) ; lv_disp_flush_ready ( drv ) ; }
Flush a buffer to the marked area
 @param drv pointer to driver where this function belongs
 @param area an area where to copy `color_p`
 @param color_p an array of pixel to copy to the `area` part of the screen
Flush a buffer to the marked area @param drv pointer to driver where this function belongs @param area an area where to copy ` color_p ` @param color_p an array of pixel to copy to the ` area ` part of the screen
/*Truncate the area to the screen*/ /*32 or 24 bit per pixel*/ /*16 bit per pixel*/ /*8 bit per pixel*/ /*1 bit per pixel*/ /* find the byte we need to change */ /* inside the byte found, find the bit we need to change */ /*Not supported bit per pixel*/ // "pan" the framebuffer, some gpu drivers only update when told to this way. // Don't check for errors, it's not important here.