Skip to content

Commit

Permalink
it works
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertGawron committed Dec 12, 2024
1 parent b194497 commit 348cc75
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions Software/STM32F103RBTx/Application/Device/Src/Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,23 @@ static const uint8_t u8x8_d_st7735_init_seq[] = {

};

uint8_t my_u8x8_d_st7735(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
uint8_t u8x8_d_st7735(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
{
switch (msg)
{
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
{
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7735_128x128_display_info);
break;
}
break;

case U8X8_MSG_DISPLAY_INIT:
{
printf("Display initialization\n");
u8x8_d_helper_display_init(u8x8);
u8x8_cad_SendSequence(u8x8, u8x8_d_st7735_init_seq);
break;
}
break;

case U8X8_MSG_DISPLAY_DRAW_TILE:
{
Expand Down Expand Up @@ -96,29 +100,35 @@ uint8_t my_u8x8_d_st7735(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_p

tile++;
}
break;
}
break;

case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
printf("Power save mode: %s\n", arg_int ? "ON" : "OFF");
break;
{
}
break;

case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
printf("Flip mode: %s\n", arg_int ? "ON" : "OFF");
break;
{
}
break;

case U8X8_MSG_DISPLAY_REFRESH:;
break;
case U8X8_MSG_DISPLAY_REFRESH:
{
}
break;

default:
{
printf("Unhandled message: %d\n", msg);
break;
}
break;
}

return U8G2_STATUS_OK;
}

void my_u8g2_Setup_st7735(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb)
void u8g2_Setup_st7735(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb)
{
// Calculate the number of tile rows needed for 128x128 resolution.
// Each tile is 8 pixels high, so for a 128-pixel height:
Expand All @@ -137,36 +147,32 @@ void my_u8g2_Setup_st7735(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb b
}

// Setup the display with the appropriate parameters.
u8g2_SetupDisplay(u8g2, my_u8x8_d_st7735, u8x8_cad_001, byte_cb, gpio_and_delay_cb);
u8g2_SetupDisplay(u8g2, u8x8_d_st7735, u8x8_cad_001, byte_cb, gpio_and_delay_cb);

// Configure the buffer and the rendering method (vertical top to bottom).
u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation);

printf("Buffer allocated: %d bytes\n", 128 * tile_buf_height);
printf("%s %d\n", __FILE__, __LINE__);
}

uint8_t my_u8x8_byte_rtthread_4wire_hw_spi(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
uint8_t u8x8_byte_rtthread_4wire_hw_spi(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
{
// Not used. Required by the u8g2 library, but this action is handled by the St7735DisplayDriver class.
return U8G2_STATUS_OK;
}

uint8_t my_u8x8_gpio_and_delay_rtthread(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
uint8_t u8x8_gpio_and_delay_rtthread(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
{
// Not used. Required by the u8g2 library, but this action is handled by the St7735DisplayDriver class.
return U8G2_STATUS_OK;
}
namespace Device
{
Display::Display(Driver::IDisplayDriver &_displayDriver) : displayDriver(_displayDriver)
// Display::Display() /*: U8G2(U8G2_R0)*/
{
const u8g2_cb_t *rotation = U8G2_R0;
uint8_t cs;
uint8_t dc;
uint8_t reset = 0; // U8X8_PIN_NONE;
my_u8g2_Setup_st7735(&u8g2, rotation, my_u8x8_byte_rtthread_4wire_hw_spi, my_u8x8_gpio_and_delay_rtthread);
u8g2_Setup_st7735(&u8g2, rotation, u8x8_byte_rtthread_4wire_hw_spi, u8x8_gpio_and_delay_rtthread);
}

void Display::check()
Expand Down

0 comments on commit 348cc75

Please sign in to comment.