IOsetting / wm-sdk-w806

A SDK for WinnerMicro W806
Apache License 2.0
129 stars 50 forks source link

硬件SPI ST7567那部分,为何显示不全? #28

Closed ohmytime closed 1 year ago

ohmytime commented 1 year ago

看起来只有上面一点能显示出来想要的字符 下图是我用Fill(1)的结果 image

ohmytime commented 1 year ago

问题出在了偏移量上吗?我的也是ST7567

ohmytime commented 1 year ago

确切来说,只显示了上面8行,下面的都没显示。

IOsetting commented 1 year ago

I met this problem before, some ST7567 doesn't support row/page shift, so the following code might not work

void ST7567_UpdateScreen(void) 
{
    ST7567_WriteCommand(ST7567_SET_PAGE_ADDRESS | (0x00 & ST7567_SET_PAGE_ADDRESS_MASK));
    ST7567_WriteCommand(ST7567_SET_COLUMN_ADDRESS_MSB);
    ST7567_WriteCommand(ST7567_SET_COLUMN_ADDRESS_LSB);
    ST7567_Transmit(ST7567_Buffer_all, sizeof(ST7567_Buffer_all), ST7567_TIMEOUT);
}

You need to update it page by page like this. The following code might not work out-of-box, just for your reference.

void ST7567_UpdateScreen(void) 
{
    uint8_t i = 0, *pt = ST7567_Buffer_all;
    for (i = 0; i < ST7567_PAGES; i++)
    {
        ST7567_WriteCommand(ST7567_SET_PAGE_ADDRESS|(i & ST7567_SET_PAGE_ADDRESS_MASK));
        ST7567_WriteCommand(ST7567_SET_COLUMN_ADDRESS_MSB|(ST7567_X_OFFSET >> 4));
        ST7567_WriteCommand(ST7567_SET_COLUMN_ADDRESS_LSB|(ST7567_X_OFFSET & 0x0F));
        ST7567_Transmit(pt + (ST7567_WIDTH * i), ST7567_WIDTH, ST7567_TIMEOUT);
    }
}
ohmytime commented 1 year ago

Thank you for your Tips ~

After I use your reference code, the screen can be fully displayed, but a new problem has appeared, It seems to be displayed a bit misplaced. image

IOsetting commented 1 year ago

Adjust the following configurations, depends on your hardware and display mode

// Additional bytes in each row
#define ST7567_SEG_EXPAND 4
// X orientation
#define ST7567_X_ORIENT ST7567_SEG_DIRECTION_REVERSE
// Y orientation
#define ST7567_Y_ORIENT ST7567_COM_DIRECTION_NORMAL

and

#if ST7567_X_ORIENT == ST7567_SEG_DIRECTION_REVERSE
    #define ST7567_X_OFFSET  ST7567_SEG_EXPAND
#else
    #define ST7567_X_OFFSET  0
#endif
ohmytime commented 1 year ago

Adjust the following configurations, depends on your hardware and display mode

// Additional bytes in each row
#define ST7567_SEG_EXPAND 4
// X orientation
#define ST7567_X_ORIENT ST7567_SEG_DIRECTION_REVERSE
// Y orientation
#define ST7567_Y_ORIENT ST7567_COM_DIRECTION_NORMAL

and

#if ST7567_X_ORIENT == ST7567_SEG_DIRECTION_REVERSE
    #define ST7567_X_OFFSET  ST7567_SEG_EXPAND
#else
    #define ST7567_X_OFFSET  0
#endif

Thank you so much for your fast reply, I will try.

ohmytime commented 1 year ago

I change it to this,finally it works.

// Additional bytes in each row
#define ST7567_SEG_EXPAND 0
// X orientation
#define ST7567_X_ORIENT ST7567_SEG_DIRECTION_NORMAL
// Y orientation
// #define ST7567_Y_ORIENT ST7567_COM_DIRECTION_NORMAL
#define ST7567_Y_ORIENT ST7567_COM_DIRECTION_REVERSE
IOsetting commented 1 year ago

Cool!

ohmytime commented 1 year ago

Thanks a lot for your open source library, it's very cool !

IOsetting commented 1 year ago

You are welcome.