Skip to content

Commit

Permalink
remove check()
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertGawron committed Dec 12, 2024
1 parent 1813e52 commit 959f8eb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,7 @@ namespace BusinessLogic

Device::Display u8g2(display);

printf("===================== DRAW =======================\n");

u8g2.firstPage();
do
{
// u8g2.drawBox(0, 0, 50, 50);

printf("Processing page...\n");

} while (u8g2.nextPage());
u8g2.init();

MUIU8G2 mui;

Expand Down
61 changes: 28 additions & 33 deletions Software/STM32F103RBTx/Application/Device/Src/Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,37 @@

namespace Device
{
static const uint8_t U8G2_STATUS_OK = 1u;
static const uint8_t U8G2_STATUS_NOT_OK = 0u;

// Maximum number of Display instances supported
static const uint8_t MAX_DISPLAYS = 1u;

struct DisplayMapEntry
{
u8x8_t *u8x8Ptr;
Device::Display *displayPtr;
u8x8_t *u8x8;
Device::Display *display;
};

static DisplayMapEntry gDisplayMap[MAX_DISPLAYS];
static uint8_t gDisplayCount = 1;
static DisplayMapEntry displayMap[MAX_DISPLAYS];
static uint8_t displayCount = 1;

// This is trampoline function.
// It must have the same signature as u8x8_d_st7735.
static uint8_t trampolineU8x8DSt7735(u8x8_t *u8x8, uint8_t msg, uint8_t argInt, void *argPtr)
{
for (int i = 0; i < gDisplayCount; i++)
for (int i = 0; i < displayCount; i++)
{
if (gDisplayMap[i].u8x8Ptr == u8x8)
if (displayMap[i].u8x8 == u8x8)
{
// Found the matching display instance
return gDisplayMap[i].displayPtr->u8x8DSt7735Impl(u8x8, msg, argInt, argPtr);
return displayMap[i].display->u8x8DSt7735Impl(u8x8, msg, argInt, argPtr);
}
}
// No match found, return an error or default response
return 0;
// No match found
return U8G2_STATUS_NOT_OK;
}

static const uint8_t U8G2_STATUS_OK = 1u;
static const uint8_t U8G2_STATUS_NOT_OK = 0u;

static const u8x8_display_info_t u8x8_st7735_128x128_display_info =
{
/* chip_enable_level = */ 0,
Expand Down Expand Up @@ -74,6 +73,18 @@ namespace Device

};

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

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

uint8_t Display::u8x8DSt7735Impl(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)

{
Expand Down Expand Up @@ -155,18 +166,6 @@ namespace Device
return U8G2_STATUS_OK;
}

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

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

void Display::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.
Expand Down Expand Up @@ -195,19 +194,15 @@ namespace Device
Display::Display(Driver::IDisplayDriver &_displayDriver) : displayDriver(_displayDriver)
{

gDisplayMap[0].u8x8Ptr = &u8g2.u8x8;
gDisplayMap[0].displayPtr = this;

const u8g2_cb_t *rotation = U8G2_R0;
uint8_t cs;
uint8_t dc;
uint8_t reset = 0; // U8X8_PIN_NONE;

u8g2_Setup_st7735(&u8g2, rotation, u8x8_byte_dummy_callback, u8x8_gpio_and_delay_dummy_callback);
displayMap[0].u8x8 = &u8g2.u8x8;
displayMap[0].display = this;
}

bool Display::init()
{
const u8g2_cb_t *rotation = U8G2_R0;
u8g2_Setup_st7735(&u8g2, rotation, u8x8_byte_dummy_callback, u8x8_gpio_and_delay_dummy_callback);

return true;
}

Expand Down

0 comments on commit 959f8eb

Please sign in to comment.