You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tested it on Arduino and it works well U8G2_ST7565_ERC12864_ALT_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ PB3, /* data=*/ PB5, /* cs=*/ PC12, /* dc=*/ PB6, /* reset=*/ PB7);
But when I port u8g2 lib to CubeIDE + HAL, it does not work, just shows blank
Please help me check this issue. Thank you !!!
This is my code:
uint8_tu8g2_gpio_and_delay_stm32(u8x8_t*u8x8, uint8_tmsg, uint8_targ_int, void*arg_ptr)
{
switch(msg)
{
caseU8X8_MSG_GPIO_AND_DELAY_INIT:
break;
caseU8X8_MSG_DELAY_MILLI:
HAL_Delay(arg_int);
break;
caseU8X8_MSG_GPIO_CS:
HAL_GPIO_WritePin(LCD_CS_GPIO_Port, LCD_CS_Pin, arg_int);
break;
caseU8X8_MSG_GPIO_DC:
HAL_GPIO_WritePin(LCD_DC_GPIO_Port, LCD_DC_Pin, arg_int);
break;
caseU8X8_MSG_GPIO_RESET:
HAL_GPIO_WritePin(LCD_RST_GPIO_Port, LCD_RST_Pin, arg_int);
break;
}
return1;
}
uint8_tu8x8_byte_stm32_hw_spi(u8x8_t*u8x8, uint8_tmsg, uint8_targ_int, void*arg_ptr)
{
switch(msg) {
caseU8X8_MSG_BYTE_SEND:
/* Insert codes to transmit data */if(HAL_SPI_Transmit(&hspi1, arg_ptr, arg_int, 1000) !=HAL_OK) return0;
break;
caseU8X8_MSG_BYTE_INIT:
/* Insert codes to begin SPI transmission */break;
caseU8X8_MSG_BYTE_SET_DC:
/* Control DC pin, U8X8_MSG_GPIO_DC will be called */u8x8_gpio_SetDC(u8x8, arg_int);
break;
caseU8X8_MSG_BYTE_START_TRANSFER:
/* Select slave, U8X8_MSG_GPIO_CS will be called */u8x8_gpio_SetCS(u8x8, u8x8->display_info->chip_enable_level);
HAL_Delay(1);
break;
caseU8X8_MSG_BYTE_END_TRANSFER:
HAL_Delay(1);
/* Insert codes to end SPI transmission */u8x8_gpio_SetCS(u8x8, u8x8->display_info->chip_disable_level);
break;
default:
return0;
}
return1;
}
voidlcd_run(void)
{
u8g2_Setup_st7565_erc12864_alt_f(&u8g2, U8G2_R0, u8x8_byte_stm32_hw_spi, u8g2_gpio_and_delay_stm32);
u8g2_InitDisplay(&u8g2);
u8g2_SetPowerSave(&u8g2, 0);
u8g2_ClearBuffer(&u8g2);
u8g2_SetContrast(&u8g2, 80);
while (1)
{
u8g2_FirstPage(&u8g2);
do
{
u8g2_SetFont(&u8g2, u8g2_font_ncenB14_tr);
u8g2_DrawStr(&u8g2, 0, 15, "Hello World!");
u8g2_DrawCircle(&u8g2, 64, 40, 10, U8G2_DRAW_ALL);
} while (u8g2_NextPage(&u8g2));
}
}
CubeMX Configuration:
The text was updated successfully, but these errors were encountered:
I tested it on Arduino and it works well
U8G2_ST7565_ERC12864_ALT_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ PB3, /* data=*/ PB5, /* cs=*/ PC12, /* dc=*/ PB6, /* reset=*/ PB7);
But when I port u8g2 lib to CubeIDE + HAL, it does not work, just shows blank
Please help me check this issue. Thank you !!!
This is my code:
CubeMX Configuration:
The text was updated successfully, but these errors were encountered: