C
Qt Quick Ultralite freertos_app_switch Example
// Copyright (C) 2024 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial #include "hal_data.h" #include "bg_image.h" #include "string.h" //for memcpy and memset extern bsp_leds_t g_bsp_leds; #if defined(__ICCARM__) #pragma location = ".noinit" #elif defined(__GNUC__) __attribute__((section(".noinit"))) #endif int selectedApplication; #define APP_IMG_WIDTH 480 #define APP_IMG_HEIGHT 272 #define BG_IMG_WIDTH 200 #define BG_IMG_HEIGHT BG_IMG_WIDTH int readBootValue() { return selectedApplication; } void writeBootValue(int app) { selectedApplication = app; } void reset(int app) { writeBootValue(app); NVIC_SystemReset(); } void initLED() {} void toggleLED() { const bsp_io_port_pin_t pin = (bsp_io_port_pin_t) g_bsp_leds.p_leds[BSP_LED_LED1]; R_BSP_PinAccessEnable(); const bsp_io_level_t level = (bsp_io_level_t) R_BSP_PinRead(pin); R_BSP_PinWrite(pin, level == BSP_IO_LEVEL_LOW ? BSP_IO_LEVEL_HIGH : BSP_IO_LEVEL_LOW); R_BSP_PinAccessDisable(); } void displayApp2Background() { R_GLCDC_Open(g_display0.p_ctrl, g_display0.p_cfg); R_GLCDC_Start(g_display0.p_ctrl); // Get framebuffer pointer unsigned char *fb = fb_background[0]; //Set white background (memset framebuffer to 255) const int width = APP_IMG_WIDTH; const int height = APP_IMG_HEIGHT; const int bpp = 2; memset((void *) fb, 255, width * height * bpp); //Copy the content of bg_image to the framebuffer line by line 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); } R_GLCDC_BufferChange(&g_display0.p_ctrl, fb, DISPLAY_FRAME_LAYER_1); }