Noise on OLED (SSD1306) - JohnHau/mis GitHub Wiki

https://forum.lvgl.io/t/noise-on-oled-ssd1306/624/11

Description I am trying to use LittlevGL on OLED(SSD1306) using Nordic’s nRF52840. I am not getting the desired output. It is noise which seems random but is the same every time you power on the OLED.

What MCU/Processor/Board and compiler are you using? MCU - nRF52840

What do you experience? Screen is showing random noise. Actually the pattern made by this noise is always same. I am guessing there is some problem with the generated buffer.

I have ported LittlevGL using guide and set callbacks for disp_flush, set_px_cb, rounder_cb. Using these guides.

image

disp_flush function

static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
{
    /*The most simple case (but also the slowest) to put all pixels to the screen one-by-one*/

    int16_t x;
    int16_t y;
    uint8_t *buf = (uint8_t*) color_p;
    for(y = area->y1; y <= area->y2; y++) {
        for(x = area->x1; x <= area->x2; x++) {
            /* Put a pixel to the display. For example: */
            /* put_px(x, y, *color_p)*/
            Adafruit_GFX_drawPixel(x, y, *buf);
            buf++;
        }
    }

    NRF_LOG_INFO("Written to screen"); NRF_LOG_FLUSH();

    /* IMPORTANT!!!
    * Inform the graphics library that you are ready with the flushing*/
    lv_disp_flush_ready(disp_drv);
}

image

image

My Callback function

void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p) { /The most simple case (but also the slowest) to put all pixels to the screen one-by-one/

int16_t x;
int16_t y;
uint8_t *buf = (uint8_t*) color_p;
//copyToBuffer(buf);
NRF_LOG_INFO("X1 Value %d | X2 Value %d | Y1 Value %d | Y2 Value %d", area->x1, area->x2, area->y1, area->y2); NRF_LOG_FLUSH();
for(y = area->y1; y <= area->y2; y++) {
    for(x = area->x1; x <= area->x2; x++) {
        SSD1306_drawPixel(x, y, *buf);
        buf++;
    }
}

SSD1306_display();

NRF_LOG_INFO("Written to screen"); NRF_LOG_FLUSH();

/* IMPORTANT!!!
 * Inform the graphics library that you are ready with the flushing*/
lv_disp_flush_ready(disp_drv);

}

image

image

littlevgl/lv_drivers/blob/82f48926dac9333b2b2fa2c5a301a43a619b6f8c/display/ST7565.c#L145-L166 19 int32_t act_x1 = x1 < 0 ? 0 : x1; int32_t act_y1 = y1 < 0 ? 0 : y1; int32_t act_x2 = x2 > ST7565_HOR_RES - 1 ? ST7565_HOR_RES - 1 : x2; int32_t act_y2 = y2 > ST7565_VER_RES - 1 ? ST7565_VER_RES - 1 : y2;

int32_t x, y;

/*Set the first row in */

/Refresh frame buffer/ for(y = act_y1; y <= act_y2; y++) { for(x = act_x1; x <= act_x2; x++) { if(lv_color_to1(*color_p) != 0) { lcd_fb[x + (y / 8)*ST7565_HOR_RES] &= ~(1 << (7 - (y % 8))); } else { lcd_fb[x + (y / 8)*ST7565_HOR_RES] |= (1 << (7 - (y % 8))); } color_p ++; }

image

image

image

image

⚠️ **GitHub.com Fallback** ⚠️