extern const uint8_t LOG_map[84 * 82 * 2];
static ARM_NOINIT arm_2d_helper_pfb_t s_tExamplePFB;
extern const uint8_t c_bmpBlueSlashes[];
const arm_2d_tile_t c_tileBlueSlashes = {
.tRegion = {
.tSize = {
.iWidth = 84,
.iHeight = 82
},
},
.tInfo.bIsRoot = true,
.phwBuffer = (uint16_t *)LOG_map,
};
static char LCD_TextBuffer[128];
void log_refresh_handler(const arm_2d_tile_t *ptTarget)
{
arm_2d_region_t tBarRegion = {
.tLocation = {
.iX = (ptTarget->tRegion.tSize.iWidth - c_tileBlueSlashes.tRegion.tSize.iWidth) / 2,
.iY = (ptTarget->tRegion.tSize.iHeight - c_tileBlueSlashes.tRegion.tSize.iHeight) / (int16_t)2,
},
.tSize = {
.iWidth = 84,
.iHeight = 82,
},
};
arm_2d_rgb16_tile_copy( &c_tileBlueSlashes,
ptTarget,
&tBarRegion,
ARM_2D_CP_MODE_COPY);
lcd_text_location(200, 200);
snprintf(LCD_TextBuffer, sizeof(LCD_TextBuffer), "%s\r\n", "SD卡升");
lcd_puts(LCD_TextBuffer, 0xffffffff);
}
static
IMPL_PFB_ON_DRAW(__pfb_draw_LOG_handler)
{
ARM_2D_UNUSED(pTarget);
arm_2d_rgb16_fill_colour(ptTile, NULL, 0x24ff);
log_refresh_handler(ptTile);
return arm_fsm_rt_cpl;
}
static
IMPL_PFB_ON_DRAW(__pfb_draw_background_handler)
{
ARM_2D_UNUSED(pTarget);
ARM_2D_UNUSED(bIsNewFrame);
arm_2d_rgb16_fill_colour(ptTile, NULL, 0x24ff );
return arm_fsm_rt_cpl;
}
static
IMPL_PFB_ON_LOW_LV_RENDERING(__pfb_render_handler)
{
const arm_2d_tile_t *ptTile = &(ptPFB->tTile);
ARM_2D_UNUSED(pTarget);
ARM_2D_UNUSED(bIsNewFrame);
GLCD_DrawBitmap(ptTile->tRegion.tLocation.iX,
ptTile->tRegion.tLocation.iY,
ptTile->tRegion.tSize.iWidth,
ptTile->tRegion.tSize.iHeight,
ptTile->pchBuffer);
arm_2d_helper_pfb_report_rendering_complete(&s_tExamplePFB,
(arm_2d_pfb_t *)ptPFB);
}
void display_task(void)
{
/*! define dirty regions */
IMPL_ARM_2D_REGION_LIST(s_tDirtyRegions, static const)
ADD_REGION_TO_LIST(s_tDirtyRegions,
.tLocation = {0,
0},
.tSize = {
.iWidth = 480,
.iHeight = 272,
},
),
END_IMPL_ARM_2D_REGION_LIST()
//! call partial framebuffer helper service
while(arm_fsm_rt_cpl != arm_2d_helper_pfb_task(
&s_tExamplePFB,
(arm_2d_region_list_item_t *)s_tDirtyRegions));
}
void Peripherals_Init(void)
{
lcd_memory_init();
lcd_rgb_init();
gt9x_init();
GPIO_Init(GPIOM, PIN16, 0, 1, 0);
GPIO_Init(GPIOM, PIN18, 1, 1, 0);
}
int main(void)
{
SystemInit();
systick_init();
Peripherals_Init();
arm_irq_safe
{
arm_2d_init();
}
//! initialise FPB helper
if (ARM_2D_HELPER_PFB_INIT(
&s_tExamplePFB, //!< FPB Helper object
APP_SCREEN_WIDTH, //!< screen width
APP_SCREEN_HEIGHT, //!< screen height
uint16_t, //!< colour date type
PFB_BLOCK_WIDTH, //!< PFB block width
PFB_BLOCK_HEIGHT, //!< PFB block height
1, //!< number of PFB in the PFB pool
{
.evtOnLowLevelRendering = {
//! callback for low level rendering
.fnHandler = &__pfb_render_handler,
},
.evtOnDrawing = {
//! callback for drawing GUI
.fnHandler = &__pfb_draw_background_handler,
},
}
) < 0) {
//! error detected
assert(false);
}
//! draw background first
while (arm_fsm_rt_cpl != arm_2d_helper_pfb_task(&s_tExamplePFB, NULL));
//! update draw function
ARM_2D_HELPER_PFB_UPDATE_ON_DRAW_HANDLER(&s_tExamplePFB,
&__pfb_draw_LOG_handler);
while (1) {
display_task();
GPIO_InvBit(GPIOM, PIN18);
swm_delay_ms(500);
}
}
离线