C
Qt Quick Ultralite freertos_app_switch Example
/****************************************************************************** ** ** Copyright (C) 2022 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Quick Ultralite module. ** ** $QT_BEGIN_LICENSE:COMM$ ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see http://www.qt.io/terms-conditions. For further ** information use the contact form at http://www.qt.io/contact-us. ** ** $QT_END_LICENSE$ ** ******************************************************************************/ #include <stm32f769i_discovery.h> #include "bg_image.h" #include "string.h" //for memcpy and memset extern int __BOOT_VAL_ADDR; extern unsigned char *backBuffer(); extern void QUL_CleanInvalidateDCache_by_Addr(void *, int); extern int imgWidth(); extern int imgHeight(); extern int flushFrame(int, int *); #define BG_IMG_WIDTH 200 #define BG_IMG_HEIGHT BG_IMG_WIDTH int readBootValue() { int *ptr = &__BOOT_VAL_ADDR; return *ptr; } void writeBootValue(int app) { int *ptr = &__BOOT_VAL_ADDR; *ptr = app; QUL_CleanInvalidateDCache_by_Addr((void *) ptr, 4); } void reset(int app) { writeBootValue(app); NVIC_SystemReset(); } void initLED() { BSP_LED_Init(LED1); } void toggleLED() { BSP_LED_Toggle(LED1); } void displayApp2Background() { // Get framebuffer pointer unsigned char *fb = backBuffer(); //Set white background (memset framebuffer to 255) const int width = imgWidth(); const int height = imgHeight(); const int bpp = 4; memset((void *) fb, 255, width * height * bpp); //Copy the content of bg_image to the framebuffer line by line int dummyBudget = 0; const unsigned int h_offset = ((height - BG_IMG_HEIGHT) / 2) * width * bpp; const unsigned int w_offset = ((width - BG_IMG_WIDTH) / 2) * bpp; for (int i = 0; i < BG_IMG_HEIGHT; ++i) { unsigned char *dst = fb + h_offset + w_offset + i * width * bpp; unsigned char *src = &bg_image[i * BG_IMG_WIDTH * bpp]; memcpy((void *) dst, (void *) src, BG_IMG_WIDTH * bpp); } flushFrame(-1, &dummyBudget); }