Gabriel Wang преди 1 година
родител
ревизия
1b5b42c414
променени са 27 файла, в които са добавени 8569 реда и са изтрити 1 реда
  1. 2 0
      .gitignore
  2. 0 1
      projects/arm2d/vision_board_mipi_2.0inch_arm2d/.gitignore
  3. 303 0
      projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d.c
  4. 248 0
      projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_cfg.h
  5. 1078 0
      projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_disp_adapter_0.c
  6. 529 0
      projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_disp_adapter_0.h
  7. 174 0
      projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_helper_rtos_rt_thread.c
  8. 491 0
      projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_atom.c
  9. 124 0
      projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_atom.h
  10. 397 0
      projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_audiomark.c
  11. 146 0
      projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_audiomark.h
  12. 365 0
      projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_basics.c
  13. 110 0
      projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_basics.h
  14. 308 0
      projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_console_window.c
  15. 113 0
      projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_console_window.h
  16. 363 0
      projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_gas_gauge.c
  17. 115 0
      projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_gas_gauge.h
  18. 565 0
      projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_listview.c
  19. 114 0
      projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_listview.h
  20. 659 0
      projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_menu.c
  21. 114 0
      projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_menu.h
  22. 544 0
      projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_panel.c
  23. 114 0
      projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_panel.h
  24. 408 0
      projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_progress_status.c
  25. 114 0
      projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_progress_status.h
  26. 585 0
      projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/img2c.py
  27. 486 0
      projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/ttf2c.py

+ 2 - 0
.gitignore

@@ -17,3 +17,5 @@ rtthread.map
 *@*
 *.0???
 *.d
+RTE_Components.h
+Pre_Include_Global.h

+ 0 - 1
projects/arm2d/vision_board_mipi_2.0inch_arm2d/.gitignore

@@ -1,4 +1,3 @@
-/RTE
 /Listings
 /Objects
 ra_cfg.txt

+ 303 - 0
projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d.c

@@ -0,0 +1,303 @@
+/*
+ * Copyright (C) 2010-2022 Arm Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* ----------------------------------------------------------------------
+ * Project:      Arm-2D Library
+ * Title:        arm-2d.c
+ * Description:  Essential components of Arm-2D
+ *
+ * $Date:        4. April 2024
+ * $Revision:    V.1.3.2
+ *
+ * Target Processor:  Cortex-M cores
+ *
+ * -------------------------------------------------------------------- */
+
+
+/*============================ INCLUDES ======================================*/
+#define __ARM_2D_IMPL__
+
+#include "arm_2d.h"
+#include "__arm_2d_impl.h"
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+
+#define __ARM_2D_COMPILATION_UNIT
+#include "../Source/__arm_2d_core.c"
+
+#define __ARM_2D_COMPILATION_UNIT
+#include "../Source/__arm_2d_tile.c"
+
+#if defined(__clang__)
+#   pragma clang diagnostic ignored "-Wunknown-warning-option"
+#   pragma clang diagnostic ignored "-Wformat-nonliteral"
+#endif
+
+
+#ifdef   __cplusplus
+extern "C" {
+#endif
+
+
+
+/*============================ MACROS ========================================*/
+
+#if !defined(__ARM_2D_HAS_ACI__) || !__ARM_2D_HAS_ACI__
+#   define __arm_2d_aci_init()
+#endif
+
+#if !defined(__ARM_2D_HAS_HELIUM__) || !__ARM_2D_HAS_HELIUM__
+#   define __arm_2d_helium_init()
+#endif
+
+#if !defined(__ARM_2D_HAS_TIGHTLY_COUPLED_ACC__) || !__ARM_2D_HAS_TIGHTLY_COUPLED_ACC__
+#   define __arm_2d_sync_acc_init()
+#endif
+
+#if defined(__ARM_2D_HAS_HW_ACC__) && !__ARM_2D_HAS_HW_ACC__
+#   define __arm_2d_async_acc_init()
+#endif
+
+#if defined(__ARM_2D_HAS_ASYNC__) && !__ARM_2D_HAS_ASYNC__
+#   define __arm_2d_async_init(...)
+#endif
+
+#ifndef __ARM_2D_CFG_DEFAULT_SUB_TASK_POOL_SIZE__
+#   define __ARM_2D_CFG_DEFAULT_SUB_TASK_POOL_SIZE__          4
+#endif
+#if __ARM_2D_CFG_DEFAULT_SUB_TASK_POOL_SIZE__ < 4
+#   warning The __ARM_2D_CFG_DEFAULT_SUB_TASK_POOL_SIZE__ should be larger than or\
+ equal to 4, set it to the default value 4.
+#   undef __ARM_2D_CFG_DEFAULT_SUB_TASK_POOL_SIZE__
+#   define __ARM_2D_CFG_DEFAULT_SUB_TASK_POOL_SIZE__          4
+#endif
+
+#if defined(__IS_COMPILER_IAR__) && __IS_COMPILER_IAR__
+#define __va_list    va_list
+#endif
+
+/*============================ MACROFIED FUNCTIONS ===========================*/
+/*============================ TYPES =========================================*/
+/*============================ GLOBAL VARIABLES ==============================*/
+/*============================ PROTOTYPES ====================================*/
+
+#if defined(__ARM_2D_HAS_ASYNC__) && __ARM_2D_HAS_ASYNC__
+/*! 
+ * \brief initialise the arm-2d pipeline
+ * \param ptSubTasks an array of __arm_2d_sub_task_t objects
+ * \param hwCount the number of items in the array
+ * \return arm_2d_err_t error code
+ */
+extern
+arm_2d_err_t __arm_2d_async_init(   __arm_2d_sub_task_t *ptSubTasks, 
+                                    uint_fast16_t hwCount);
+#endif
+
+#if defined(__ARM_2D_HAS_HELIUM__) && __ARM_2D_HAS_HELIUM__
+/*! 
+ * \brief initialise the helium acceleration
+ */
+extern
+void __arm_2d_helium_init(void);
+#endif
+
+#if defined(__ARM_2D_HAS_ACI__) && __ARM_2D_HAS_ACI__
+/*! 
+ * \brief initialise the ACI service
+ */
+extern
+void __arm_2d_aci_init(void);
+#endif
+
+#if defined(__ARM_2D_HAS_HW_ACC__) && __ARM_2D_HAS_HW_ACC__
+/*! 
+ * \brief initialise the hardware (async) acceleration
+ */
+extern
+void __arm_2d_async_acc_init(void);
+#endif
+
+#if defined(__ARM_2D_HAS_TIGHTLY_COUPLED_ACC__) && __ARM_2D_HAS_TIGHTLY_COUPLED_ACC__
+/*! 
+ * \brief initialise the tightly-coupled (sync) acceleration
+ */
+extern
+void __arm_2d_sync_acc_init(void);
+#endif
+
+
+/*! 
+ *  \brief initialise the arm-2d core service
+ */
+extern
+void __arm_2d_init(void);
+
+/*============================ LOCAL VARIABLES ===============================*/
+/*============================ IMPLEMENTATION ================================*/
+
+/*! 
+ * \brief initialise arm-2d
+ */
+void arm_2d_init(void)
+{
+    __arm_2d_init();      
+    
+    do {
+        static __arm_2d_sub_task_t 
+            s_tDefaultTaskPool[__ARM_2D_CFG_DEFAULT_SUB_TASK_POOL_SIZE__];
+
+        ARM_2D_UNUSED(s_tDefaultTaskPool);
+
+        __arm_2d_async_init(s_tDefaultTaskPool, dimof(s_tDefaultTaskPool));
+    } while(0);
+
+    __arm_2d_helium_init();                                             
+    __arm_2d_aci_init();   
+    __arm_2d_sync_acc_init();                                             
+    __arm_2d_async_acc_init();                                                
+}
+
+__WEAK
+void *__arm_2d_allocate_scratch_memory( uint32_t wSize, 
+                                        uint_fast8_t nAlign,
+                                        arm_2d_mem_type_t tType)
+{
+    ARM_2D_UNUSED(nAlign);
+    ARM_2D_UNUSED(tType);
+
+    /* ensure nAlign is 2^n */
+    assert((((~nAlign) + 1) & nAlign) == nAlign);
+
+    void *pBuff = malloc(wSize);
+    assert(0 == ((uintptr_t)pBuff & (nAlign - 1)));
+    
+    return pBuff;
+}
+
+__WEAK
+void __arm_2d_free_scratch_memory( arm_2d_mem_type_t tType,
+                                   void *pBuff)
+{
+    ARM_2D_UNUSED(tType);
+
+    free(pBuff);
+}
+
+
+typedef union arm_2d_log_chn_t {
+    struct {
+        uint32_t        u28ChannelMask  : 28;
+        uint32_t        u4Type          : 4; 
+    };
+    uint32_t wValue;
+} arm_2d_log_chn_t;
+
+
+__WEAK
+void __arm_2d_log_printf(int32_t nIndentLevel, 
+                         uint32_t wChannelMask,
+                         const char *pchPrefix,
+                         const char *pchFormatString,
+                         ...)
+{
+//    arm_2d_log_chn_t tChannelInfo = {
+//        .wValue = wChannelMask,
+//    };
+    static uint32_t s_wLineNumber = 0;
+    if ((__ARM_2D_LOG_CHANNEL_MASK_FILTER__ & wChannelMask) != wChannelMask) {
+        return ;
+    }
+
+    uint32_t wMask = _BV(27);
+
+    for (int32_t i = 0; i < 4; i++) {
+        wMask <<= 1;
+        if (!(wMask & wChannelMask)) {
+            continue;
+        }
+        
+        s_wLineNumber++;
+
+        /* start a new line */
+        __ARM_2D_PORT_PRINTF__("\r\n[%010" PRIu32 "]\t", s_wLineNumber);
+
+        for (int32_t n = 0; n < nIndentLevel; n++) {
+            __ARM_2D_PORT_PRINTF__("\t");
+        }
+
+        if          (ARM_2D_LOG_CHN_TYPE_USER       == wMask) {
+            __ARM_2D_PORT_PRINTF__("[USER]");
+        } else if   (ARM_2D_LOG_CHN_TYPE_INFO       == wMask) {
+        #if defined(__ARM_2D_CFG_LOG_OUTPUT_SUPPORT_COLOUR__) && __ARM_2D_CFG_LOG_OUTPUT_SUPPORT_COLOUR__
+            __ARM_2D_PORT_PRINTF__(ARM_2D_TERMINAL_COLOUR_BRIGHT_BLACK "[INFO]" ARM_2D_TERMINAL_COLOUR_DEFAULT);
+        #endif
+        } else if   (ARM_2D_LOG_CHN_TYPE_WARNING    == wMask) {
+            __ARM_2D_PORT_PRINTF__(ARM_2D_TERMINAL_COLOUR_YELLOW "[WARNING]" ARM_2D_TERMINAL_COLOUR_DEFAULT);
+        } else if   (ARM_2D_LOG_CHN_TYPE_ERROR      == wMask) {
+            __ARM_2D_PORT_PRINTF__(ARM_2D_TERMINAL_COLOUR_RED "[ERROR]" ARM_2D_TERMINAL_COLOUR_DEFAULT);
+        }
+
+        if (NULL != pchPrefix && strlen(pchPrefix) > 0) {
+            __ARM_2D_PORT_PRINTF__("[%s]", pchPrefix);
+        }
+
+        int real_size;
+        char *pchStringBuffer = __arm_2d_allocate_scratch_memory(__ARM_2D_LOG_MAX_STRING_LEN__, 1, ARM_2D_MEM_TYPE_FAST);
+        
+        if (NULL != pchStringBuffer) {
+            __va_list ap;
+            va_start(ap, pchFormatString);
+                real_size = vsnprintf(pchStringBuffer, __ARM_2D_LOG_MAX_STRING_LEN__-1, pchFormatString, ap);
+            va_end(ap);
+            real_size = MIN(__ARM_2D_LOG_MAX_STRING_LEN__-1, real_size);
+            pchStringBuffer[real_size] = '\0';
+
+            __ARM_2D_PORT_PRINTF__("%s", pchStringBuffer);
+
+            free(pchStringBuffer);
+        } else {
+            __ARM_2D_PORT_PRINTF__("[Insufficient memory for logging]%s", pchFormatString);
+        }
+    }
+
+}
+
+
+__WEAK
+arm_2d_op_core_t *arm_2d_op_init(arm_2d_op_core_t *ptOP, size_t tSize)
+{
+    if (NULL != ptOP) {
+        memset(ptOP, 0, MAX(tSize, sizeof(arm_2d_op_core_t)));
+    }
+
+    return ptOP;
+}
+
+__WEAK
+arm_2d_op_core_t *arm_2d_op_depose(arm_2d_op_core_t *ptOP, size_t tSize)
+{
+    ARM_2D_UNUSED(tSize);
+
+    return ptOP;
+}
+
+#ifdef   __cplusplus
+}
+#endif

+ 248 - 0
projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_cfg.h

@@ -0,0 +1,248 @@
+/*
+ * Copyright (c) 2009-2022 Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __ARM_2D_USER_CFG_H__
+#define __ARM_2D_USER_CFG_H__
+
+/*============================ INCLUDES ======================================*/
+
+#if defined(_RTE_)
+#   include "RTE_Components.h"
+#endif
+
+#if defined(__ARM_2D_USER_APP_CFG_H__)
+#   include __ARM_2D_USER_APP_CFG_H__
+#endif
+
+#ifdef   __cplusplus
+extern "C" {
+#endif
+
+/*============================ MACROS ========================================*/
+/*============================ MACROFIED FUNCTIONS ===========================*/
+
+
+//-------- <<< Use Configuration Wizard in Context Menu >>> -----------------
+//
+// <h>Arm-2D General Configurations
+// =======================
+//
+// <q>Enable Asynchronous Programmers' model support
+// <i> Note that if you don't have any hardware accelerator, disable this feature can reduce code size and gain a small performance uplift.
+// <i> This feature is enabled by default.
+#ifndef __ARM_2D_HAS_ASYNC__
+#   define __ARM_2D_HAS_ASYNC__                                     0
+#endif
+
+// <q>Enable anti-alias support for all tranform operations.
+// <i> Note that enabling this feature suffers a non-negligible performance drop.
+// <i> This feature is disabled by default.
+#ifndef __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__
+#   define __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__                      1
+#endif
+
+// <q>Enable support for accessing individual colour channels
+// <i> Note that enabling this feature will add the support for a special colour type: ARM_2D_CHANNEL_8in32
+// <i> This feature is disabled by default to save code size
+#ifndef __ARM_2D_CFG_SUPPORT_COLOUR_CHANNEL_ACCESS__
+#   define __ARM_2D_CFG_SUPPORT_COLOUR_CHANNEL_ACCESS__             1
+#endif
+
+// <q>Enable ccca8888(ARGB8888) implicit conversion 
+// <i> This feature is disabled by default to save code size
+#ifndef __ARM_2D_CFG_SUPPORT_CCCA8888_IMPLICIT_CONVERSION__
+#   define __ARM_2D_CFG_SUPPORT_CCCA8888_IMPLICIT_CONVERSION__      1
+#endif
+
+// <q>Improve the Quality of IIR Blur
+// <i> Note that enabling this feature will half the performance of IIR Blur and only works correctly in Full framebuffer mode
+// <i> This feature is disabled by default to improve performance
+#ifndef __ARM_2D_CFG_USE_IIR_BLUR_REVERSE_PATH__
+#   define __ARM_2D_CFG_USE_IIR_BLUR_REVERSE_PATH__                 0
+#endif
+// </h>
+
+// <h>Log and Debug
+// =======================
+// <q>Enable Log
+// <i> This feature is disabled by default.
+#ifndef __ARM_2D_CFG_ENABLE_LOG__
+#   define __ARM_2D_CFG_ENABLE_LOG__                                0
+#endif
+
+// <q>The terminal support colour
+// <i> The terminal is compatible with VT100 and support colour display. This feature is disabled by default.
+#ifndef __ARM_2D_CFG_LOG_OUTPUT_SUPPORT_COLOUR__
+#   define __ARM_2D_CFG_LOG_OUTPUT_SUPPORT_COLOUR__                 0
+#endif
+
+// <o>The maximum length of log string <64-65535>
+// <i> The number of bytes requested from heap during log output
+// <i> Default: 256
+#ifndef __ARM_2D_LOG_MAX_STRING_LEN__
+#   define __ARM_2D_LOG_MAX_STRING_LEN__        256
+#endif
+
+/* The filter of log channels. Please comment the channels that you want to mask.
+ */
+#ifndef __ARM_2D_LOG_CHANNEL_MASK_FILTER__
+#   define __ARM_2D_LOG_CHANNEL_MASK_FILTER__                                   \
+            (   ARM_2D_LOG_CHN_TYPE_USER                                        \
+            |   ARM_2D_LOG_CHN_TYPE_INFO                                        \
+            |   ARM_2D_LOG_CHN_TYPE_WARNING                                     \
+            |   ARM_2D_LOG_CHN_TYPE_ERROR                                       \
+            |   ARM_2D_LOG_CHN_PIPELINE                                         \
+            |   ARM_2D_LOG_CHN_OPCODE                                           \
+            |   ARM_2D_LOG_CHN_HELPER                                           \
+            |   ARM_2D_LOG_CHN_HELPER_PFB                                       \
+            |   ARM_2D_LOG_CHN_SCENE_PLAYER                                     \
+            |   ARM_2D_LOG_CHN_DIRTY_REGION_OPTIMISATION                        \
+            |   ARM_2D_LOG_CHN_STATISTICS                                       \
+            |   ARM_2D_LOG_CHN_CONTROLS                                         \
+            |   ARM_2D_LOG_CHN_APP)
+#endif
+
+// <q>Enable The Layout Debug Mode
+// <i> Arm-2D will mark the layout areas.
+#ifndef __ARM_2D_HELPER_CFG_LAYOUT_DEBUG_MODE__
+#   define __ARM_2D_HELPER_CFG_LAYOUT_DEBUG_MODE__                  0
+#endif
+
+// </h>
+
+// <h>Patches for improving performance
+// =======================
+// 
+// <c1> Do NOT treat alpha value 255 as completely opaque in mask related operations
+// <i> When define this macro, alpha value 0xFF will not be treated as opaque in mask related operations and you can barely see the background. Defining this macro improves performance.
+//#define __ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__  
+// </c>
+
+// <c1> Ignore calibrartion for small angles in transform operations
+// <i> This option is used to speed up M-cores without DSP support. It skips saturation in the QADD/QDADD/QDSUB involved in the rotation. The chances of overflow remain low as elements involved are using non-accumulating Q15.16 format and integer parts are in the range of the screen size providing enough margin.
+//#define __ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_TRANSFORM__ 
+// </c>
+
+// <c1> Ignore satuation protection in fixed-point operations
+// <i> This option is used to remove calibration in angle computations to gain a better performance, small error might be noticible for angles like 90, 180, 270 etc.
+//#define __ARM_2D_CFG_UNSAFE_NO_SATURATION_IN_FIXED_POINT__ 
+// </c>
+
+
+// <q> Optimize the scaler version of transform operations for pointer-like resources
+// <i> This feature is enabled by default. There is no guarantee that the performance will increase or decrease. It is all depends your applications. In most of the case, enabling it helps.
+// <i> This feature has no meaning when the anti-alias transform is disabled or the helium acceleration is available.
+#ifndef __ARM_2D_CFG_OPTIMIZE_FOR_POINTER_LIKE_SHAPES_IN_TRANSFORM__
+#   define __ARM_2D_CFG_OPTIMIZE_FOR_POINTER_LIKE_SHAPES_IN_TRANSFORM__     1
+#endif
+
+// <q> Optimize the scaler version of transform operations for hollow out masks
+// <i> This feature is disabled by default. There is no guarantee that the performance will increase or decrease. It is all depends your applications. If your application uses a lot of hollow out masks, it might help.
+// <i> This feature has no meaning when the anti-alias transform is disabled or the helium acceleration is available.
+#ifndef __ARM_2D_CFG_OPTIMIZE_FOR_HOLLOW_OUT_MASK_IN_TRANSFORM__
+#   define __ARM_2D_CFG_OPTIMIZE_FOR_HOLLOW_OUT_MASK_IN_TRANSFORM__         0
+#endif
+
+// </h>
+
+
+// <h>Extra Components
+// =======================
+//
+#ifndef __GLCD_CFG_COLOUR_DEPTH__
+// <o __GLCD_CFG_COLOUR_DEPTH__> Select the screen colour depth
+//     <8=>     8 Bits
+//     <16=>    16Bits
+//     <32=>    32Bits
+// <i> The colour depth of your LCD
+// <i> Default: 16
+#   define __GLCD_CFG_COLOUR_DEPTH__                                    16
+#endif
+
+// <o> The size of the LCD printf text buffer <16-65535>
+// <i> The text buffer size for the lcd printf service. It determins how many character you can use in one printf string.
+#ifndef __LCD_PRINTF_CFG_TEXT_BUFFER_SIZE__
+#   define __LCD_PRINTF_CFG_TEXT_BUFFER_SIZE__                          64
+#endif
+
+// <h>Benchmark
+
+// <o>Width of the screen <8-32767>
+// <i> The width of your screen for running benchmark
+// <i> Default: 320
+#ifndef __GLCD_CFG_SCEEN_WIDTH__
+#   define __GLCD_CFG_SCEEN_WIDTH__                                     480
+#endif
+
+// <o>Height of the screen <8-32767>
+// <i> The height of your screen for running benchmark
+// <i> Default: 240
+#ifndef __GLCD_CFG_SCEEN_HEIGHT__
+#   define __GLCD_CFG_SCEEN_HEIGHT__                                    360
+#endif
+
+// <o>Number of iterations <1-2000>
+// <i> run number of iterations in arm-2d benchmark before calculating the result.
+#ifndef ITERATION_CNT
+#   define ITERATION_CNT                                                1000
+#endif
+
+// <q>Use Tiny mode to run benchmark
+// <i> Enable this mode to reduce the benchmark memory footprint (removing background picture etc.)
+// <i> This feature is disabled by default.
+#ifndef __ARM_2D_CFG_BENCHMARK_TINY_MODE__
+#   define __ARM_2D_CFG_BENCHMARK_TINY_MODE__                           0
+#endif
+
+// <q> Enable Stopwatch mode in the Benchmark:Watch-panel
+// <i> Only update the second-hand (i.e. red pointer) every second in the watch-panel demo
+// <i> This feature is disabled by default.
+#ifndef __ARM_2D_CFG_WATCH_PANEL_STOPWATCH_MODE__
+#   define __ARM_2D_CFG_WATCH_PANEL_STOPWATCH_MODE__                    0
+#endif
+
+// <q> Enable the nebula effect mode in the Benchmark:Watch-panel
+// <i> This feature is disabled by default and it is only available in the Tiny mode.
+#ifndef __ARM_2D_CFG_BENCHMARK_WATCH_PANEL_USE_NEBULA__
+#   define __ARM_2D_CFG_BENCHMARK_WATCH_PANEL_USE_NEBULA__              0
+#endif
+
+// <q> Exit benchmark when finished
+// <i> Exit the arm_2d_run_benchmark() after running specified iterations
+// <i> This feature is disabled by default.
+#ifndef __ARM_2D_CFG_BENCHMARK_EXIT_WHEN_FINISH__
+#   define __ARM_2D_CFG_BENCHMARK_EXIT_WHEN_FINISH__                    0
+#endif
+
+//</h>
+// </h>
+
+// <<< end of configuration section >>>
+
+
+/*============================ TYPES =========================================*/
+/*============================ GLOBAL VARIABLES ==============================*/
+/*============================ LOCAL VARIABLES ===============================*/
+/*============================ PROTOTYPES ====================================*/
+
+
+#ifdef   __cplusplus
+}
+#endif
+
+#endif

+ 1078 - 0
projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_disp_adapter_0.c

@@ -0,0 +1,1078 @@
+/*
+ * Copyright (c) 2009-2024 Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*============================ INCLUDES ======================================*/
+
+#include "arm_2d.h"
+
+#ifdef RTE_Acceleration_Arm_2D_Helper_Disp_Adapter0
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "arm_2d_helper.h"
+#include "arm_extra_lcd_printf.h"
+#include "arm_2d_example_controls.h"
+#include "arm_2d_disp_adapter_0.h"
+
+#if defined(__clang__)
+#   pragma clang diagnostic push
+#   pragma clang diagnostic ignored "-Wunknown-warning-option"
+#   pragma clang diagnostic ignored "-Wreserved-identifier"
+#   pragma clang diagnostic ignored "-Wdeclaration-after-statement"
+#   pragma clang diagnostic ignored "-Wsign-conversion"
+#   pragma clang diagnostic ignored "-Wpadded"
+#   pragma clang diagnostic ignored "-Wcast-qual"
+#   pragma clang diagnostic ignored "-Wcast-align"
+#   pragma clang diagnostic ignored "-Wmissing-field-initializers"
+#   pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
+#   pragma clang diagnostic ignored "-Wmissing-prototypes"
+#   pragma clang diagnostic ignored "-Wunused-variable"
+#   pragma clang diagnostic ignored "-Wgnu-statement-expression"
+#   pragma clang diagnostic ignored "-Wdouble-promotion"
+#   pragma clang diagnostic ignored "-Wembedded-directive"
+#elif __IS_COMPILER_ARM_COMPILER_5__
+#elif __IS_COMPILER_IAR__
+#   pragma diag_suppress=Pa089,Pe188,Pe177,Pe174
+#elif __IS_COMPILER_GCC__
+#   pragma GCC diagnostic push
+#   pragma GCC diagnostic ignored "-Wformat="
+#   pragma GCC diagnostic ignored "-Wpedantic"
+#   pragma GCC diagnostic ignored "-Wunused-function"
+#   pragma GCC diagnostic ignored "-Wunused-variable"
+#   pragma GCC diagnostic ignored "-Wunused-value"
+#endif
+
+/*============================ MACROS ========================================*/
+
+#ifndef __DISP0_CFG_ITERATION_CNT__
+#   define __DISP0_CFG_ITERATION_CNT__     30
+#endif
+
+#if __DISP0_CFG_OPTIMIZE_DIRTY_REGIONS__
+#   if      !defined(__DISP0_CFG_DIRTY_REGION_POOL_SIZE__)             \
+        ||  __DISP0_CFG_DIRTY_REGION_POOL_SIZE__ < 4
+#       undef __DISP0_CFG_DIRTY_REGION_POOL_SIZE__
+#       define __DISP0_CFG_DIRTY_REGION_POOL_SIZE__            4
+#   endif
+#endif
+
+#if __DISP0_CFG_USE_CONSOLE__
+
+#ifndef __DISP0_CONSOLE_WIDTH__
+#   if __DISP0_CFG_SCEEN_WIDTH__ < 204
+#       define __DISP0_CONSOLE_WIDTH__      __DISP0_CFG_SCEEN_WIDTH__
+#   else
+#       define __DISP0_CONSOLE_WIDTH__      204
+#   endif
+#endif
+
+#ifndef __DISP0_CONSOLE_HEIGHT__
+#   if __DISP0_CFG_SCEEN_HEIGHT__ < 200
+#       define __DISP0_CONSOLE_HEIGHT__      __DISP0_CFG_SCEEN_HEIGHT__
+#   else
+#       define __DISP0_CONSOLE_HEIGHT__      192
+#   endif
+#endif
+
+#endif
+
+/*============================ MACROFIED FUNCTIONS ===========================*/
+/*============================ TYPES =========================================*/
+/*============================ GLOBAL VARIABLES ==============================*/
+extern uint32_t SystemCoreClock;
+
+/*============================ PROTOTYPES ====================================*/
+extern 
+int32_t Disp0_DrawBitmap(int16_t x, 
+                        int16_t y, 
+                        int16_t width, 
+                        int16_t height, 
+                        const uint8_t *bitmap);
+
+/*============================ LOCAL VARIABLES ===============================*/
+
+#if __DISP0_CFG_NAVIGATION_LAYER_MODE__ == 2
+/* the round mode */
+IMPL_ARM_2D_REGION_LIST(s_tNavDirtyRegionList, static)
+
+    /* a region for the status bar on the bottom of the screen */
+    ADD_LAST_REGION_TO_LIST(s_tNavDirtyRegionList,
+        .tSize = {
+            .iWidth = 100,
+            .iHeight = 24,
+        },
+    ),
+
+END_IMPL_ARM_2D_REGION_LIST(s_tNavDirtyRegionList)
+#endif
+
+ARM_NOINIT 
+arm_2d_scene_player_t DISP0_ADAPTER;
+
+#if __DISP0_CFG_ENABLE_3FB_HELPER_SERVICE__
+ARM_NOINIT
+static 
+arm_2d_helper_3fb_t s_tDirectModeHelper;
+#endif
+
+#if __DISP0_CFG_USE_CONSOLE__
+static 
+struct {
+    console_box_t tConsole;
+    int64_t lTimestamp;
+    arm_2d_region_list_item_t tBackground;
+    uint32_t Signature;
+    bool bShowConsole;
+    uint8_t chOpacity;
+} DISP0_CONSOLE;
+#endif
+
+/*============================ IMPLEMENTATION ================================*/
+static void __on_frame_start(arm_2d_scene_t *ptScene)
+{
+    ARM_2D_UNUSED(ptScene);
+}
+
+static void __on_frame_complete(arm_2d_scene_t *ptScene)
+{
+    ARM_2D_UNUSED(ptScene);
+}
+
+
+static
+IMPL_PFB_ON_DRAW(__pfb_draw_handler)
+{
+    ARM_2D_PARAM(pTarget);
+    ARM_2D_PARAM(ptTile);
+
+    arm_2d_canvas(ptTile, __top_container) {
+        
+        arm_2d_align_centre(__top_container, 100, 100) {
+            draw_round_corner_box(  ptTile,
+                                    &__centre_region,
+                                    GLCD_COLOR_BLACK,
+                                    64,
+                                    bIsNewFrame);
+        }
+
+        busy_wheel2_show(ptTile, bIsNewFrame);
+    }
+
+    arm_2d_op_wait_async(NULL);
+
+    return arm_fsm_rt_cpl;
+}
+
+#if __DISP0_CFG_NAVIGATION_LAYER_MODE__
+
+__WEAK 
+IMPL_PFB_ON_DRAW(__disp_adapter0_user_draw_navigation)
+{
+    ARM_2D_PARAM(ptTile);
+    ARM_2D_PARAM(pTarget);
+    ARM_2D_PARAM(bIsNewFrame);
+
+    return arm_fsm_rt_cpl;
+}
+
+__WEAK
+IMPL_PFB_ON_DRAW(__disp_adapter0_draw_navigation)
+{
+    ARM_2D_PARAM(pTarget);
+    ARM_2D_PARAM(bIsNewFrame);
+
+    while(  arm_fsm_rt_cpl != 
+            __disp_adapter0_user_draw_navigation(  pTarget, 
+                                                            ptTile, 
+                                                            bIsNewFrame));
+
+#if __DISP0_CFG_USE_CONSOLE__
+
+    if (bIsNewFrame) {
+        if (console_box_on_frame_start(&DISP0_CONSOLE.tConsole)) {
+            DISP0_CONSOLE.lTimestamp = 0;
+            if (!DISP0_CONSOLE.bShowConsole) {
+                arm_2d_dirty_region_item_ignore_set(&DISP0_CONSOLE.tBackground, false);
+            } else {
+                arm_2d_dirty_region_item_ignore_set(&DISP0_CONSOLE.tBackground, true);
+            }
+            DISP0_CONSOLE.bShowConsole = true;
+            DISP0_CONSOLE.chOpacity = 255;
+        }
+
+    #if __DISP0_CFG_CONSOLE_DISPALY_TIME__ >= 1000                              \
+    && __DISP0_CFG_CONSOLE_DISPALY_TIME__ != 0xFFFFFFFF
+        if (DISP0_CONSOLE.bShowConsole) {
+            if (arm_2d_helper_is_time_out(__DISP0_CFG_CONSOLE_DISPALY_TIME__, &DISP0_CONSOLE.lTimestamp)) {
+                DISP0_CONSOLE.bShowConsole = false;
+            } else {
+                int64_t lTimeElapsedInMs = -arm_2d_helper_time_elapsed(&DISP0_CONSOLE.lTimestamp);
+                if (lTimeElapsedInMs > 255) {
+                    DISP0_CONSOLE.chOpacity = 255;
+                } else {
+                    DISP0_CONSOLE.chOpacity = lTimeElapsedInMs;
+                }
+            }
+        }
+    #endif
+    }
+
+    arm_2d_canvas(ptTile, __navigation_canvas) {
+
+        if (DISP0_CONSOLE.bShowConsole) {
+            arm_2d_align_top_left(  __navigation_canvas, 
+                                    __DISP0_CONSOLE_WIDTH__ + 8, 
+                                    __DISP0_CONSOLE_HEIGHT__ + 8) {
+
+                draw_round_corner_box(  ptTile, 
+                                        &__top_left_region, 
+                                        GLCD_COLOR_DARK_GREY, 
+                                        (128 * DISP0_CONSOLE.chOpacity) >> 8,
+                                        bIsNewFrame);
+
+                console_box_show(&DISP0_CONSOLE.tConsole,
+                                ptTile,
+                                &__top_left_region,
+                                bIsNewFrame,
+                                DISP0_CONSOLE.chOpacity);
+            }
+        }
+    }
+
+#endif
+
+#if __DISP0_CFG_NAVIGATION_LAYER_MODE__ == 2
+    /* round mode */
+    arm_lcd_text_set_target_framebuffer((arm_2d_tile_t *)ptTile);
+    arm_lcd_text_set_font(&ARM_2D_FONT_6x8.use_as__arm_2d_font_t);
+    arm_lcd_text_set_draw_region(&(s_tNavDirtyRegionList[0].tRegion));
+    
+    if (__DISP0_CFG_ITERATION_CNT__) {
+        draw_round_corner_box(  ptTile, 
+                                &(s_tNavDirtyRegionList[0].tRegion), 
+                                __RGB(64,64,64),
+                                255-32,
+                                bIsNewFrame);
+
+        ARM_2D_OP_WAIT_ASYNC();
+
+        arm_lcd_text_set_colour(GLCD_COLOR_GREEN, GLCD_COLOR_WHITE);
+        arm_lcd_text_location(0,0);
+        if (DISP0_ADAPTER.Benchmark.wAverage) {
+            arm_lcd_printf(
+                "  FPS:%3"PRIu32":%"PRIu32"ms\r\n",
+                MIN(arm_2d_helper_get_reference_clock_frequency() / DISP0_ADAPTER.Benchmark.wAverage, 999),
+                (uint32_t)arm_2d_helper_convert_ticks_to_ms(DISP0_ADAPTER.Benchmark.wAverage));
+        }
+        arm_lcd_printf( 
+            "  CPU:%2.2f%% \r\n", 
+            DISP0_ADAPTER.Benchmark.fCPUUsage);
+
+        arm_lcd_printf( 
+            "  LCD:%2"PRIu32"ms",
+            (uint32_t)arm_2d_helper_convert_ticks_to_ms(DISP0_ADAPTER.Benchmark.wLCDLatency) );
+        
+    }
+#else
+    arm_lcd_text_set_target_framebuffer((arm_2d_tile_t *)ptTile);
+    arm_lcd_text_set_font(&ARM_2D_FONT_6x8.use_as__arm_2d_font_t);
+    arm_lcd_text_set_draw_region(NULL);
+
+    /* draw real-time FPS info */
+    if (__DISP0_CFG_ITERATION_CNT__) {
+        arm_2dp_fill_colour_with_opacity(
+                    NULL, 
+                    ptTile, 
+                    (arm_2d_region_t []){
+                        {
+                            .tLocation = {
+                                .iX = 0,
+                                .iY = ((__DISP0_CFG_SCEEN_HEIGHT__ + 7) / 8 - 2) * 8},
+                            .tSize = {
+                                .iWidth = __DISP0_CFG_SCEEN_WIDTH__,
+                                .iHeight = 8,
+                            },
+                        },
+                    }, 
+                    (__arm_2d_color_t){__RGB(64,64,64)}, 
+                    255 - 32);
+
+        ARM_2D_OP_WAIT_ASYNC();
+
+        arm_lcd_text_set_colour(GLCD_COLOR_GREEN, GLCD_COLOR_WHITE);
+        arm_lcd_text_location((__DISP0_CFG_SCEEN_HEIGHT__ + 7) / 8 - 2,
+                              0);
+
+        if (DISP0_ADAPTER.Benchmark.wAverage) {
+            arm_lcd_printf(
+                "FPS:%3"PRIu32":%"PRIu32"ms ",
+                MIN(arm_2d_helper_get_reference_clock_frequency() / DISP0_ADAPTER.Benchmark.wAverage, 999),
+                (uint32_t)arm_2d_helper_convert_ticks_to_ms(DISP0_ADAPTER.Benchmark.wAverage));
+        }
+
+#if __DISP0_CFG_SCEEN_WIDTH__ >= 240
+        arm_lcd_printf( 
+            "CPU:%2.2f%% LCD-Latency:%2"PRIu32"ms", 
+            DISP0_ADAPTER.Benchmark.fCPUUsage,
+            (uint32_t)arm_2d_helper_convert_ticks_to_ms(DISP0_ADAPTER.Benchmark.wLCDLatency));
+#else
+        arm_lcd_printf( 
+            "LCD:%2"PRIu32"ms",
+            (uint_fast64_t)arm_2d_helper_convert_ticks_to_ms(DISP0_ADAPTER.Benchmark.wLCDLatency) );
+#endif
+    }
+
+#if __DISP0_CFG_SCEEN_WIDTH__ >= 320 
+
+    /* draw verion info on the bottom right corner */
+    arm_lcd_text_set_colour(GLCD_COLOR_LIGHT_GREY, GLCD_COLOR_WHITE);
+    arm_lcd_text_location( (__DISP0_CFG_SCEEN_HEIGHT__ + 7) / 8 - 2, 
+                            (__DISP0_CFG_SCEEN_WIDTH__ / 6) - 12);
+    arm_lcd_printf("v" 
+                    ARM_TO_STRING(ARM_2D_VERSION_MAJOR)
+                    "."
+                    ARM_TO_STRING(ARM_2D_VERSION_MINOR)
+                    "."
+                    ARM_TO_STRING(ARM_2D_VERSION_PATCH)
+                    "-"
+                    ARM_2D_VERSION_STR
+                    );
+#endif
+#endif
+    ARM_2D_OP_WAIT_ASYNC();
+
+    return arm_fsm_rt_cpl;
+}
+#endif
+
+#if __DISP0_CFG_ENABLE_3FB_HELPER_SERVICE__
+__WEAK
+IMPL_PFB_ON_LOW_LV_RENDERING(__disp_adapter0_pfb_render_handler)
+{
+    const arm_2d_tile_t *ptTile = &(ptPFB->tTile);
+
+    ARM_2D_PARAM(pTarget);
+    ARM_2D_PARAM(bIsNewFrame);
+
+    if (__arm_2d_helper_3fb_draw_bitmap(&s_tDirectModeHelper,
+                                        ptPFB)) {
+
+        arm_2d_helper_pfb_report_rendering_complete(
+                        &DISP0_ADAPTER.use_as__arm_2d_helper_pfb_t);
+    }
+}
+
+void *disp_adapter0_3fb_get_flush_pointer(void)
+{
+    return arm_2d_helper_3fb_get_flush_pointer(&s_tDirectModeHelper);
+}
+
+
+#   if __DISP0_CFG_ENABLE_ASYNC_FLUSHING__
+/* using asynchronous flushing, e.g. using DMA + ISR to offload CPU etc. 
+ * It can significantly reduce the LCD Latency hence improve the overrall 
+ * framerate. 
+ */
+
+void disp_adapter0_insert_2d_copy_complete_event_handler(void)
+{
+    arm_2d_helper_pfb_report_rendering_complete(
+                    &DISP0_ADAPTER.use_as__arm_2d_helper_pfb_t);
+}
+
+/* using asynchronous flushing, e.g. using DMA + ISR to offload CPU etc. 
+ * It can significantly reduce the LCD Latency hence improve the overrall 
+ * framerate. 
+ */
+
+void disp_adapter0_insert_dma_copy_complete_event_handler(void)
+{
+    arm_2d_helper_3fb_report_dma_copy_complete(&s_tDirectModeHelper);
+}
+
+
+#   endif
+
+#else
+#   if __DISP0_CFG_ENABLE_ASYNC_FLUSHING__
+
+/* using asynchronous flushing, e.g. using DMA + ISR to offload CPU etc. 
+ * It can significantly reduce the LCD Latency hence improve the overrall 
+ * framerate. 
+ */
+
+void disp_adapter0_insert_async_flushing_complete_event_handler(void)
+{
+    arm_2d_helper_pfb_report_rendering_complete(
+                    &DISP0_ADAPTER.use_as__arm_2d_helper_pfb_t);
+}
+
+__WEAK
+IMPL_PFB_ON_LOW_LV_RENDERING(__disp_adapter0_pfb_render_handler)
+{
+    const arm_2d_tile_t *ptTile = &(ptPFB->tTile);
+
+    ARM_2D_PARAM(pTarget);
+    ARM_2D_PARAM(bIsNewFrame);
+
+    /* request an asynchronous flushing */
+    __disp_adapter0_request_async_flushing(
+                    pTarget,
+                    bIsNewFrame,
+                    ptTile->tRegion.tLocation.iX,
+                    ptTile->tRegion.tLocation.iY,
+                    ptTile->tRegion.tSize.iWidth,
+                    ptTile->tRegion.tSize.iHeight,
+                    (const COLOUR_INT *)ptTile->pchBuffer);
+
+}
+
+#   else
+/* using asynchronous flushing, i.e. use CPU to flush LCD.
+ * The LCD Latency will be high and reduce the overral framerate.
+ * Meanwhile, in developing stage, this method can ensure a robust flushing. 
+ */
+
+__WEAK
+IMPL_PFB_ON_LOW_LV_RENDERING(__disp_adapter0_pfb_render_handler)
+{
+    const arm_2d_tile_t *ptTile = &(ptPFB->tTile);
+
+    ARM_2D_PARAM(pTarget);
+    ARM_2D_PARAM(bIsNewFrame);
+
+    Disp0_DrawBitmap(ptTile->tRegion.tLocation.iX,
+                    ptTile->tRegion.tLocation.iY,
+                    ptTile->tRegion.tSize.iWidth,
+                    ptTile->tRegion.tSize.iHeight,
+                    (const uint8_t *)ptTile->pchBuffer);
+
+    arm_2d_helper_pfb_report_rendering_complete(
+                    &DISP0_ADAPTER.use_as__arm_2d_helper_pfb_t);
+}
+#   endif
+#endif
+
+static bool __on_each_frame_complete(void *ptTarget)
+{
+    ARM_2D_PARAM(ptTarget);
+    
+    int64_t lTimeStamp = arm_2d_helper_get_system_timestamp();
+    
+#if __DISP0_CFG_FPS_CACULATION_MODE__ == ARM_2D_FPS_MODE_REAL
+    static int64_t s_lLastTimeStamp = 0;
+
+    int32_t nElapsed = 0;
+    if (0 != s_lLastTimeStamp) {
+        nElapsed = (int32_t)(lTimeStamp - s_lLastTimeStamp);
+    }
+    s_lLastTimeStamp = lTimeStamp;
+    
+#else /* __DISP0_CFG_FPS_CACULATION_MODE__ == ARM_2D_FPS_MODE_RENDER_ONLY */
+    int32_t nElapsed = DISP0_ADAPTER.use_as__arm_2d_helper_pfb_t.Statistics.nTotalCycle;
+#endif
+
+    int32_t nTotalLCDCycCount = DISP0_ADAPTER.use_as__arm_2d_helper_pfb_t.Statistics.nRenderingCycle;
+    DISP0_ADAPTER.Benchmark.wLCDLatency = nTotalLCDCycCount;
+
+    /* calculate real-time FPS */
+    if (__DISP0_CFG_ITERATION_CNT__) {
+        if (DISP0_ADAPTER.Benchmark.hwIterations) {
+            int32_t nRenderCycle = DISP0_ADAPTER.use_as__arm_2d_helper_pfb_t.Statistics.nTotalCycle;
+            DISP0_ADAPTER.Benchmark.wMin = MIN((uint32_t)nElapsed, DISP0_ADAPTER.Benchmark.wMin);
+            DISP0_ADAPTER.Benchmark.wMax = MAX(nElapsed, (int32_t)DISP0_ADAPTER.Benchmark.wMax);
+            DISP0_ADAPTER.Benchmark.dwTotal += nElapsed;
+            DISP0_ADAPTER.Benchmark.dwRenderTotal += nRenderCycle;
+            DISP0_ADAPTER.Benchmark.hwIterations--;
+            DISP0_ADAPTER.Benchmark.hwFrameCounter += (nRenderCycle != 0) ? 1 : 0;
+
+            if (0 == DISP0_ADAPTER.Benchmark.hwIterations) {
+
+                if (0 == DISP0_ADAPTER.Benchmark.hwFrameCounter) {
+                    DISP0_ADAPTER.Benchmark.wAverage = 0;
+                } else {
+                    DISP0_ADAPTER.Benchmark.wAverage =
+                        (uint32_t)(DISP0_ADAPTER.Benchmark.dwTotal / (uint64_t)DISP0_ADAPTER.Benchmark.hwFrameCounter);
+                    DISP0_ADAPTER.Benchmark.wAverage = MAX(1, DISP0_ADAPTER.Benchmark.wAverage);
+                }
+
+                int64_t lElapsed = lTimeStamp - DISP0_ADAPTER.Benchmark.lTimestamp;
+                if (lElapsed) {
+                    DISP0_ADAPTER.Benchmark.fCPUUsage = (float)((double)DISP0_ADAPTER.Benchmark.dwRenderTotal / (double)lElapsed) * 100.0f;
+                }
+
+                /* log statistics */
+                if (DISP0_ADAPTER.Benchmark.wAverage) {
+                    ARM_2D_LOG_INFO(
+                        STATISTICS, 
+                        0, 
+                        "DISP_ADAPTER0", 
+                        "FPS:%3d(%dms)\tCPU:%2.2f%%\tLCD-Latency:%2dms",
+                        MIN(arm_2d_helper_get_reference_clock_frequency() / DISP0_ADAPTER.Benchmark.wAverage, 999),
+                        (int32_t)arm_2d_helper_convert_ticks_to_ms(DISP0_ADAPTER.Benchmark.wAverage),
+                        DISP0_ADAPTER.Benchmark.fCPUUsage,
+                        (int32_t)arm_2d_helper_convert_ticks_to_ms(DISP0_ADAPTER.Benchmark.wLCDLatency)
+                    );
+                } else {
+                    ARM_2D_LOG_INFO(
+                        STATISTICS, 
+                        0, 
+                        "DISP_ADAPTER0", 
+                        "FPS: SKIPPED\tCPU:%2.2f%%\tLCD-Latency:%2dms",
+                        DISP0_ADAPTER.Benchmark.fCPUUsage,
+                        (int32_t)arm_2d_helper_convert_ticks_to_ms(DISP0_ADAPTER.Benchmark.wLCDLatency)
+                    );
+                }
+                 
+                DISP0_ADAPTER.Benchmark.wMin = UINT32_MAX;
+                DISP0_ADAPTER.Benchmark.wMax = 0;
+                DISP0_ADAPTER.Benchmark.dwTotal = 0;
+                DISP0_ADAPTER.Benchmark.dwRenderTotal = 0;
+                DISP0_ADAPTER.Benchmark.hwIterations = __DISP0_CFG_ITERATION_CNT__;
+                DISP0_ADAPTER.Benchmark.hwFrameCounter = 0;
+
+                DISP0_ADAPTER.Benchmark.lTimestamp = arm_2d_helper_get_system_timestamp();
+            }
+        }
+    }
+    
+    return true;
+}
+
+
+#if __DISP0_CFG_ROTATE_SCREEN__
+/*!
+ * \brief before-flushing event handler
+ * \param[in] ptOrigin the original PFB
+ * \param[in] ptScratch A scratch PFB
+ * \return true the new content is stored in ptScratch
+ * \return false the new content is stored in ptOrigin
+ */
+static IMPL_PFB_BEFORE_FLUSHING(__before_flushing)
+{
+    ARM_2D_PARAM(pTarget);
+    ARM_2D_PARAM(ptOrigin);
+    ARM_2D_PARAM(ptScratch);
+
+
+#if      __DISP0_CFG_COLOUR_DEPTH__ == 8
+#   define __COLOUR_NAME__  c8bit
+#elif    __DISP0_CFG_COLOUR_DEPTH__ == 16
+#   define __COLOUR_NAME__  rgb16
+#elif    __DISP0_CFG_COLOUR_DEPTH__ == 32
+#   define __COLOUR_NAME__  rgb32
+#endif
+
+#if     __DISP0_CFG_ROTATE_SCREEN__ == 1
+#   define __ROTATE__       90
+#elif   __DISP0_CFG_ROTATE_SCREEN__ == 2
+#   define __ROTATE__       180
+#elif   __DISP0_CFG_ROTATE_SCREEN__ == 3
+#   define __ROTATE__       270
+#endif
+
+    ARM_CONNECT(__arm_2d_helper_pfb_rotate, __ROTATE__,_, __COLOUR_NAME__)(
+        ptOrigin, 
+        ptScratch,
+        (arm_2d_size_t []) {
+            {
+                __DISP0_CFG_SCEEN_WIDTH__,
+                __DISP0_CFG_SCEEN_HEIGHT__
+            }
+        });
+
+    return true;
+}
+
+#endif
+
+static void __user_scene_player_init(void)
+{
+    memset(&DISP0_ADAPTER, 0, sizeof(DISP0_ADAPTER));
+
+#if __DISP0_CFG_OPTIMIZE_DIRTY_REGIONS__
+    ARM_NOINIT
+    static arm_2d_region_list_item_t s_tDirtyRegionList[__DISP0_CFG_DIRTY_REGION_POOL_SIZE__]; 
+#endif
+
+    //! initialise FPB helper
+    if (ARM_2D_HELPER_PFB_INIT(
+        &DISP0_ADAPTER.use_as__arm_2d_helper_pfb_t,                            //!< FPB Helper object
+        __DISP0_CFG_SCEEN_WIDTH__,                                     //!< screen width
+        __DISP0_CFG_SCEEN_HEIGHT__,                                    //!< screen height
+        COLOUR_INT,                                                             //!< colour date type
+        __DISP0_COLOUR_FORMAT__,                                       //!< colour format
+        __DISP0_CFG_PFB_BLOCK_WIDTH__,                                 //!< PFB block width
+        __DISP0_CFG_PFB_BLOCK_HEIGHT__,                                //!< PFB block height
+        __DISP0_CFG_PFB_HEAP_SIZE__                                    //!< number of PFB in the PFB pool
+
+#if     __DISP0_CFG_VIRTUAL_RESOURCE_HELPER__                          \
+    &&  !__DISP0_CFG_USE_HEAP_FOR_VIRTUAL_RESOURCE_HELPER__
+        + __DISP0_CFG_VIRTUAL_RESOURCE_HELPER__
+#else
+        + (__DISP0_CFG_ROTATE_SCREEN__ > 0)
+#endif
+        ,{
+            .evtOnLowLevelRendering = {
+                //! callback for low level rendering
+                .fnHandler = &__disp_adapter0_pfb_render_handler,
+            },
+            .evtOnEachFrameCPL = {
+                .fnHandler = &__on_each_frame_complete,
+            },
+#if __DISP0_CFG_ROTATE_SCREEN__
+            .evtBeforeFlushing = {
+                .fnHandler = &__before_flushing,
+            },
+#endif
+        },
+#if __DISP0_CFG_SWAP_RGB16_HIGH_AND_LOW_BYTES__
+        .FrameBuffer.bSwapRGB16 = true,
+#endif
+#if __DISP0_CFG_DEBUG_DIRTY_REGIONS__
+        .FrameBuffer.bDebugDirtyRegions = true,
+#endif
+        .FrameBuffer.u3PixelWidthAlign = __DISP0_CFG_PFB_PIXEL_ALIGN_WIDTH__,
+        .FrameBuffer.u3PixelHeightAlign = __DISP0_CFG_PFB_PIXEL_ALIGN_HEIGHT__,
+#if     __DISP0_CFG_VIRTUAL_RESOURCE_HELPER__                          \
+    &&  !__DISP0_CFG_USE_HEAP_FOR_VIRTUAL_RESOURCE_HELPER__
+        // reserve PFB blocks for the virtual resource service
+        .FrameBuffer.u4PoolReserve = __DISP0_CFG_VIRTUAL_RESOURCE_HELPER__,
+#endif
+#if __DISP0_CFG_OPTIMIZE_DIRTY_REGIONS__
+        .DirtyRegion.ptRegions = s_tDirtyRegionList,
+        .DirtyRegion.chCount = dimof(s_tDirtyRegionList),
+#endif
+    ) < 0) {
+        //! error detected
+        assert(false);
+    }
+
+#if __DISP0_CFG_ENABLE_3FB_HELPER_SERVICE__
+    do {
+    extern uintptr_t __DISP_ADAPTER0_3FB_FB0_ADDRESS__;
+    extern uintptr_t __DISP_ADAPTER0_3FB_FB1_ADDRESS__;
+    extern uintptr_t __DISP_ADAPTER0_3FB_FB2_ADDRESS__;
+    
+    extern arm_2d_helper_2d_copy_handler_t __disp_adapter0_request_2d_copy;
+    extern arm_2d_helper_dma_copy_handler_t __disp_adapter0_request_dma_copy;
+    
+    
+        arm_2d_helper_3fb_cfg_t tCFG = {
+            .tScreenSize = {
+                __DISP0_CFG_SCEEN_WIDTH__,
+                __DISP0_CFG_SCEEN_HEIGHT__,
+            },
+            .chPixelBits = __DISP0_CFG_COLOUR_DEPTH__,
+            .pnAddress = {
+                [0] = ((uintptr_t)__DISP_ADAPTER0_3FB_FB0_ADDRESS__),
+                [1] = ((uintptr_t)__DISP_ADAPTER0_3FB_FB1_ADDRESS__),
+                [2] = ((uintptr_t)__DISP_ADAPTER0_3FB_FB2_ADDRESS__),
+            },
+#if __DISP0_CFG_ENABLE_ASYNC_FLUSHING__
+            .evtOn2DCopy = {
+                .fnHandler = __disp_adapter0_request_2d_copy,
+            },
+            .evtOnDMACopy = {
+                .fnHandler = __disp_adapter0_request_dma_copy,
+            },
+#endif
+        };
+        
+        arm_2d_helper_3fb_init(&s_tDirectModeHelper, &tCFG);
+    
+    } while(0);
+#endif
+
+    arm_lcd_text_init((arm_2d_region_t []) {
+                        { .tSize = {
+                            .iWidth = __DISP0_CFG_SCEEN_WIDTH__,
+                            .iHeight = __DISP0_CFG_SCEEN_HEIGHT__,
+                        }}});
+
+    DISP0_ADAPTER.Benchmark.wMin = UINT32_MAX;
+    DISP0_ADAPTER.Benchmark.hwIterations = __DISP0_CFG_ITERATION_CNT__;
+    DISP0_ADAPTER.Benchmark.hwFrameCounter = 0;
+}
+
+#if __DISP0_CFG_NAVIGATION_LAYER_MODE__
+__WEAK 
+void disp_adapter0_navigator_init(void)
+{
+#if __DISP0_CFG_NAVIGATION_LAYER_MODE__ == 2
+    
+    static const arm_2d_region_t tScreen = {
+        .tSize = {
+            .iWidth = __DISP0_CFG_SCEEN_WIDTH__,
+            .iHeight = __DISP0_CFG_SCEEN_HEIGHT__,
+        },
+    };
+    
+    arm_2d_align_bottom_centre(tScreen, s_tNavDirtyRegionList[0].tRegion.tSize) {
+        s_tNavDirtyRegionList[0].tRegion = __bottom_centre_region;
+        s_tNavDirtyRegionList[0].tRegion.tLocation.iY -= 16;
+    }
+#else
+    /*! define dirty regions for the navigation layer */
+    IMPL_ARM_2D_REGION_LIST(s_tNavDirtyRegionList, static)
+
+        /* a region for the status bar on the bottom of the screen */
+        ADD_LAST_REGION_TO_LIST(s_tNavDirtyRegionList,
+            .tLocation = {
+                .iX = 0,
+                .iY = ((__DISP0_CFG_SCEEN_HEIGHT__ + 7) / 8 - 2) * 8},
+            .tSize = {
+                .iWidth = __DISP0_CFG_SCEEN_WIDTH__,
+                .iHeight = 8,
+            },
+        ),
+
+    END_IMPL_ARM_2D_REGION_LIST(s_tNavDirtyRegionList)
+#endif
+
+#if __DISP0_CFG_USE_CONSOLE__
+    do {
+
+    #if __DISP0_CFG_CONSOLE_INPUT_BUFFER__
+        static uint8_t s_chInputBuffer[256];
+    #endif
+        static uint8_t s_chConsoleBuffer[   (__DISP0_CONSOLE_WIDTH__ / 6) 
+                                        *   (__DISP0_CONSOLE_HEIGHT__ / 8)];
+        console_box_cfg_t tCFG = {
+            .tBoxSize = {
+                .iWidth = __DISP0_CONSOLE_WIDTH__, 
+                .iHeight = __DISP0_CONSOLE_HEIGHT__,
+            },
+
+            .pchConsoleBuffer = s_chConsoleBuffer,
+            .hwConsoleBufferSize = sizeof(s_chConsoleBuffer),
+
+        #if __DISP0_CFG_CONSOLE_INPUT_BUFFER__
+            .pchInputBuffer = s_chInputBuffer,
+            .hwInputBufferSize = sizeof(s_chInputBuffer),
+        #endif
+
+            .tColor = GLCD_COLOR_GREEN,
+            .bUseDirtyRegion = true,
+            .ppDirtyRegionList = (arm_2d_region_list_item_t **)&s_tNavDirtyRegionList,
+        };
+
+        console_box_init(   &DISP0_CONSOLE.tConsole, 
+                            NULL, 
+                            &tCFG);
+    } while(0);
+
+    arm_2d_dirty_region_item_ignore_set(&DISP0_CONSOLE.tBackground, true);
+    
+    arm_2d_region_t tScreen = {
+        .tSize = {
+            __DISP0_CFG_SCEEN_WIDTH__, 
+            __DISP0_CFG_SCEEN_HEIGHT__
+        },
+    };
+
+    arm_2d_align_top_left(tScreen, 220, 200) {
+        DISP0_CONSOLE.tBackground.tRegion = __top_left_region;
+    }
+
+    arm_2d_helper_pfb_append_dirty_regions_to_list(
+                                (arm_2d_region_list_item_t **)&s_tNavDirtyRegionList,
+                                &DISP0_CONSOLE.tBackground,
+                                1);
+ 
+    DISP0_CONSOLE.lTimestamp = 0;
+
+    DISP0_CONSOLE.Signature = ARM_2D_VERSION;
+#endif
+
+    /* register event handler for evtOnDrawNavigation */
+    arm_2d_scene_player_register_on_draw_navigation_event_handler(
+                    &DISP0_ADAPTER,
+                    __disp_adapter0_draw_navigation,
+                    NULL,
+                    (arm_2d_region_list_item_t *)s_tNavDirtyRegionList);
+}
+#else
+__WEAK 
+void disp_adapter0_navigator_init(void)
+{
+
+}
+#endif
+
+#if __DISP0_CFG_USE_CONSOLE__
+
+#include <stdarg.h>
+
+#if defined(__IS_COMPILER_IAR__) && __IS_COMPILER_IAR__
+#define __va_list    va_list
+#endif
+
+ARM_NONNULL(1)
+int disp_adapter0_printf(const char *format, ...)
+{
+    int real_size, n;
+    char s_chBuffer[128];
+    char *pchSrc = s_chBuffer;
+
+    __va_list ap;
+    va_start(ap, format);
+        real_size = vsnprintf(s_chBuffer, sizeof(s_chBuffer)-1, format, ap);
+    va_end(ap);
+    real_size = MIN(sizeof(s_chBuffer)-1, real_size);
+    s_chBuffer[real_size] = '\0';
+    n = real_size;
+
+    do {
+        if (!console_box_putchar(&DISP0_CONSOLE.tConsole, *pchSrc++)) {
+            break;
+        }
+    } while(--n);
+
+    return real_size;
+}
+
+bool disp_adapter0_putchar(uint8_t chChar)
+{
+    if (DISP0_CONSOLE.Signature != ARM_2D_VERSION) {
+        return false;
+    }
+
+    return console_box_putchar(&DISP0_CONSOLE.tConsole,chChar);
+}
+
+#endif
+
+/*----------------------------------------------------------------------------*
+ * Display Adapter Entry                                                      *
+ *----------------------------------------------------------------------------*/
+
+void disp_adapter0_init(void)
+{
+    __user_scene_player_init();
+
+    arm_extra_controls_init();
+
+    disp_adapter0_navigator_init();
+
+    DISP0_ADAPTER.Benchmark.lTimestamp = arm_2d_helper_get_system_timestamp();
+
+    if (!__DISP0_CFG_DISABLE_DEFAULT_SCENE__) {
+    #if 0
+        /*! define dirty regions */
+        IMPL_ARM_2D_REGION_LIST(s_tDirtyRegions, const static)
+
+            /* a region for the busy wheel */
+            ADD_LAST_REGION_TO_LIST(s_tDirtyRegions,
+                .tLocation = {
+                    .iX = ((__DISP0_CFG_SCEEN_WIDTH__ - 100) >> 1),
+                    .iY = ((__DISP0_CFG_SCEEN_HEIGHT__ - 100) >> 1),
+                },
+                .tSize = {
+                    .iWidth = 100,
+                    .iHeight = 100,
+                },
+            ),
+
+        END_IMPL_ARM_2D_REGION_LIST()
+    #endif
+    
+        static arm_2d_scene_t s_tScenes[] = {
+            [0] = {
+            
+                /* the canvas colour */
+                .tCanvas = {GLCD_COLOR_WHITE}, 
+        
+                .fnScene        = &__pfb_draw_handler,
+                //.ptDirtyRegion  = (arm_2d_region_list_item_t *)s_tDirtyRegions,
+                .fnOnFrameStart = &__on_frame_start,
+                .fnOnFrameCPL   = &__on_frame_complete,
+                .fnDepose       = NULL,
+            },
+        };
+        arm_2d_scene_player_append_scenes( 
+                                        &DISP0_ADAPTER,
+                                        (arm_2d_scene_t *)s_tScenes,
+                                        dimof(s_tScenes));
+    }
+}
+
+arm_fsm_rt_t __disp_adapter0_task(void)
+{
+    return arm_2d_scene_player_task(&DISP0_ADAPTER);
+}
+
+
+/*----------------------------------------------------------------------------*
+ * Virtual Resource Helper                                                    *
+ *----------------------------------------------------------------------------*/
+
+#if __DISP0_CFG_VIRTUAL_RESOURCE_HELPER__
+
+__WEAK
+void * __disp_adapter0_aligned_malloc(size_t nSize, size_t nAlign)
+{
+    ARM_2D_UNUSED(nAlign);
+
+    /* ensure nAlign is 2^n */
+    assert((((~nAlign) + 1) & nAlign) == nAlign);
+
+    void * pMem = malloc(nSize);
+    assert( 0 == ((uintptr_t)pMem & (nAlign - 1)));
+    return pMem;
+}
+
+__WEAK
+void __disp_adapter0_free(void *pMem)
+{
+    if (NULL != pMem) {
+        free(pMem);
+    }
+}
+
+
+
+intptr_t __disp_adapter0_vres_asset_loader (
+                                            uintptr_t pObj, 
+                                            arm_2d_vres_t *ptVRES, 
+                                            arm_2d_region_t *ptRegion)
+{
+    COLOUR_INT *pBuffer = NULL;
+    size_t nPixelSize = sizeof(COLOUR_INT);
+    size_t tBufferSize;
+    uint32_t nBytesPerLine = ptRegion->tSize.iWidth * nPixelSize;
+    size_t nBitsPerPixel = sizeof(COLOUR_INT) << 3;
+
+    if (0 != ptVRES->tTile.tColourInfo.chScheme) {
+        nBitsPerPixel = (1 << ptVRES->tTile.tColourInfo.u3ColourSZ);
+        if (ptVRES->tTile.tColourInfo.u3ColourSZ >= 3) {
+            nPixelSize = (1 << (ptVRES->tTile.tColourInfo.u3ColourSZ - 3));
+            nBytesPerLine = ptRegion->tSize.iWidth * nPixelSize;
+        } else {
+            /* for A1, A2 and A4 */
+            size_t nPixelPerByte = 1 << (3 - ptVRES->tTile.tColourInfo.u3ColourSZ);
+            int16_t iOffset = ptRegion->tLocation.iX & (nPixelPerByte - 1);
+            
+            uint32_t nBitsPerLine =  nBitsPerPixel * (iOffset + ptRegion->tSize.iWidth);
+            nBytesPerLine = (nBitsPerLine + 7) >> 3;
+        }
+    }
+    
+    /* default condition */
+    tBufferSize = ptRegion->tSize.iHeight * nBytesPerLine;
+    
+    
+#if __DISP0_CFG_USE_HEAP_FOR_VIRTUAL_RESOURCE_HELPER__
+    pBuffer = __disp_adapter0_aligned_malloc(tBufferSize, nPixelSize);
+    assert(NULL != pBuffer);
+
+    if (NULL == pBuffer) {
+        return (intptr_t)NULL;
+    }
+#else
+    arm_2d_pfb_t *ptPFB = __arm_2d_helper_pfb_new(&DISP0_ADAPTER.use_as__arm_2d_helper_pfb_t);
+    assert(NULL != ptPFB);
+    
+    assert(ptPFB->u24Size >= tBufferSize);
+    
+    if (tBufferSize > ptPFB->u24Size) {
+        return (intptr_t)NULL;
+    }
+    pBuffer = (COLOUR_INT *)((uintptr_t)ptPFB + sizeof(arm_2d_pfb_t));
+#endif
+    /* load content into the buffer */
+    if (nBitsPerPixel < 8) {
+        /* A1, A2 and A4 support */
+        uintptr_t pSrc = __disp_adapter0_vres_get_asset_address(pObj, ptVRES);
+        uintptr_t pDes = (uintptr_t)pBuffer;
+        
+        uint32_t iBitsperLineInSource = ptVRES->tTile.tRegion.tSize.iWidth * nBitsPerPixel;
+        int16_t iSourceStride = (int16_t)((uint32_t)(iBitsperLineInSource + 7) >> 3);
+
+        /* calculate offset */
+        pSrc += (ptRegion->tLocation.iY * iSourceStride);
+        pSrc += (ptRegion->tLocation.iX * nBitsPerPixel) >> 3;
+        
+        for (int_fast16_t y = 0; y < ptRegion->tSize.iHeight; y++) {
+            __disp_adapter0_vres_read_memory(   pObj, 
+                                                (void *)pDes, 
+                                                (uintptr_t)pSrc, 
+                                                nBytesPerLine);
+
+            pDes += nBytesPerLine;
+            pSrc += iSourceStride;
+        }
+    } else {
+        uintptr_t pSrc = __disp_adapter0_vres_get_asset_address(pObj, ptVRES);
+        uintptr_t pDes = (uintptr_t)pBuffer;
+        int16_t iTargetStride = ptRegion->tSize.iWidth;
+        int16_t iSourceStride = ptVRES->tTile.tRegion.tSize.iWidth;
+
+        /* calculate offset */
+        pSrc += (ptRegion->tLocation.iY * iSourceStride + ptRegion->tLocation.iX) * nPixelSize;
+        
+        for (int_fast16_t y = 0; y < ptRegion->tSize.iHeight; y++) {
+            __disp_adapter0_vres_read_memory( 
+                                            pObj, 
+                                            (void *)pDes, 
+                                            (uintptr_t)pSrc, 
+                                            nPixelSize * iTargetStride);
+            
+            pDes += iTargetStride * nPixelSize;
+            pSrc += iSourceStride * nPixelSize;
+        }
+    } while(0);
+    
+    return (intptr_t)pBuffer;
+}
+
+
+void __disp_adapter0_vres_buffer_deposer (
+                                            uintptr_t pTarget, 
+                                            arm_2d_vres_t *ptVRES, 
+                                            intptr_t pBuffer )
+{
+#if __DISP0_CFG_USE_HEAP_FOR_VIRTUAL_RESOURCE_HELPER__
+    ARM_2D_UNUSED(pTarget);
+    ARM_2D_UNUSED(ptVRES);
+
+    if ((intptr_t)NULL != pBuffer) {
+        __disp_adapter0_free((void *)pBuffer);
+    }
+#else
+    ARM_2D_UNUSED(pTarget);
+    ARM_2D_UNUSED(ptVRES);
+    if ((intptr_t)NULL == pBuffer) {
+        return ;
+    }
+    
+    arm_2d_pfb_t *ptPFB = (arm_2d_pfb_t *)((uintptr_t)pBuffer - sizeof(arm_2d_pfb_t));
+    __arm_2d_helper_pfb_free(&DISP0_ADAPTER.use_as__arm_2d_helper_pfb_t, ptPFB);
+#endif
+}
+
+#endif
+
+
+#if defined(__clang__)
+#   pragma clang diagnostic pop
+#endif
+
+#endif
+
+

+ 529 - 0
projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_disp_adapter_0.h

@@ -0,0 +1,529 @@
+/*
+ * Copyright (c) 2009-2024 Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __ARM_2D_DISP_ADAPTER0_H__
+#define __ARM_2D_DISP_ADAPTER0_H__
+
+#include "arm_2d.h"
+
+#ifdef RTE_Acceleration_Arm_2D_Helper_Disp_Adapter0
+
+#include "arm_2d_helper_scene.h"
+#include "__common.h"
+
+#ifdef   __cplusplus
+extern "C" {
+#endif
+
+#if defined(__clang__)
+#   pragma clang diagnostic push
+#   pragma clang diagnostic ignored "-Wunknown-warning-option"
+#   pragma clang diagnostic ignored "-Wreserved-identifier"
+#   pragma clang diagnostic ignored "-Wdeclaration-after-statement"
+#   pragma clang diagnostic ignored "-Wpadded"
+#   pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
+#endif
+
+/*============================ INCLUDES ======================================*/
+/*============================ MACROS ========================================*/
+
+//-------- <<< Use Configuration Wizard in Context Menu >>> -----------------
+//
+// <o> Select the screen colour depth
+//     <8=>     8 Bits
+//     <16=>    16Bits
+//     <32=>    32Bits
+// <i> The colour depth of your screen
+#ifndef __DISP0_CFG_COLOUR_DEPTH__
+#   define __DISP0_CFG_COLOUR_DEPTH__                              16
+#endif
+
+// <o>Width of the screen <8-32767>
+// <i> The width of your screen
+// <i> Default: 320
+#ifndef __DISP0_CFG_SCEEN_WIDTH__
+#   define __DISP0_CFG_SCEEN_WIDTH__                               480
+#endif
+
+// <o>Height of the screen <8-32767>
+// <i> The height of your screen
+// <i> Default: 240
+#ifndef __DISP0_CFG_SCEEN_HEIGHT__
+#   define __DISP0_CFG_SCEEN_HEIGHT__                              360
+#endif
+
+/*
+  ARM_SCREEN_NO_ROTATION   0
+  ARM_SCREEN_ROTATE_90     1
+  ARM_SCREEN_ROTATE_180    2
+  ARM_SCREEN_ROTATE_270    3
+ */
+
+// <o>Rotate the Screen
+//     <0=>  NO Rotation
+//     <1=>    90 Degree
+//     <2=>   180 Degree
+//     <3=>   270 Degree
+// <i> Rotate the Screen for specified degrees.
+// <i> NOTE: This is extremely slow. Please avoid using it whenever it is possible.
+#ifndef __DISP0_CFG_ROTATE_SCREEN__
+#   define __DISP0_CFG_ROTATE_SCREEN__                             0
+#endif
+
+// <o>Width of the PFB block
+// <i> The width of your PFB block size used in disp0
+#ifndef __DISP0_CFG_PFB_BLOCK_WIDTH__
+#   define __DISP0_CFG_PFB_BLOCK_WIDTH__                           480
+#endif
+
+// <o>Height of the PFB block
+// <i> The height of your PFB block size used in disp0
+#ifndef __DISP0_CFG_PFB_BLOCK_HEIGHT__
+#   define __DISP0_CFG_PFB_BLOCK_HEIGHT__                          36
+#endif
+
+// <o>Width Alignment of generated PFBs
+//     <0=>     1 pixel
+//     <1=>     2 pixel
+//     <2=>     4 pixel
+//     <3=>     8 pixel
+//     <4=>    16 pixel
+//     <5=>    32 pixel
+//     <6=>    64 pixel
+//     <7=>   128 pixel
+// <i> Make sure the x and width of the PFB is always aligned to 2^n pixels
+#ifndef __DISP0_CFG_PFB_PIXEL_ALIGN_WIDTH__
+#   define __DISP0_CFG_PFB_PIXEL_ALIGN_WIDTH__                     1
+#endif
+
+// <o>Height Alignment of generated PFBs
+//     <0=>     1 pixel
+//     <1=>     2 pixel
+//     <2=>     4 pixel
+//     <3=>     8 pixel
+//     <4=>    16 pixel
+//     <5=>    32 pixel
+//     <6=>    64 pixel
+//     <7=>   128 pixel
+// <i> Make sure the y and height of the PFB is always aligned to 2^n pixels
+#ifndef __DISP0_CFG_PFB_PIXEL_ALIGN_HEIGHT__
+#   define __DISP0_CFG_PFB_PIXEL_ALIGN_HEIGHT__                    0
+#endif
+
+// <o>PFB Block Count <1-65535>
+// <i> The number of blocks in the PFB pool.
+#ifndef __DISP0_CFG_PFB_HEAP_SIZE__
+#   define __DISP0_CFG_PFB_HEAP_SIZE__                             1
+#endif
+
+// <o>Number of iterations <0-2000>
+// <i> run number of iterations before calculate the FPS.
+#ifndef __DISP0_CFG_ITERATION_CNT__
+#   define __DISP0_CFG_ITERATION_CNT__                             30
+#endif
+
+// <o>FPS Calculation Mode
+//     <0=>     Render-Only FPS
+//     <1=>     Real FPS
+// <i> Decide the meaning of the real time FPS display
+#ifndef __DISP0_CFG_FPS_CACULATION_MODE__
+#   define __DISP0_CFG_FPS_CACULATION_MODE__                       1
+#endif
+
+// <q> Enable Dirty Region Debug Mode
+// <i> Draw dirty regions on the screen for debug.
+#ifndef __DISP0_CFG_DEBUG_DIRTY_REGIONS__
+#   define __DISP0_CFG_DEBUG_DIRTY_REGIONS__                       0
+#endif
+
+// <q> Enable Dirty Region Optimization Service
+// <i> Optimize dirty regions to avoid fresh overlapped areas
+#ifndef __DISP0_CFG_OPTIMIZE_DIRTY_REGIONS__
+#   define __DISP0_CFG_OPTIMIZE_DIRTY_REGIONS__                    1
+#endif
+
+// <o> Dirty Region Pool Size <4-255>
+// <i> The number of dirty region items available for the dirty region optimization service
+#ifndef __DISP0_CFG_DIRTY_REGION_POOL_SIZE__
+#   define __DISP0_CFG_DIRTY_REGION_POOL_SIZE__                    8
+#endif
+
+// <q> Swap the high and low bytes
+// <i> Swap the high and low bytes of the 16bit-pixels
+#ifndef __DISP0_CFG_SWAP_RGB16_HIGH_AND_LOW_BYTES__
+#   define __DISP0_CFG_SWAP_RGB16_HIGH_AND_LOW_BYTES__             0
+#endif
+
+// <q>Enable the helper service for Asynchronous Flushing
+// <i> Please select this option when using asynchronous flushing, e.g. DMA + ISR 
+#ifndef __DISP0_CFG_ENABLE_ASYNC_FLUSHING__
+#   define __DISP0_CFG_ENABLE_ASYNC_FLUSHING__                     0
+#endif
+
+// <q>Enable the helper service for 3FB (LCD Direct Mode)
+// <i> You can select this option when your LCD controller supports direct mode
+#ifndef __DISP0_CFG_ENABLE_3FB_HELPER_SERVICE__
+#   define __DISP0_CFG_ENABLE_3FB_HELPER_SERVICE__                 0
+#endif
+
+// <q>Disable the default scene
+// <i> Remove the default scene for this display adapter. We highly recommend you to disable the default scene when creating real applications.
+#ifndef __DISP0_CFG_DISABLE_DEFAULT_SCENE__
+#   define __DISP0_CFG_DISABLE_DEFAULT_SCENE__                     0
+#endif
+
+// <o>Navigation Layer Mode
+//     <0=>     Disable Navigation Layer
+//     <1=>     Normal Mode (Bottom)
+//     <2=>     Tiny Mode (Bottom Centre)
+// <i> Configure the default navigation layer of this display adapter. 
+// <i> NOTE: Disable the navigation layer will also remove the real-time FPS display.
+#ifndef __DISP0_CFG_NAVIGATION_LAYER_MODE__
+#   define __DISP0_CFG_NAVIGATION_LAYER_MODE__                              1
+#endif
+
+// <q> Enable Console
+// <i> Add a simple console to the display adapter in a floating window.
+// <i> This feature is disabled by default.
+#ifndef __DISP0_CFG_USE_CONSOLE__
+#   define __DISP0_CFG_USE_CONSOLE__                                0
+#endif
+
+// <o> Console Input Buffer Size
+// <i> The size of console input buffer, 0 means no input buffer
+#ifndef __DISP0_CFG_CONSOLE_INPUT_BUFFER__
+#   define __DISP0_CFG_CONSOLE_INPUT_BUFFER__                       255
+#endif
+
+// <o> Console Display Time in ms <1000-0xFFFFFFFF>
+// <i> The time before the console disappear for each content update.
+#ifndef __DISP0_CFG_CONSOLE_DISPALY_TIME__
+#   define __DISP0_CFG_CONSOLE_DISPALY_TIME__                       3000
+#endif
+
+// <o>Maximum number of Virtual Resources used per API
+//     <0=>     NO Virtual Resource
+//     <1=>     1 Per API
+//     <2=>     2 Per API
+//     <3=>     3 Per API
+// <i> Introduce a helper service for loading virtual resources.
+// <i> This feature is disabled by default.
+#ifndef __DISP0_CFG_VIRTUAL_RESOURCE_HELPER__
+#   define __DISP0_CFG_VIRTUAL_RESOURCE_HELPER__                   0
+#endif
+
+// <q>Use heap to allocate buffer in the virtual resource helper service
+// <i> Use malloc and free in the virtual resource helper service. When disabled, a static buffer in the size of current display adapter PFB will be used. 
+// <i> This feature is disabled by default.
+#ifndef __DISP0_CFG_USE_HEAP_FOR_VIRTUAL_RESOURCE_HELPER__
+#   define __DISP0_CFG_USE_HEAP_FOR_VIRTUAL_RESOURCE_HELPER__      0
+#endif
+// <<< end of configuration section >>>
+
+#ifndef __DISP0_COLOUR_FORMAT__
+#   if      __DISP0_CFG_COLOUR_DEPTH__ == 8
+#       define __DISP0_COLOUR_FORMAT__  ARM_2D_COLOUR_GRAY8
+#   elif    __DISP0_CFG_COLOUR_DEPTH__ == 16
+#       define __DISP0_COLOUR_FORMAT__  ARM_2D_COLOUR_RGB565
+#   elif    __DISP0_CFG_COLOUR_DEPTH__ == 32
+#       define __DISP0_COLOUR_FORMAT__  ARM_2D_COLOUR_CCCN888
+#   endif
+#endif
+
+/*============================ MACROFIED FUNCTIONS ===========================*/
+
+#if __DISP0_CFG_VIRTUAL_RESOURCE_HELPER__
+#define disp_adapter0_impl_vres(__COLOUR_FORMAT, __WIDTH, __HEIGHT,...)         \
+{                                                                               \
+    .tTile = {                                                                  \
+        .tRegion = {                                                            \
+            .tSize = {                                                          \
+                .iWidth = (__WIDTH),                                            \
+                .iHeight =(__HEIGHT),                                           \
+            },                                                                  \
+        },                                                                      \
+        .tInfo = {                                                              \
+            .bIsRoot = true,                                                    \
+            .bHasEnforcedColour = true,                                         \
+            .bVirtualResource = true,                                           \
+            .tColourInfo = {                                                    \
+                .chScheme = (__COLOUR_FORMAT),                                  \
+            },                                                                  \
+        },                                                                      \
+    },                                                                          \
+    .Load       = &__disp_adapter0_vres_asset_loader,                           \
+    .Depose     = &__disp_adapter0_vres_buffer_deposer,                         \
+    __VA_ARGS__                                                                 \
+}
+#endif
+
+#define disp_adapter0_task(...)                                                 \
+        ({                                                                      \
+        static bool ARM_2D_SAFE_NAME(s_bRefreshLCD) = false;                    \
+        arm_fsm_rt_t ARM_2D_SAFE_NAME(ret) = arm_fsm_rt_on_going;               \
+        if (!__ARM_VA_NUM_ARGS(__VA_ARGS__)) {                                  \
+            ARM_2D_SAFE_NAME(ret) = __disp_adapter0_task();                     \
+        } else {                                                                \
+            if (!ARM_2D_SAFE_NAME(s_bRefreshLCD)) {                             \
+                /* lock framerate */                                            \
+                if (arm_2d_helper_is_time_out(1000 / (1000,##__VA_ARGS__))) {   \
+                    ARM_2D_SAFE_NAME(s_bRefreshLCD) = true;                     \
+                }                                                               \
+            } else {                                                            \
+                ARM_2D_SAFE_NAME(ret) = __disp_adapter0_task();                 \
+                if (arm_fsm_rt_cpl == ARM_2D_SAFE_NAME(ret)) {                  \
+                    ARM_2D_SAFE_NAME(s_bRefreshLCD) = false;                    \
+                }                                                               \
+            }                                                                   \
+        };                                                                      \
+        ARM_2D_SAFE_NAME(ret);})
+
+/*============================ TYPES =========================================*/
+/*============================ GLOBAL VARIABLES ==============================*/
+ARM_NOINIT
+extern
+arm_2d_scene_player_t DISP0_ADAPTER;
+
+/*============================ PROTOTYPES ====================================*/
+
+extern
+void disp_adapter0_init(void);
+
+extern
+arm_fsm_rt_t __disp_adapter0_task(void);
+
+
+#if __DISP0_CFG_VIRTUAL_RESOURCE_HELPER__
+/*!
+ *  \brief a method to load a specific part of an image
+ *  \note It is NOT an API for users to call, plese leave it alone
+ *
+ *  \param[in] pTarget a reference of an user object 
+ *  \param[in] ptVRES a reference of this virtual resource
+ *  \param[in] ptRegion the target region of the image
+ *  \return intptr_t the address of a resource buffer which holds the content
+ */
+intptr_t __disp_adapter0_vres_asset_loader   (
+                                                uintptr_t pTarget, 
+                                                arm_2d_vres_t *ptVRES, 
+                                                arm_2d_region_t *ptRegion);
+    
+/*!
+ *  \brief a method to despose the buffer
+ *  \note It is NOT an API for users to call, plese leave it alone
+ *
+ *  \param[in] pTarget a reference of an user object 
+ *  \param[in] ptVRES a reference of this virtual resource
+ *  \param[in] pBuffer the target buffer
+ */
+void __disp_adapter0_vres_buffer_deposer (  uintptr_t pTarget, 
+                                                arm_2d_vres_t *ptVRES, 
+                                                intptr_t pBuffer );
+
+/*!
+ * \brief A user implemented function to return the address for specific asset
+ *        stored in external memory, e.g. SPI Flash
+ * \note You MUST provide an implementation when 
+ *       __DISP0_CFG_VIRTUAL_RESOURCE_HELPER__ is enabled(1)
+ *
+ * \param[in] pObj an pointer of user defined object, it is used for OOC
+ * \note You can ignore pObj if you don't care/don't use OOC 
+ *
+ * \param[in] ptVRES the target virtual resource object
+ * \return uintptr_t the address of the target asset in external memory
+ */
+extern
+uintptr_t __disp_adapter0_vres_get_asset_address(
+                                                        uintptr_t pObj,
+                                                        arm_2d_vres_t *ptVRES);
+
+/*!
+ * \brief A user implemented function to copy content from external memory
+ *        (e.g. SPI Flash) to a local buffer with specified address and size.
+ *
+ * \note You MUST provide an implementation when 
+ *       __DISP0_CFG_VIRTUAL_RESOURCE_HELPER__ is enabled(1)
+ *
+ * \param[in] pObj an pointer of user defined object, it is used for OOC
+ * \note You can ignore pObj if you don't care/don't use OOC 
+ *
+ * \param[in] pBuffer the address of the local buffer
+ * \param[in] pAddress the address in the external memory
+ * \param[in] nSizeInByte number of bytes to read
+ */
+extern
+void __disp_adapter0_vres_read_memory( intptr_t pObj, 
+                                                void *pBuffer,
+                                                uintptr_t pAddress,
+                                                size_t nSizeInByte);
+
+#endif
+
+#if __DISP0_CFG_ENABLE_ASYNC_FLUSHING__
+
+#   if __DISP0_CFG_ENABLE_3FB_HELPER_SERVICE__
+
+/*!
+ * \brief An user implemented interface for DMA memory-to-memory copy.
+ *        You should implement an ISR for copy-complete event and call
+ *        disp_adapter0_insert_dma_copy_complete_event_handler() or
+ *        arm_2d_helper_3fb_report_dma_copy_complete() to notify the 
+ *        3FB (direct mode) helper service.
+ * 
+ * \param[in] ptThis the helper service control block
+ * \param[in] pObj the address of the user object
+ * \param[in] pnSource the source address of the memory block
+ * \param[in] pnTarget the target address
+ * \param[in] nDataItemCount the number of date items
+ * \param[in] chDataItemSize the size of each data item 
+ */
+extern
+void __disp_adapter0_request_dma_copy(  arm_2d_helper_3fb_t *ptThis,
+                                        void *pObj,
+                                        uintptr_t pnSource,
+                                        uintptr_t pnTarget,
+                                        uint32_t nDataItemCount,
+                                        uint_fast8_t chDataItemSize);
+
+/*!
+ * \brief An user implemented interface for 2D-Copy.
+ * \param[in] pnSource the source image address
+ * \param[in] wSourceStride the stride of the source image
+ * \param[in] pnTarget the address in the target framebuffer
+ * \param[in] wTargetStride the stride of the target framebuffer
+ * \param[in] iWidth the safe width of the source image
+ * \param[in] iHeight the safe height of the source image
+ * \retval true the 2D copy is complete when leaving this function
+ * \retval false An async 2D copy request is sent to the DMA
+ *
+ * \note if false is replied, you have to call 
+ *       disp_adapter0_insert_2d_copy_complete_event_handler() to report
+ *       the completion of the 2d-copy. 
+ */
+bool __disp_adapter0_request_2d_copy(   arm_2d_helper_3fb_t *ptThis,
+                                        void *pObj,
+                                        uintptr_t pnSource,
+                                        uint32_t wSourceStride,
+                                        uintptr_t pnTarget,
+                                        uint32_t wTargetStride,
+                                        int16_t iWidth,
+                                        int16_t iHeight,
+                                        uint_fast8_t chBytePerPixel );
+
+/*!
+ * \brief the handler for the 2d copy complete event.
+ * \note When both __DISP0_CFG_ENABLE_ASYNC_FLUSHING__ and 
+ *       __DISP0_CFG_ENABLE_3FB_HELPER_SERVICE__ is set to '1', user 
+ *       MUST call this function to notify the PFB helper that the previous
+ *       asynchronouse 2d copy is complete. 
+ * \note When people using DMA+ISR to offload CPU, this fucntion is called in 
+ *       the DMA transfer complete ISR.
+ */
+extern
+void disp_adapter0_insert_2d_copy_complete_event_handler(void);
+
+/*!
+ * \brief the handler for the dma copy complete event.
+ * \note When both __DISP0_CFG_ENABLE_ASYNC_FLUSHING__ and 
+ *       __DISP0_CFG_ENABLE_3FB_HELPER_SERVICE__ is set to '1', user 
+ *       MUST call this function to notify the PFB helper that the previous
+ *       dma copy is complete. 
+ * \note When people using DMA+ISR to offload CPU, this fucntion is called in 
+ *       the DMA transfer complete ISR.
+ */
+extern
+void disp_adapter0_insert_dma_copy_complete_event_handler(void);
+
+#   else
+
+/*!
+ * \brief It is an user implemented function that request an LCD flushing in 
+ *        asynchronous manner. 
+ * \note User MUST implement this function when 
+ *       __DISP0_CFG_ENABLE_ASYNC_FLUSHING__ is set to '1'
+ *
+ * \param[in] pTarget an user specified object address
+ * \param[in] bIsNewFrame whether this flushing request is the first iteration 
+ *            of a new frame.
+ * \param[in] iX the x coordinate of a flushing window in the target screen
+ * \param[in] iY the y coordinate of a flushing window in the target screen
+ * \param[in] iWidth the width of a flushing window
+ * \param[in] iHeight the height of a flushing window
+ * \param[in] pBuffer the frame buffer address
+ */
+extern void __disp_adapter0_request_async_flushing( 
+                                                    void *pTarget,
+                                                    bool bIsNewFrame,
+                                                    int16_t iX, 
+                                                    int16_t iY,
+                                                    int16_t iWidth,
+                                                    int16_t iHeight,
+                                                    const COLOUR_INT *pBuffer);
+
+
+/*!
+ * \brief the handler for the asynchronous flushing complete event.
+ * \note When __DISP0_CFG_ENABLE_ASYNC_FLUSHING__ is set to '1', user 
+ *       MUST call this function to notify the PFB helper that the previous
+ *       asynchronous flushing is complete. 
+ * \note When people using DMA+ISR to offload CPU, this fucntion is called in 
+ *       the DMA transfer complete ISR.
+ */
+extern
+void disp_adapter0_insert_async_flushing_complete_event_handler(void);
+
+#   endif
+#endif
+
+#if __DISP0_CFG_ENABLE_3FB_HELPER_SERVICE__
+
+/*!
+ * \brief get a pointer for flushing
+ * \return void * the address of a framebuffer
+ * 
+ * \note please only call this function when on vsync event.
+ */
+extern
+void *disp_adapter0_3fb_get_flush_pointer(void);
+
+#endif
+
+
+#if __DISP0_CFG_USE_CONSOLE__
+extern
+ARM_NONNULL(1)
+int disp_adapter0_printf(const char *format, ...);
+
+extern
+bool disp_adapter0_putchar(uint8_t chChar);
+#else
+#   define disp_adapter0_printf(__format_string, ...)
+#   define disp_adapter0_putchar(...)           (true)
+#endif
+
+#if defined(__clang__)
+#   pragma clang diagnostic pop
+#endif
+
+#ifdef   __cplusplus
+}
+#endif
+
+#endif
+
+#endif

+ 174 - 0
projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_helper_rtos_rt_thread.c

@@ -0,0 +1,174 @@
+/*
+ * Copyright (c) 2009-2024 Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*============================ INCLUDES ======================================*/
+
+
+#include "arm_2d_helper.h"
+#include "arm_2d_disp_adapters.h"
+#include "rtthread.h"
+
+#if defined(__PERF_COUNTER__) && defined(__PERF_CNT_USE_RTOS__)
+#   include "perf_counter.h"
+#endif
+
+#if defined(__clang__)
+#   pragma clang diagnostic push
+#   pragma clang diagnostic ignored "-Wunknown-warning-option"
+#   pragma clang diagnostic ignored "-Wreserved-identifier"
+#   pragma clang diagnostic ignored "-Wdeclaration-after-statement"
+#   pragma clang diagnostic ignored "-Wsign-conversion"
+#   pragma clang diagnostic ignored "-Wpadded"
+#   pragma clang diagnostic ignored "-Wcast-qual"
+#   pragma clang diagnostic ignored "-Wcast-align"
+#   pragma clang diagnostic ignored "-Wmissing-field-initializers"
+#   pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
+#   pragma clang diagnostic ignored "-Wmissing-prototypes"
+#   pragma clang diagnostic ignored "-Wunused-variable"
+#   pragma clang diagnostic ignored "-Wgnu-statement-expression"
+#   pragma clang diagnostic ignored "-Wmissing-variable-declarations"
+#   pragma clang diagnostic ignored "-Wbad-function-cast"
+#   pragma clang diagnostic ignored "-Wunreachable-code-break"
+#   pragma clang diagnostic ignored "-Wshorten-64-to-32"
+#   pragma clang diagnostic ignored "-Wdouble-promotion"
+#elif __IS_COMPILER_ARM_COMPILER_5__
+#elif __IS_COMPILER_GCC__
+#   pragma GCC diagnostic push
+#   pragma GCC diagnostic ignored "-Wformat="
+#   pragma GCC diagnostic ignored "-Wpedantic"
+#endif
+
+/*============================ MACROS ========================================*/
+/*============================ MACROFIED FUNCTIONS ===========================*/
+/*============================ TYPES =========================================*/
+/*============================ GLOBAL VARIABLES ==============================*/
+/*============================ PROTOTYPES ====================================*/
+extern
+void *__arm_2d_helper_perf_counter_get(arm_2d_perfc_type_t tType);
+/*============================ LOCAL VARIABLES ===============================*/
+
+/*============================ IMPLEMENTATION ================================*/
+
+__OVERRIDE_WEAK
+arm_2d_runtime_feature_t ARM_2D_RUNTIME_FEATURE = {
+    .TREAT_OUT_OF_RANGE_AS_COMPLETE         = 1,
+    .HAS_DEDICATED_THREAD_FOR_2D_TASK       = __ARM_2D_HAS_ASYNC__,
+};
+
+
+/*----------------------------------------------------------------------------*
+ * RTOS Port                                                                  *
+ *----------------------------------------------------------------------------*/
+__OVERRIDE_WEAK
+uintptr_t arm_2d_port_new_semaphore(void)
+{
+    rt_sem_t pSemaphore = RT_NULL;
+    pSemaphore = rt_sem_create("dsem", 0, RT_IPC_FLAG_PRIO);    
+    assert(NULL != pSemaphore);
+
+    return (uintptr_t)pSemaphore;
+}
+
+__OVERRIDE_WEAK
+void arm_2d_port_free_semaphore(uintptr_t pSemaphore)
+{
+    rt_sem_t evtFlag = (rt_sem_t)pSemaphore;
+    if (NULL != evtFlag) {
+        rt_sem_delete((rt_sem_t)pSemaphore);
+    }
+}
+
+__OVERRIDE_WEAK
+bool arm_2d_port_wait_for_semaphore(uintptr_t pSemaphore)
+{
+    rt_sem_t evtFlag = (rt_sem_t)pSemaphore;
+    if (NULL != evtFlag) {
+        rt_sem_take(evtFlag, RT_WAITING_FOREVER);
+    }
+    return true;
+}
+
+__OVERRIDE_WEAK
+void arm_2d_port_set_semaphoret(uintptr_t pSemaphore)
+{
+    rt_sem_t evtFlag = (rt_sem_t)pSemaphore;
+    if (NULL != evtFlag) {
+        rt_sem_release(evtFlag);
+    }    
+}
+
+
+/*----------------------------------------------------------------------------*
+ * Application main thread                                                    *
+ *----------------------------------------------------------------------------*/
+
+
+__NO_RETURN
+void arm_2d_backend_thread(void *argument)
+{
+    ARM_2D_UNUSED(argument);
+
+#if defined(__PERF_COUNTER__) && defined(__PERF_CNT_USE_RTOS__)
+    /* init the cycle counter for the current task */
+    init_task_cycle_counter();
+    
+    
+    do {
+        task_cycle_info_t *ptInfo = __arm_2d_helper_perf_counter_get(ARM_2D_PERFC_RENDER);
+        if (NULL == ptInfo) {
+            break;
+        }
+        static task_cycle_info_agent_t s_tAgent;
+        
+        /* initialize the cross tasks task-cycle-info object */
+        init_task_cycle_info(ptInfo);
+        register_task_cycle_agent(ptInfo, &s_tAgent);
+
+    } while(0);
+#endif
+
+    arm_2d_helper_backend_task();
+    
+    //osThreadExit();
+    while(1) __NOP();
+}
+
+
+void arm_2d_helper_rtos_init(void)
+{
+    
+    static uint64_t s_dwThreadStack[2048 / sizeof(uint64_t)];
+    static struct rt_thread s_BackendThread;     
+
+    rt_thread_init(&s_BackendThread,
+                   "Arm2dBackend",
+                   arm_2d_backend_thread,
+                   RT_NULL,
+                   &s_dwThreadStack[0],
+                   sizeof(s_dwThreadStack),
+                   25, 100);
+    rt_thread_startup(&s_BackendThread);
+
+    
+}
+
+#if defined(__clang__)
+#   pragma clang diagnostic pop
+#endif
+
+

+ 491 - 0
projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_atom.c

@@ -0,0 +1,491 @@
+/*
+ * Copyright (c) 2009-2024 Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*============================ INCLUDES ======================================*/
+
+#if defined(_RTE_)
+#   include "RTE_Components.h"
+#endif
+
+#if defined(RTE_Acceleration_Arm_2D_Helper_PFB)
+
+#include "arm_2d.h"
+
+#define __USER_SCENE_ATOM_IMPLEMENT__
+#include "arm_2d_scene_atom.h"
+
+#include "arm_2d_helper.h"
+#include "arm_2d_example_controls.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#if defined(__clang__)
+#   pragma clang diagnostic push
+#   pragma clang diagnostic ignored "-Wunknown-warning-option"
+#   pragma clang diagnostic ignored "-Wreserved-identifier"
+#   pragma clang diagnostic ignored "-Wsign-conversion"
+#   pragma clang diagnostic ignored "-Wpadded"
+#   pragma clang diagnostic ignored "-Wcast-qual"
+#   pragma clang diagnostic ignored "-Wcast-align"
+#   pragma clang diagnostic ignored "-Wmissing-field-initializers"
+#   pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
+#   pragma clang diagnostic ignored "-Wmissing-prototypes"
+#   pragma clang diagnostic ignored "-Wunused-variable"
+#   pragma clang diagnostic ignored "-Wgnu-statement-expression"
+#   pragma clang diagnostic ignored "-Wdeclaration-after-statement"
+#   pragma clang diagnostic ignored "-Wunused-function"
+#   pragma clang diagnostic ignored "-Wmissing-declarations"  
+#elif __IS_COMPILER_ARM_COMPILER_5__
+#   pragma diag_suppress 64,177
+#elif __IS_COMPILER_IAR__
+#   pragma diag_suppress=Pa089,Pe188,Pe177,Pe174
+#elif __IS_COMPILER_GCC__
+#   pragma GCC diagnostic push
+#   pragma GCC diagnostic ignored "-Wformat="
+#   pragma GCC diagnostic ignored "-Wpedantic"
+#   pragma GCC diagnostic ignored "-Wunused-function"
+#   pragma GCC diagnostic ignored "-Wunused-variable"
+#   pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
+#endif
+
+/*============================ MACROS ========================================*/
+
+#if __GLCD_CFG_COLOUR_DEPTH__ == 8
+
+#   define c_tileCMSISLogo          c_tileCMSISLogoGRAY8
+
+#elif __GLCD_CFG_COLOUR_DEPTH__ == 16
+
+#   define c_tileCMSISLogo          c_tileCMSISLogoRGB565
+
+#elif __GLCD_CFG_COLOUR_DEPTH__ == 32
+
+#   define c_tileCMSISLogo          c_tileCMSISLogoCCCA8888
+#else
+#   error Unsupported colour depth!
+#endif
+
+/*============================ MACROFIED FUNCTIONS ===========================*/
+#undef this
+#define this (*ptThis)
+
+/*============================ TYPES =========================================*/
+/*============================ GLOBAL VARIABLES ==============================*/
+
+extern const arm_2d_tile_t c_tileCMSISLogo;
+extern const arm_2d_tile_t c_tileCMSISLogoMask;
+extern const arm_2d_tile_t c_tileCMSISLogoA2Mask;
+extern const arm_2d_tile_t c_tileCMSISLogoA4Mask;
+
+extern const arm_2d_tile_t c_tileWhiteDotMiddleA4Mask;
+extern const arm_2d_tile_t c_tileWhiteDotMask;
+
+/*============================ PROTOTYPES ====================================*/
+/*============================ LOCAL VARIABLES ===============================*/
+/*============================ IMPLEMENTATION ================================*/
+
+static void __on_scene_atom_load(arm_2d_scene_t *ptScene)
+{
+    user_scene_atom_t *ptThis = (user_scene_atom_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+
+    arm_2d_helper_dirty_region_add_items(&this.use_as__arm_2d_scene_t.tDirtyRegionHelper,
+                                         &this.Electronic[0].tDirtyRegionItem,
+                                         1);
+
+    arm_2d_helper_dirty_region_add_items(&this.use_as__arm_2d_scene_t.tDirtyRegionHelper,
+                                         &this.Electronic[1].tDirtyRegionItem,
+                                         1);
+
+}
+
+static void __on_scene_atom_depose(arm_2d_scene_t *ptScene)
+{
+    user_scene_atom_t *ptThis = (user_scene_atom_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+    
+    ptScene->ptPlayer = NULL;
+    
+    arm_foreach(int64_t,this.lTimestamp, ptItem) {
+        *ptItem = 0;
+    }
+
+    if (!this.bUserAllocated) {
+        __arm_2d_free_scratch_memory(ARM_2D_MEM_TYPE_UNSPECIFIED, ptScene);
+    }
+}
+
+/*----------------------------------------------------------------------------*
+ * Scene atom                                                                    *
+ *----------------------------------------------------------------------------*/
+
+static void __on_scene_atom_background_start(arm_2d_scene_t *ptScene)
+{
+    user_scene_atom_t *ptThis = (user_scene_atom_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+
+}
+
+static void __on_scene_atom_background_complete(arm_2d_scene_t *ptScene)
+{
+    user_scene_atom_t *ptThis = (user_scene_atom_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+
+}
+
+
+static void __on_scene_atom_frame_start(arm_2d_scene_t *ptScene)
+{
+    user_scene_atom_t *ptThis = (user_scene_atom_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+
+    /* update core and electronics coordinates */
+    do {
+
+        int32_t nResult;
+        const int16_t iRadiusX = 110;
+        const int16_t iRadiusY = 110;
+
+        /* calculate core vibration */
+        arm_2d_helper_time_cos_slider(-5, 5, 100, ARM_2D_ANGLE(0.0f), &nResult, &this.lTimestamp[1]);
+        this.Core.tVibration.iX = nResult;
+        
+        arm_2d_helper_time_cos_slider(-5, 5, 150, ARM_2D_ANGLE(30.0f), &nResult, &this.lTimestamp[2]);
+        this.Core.tVibration.iY = nResult;
+
+        /* calculate electronic0 vibration */
+        arm_2d_helper_time_cos_slider(-iRadiusX, iRadiusX, 1300, ARM_2D_ANGLE(0.0f), &nResult, &this.lTimestamp[3]);
+        this.Electronic[0].tOffset.iX = nResult;
+        
+        arm_2d_helper_time_cos_slider(-iRadiusY, iRadiusY, 1300, ARM_2D_ANGLE(45.0f), &nResult, &this.lTimestamp[4]);
+        this.Electronic[0].tOffset.iY = nResult;
+
+        arm_2d_helper_time_cos_slider(128, 255, 1300, ARM_2D_ANGLE(45.0f), &nResult, &this.lTimestamp[7]);
+        this.Electronic[0].chOpacity = nResult;
+
+        /* calculate electronic 1 vibration */
+        arm_2d_helper_time_cos_slider(-iRadiusX, iRadiusX, 1300, ARM_2D_ANGLE(180.0f), &nResult, &this.lTimestamp[5]);
+        this.Electronic[1].tOffset.iX = nResult;
+        
+        arm_2d_helper_time_cos_slider(-iRadiusY, iRadiusY, 1300, ARM_2D_ANGLE(45.0f), &nResult, &this.lTimestamp[6]);
+        this.Electronic[1].tOffset.iY = nResult;
+
+        arm_2d_helper_time_cos_slider(128, 255, 1300, ARM_2D_ANGLE(45.0f), &nResult, &this.lTimestamp[8]);
+        this.Electronic[1].chOpacity = nResult;
+
+    } while(0);
+
+}
+
+static void __on_scene_atom_frame_complete(arm_2d_scene_t *ptScene)
+{
+    user_scene_atom_t *ptThis = (user_scene_atom_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+    
+    /* switch to next scene after 5s */
+    if (arm_2d_helper_is_time_out(5000, &this.lTimestamp[0])) {
+        arm_2d_scene_player_switch_to_next_scene(ptScene->ptPlayer);
+    }
+}
+
+static void __before_scene_atom_switching_out(arm_2d_scene_t *ptScene)
+{
+    user_scene_atom_t *ptThis = (user_scene_atom_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+
+}
+
+static
+IMPL_PFB_ON_DRAW(__pfb_draw_scene_atom_handler)
+{
+    ARM_2D_PARAM(pTarget);
+    ARM_2D_PARAM(ptTile);
+    ARM_2D_PARAM(bIsNewFrame);
+
+    user_scene_atom_t *ptThis = (user_scene_atom_t *)pTarget;
+    arm_2d_size_t tScreenSize = ptTile->tRegion.tSize;
+
+    ARM_2D_UNUSED(tScreenSize);
+
+    arm_2d_canvas(ptTile, __top_canvas) {
+    /*-----------------------draw the foreground begin-----------------------*/
+
+        arm_2d_size_t tCharSize = ARM_2D_FONT_A4_DIGITS_ONLY
+                                .use_as__arm_2d_user_font_t
+                                    .use_as__arm_2d_font_t.tCharSize;
+        arm_2d_size_t tAtomCoreSize = {
+            .iWidth = c_tileWhiteDotMiddleA4Mask.tRegion.tSize.iWidth * 2,
+            .iHeight = c_tileWhiteDotMiddleA4Mask.tRegion.tSize.iHeight * 2 
+                     + tCharSize.iHeight,
+        };
+        
+        /* draw atom core */
+        arm_2d_align_centre(__top_canvas, tAtomCoreSize) {
+
+            arm_2d_layout(__centre_region, true) {
+            
+                __item_line_dock_vertical(c_tileWhiteDotMiddleA4Mask.tRegion.tSize.iHeight * 2) {
+                    
+                    /* apply vibration */
+                    __item_region.tLocation.iX += this.Core.tVibration.iX;
+                    __item_region.tLocation.iY += this.Core.tVibration.iY;
+
+                    arm_2d_region_t tDirtyRegion = __item_region;
+                    tDirtyRegion.tSize.iHeight += tCharSize.iHeight;
+
+                    /* update dirty region */
+                    arm_2d_helper_dirty_region_update_item(&this.use_as__arm_2d_scene_t.tDirtyRegionHelper,
+                                                           &this.use_as__arm_2d_scene_t.tDirtyRegionHelper.tDefaultItem,
+                                                            (arm_2d_tile_t *)ptTile,
+                                                            &__top_canvas,
+                                                            &tDirtyRegion);
+
+                    do {
+                        arm_2d_region_t tHadron = __item_region;
+
+                        tHadron.tLocation.iX += (c_tileWhiteDotMiddleA4Mask.tRegion.tSize.iWidth >> 1) + 5;
+                        arm_2d_fill_colour_with_a4_mask_and_opacity(
+                            ptTile,
+                            &tHadron,
+                            &c_tileWhiteDotMiddleA4Mask,
+                            (__arm_2d_color_t){GLCD_COLOR_RED},
+                            128);
+                        
+                        ARM_2D_OP_WAIT_ASYNC();
+                    } while(0);
+
+                    do {
+                        arm_2d_region_t tHadron = __item_region;
+
+                        tHadron.tLocation.iX += c_tileWhiteDotMiddleA4Mask.tRegion.tSize.iWidth >> 1;
+                        tHadron.tLocation.iY += (c_tileWhiteDotMiddleA4Mask.tRegion.tSize.iHeight >> 1) + 5;
+                        arm_2d_fill_colour_with_a4_mask_and_opacity(
+                            ptTile,
+                            &tHadron,
+                            &c_tileWhiteDotMiddleA4Mask,
+                            (__arm_2d_color_t){GLCD_COLOR_BLUE},
+                            256 - 64);
+                        
+                        ARM_2D_OP_WAIT_ASYNC();
+                    } while(0);
+
+                    do {
+                        arm_2d_region_t tHadron = __item_region;
+                        tHadron.tLocation.iX += 5;
+                        tHadron.tLocation.iY += (c_tileWhiteDotMiddleA4Mask.tRegion.tSize.iHeight >> 1) - 5;
+                        arm_2d_fill_colour_with_a4_mask_and_opacity(
+                            ptTile,
+                            &tHadron,
+                            &c_tileWhiteDotMiddleA4Mask,
+                            (__arm_2d_color_t){GLCD_COLOR_BLUE},
+                            256 - 32);
+                        
+                        ARM_2D_OP_WAIT_ASYNC();
+                    } while(0);
+
+                    do {
+                        arm_2d_region_t tHadron = __item_region;
+
+                        tHadron.tLocation.iX += c_tileWhiteDotMiddleA4Mask.tRegion.tSize.iWidth;
+                        tHadron.tLocation.iY += c_tileWhiteDotMiddleA4Mask.tRegion.tSize.iHeight >> 1;
+                        arm_2d_fill_colour_with_a4_mask_and_opacity(
+                            ptTile,
+                            &tHadron,
+                            &c_tileWhiteDotMiddleA4Mask,
+                            (__arm_2d_color_t){GLCD_COLOR_RED},
+                            255);
+                        
+                        ARM_2D_OP_WAIT_ASYNC();
+                    } while(0);
+                }
+
+                __item_line_dock_vertical() {
+
+                    /* apply vibration */
+                    __item_region.tLocation.iX += this.Core.tVibration.iX;
+                    __item_region.tLocation.iY += this.Core.tVibration.iY;
+
+                    arm_lcd_text_set_target_framebuffer((arm_2d_tile_t *)ptTile);
+                    arm_lcd_text_set_colour(GLCD_COLOR_RED, GLCD_COLOR_WHITE);
+                    arm_print_banner("2+", __item_region, &ARM_2D_FONT_A4_DIGITS_ONLY);
+                }
+            }
+        }
+
+        /* draw electronics */
+        do {
+            arm_2d_align_centre(__top_canvas, 
+                                220, 
+                                220) {
+
+                arm_2d_size_t tElectronicSize = {
+                    .iWidth = c_tileWhiteDotMask.tRegion.tSize.iWidth
+                            + tCharSize.iWidth,
+                    .iHeight = c_tileWhiteDotMask.tRegion.tSize.iWidth
+                            + tCharSize.iHeight,
+                };
+
+                /* electronic 0 */
+                arm_2d_align_centre(__centre_region, tElectronicSize) {
+
+                    __centre_region.tLocation.iX += this.Electronic[0].tOffset.iX;
+                    __centre_region.tLocation.iY += this.Electronic[0].tOffset.iY;
+              
+                    /* update dirty region */
+                    arm_2d_helper_dirty_region_update_item( &this.use_as__arm_2d_scene_t.tDirtyRegionHelper,
+                                                            &this.Electronic[0].tDirtyRegionItem,
+                                                            (arm_2d_tile_t *)ptTile,
+                                                            &__top_canvas,
+                                                            &__centre_region);
+
+                    arm_2d_align_bottom_left(__centre_region, c_tileWhiteDotMask.tRegion.tSize) {
+
+                        arm_2d_fill_colour_with_mask_and_opacity(
+                            ptTile,
+                            &__bottom_left_region,
+                            &c_tileWhiteDotMask,
+                            (__arm_2d_color_t){GLCD_COLOR_GREEN},
+                            this.Electronic[0].chOpacity);
+
+                        ARM_2D_OP_WAIT_ASYNC();
+                    }
+
+                    arm_2d_align_mid_right(__centre_region, tCharSize) {
+                        arm_lcd_text_set_target_framebuffer((arm_2d_tile_t *)ptTile);
+                        arm_lcd_text_set_colour(GLCD_COLOR_GREEN, GLCD_COLOR_WHITE);
+                        arm_print_banner("-", __mid_right_region, &ARM_2D_FONT_A4_DIGITS_ONLY);
+                    }
+                }
+                
+                /* electronic 1 */
+                arm_2d_align_centre(__centre_region, tElectronicSize) {
+
+                    __centre_region.tLocation.iX += this.Electronic[1].tOffset.iX;
+                    __centre_region.tLocation.iY += this.Electronic[1].tOffset.iY;
+
+                    /* update dirty region */
+                    arm_2d_helper_dirty_region_update_item( &this.use_as__arm_2d_scene_t.tDirtyRegionHelper,
+                                                            &this.Electronic[1].tDirtyRegionItem,
+                                                            (arm_2d_tile_t *)ptTile,
+                                                            &__top_canvas,
+                                                            &__centre_region);
+
+                    arm_2d_align_bottom_left(__centre_region, c_tileWhiteDotMask.tRegion.tSize) {
+
+                        arm_2d_fill_colour_with_mask_and_opacity(
+                            ptTile,
+                            &__bottom_left_region,
+                            &c_tileWhiteDotMask,
+                            (__arm_2d_color_t){GLCD_COLOR_GREEN},
+                            this.Electronic[1].chOpacity);
+
+                        ARM_2D_OP_WAIT_ASYNC();
+                    }
+
+                    arm_2d_align_mid_right(__centre_region, tCharSize) {
+
+                        arm_lcd_text_set_target_framebuffer((arm_2d_tile_t *)ptTile);
+                        arm_lcd_text_set_colour(GLCD_COLOR_GREEN, GLCD_COLOR_WHITE);
+                        arm_print_banner("-", __mid_right_region, &ARM_2D_FONT_A4_DIGITS_ONLY);
+                        
+                    }
+                }
+
+            }
+        } while(0);
+
+        /* draw text at the top-left corner */
+        arm_lcd_text_set_target_framebuffer((arm_2d_tile_t *)ptTile);
+        arm_lcd_text_set_font(&ARM_2D_FONT_6x8.use_as__arm_2d_font_t);
+        arm_lcd_text_set_draw_region(NULL);
+        arm_lcd_text_set_colour(GLCD_COLOR_RED, GLCD_COLOR_WHITE);
+        arm_lcd_text_location(0,0);
+        arm_lcd_puts("Scene Atom");
+
+    /*-----------------------draw the foreground end  -----------------------*/
+    }
+    arm_2d_op_wait_async(NULL);
+
+    return arm_fsm_rt_cpl;
+}
+
+ARM_NONNULL(1)
+user_scene_atom_t *__arm_2d_scene_atom_init(   arm_2d_scene_player_t *ptDispAdapter, 
+                                        user_scene_atom_t *ptThis)
+{
+    bool bUserAllocated = false;
+    assert(NULL != ptDispAdapter);
+
+    if (NULL == ptThis) {
+        ptThis = (user_scene_atom_t *)
+                    __arm_2d_allocate_scratch_memory(   sizeof(user_scene_atom_t),
+                                                        __alignof__(user_scene_atom_t),
+                                                        ARM_2D_MEM_TYPE_UNSPECIFIED);
+        assert(NULL != ptThis);
+        if (NULL == ptThis) {
+            return NULL;
+        }
+    } else {
+        bUserAllocated = true;
+    }
+
+    memset(ptThis, 0, sizeof(user_scene_atom_t));
+
+    *ptThis = (user_scene_atom_t){
+        .use_as__arm_2d_scene_t = {
+
+            /* the canvas colour */
+            .tCanvas = {GLCD_COLOR_BLACK}, 
+
+            /* Please uncommon the callbacks if you need them
+             */
+            .fnOnLoad       = &__on_scene_atom_load,
+            .fnScene        = &__pfb_draw_scene_atom_handler,
+
+            //.fnOnBGStart    = &__on_scene_atom_background_start,
+            //.fnOnBGComplete = &__on_scene_atom_background_complete,
+            .fnOnFrameStart = &__on_scene_atom_frame_start,
+            //.fnBeforeSwitchOut = &__before_scene_atom_switching_out,
+            .fnOnFrameCPL   = &__on_scene_atom_frame_complete,
+            .fnDepose       = &__on_scene_atom_depose,
+
+            .bUseDirtyRegionHelper = true,
+        },
+        .bUserAllocated = bUserAllocated,
+    };
+
+    /* ------------   initialize members of user_scene_atom_t begin ---------------*/
+
+    /* ------------   initialize members of user_scene_atom_t end   ---------------*/
+
+    arm_2d_scene_player_append_scenes(  ptDispAdapter, 
+                                        &this.use_as__arm_2d_scene_t, 
+                                        1);
+
+    return ptThis;
+}
+
+
+#if defined(__clang__)
+#   pragma clang diagnostic pop
+#endif
+
+#endif
+
+

+ 124 - 0
projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_atom.h

@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2009-2024 Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __ARM_2D_SCENE_ATOM_H__
+#define __ARM_2D_SCENE_ATOM_H__
+
+/*============================ INCLUDES ======================================*/
+
+#if defined(_RTE_)
+#   include "RTE_Components.h"
+#endif
+
+#if defined(RTE_Acceleration_Arm_2D_Helper_PFB)
+
+#include "arm_2d.h"
+
+#include "arm_2d_helper_scene.h"
+
+#ifdef   __cplusplus
+extern "C" {
+#endif
+
+#if defined(__clang__)
+#   pragma clang diagnostic push
+#   pragma clang diagnostic ignored "-Wunknown-warning-option"
+#   pragma clang diagnostic ignored "-Wreserved-identifier"
+#   pragma clang diagnostic ignored "-Wmissing-declarations"
+#   pragma clang diagnostic ignored "-Wpadded"
+#elif __IS_COMPILER_ARM_COMPILER_5__
+#elif __IS_COMPILER_GCC__
+#   pragma GCC diagnostic push
+#   pragma GCC diagnostic ignored "-Wformat="
+#   pragma GCC diagnostic ignored "-Wpedantic"
+#   pragma GCC diagnostic ignored "-Wpadded"
+#endif
+
+/*============================ MACROS ========================================*/
+
+/* OOC header, please DO NOT modify  */
+#ifdef __USER_SCENE_ATOM_IMPLEMENT__
+#   undef __USER_SCENE_ATOM_IMPLEMENT__
+#   define __ARM_2D_IMPL__
+#endif
+#include "arm_2d_utils.h"
+
+/*============================ MACROFIED FUNCTIONS ===========================*/
+
+/*!
+ * \brief initalize scene_atom and add it to a user specified scene player
+ * \param[in] __DISP_ADAPTER_PTR the target display adapter (i.e. scene player)
+ * \param[in] ... this is an optional parameter. When it is NULL, a new 
+ *            user_scene_atom_t will be allocated from HEAP and freed on
+ *            the deposing event. When it is non-NULL, the life-cycle is managed
+ *            by user.
+ * \return user_scene_atom_t* the user_scene_atom_t instance
+ */
+#define arm_2d_scene_atom_init(__DISP_ADAPTER_PTR, ...)                    \
+            __arm_2d_scene_atom_init((__DISP_ADAPTER_PTR), (NULL, ##__VA_ARGS__))
+
+/*============================ TYPES =========================================*/
+/*!
+ * \brief a user class for scene atom
+ */
+typedef struct user_scene_atom_t user_scene_atom_t;
+
+struct user_scene_atom_t {
+    implement(arm_2d_scene_t);                                                  //! derived from class: arm_2d_scene_t
+
+ARM_PRIVATE(
+    /* place your private member here, following two are examples */
+    int64_t lTimestamp[9];
+    bool bUserAllocated;
+
+    struct {
+        arm_2d_location_t tVibration;
+    } Core;
+
+    struct {
+        arm_2d_helper_dirty_region_item_t tDirtyRegionItem;
+        arm_2d_location_t tOffset;
+        uint8_t chOpacity;
+    } Electronic[2];
+
+)
+    /* place your public member here */
+    
+};
+
+/*============================ GLOBAL VARIABLES ==============================*/
+/*============================ PROTOTYPES ====================================*/
+
+ARM_NONNULL(1)
+extern
+user_scene_atom_t *__arm_2d_scene_atom_init(   arm_2d_scene_player_t *ptDispAdapter, 
+                                        user_scene_atom_t *ptScene);
+
+#if defined(__clang__)
+#   pragma clang diagnostic pop
+#elif __IS_COMPILER_GCC__
+#   pragma GCC diagnostic pop
+#endif
+
+#ifdef   __cplusplus
+}
+#endif
+
+#endif
+
+#endif

+ 397 - 0
projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_audiomark.c

@@ -0,0 +1,397 @@
+/*
+ * Copyright (c) 2009-2022 Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*============================ INCLUDES ======================================*/
+
+#if defined(_RTE_)
+#   include "RTE_Components.h"
+#endif
+
+#if defined(RTE_Acceleration_Arm_2D_Helper_PFB)
+
+#include "arm_2d.h"
+
+#define __USER_SCENE_AUDIOMARK_IMPLEMENT__
+#include "arm_2d_scene_audiomark.h"
+
+#include "arm_2d_helper.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#if defined(__clang__)
+#   pragma clang diagnostic push
+#   pragma clang diagnostic ignored "-Wunknown-warning-option"
+#   pragma clang diagnostic ignored "-Wreserved-identifier"
+#   pragma clang diagnostic ignored "-Wsign-conversion"
+#   pragma clang diagnostic ignored "-Wpadded"
+#   pragma clang diagnostic ignored "-Wcast-qual"
+#   pragma clang diagnostic ignored "-Wcast-align"
+#   pragma clang diagnostic ignored "-Wmissing-field-initializers"
+#   pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
+#   pragma clang diagnostic ignored "-Wmissing-prototypes"
+#   pragma clang diagnostic ignored "-Wunused-variable"
+#   pragma clang diagnostic ignored "-Wgnu-statement-expression"
+#   pragma clang diagnostic ignored "-Wdeclaration-after-statement"
+#   pragma clang diagnostic ignored "-Wunused-function"
+#   pragma clang diagnostic ignored "-Wmissing-declarations"  
+#elif __IS_COMPILER_ARM_COMPILER_5__
+#   pragma diag_suppress 64,177
+#elif __IS_COMPILER_IAR__
+#   pragma diag_suppress=Pa089,Pe188,Pe177,Pe174
+#elif __IS_COMPILER_GCC__
+#   pragma GCC diagnostic push
+#   pragma GCC diagnostic ignored "-Wformat="
+#   pragma GCC diagnostic ignored "-Wpedantic"
+#   pragma GCC diagnostic ignored "-Wunused-function"
+#   pragma GCC diagnostic ignored "-Wunused-variable"
+#   pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
+#endif
+
+/*============================ MACROS ========================================*/
+
+#if __GLCD_CFG_COLOUR_DEPTH__ == 8
+
+#   define c_tileCMSISLogo          c_tileCMSISLogoGRAY8
+
+#elif __GLCD_CFG_COLOUR_DEPTH__ == 16
+
+#   define c_tileCMSISLogo          c_tileCMSISLogoRGB565
+
+#elif __GLCD_CFG_COLOUR_DEPTH__ == 32
+
+#   define c_tileCMSISLogo          c_tileCMSISLogoCCCA8888
+#else
+#   error Unsupported colour depth!
+#endif
+
+/*============================ MACROFIED FUNCTIONS ===========================*/
+#undef this
+#define this (*ptThis)
+
+/*============================ TYPES =========================================*/
+/*============================ GLOBAL VARIABLES ==============================*/
+
+extern const arm_2d_tile_t c_tileCMSISLogo;
+extern const arm_2d_tile_t c_tileCMSISLogoMask;
+extern const arm_2d_tile_t c_tileCMSISLogoA2Mask;
+extern const arm_2d_tile_t c_tileCMSISLogoA4Mask;
+
+
+extern const arm_2d_tile_t c_tileBigWhiteDotMask;
+extern const arm_2d_tile_t c_tileQuaterArcBigMask;
+
+
+/*============================ PROTOTYPES ====================================*/
+/*============================ LOCAL VARIABLES ===============================*/
+
+#define PROCESSOR_INFO(__NAME, __SIZE, __SCORE, __COLOUR, __SCORE_COLOUR)       \
+            {__NAME, (__SIZE), (__SCORE), (__COLOUR), (__SCORE_COLOUR)}
+
+static const struct {
+    const char  *pchName;
+    int16_t     iWheelSize;
+    int16_t     iAudioMark;
+    COLOUR_INT  tColour;
+    COLOUR_INT  tScoreColour;
+} c_tProcessorInfo[] = {
+    [AUDIOMARK_CORTEX_M4]           
+        = PROCESSOR_INFO( "Cortex-M4",           100 + 75 * 0,    73,     __RGB(0x40, 0x40, 0x40),  __RGB(0x80, 0x80, 0x80) ),
+    [AUDIOMARK_CORTEX_M33]          
+        = PROCESSOR_INFO( "Cortex-M33",           65 + 75 * 1,    101,    __RGB(0x60, 0x60, 0x60),  __RGB(0xFF, 0xFF, 0xFF) ),
+    [AUDIOMARK_CORTEX_M7]           
+        = PROCESSOR_INFO( "Cortex-M7",            35 + 75 * 2,    132,    __RGB(0x80, 0x80, 0x80),  __RGB(0x80, 0x80, 0x80) ),
+    [AUDIOMARK_CORTEX_M85_SCALER]   
+        = PROCESSOR_INFO( "Cortex-M85 Scaler",    20 + 75 * 3,    201,    __RGB(0x00, 0x80, 0x00),  __RGB(0xFF, 0xFF, 0xFF) ),
+    [AUDIOMARK_CORTEX_M55_HELIUM]   
+        = PROCESSOR_INFO( "Cortex-M55 Helium",    20 + 75 * 4,    367,    __RGB(0x00, 0xC0, 0x00),  __RGB(0x00, 0xC0, 0x00) ),
+    [AUDIOMARK_CORTEX_M85_HELIUM]   
+        = PROCESSOR_INFO( "Cortex-M85 Helium",    40 + 75 * 5,    423,    GLCD_COLOR_GREEN,         __RGB(0xFF, 0x80, 0x00) ),
+};
+
+/*============================ IMPLEMENTATION ================================*/
+
+static void __on_scene_audiomark_on_load(arm_2d_scene_t *ptScene)
+{
+    user_scene_audiomark_t *ptThis = (user_scene_audiomark_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+
+    for (uint_fast8_t n = 0; n < dimof(this.Processor); n++) {
+        progress_wheel_on_load(&this.Processor[n].tWheel);
+    }
+
+}
+
+
+static void __on_scene_audiomark_depose(arm_2d_scene_t *ptScene)
+{
+    user_scene_audiomark_t *ptThis = (user_scene_audiomark_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+    
+    ptScene->ptPlayer = NULL;
+    
+    arm_foreach(int64_t,this.lTimestamp, ptItem) {
+        *ptItem = 0;
+    }
+
+    for (int_fast8_t n = 0; n < dimof(this.Processor); n ++) {
+        progress_wheel_depose(&this.Processor[n].tWheel);
+        this.Processor[n].lTimestamp = 0;
+    }
+#if __FITNESS_CFG_NEBULA_ENABLE__
+    dynamic_nebula_depose(&this.tNebula);
+#endif
+
+    if (!this.bUserAllocated) {
+        __arm_2d_free_scratch_memory(ARM_2D_MEM_TYPE_UNSPECIFIED, ptScene);
+    }
+}
+
+/*----------------------------------------------------------------------------*
+ * Scene audiomark                                                                    *
+ *----------------------------------------------------------------------------*/
+
+static void __on_scene_audiomark_background_start(arm_2d_scene_t *ptScene)
+{
+    user_scene_audiomark_t *ptThis = (user_scene_audiomark_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+
+}
+
+static void __on_scene_audiomark_background_complete(arm_2d_scene_t *ptScene)
+{
+    user_scene_audiomark_t *ptThis = (user_scene_audiomark_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+
+}
+
+
+static void __on_scene_audiomark_frame_start(arm_2d_scene_t *ptScene)
+{
+    user_scene_audiomark_t *ptThis = (user_scene_audiomark_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+
+    for (int_fast8_t n = 0; n < dimof(this.Processor); n++) {
+        
+        int32_t nResult;
+        if (arm_2d_helper_time_liner_slider(0, 
+                                            1000, 
+                                            5000ul * 100ul / (int32_t)c_tProcessorInfo[n].iAudioMark , 
+                                            &nResult, 
+                                            &this.Processor[n].lTimestamp)) {
+            this.Processor[n].lTimestamp = 0;
+        }
+
+        this.Processor[n].iProgress = (int16_t)nResult;
+    }
+    for (uint_fast8_t n = 0; n < dimof(this.Processor); n++) {
+        progress_wheel_on_frame_start(&this.Processor[n].tWheel);
+    }
+
+}
+
+static void __on_scene_audiomark_frame_complete(arm_2d_scene_t *ptScene)
+{
+    user_scene_audiomark_t *ptThis = (user_scene_audiomark_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+    
+    /* switch to next scene after 10s */
+    if (arm_2d_helper_is_time_out(10000, &this.lTimestamp[0])) {
+        arm_2d_scene_player_switch_to_next_scene(ptScene->ptPlayer);
+    }
+}
+
+static void __before_scene_audiomark_switching_out(arm_2d_scene_t *ptScene)
+{
+    user_scene_audiomark_t *ptThis = (user_scene_audiomark_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+
+}
+
+static
+IMPL_PFB_ON_DRAW(__pfb_draw_scene_audiomark_handler)
+{
+    user_scene_audiomark_t *ptThis = (user_scene_audiomark_t *)pTarget;
+    arm_2d_size_t tScreenSize = ptTile->tRegion.tSize;
+
+    int32_t iResult;
+    float fAngle;
+
+    ARM_2D_UNUSED(ptTile);
+    ARM_2D_UNUSED(bIsNewFrame);
+    ARM_2D_UNUSED(tScreenSize);
+    arm_2d_canvas(ptTile, __top_canvas) {
+    /*-----------------------draw the foreground begin-----------------------*/
+        
+        /* following code is just a demo, you can remove them */
+
+        arm_2d_align_centre(__top_canvas, 415, 415) {
+            
+            for (int_fast8_t n = 0; n < dimof(this.Processor); n++) {
+
+                progress_wheel_show(&this.Processor[n].tWheel,
+                    ptTile, 
+                    &__centre_region,       
+                    this.Processor[n].iProgress,
+                    255,
+                    bIsNewFrame);
+            }
+
+        #if __FITNESS_CFG_NEBULA_ENABLE__
+            /* show nebula */
+            dynamic_nebula_show(&this.tNebula, 
+                                ptTile, 
+                                &__bottom_centre_region, 
+                                GLCD_COLOR_WHITE, 
+                                255,
+                                bIsNewFrame);
+        #endif
+        }
+
+    /*-----------------------draw the foreground end  -----------------------*/
+    }
+    ARM_2D_OP_WAIT_ASYNC();
+
+    return arm_fsm_rt_cpl;
+}
+
+ARM_NONNULL(1)
+user_scene_audiomark_t *__arm_2d_scene_audiomark_init(   arm_2d_scene_player_t *ptDispAdapter, 
+                                        user_scene_audiomark_t *ptThis)
+{
+    bool bUserAllocated = false;
+    assert(NULL != ptDispAdapter);
+
+    if (NULL == ptThis) {
+        ptThis = (user_scene_audiomark_t *)
+                    __arm_2d_allocate_scratch_memory(   sizeof(user_scene_audiomark_t),
+                                                        __alignof__(user_scene_audiomark_t),
+                                                        ARM_2D_MEM_TYPE_UNSPECIFIED);
+        assert(NULL != ptThis);
+        if (NULL == ptThis) {
+            return NULL;
+        }
+    } else {
+        bUserAllocated = true;
+    }
+
+    memset(ptThis, 0, sizeof(user_scene_audiomark_t));
+
+    *ptThis = (user_scene_audiomark_t){
+        .use_as__arm_2d_scene_t = {
+
+            /* the canvas colour */
+            .tCanvas = {GLCD_COLOR_BLACK}, 
+        
+            /* Please uncommon the callbacks if you need them
+             */
+            .fnOnLoad       = &__on_scene_audiomark_on_load,
+            .fnScene        = &__pfb_draw_scene_audiomark_handler,
+            //.ptDirtyRegion  = (arm_2d_region_list_item_t *)s_tDirtyRegions,
+            
+
+            //.fnOnBGStart    = &__on_scene_audiomark_background_start,
+            //.fnOnBGComplete = &__on_scene_audiomark_background_complete,
+            .fnOnFrameStart = &__on_scene_audiomark_frame_start,
+            //.fnBeforeSwitchOut = &__before_scene_audiomark_switching_out,
+            .fnOnFrameCPL   = &__on_scene_audiomark_frame_complete,
+            .fnDepose       = &__on_scene_audiomark_depose,
+
+            .bUseDirtyRegionHelper = true,
+        },
+        .bUserAllocated = bUserAllocated,
+    };
+
+    /* ------------   initialize members of user_scene_audiomark_t begin ---------------*/
+
+    for (uint_fast8_t n = 0; n < dimof(this.Processor); n++) {
+
+        switch (n) {
+            case AUDIOMARK_CORTEX_M4:
+            case AUDIOMARK_CORTEX_M33:
+            case AUDIOMARK_CORTEX_M7:
+                do {
+                    progress_wheel_cfg_t tCFG = {
+                        .tDotColour     = GLCD_COLOR_WHITE,                 /* dot colour */
+                        .tWheelColour   = c_tProcessorInfo[n].tColour,      /* arc colour */
+                        .iWheelDiameter = c_tProcessorInfo[n].iWheelSize,   /* diameter, 0 means use the mask's original size */
+                        .bUseDirtyRegions = true,                           /* use dirty regions */
+                    };
+
+                    progress_wheel_init(&this.Processor[n].tWheel, 
+                                        &this.use_as__arm_2d_scene_t,
+                                        &tCFG);
+                } while(0);
+
+                break;
+            case AUDIOMARK_CORTEX_M55_HELIUM:
+            case AUDIOMARK_CORTEX_M85_SCALER:
+            case AUDIOMARK_CORTEX_M85_HELIUM:
+                do {
+                    progress_wheel_cfg_t tCFG = {
+                        .ptileArcMask   = &c_tileQuaterArcBigMask,          /* mask for arc */
+                        .ptileDotMask   = &c_tileBigWhiteDotMask,           /* mask for dot */
+                        .tDotColour     = GLCD_COLOR_WHITE,                 /* dot colour */
+                        .tWheelColour   = c_tProcessorInfo[n].tColour,      /* arc colour */
+                        .iWheelDiameter = c_tProcessorInfo[n].iWheelSize,   /* diameter, 0 means use the mask's original size */
+                        .bUseDirtyRegions = true,                           /* use dirty regions */
+                    };
+
+                    progress_wheel_init(&this.Processor[n].tWheel, 
+                                        &this.use_as__arm_2d_scene_t,
+                                        &tCFG);
+                } while(0);
+                break;
+            default:
+                assert(false);
+                break;
+        }
+
+        this.Processor[n].pchName = c_tProcessorInfo[n].pchName;
+        this.Processor[n].iProgress = 0;
+    }
+
+#if __FITNESS_CFG_NEBULA_ENABLE__
+    do {
+        dynamic_nebula_cfg_t tCFG = {
+            .fSpeed = 1.0f,
+            .iRadius = 80,
+            .iVisibleRingWidth = 80,
+            .hwParticleCount = dimof(this.tParticles),
+            .ptParticles = this.tParticles,
+        };
+        dynamic_nebula_init(&this.tNebula, &tCFG);
+    } while(0);
+#endif
+
+    /* ------------   initialize members of user_scene_audiomark_t end   ---------------*/
+
+    arm_2d_scene_player_append_scenes(  ptDispAdapter, 
+                                        &this.use_as__arm_2d_scene_t, 
+                                        1);
+
+    return ptThis;
+}
+
+
+#if defined(__clang__)
+#   pragma clang diagnostic pop
+#endif
+
+#endif
+

+ 146 - 0
projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_audiomark.h

@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2009-2022 Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __ARM_2D_SCENE_AUDIOMARK_H__
+#define __ARM_2D_SCENE_AUDIOMARK_H__
+
+/*============================ INCLUDES ======================================*/
+
+#if defined(_RTE_)
+#   include "RTE_Components.h"
+#endif
+
+#if defined(RTE_Acceleration_Arm_2D_Helper_PFB)
+
+#include "arm_2d.h"
+
+#include "arm_2d_helper_scene.h"
+#include "arm_2d_example_controls.h"
+
+#ifdef   __cplusplus
+extern "C" {
+#endif
+
+#if defined(__clang__)
+#   pragma clang diagnostic push
+#   pragma clang diagnostic ignored "-Wunknown-warning-option"
+#   pragma clang diagnostic ignored "-Wreserved-identifier"
+#   pragma clang diagnostic ignored "-Wmissing-declarations"
+#   pragma clang diagnostic ignored "-Wembedded-directive"
+#   pragma clang diagnostic ignored "-Wpadded"
+#elif __IS_COMPILER_ARM_COMPILER_5__
+#elif __IS_COMPILER_GCC__
+#   pragma GCC diagnostic push
+#   pragma GCC diagnostic ignored "-Wformat="
+#   pragma GCC diagnostic ignored "-Wpedantic"
+#   pragma GCC diagnostic ignored "-Wpadded"
+#endif
+
+/*============================ MACROS ========================================*/
+
+/* OOC header, please DO NOT modify  */
+#ifdef __USER_SCENE_AUDIOMARK_IMPLEMENT__
+#   undef __USER_SCENE_AUDIOMARK_IMPLEMENT__
+#   define __ARM_2D_IMPL__
+#endif
+#include "arm_2d_utils.h"
+
+
+#ifndef __FITNESS_CFG_NEBULA_ENABLE__
+#   define __FITNESS_CFG_NEBULA_ENABLE__        0
+#endif
+
+#if __FITNESS_CFG_NEBULA_ENABLE__
+#   define NEBULA_PARTICLE_COUNT                200
+#endif
+
+/*============================ MACROFIED FUNCTIONS ===========================*/
+
+/*!
+ * \brief initalize scene_audiomark and add it to a user specified scene player
+ * \param[in] __DISP_ADAPTER_PTR the target display adapter (i.e. scene player)
+ * \param[in] ... this is an optional parameter. When it is NULL, a new 
+ *            user_scene_audiomark_t will be allocated from HEAP and freed on
+ *            the deposing event. When it is non-NULL, the life-cycle is managed
+ *            by user.
+ * \return user_scene_audiomark_t* the user_scene_audiomark_t instance
+ */
+#define arm_2d_scene_audiomark_init(__DISP_ADAPTER_PTR, ...)                    \
+            __arm_2d_scene_audiomark_init((__DISP_ADAPTER_PTR), (NULL, ##__VA_ARGS__))
+
+/*============================ TYPES =========================================*/
+enum {
+    AUDIOMARK_CORTEX_M4,
+    AUDIOMARK_CORTEX_M33,
+    AUDIOMARK_CORTEX_M7,
+    AUDIOMARK_CORTEX_M85_SCALER,
+    AUDIOMARK_CORTEX_M55_HELIUM,
+    AUDIOMARK_CORTEX_M85_HELIUM,
+    __AUDIOMARK_PROCESSOR_NUM,
+};
+
+/*!
+ * \brief a user class for scene audiomark
+ */
+typedef struct user_scene_audiomark_t user_scene_audiomark_t;
+
+struct user_scene_audiomark_t {
+    implement(arm_2d_scene_t);                                                  //! derived from class: arm_2d_scene_t
+
+ARM_PRIVATE(
+    /* place your private member here, following two are examples */
+    int64_t lTimestamp[3];
+    bool bUserAllocated;
+
+#if __FITNESS_CFG_NEBULA_ENABLE__
+    dynamic_nebula_t tNebula;
+    dynamic_nebula_particle_t tParticles[NEBULA_PARTICLE_COUNT];
+#endif
+
+    struct {
+        progress_wheel_t tWheel;
+        int16_t iProgress;
+        int64_t lTimestamp;
+        const char *pchName;
+    } Processor[__AUDIOMARK_PROCESSOR_NUM];
+)
+    /* place your public member here */
+    
+};
+
+/*============================ GLOBAL VARIABLES ==============================*/
+/*============================ PROTOTYPES ====================================*/
+
+ARM_NONNULL(1)
+extern
+user_scene_audiomark_t *__arm_2d_scene_audiomark_init(   arm_2d_scene_player_t *ptDispAdapter, 
+                                        user_scene_audiomark_t *ptScene);
+
+#if defined(__clang__)
+#   pragma clang diagnostic pop
+#elif __IS_COMPILER_GCC__
+#   pragma GCC diagnostic pop
+#endif
+
+#ifdef   __cplusplus
+}
+#endif
+
+#endif
+
+#endif

+ 365 - 0
projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_basics.c

@@ -0,0 +1,365 @@
+/*
+ * Copyright (c) 2009-2022 Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*============================ INCLUDES ======================================*/
+
+#include "arm_2d.h"
+
+#if defined(RTE_Acceleration_Arm_2D_Helper_PFB)
+
+#define __USER_SCENE_BASICS_IMPLEMENT__
+#include "arm_2d_scene_basics.h"
+
+#include "arm_2d_helper.h"
+#include "arm_2d_example_controls.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#if defined(__clang__)
+#   pragma clang diagnostic push
+#   pragma clang diagnostic ignored "-Wunknown-warning-option"
+#   pragma clang diagnostic ignored "-Wreserved-identifier"
+#   pragma clang diagnostic ignored "-Wsign-conversion"
+#   pragma clang diagnostic ignored "-Wpadded"
+#   pragma clang diagnostic ignored "-Wcast-qual"
+#   pragma clang diagnostic ignored "-Wcast-align"
+#   pragma clang diagnostic ignored "-Wmissing-field-initializers"
+#   pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
+#   pragma clang diagnostic ignored "-Wmissing-prototypes"
+#   pragma clang diagnostic ignored "-Wunused-variable"
+#   pragma clang diagnostic ignored "-Wgnu-statement-expression"
+#   pragma clang diagnostic ignored "-Wdeclaration-after-statement"
+#   pragma clang diagnostic ignored "-Wunused-function"
+#   pragma clang diagnostic ignored "-Wmissing-declarations"  
+#elif __IS_COMPILER_ARM_COMPILER_5__
+#elif __IS_COMPILER_IAR__
+#   pragma diag_suppress=Pa089,Pe188,Pe177,Pe174
+#elif __IS_COMPILER_GCC__
+#   pragma GCC diagnostic push
+#   pragma GCC diagnostic ignored "-Wformat="
+#   pragma GCC diagnostic ignored "-Wpedantic"
+#   pragma GCC diagnostic ignored "-Wunused-function"
+#   pragma GCC diagnostic ignored "-Wunused-variable"
+#   pragma GCC diagnostic ignored "-Wunused-value"
+#endif
+
+/*============================ MACROS ========================================*/
+
+#if __GLCD_CFG_COLOUR_DEPTH__ == 8
+
+#   define c_tileCMSISLogo          c_tileCMSISLogoGRAY8
+#   define c_tileBackground         c_tileBackgroundGRAY8
+
+#elif __GLCD_CFG_COLOUR_DEPTH__ == 16
+
+#   define c_tileCMSISLogo          c_tileCMSISLogoRGB565
+#   define c_tileBackground         c_tileBackgroundRGB565
+
+#elif __GLCD_CFG_COLOUR_DEPTH__ == 32
+
+#   define c_tileCMSISLogo          c_tileCMSISLogoCCCA8888
+#   define c_tileBackground         c_tileBackgroundCCCA8888
+
+#else
+#   error Unsupported colour depth!
+#endif
+
+/*============================ MACROFIED FUNCTIONS ===========================*/
+#undef this
+#define this (*ptThis)
+
+/*============================ TYPES =========================================*/
+/*============================ GLOBAL VARIABLES ==============================*/
+
+extern const arm_2d_tile_t c_tileCMSISLogo;
+extern const arm_2d_tile_t c_tileCMSISLogoMask;
+extern const arm_2d_tile_t c_tileCMSISLogoA2Mask;
+extern const arm_2d_tile_t c_tileCMSISLogoA4Mask;
+extern const arm_2d_tile_t c_tileCMSISLogoMask2;
+
+extern const arm_2d_tile_t c_tileBackground;
+extern const arm_2d_tile_t c_tileCMSISLogoCCCA8888;
+/*============================ PROTOTYPES ====================================*/
+/*============================ LOCAL VARIABLES ===============================*/
+/*============================ IMPLEMENTATION ================================*/
+
+
+static void __on_scene_basics_depose(arm_2d_scene_t *ptScene)
+{
+    user_scene_basics_t *ptThis = (user_scene_basics_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+    
+    ptScene->ptPlayer = NULL;
+    
+    /* reset timestamp */
+    arm_foreach(int64_t,this.lTimestamp, ptItem) {
+        *ptItem = 0;
+    }
+
+    if (!this.bUserAllocated) {
+        __arm_2d_free_scratch_memory(ARM_2D_MEM_TYPE_UNSPECIFIED, ptScene);
+    }
+}
+
+/*----------------------------------------------------------------------------*
+ * Scene 0                                                                    *
+ *----------------------------------------------------------------------------*/
+
+static void __on_scene_basics_background_start(arm_2d_scene_t *ptScene)
+{
+    user_scene_basics_t *ptThis = (user_scene_basics_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+
+}
+
+static void __on_scene_basics_background_complete(arm_2d_scene_t *ptScene)
+{
+    user_scene_basics_t *ptThis = (user_scene_basics_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+
+}
+
+
+static void __on_scene_basics_frame_start(arm_2d_scene_t *ptScene)
+{
+    user_scene_basics_t *ptThis = (user_scene_basics_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+
+}
+
+static void __on_scene_basics_frame_complete(arm_2d_scene_t *ptScene)
+{
+    user_scene_basics_t *ptThis = (user_scene_basics_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+    
+    /* switch to next scene after 3s */
+    if (arm_2d_helper_is_time_out(3000, &this.lTimestamp[0])) {
+        arm_2d_scene_player_switch_to_next_scene(ptScene->ptPlayer);
+    }
+}
+
+static void __before_scene_basics_switching_out(arm_2d_scene_t *ptScene)
+{
+    user_scene_basics_t *ptThis = (user_scene_basics_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+
+}
+
+static
+IMPL_PFB_ON_DRAW(__pfb_draw_scene_basics_handler)
+{
+    user_scene_basics_t *ptThis = (user_scene_basics_t *)pTarget;
+    ARM_2D_UNUSED(ptTile);
+    ARM_2D_UNUSED(bIsNewFrame);
+    
+    arm_2d_canvas(ptTile, __top_canvas) {
+    /*-----------------------draw the foreground begin-----------------------*/
+        
+        /* following code is just a demo, you can remove them */
+
+    #if 0
+        arm_2d_align_centre(__top_canvas, c_tileBackground.tRegion.tSize) {
+            draw_round_corner_image(&c_tileBackground,
+                                    ptTile,
+                                    &__centre_region,
+                                    bIsNewFrame);
+        }
+    #endif
+
+        arm_2d_align_centre(__top_canvas, 240, 120 ) {
+            arm_2d_layout(__centre_region, true) {
+
+                __item_line_dock_vertical(c_tileCMSISLogoA4Mask.tRegion.tSize.iHeight, 0, 0, 0, 5) {
+                    draw_round_corner_box(  ptTile, 
+                                            &__item_region, 
+                                            GLCD_COLOR_WHITE, 
+                                            128,
+                                            bIsNewFrame);
+                    
+                    arm_2d_op_wait_async(NULL);
+
+                #if 1
+                    /* draw the cmsis logo in the centre of the screen */
+                    arm_2d_align_centre(__item_region, c_tileCMSISLogo.tRegion.tSize) {
+                    #if 0
+                        #if __ARM_2D_CFG_SUPPORT_CCCA8888_IMPLICIT_CONVERSION__
+                        arm_2d_tile_copy_with_src_mask_and_opacity_only( 
+                                                        &c_tileCMSISLogoCCCA8888,
+                                                        &c_tileCMSISLogoMask,
+                                                        ptTile,
+                                                        &__centre_region,
+                                                        128);
+                        #else
+                        arm_2d_tile_copy_with_src_mask( &c_tileCMSISLogo,
+                                                        &c_tileCMSISLogoMask,
+                                                        ptTile,
+                                                        &__centre_region,
+                                                        ARM_2D_CP_MODE_COPY);
+                        #endif
+                        
+                    #elif __ARM_2D_CFG_SUPPORT_CCCA8888_IMPLICIT_CONVERSION__
+                        arm_2d_tile_copy_with_opacity(  &c_tileCMSISLogoCCCA8888,
+                                                        ptTile,
+                                                        &__centre_region,
+                                                        128);
+                    #endif
+                    }
+                #else
+                    /* draw the cmsis logo using mask in the centre of the screen */
+                    arm_2d_align_centre(__item_region, c_tileCMSISLogo.tRegion.tSize) {
+                    #if 1
+                        arm_2d_fill_colour_with_a4_mask_and_opacity(   
+                                                            ptTile, 
+                                                            &__centre_region, 
+                                                            &c_tileCMSISLogoA4Mask, 
+                                                            (__arm_2d_color_t){GLCD_COLOR_BLACK},
+                                                            128);
+                    #else
+                        arm_2d_fill_colour_with_mask_xy_mirror_and_opacity(   
+                                                            ptTile, 
+                                                            &__centre_region, 
+                                                            &c_tileCMSISLogoMask2, 
+                                                            (__arm_2d_color_t){GLCD_COLOR_BLACK},
+                                                            128);
+                    #endif
+                    }
+                #endif
+                    arm_2d_op_wait_async(NULL);
+
+                    draw_round_corner_border(   ptTile, 
+                                                &__item_region, 
+                                                GLCD_COLOR_BLACK, 
+                                                (arm_2d_border_opacity_t)
+                                                    {32, 32, 255-64, 255-64},
+                                                (arm_2d_corner_opacity_t)
+                                                    {0, 128, 128, 128});
+                }
+
+                __item_line_dock_vertical() {
+                    
+                    draw_round_corner_box(  ptTile, 
+                                            &__item_region, 
+                                            GLCD_COLOR_WHITE, 
+                                            255,
+                                            bIsNewFrame);
+                    
+                    arm_2d_op_wait_async(NULL);
+
+                    draw_round_corner_border(   ptTile, 
+                                                &__item_region, 
+                                                GLCD_COLOR_BLACK, 
+                                                (arm_2d_border_opacity_t)
+                                                    {32, 32, 255-64, 255-64},
+                                                (arm_2d_corner_opacity_t)
+                                                    {0, 128, 128, 128});
+
+                    arm_2d_dock_vertical(__item_region, 
+                                        ARM_2D_FONT_A8_DIGITS_ONLY
+                                            .use_as__arm_2d_user_font_t
+                                                .use_as__arm_2d_font_t
+                                                    .tCharSize.iHeight) {
+                        arm_lcd_text_set_target_framebuffer((arm_2d_tile_t *)ptTile);
+                        arm_lcd_text_set_font((const arm_2d_font_t *)&ARM_2D_FONT_A8_DIGITS_ONLY);
+                        arm_lcd_text_set_draw_region(&__vertical_region);
+                        arm_lcd_text_set_colour(GLCD_COLOR_RED, GLCD_COLOR_WHITE);
+                        arm_lcd_text_location(0,0);
+                        
+                        for (int n = 0; n < 10; n++) {
+                            arm_lcd_text_set_scale(0.5f + 0.1f * (float)n);
+                            arm_lcd_printf("%d", n);
+                        }
+                    }
+                }
+            }                
+        }
+
+        /* draw text at the top-left corner */
+
+        arm_lcd_text_set_target_framebuffer((arm_2d_tile_t *)ptTile);
+        arm_lcd_text_set_font(&ARM_2D_FONT_6x8.use_as__arm_2d_font_t);
+        arm_lcd_text_set_draw_region(NULL);
+        arm_lcd_text_set_colour(GLCD_COLOR_RED, GLCD_COLOR_WHITE);
+        arm_lcd_text_location(0,0);
+        arm_lcd_puts("Scene 0");
+
+    /*-----------------------draw the foreground end  -----------------------*/
+    }
+    arm_2d_op_wait_async(NULL);
+
+    return arm_fsm_rt_cpl;
+}
+
+ARM_NONNULL(1)
+user_scene_basics_t *__arm_2d_scene_basics_init(   arm_2d_scene_player_t *ptDispAdapter, 
+                                        user_scene_basics_t *ptThis)
+{
+    bool bUserAllocated = false;
+    assert(NULL != ptDispAdapter);
+
+    if (NULL == ptThis) {
+        ptThis = (user_scene_basics_t *)
+                    __arm_2d_allocate_scratch_memory(   sizeof(user_scene_basics_t),
+                                                        __alignof__(user_scene_basics_t),
+                                                        ARM_2D_MEM_TYPE_UNSPECIFIED);
+        assert(NULL != ptThis);
+        if (NULL == ptThis) {
+            return NULL;
+        }
+    } else {
+        bUserAllocated = true;
+    }
+    memset(ptThis, 0, sizeof(user_scene_basics_t));
+
+    *ptThis = (user_scene_basics_t){
+        .use_as__arm_2d_scene_t = {
+
+            /* the canvas colour */
+            .tCanvas = {GLCD_COLOR_WHITE}, 
+
+            /* Please uncommon the callbacks if you need them
+             */
+            .fnScene        = &__pfb_draw_scene_basics_handler,
+
+            //.fnOnBGStart    = &__on_scene_basics_background_start,
+            //.fnOnBGComplete = &__on_scene_basics_background_complete,
+            .fnOnFrameStart = &__on_scene_basics_frame_start,
+            //.fnBeforeSwitchOut = &__before_scene_basics_switching_out,
+            .fnOnFrameCPL   = &__on_scene_basics_frame_complete,
+            .fnDepose       = &__on_scene_basics_depose,
+        },
+        .bUserAllocated = bUserAllocated,
+    };
+    
+
+    arm_2d_scene_player_append_scenes(  ptDispAdapter, 
+                                        &this.use_as__arm_2d_scene_t, 
+                                        1);
+
+    return ptThis;
+}
+
+
+
+
+#if defined(__clang__)
+#   pragma clang diagnostic pop
+#endif
+
+#endif
+

+ 110 - 0
projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_basics.h

@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2009-2022 Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __ARM_2D_SCENE_BASICS_H__
+#define __ARM_2D_SCENE_BASICS_H__
+
+/*============================ INCLUDES ======================================*/
+
+#include "arm_2d.h"
+
+#if defined(RTE_Acceleration_Arm_2D_Helper_PFB)
+
+#include "arm_2d_helper_scene.h"
+
+#ifdef   __cplusplus
+extern "C" {
+#endif
+
+#if defined(__clang__)
+#   pragma clang diagnostic push
+#   pragma clang diagnostic ignored "-Wunknown-warning-option"
+#   pragma clang diagnostic ignored "-Wreserved-identifier"
+#   pragma clang diagnostic ignored "-Wmissing-declarations"
+#   pragma clang diagnostic ignored "-Wpadded"
+#elif __IS_COMPILER_ARM_COMPILER_5__
+#elif __IS_COMPILER_GCC__
+#   pragma GCC diagnostic push
+#   pragma GCC diagnostic ignored "-Wformat="
+#   pragma GCC diagnostic ignored "-Wpedantic"
+#   pragma GCC diagnostic ignored "-Wpadded"
+#endif
+
+/*============================ MACROS ========================================*/
+
+/* OOC header, please DO NOT modify  */
+#ifdef __USER_SCENE_BASICS_IMPLEMENT__
+#   undef __USER_SCENE_BASICS_IMPLEMENT__
+#   define __ARM_2D_IMPL__
+#endif
+#include "arm_2d_utils.h"
+
+/*============================ MACROFIED FUNCTIONS ===========================*/
+
+/*!
+ * \brief initalize scene0 and add it to a user specified scene player
+ * \param[in] __DISP_ADAPTER_PTR the target display adatper (i.e. scene player)
+ * \param[in] ... this is an optional parameter. When it is NULL, a new 
+ *            user_scene_basics_t will be allocated from HEAP and freed on
+ *            the deposing event. When it is non-NULL, the life-cycle is managed
+ *            by user.
+ * \return user_scene_basics_t* the user_scene_basics_t instance
+ */
+#define arm_2d_scene_basics_init(__DISP_ADAPTER_PTR, ...)                    \
+            __arm_2d_scene_basics_init((__DISP_ADAPTER_PTR), (NULL, ##__VA_ARGS__))
+
+/*============================ TYPES =========================================*/
+/*!
+ * \brief a user class for scene 0
+ */
+typedef struct user_scene_basics_t user_scene_basics_t;
+
+struct user_scene_basics_t {
+    implement(arm_2d_scene_t);                                                  //! derived from class: arm_2d_scene_t
+
+ARM_PRIVATE(
+    /* place your private member here, following two are examples */
+    int64_t lTimestamp[1];
+    bool bUserAllocated;
+
+)
+    /* place your public member here */
+    
+};
+
+/*============================ GLOBAL VARIABLES ==============================*/
+/*============================ PROTOTYPES ====================================*/
+
+ARM_NONNULL(1)
+extern
+user_scene_basics_t *__arm_2d_scene_basics_init(   arm_2d_scene_player_t *ptDispAdapter, 
+                                        user_scene_basics_t *ptScene);
+
+#if defined(__clang__)
+#   pragma clang diagnostic pop
+#elif __IS_COMPILER_GCC__
+#   pragma GCC diagnostic pop
+#endif
+
+#ifdef   __cplusplus
+}
+#endif
+
+#endif
+
+#endif

+ 308 - 0
projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_console_window.c

@@ -0,0 +1,308 @@
+/*
+ * Copyright (c) 2009-2022 Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*============================ INCLUDES ======================================*/
+
+#if defined(_RTE_)
+#   include "RTE_Components.h"
+#endif
+
+#if defined(RTE_Acceleration_Arm_2D_Helper_PFB)
+#include "arm_2d.h"
+
+#define __USER_SCENE_CONSOLE_WINDOW_IMPLEMENT__
+#include "arm_2d_scene_console_window.h"
+
+#include "arm_2d_helper.h"
+
+#include "arm_2d_disp_adapters.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#if defined(__clang__)
+#   pragma clang diagnostic push
+#   pragma clang diagnostic ignored "-Wunknown-warning-option"
+#   pragma clang diagnostic ignored "-Wreserved-identifier"
+#   pragma clang diagnostic ignored "-Wsign-conversion"
+#   pragma clang diagnostic ignored "-Wpadded"
+#   pragma clang diagnostic ignored "-Wcast-qual"
+#   pragma clang diagnostic ignored "-Wcast-align"
+#   pragma clang diagnostic ignored "-Wmissing-field-initializers"
+#   pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
+#   pragma clang diagnostic ignored "-Wmissing-prototypes"
+#   pragma clang diagnostic ignored "-Wunused-variable"
+#   pragma clang diagnostic ignored "-Wgnu-statement-expression"
+#   pragma clang diagnostic ignored "-Wdeclaration-after-statement"
+#   pragma clang diagnostic ignored "-Wunused-function"
+#   pragma clang diagnostic ignored "-Wmissing-declarations"  
+#elif __IS_COMPILER_ARM_COMPILER_5__
+#   pragma diag_suppress 64,177
+#elif __IS_COMPILER_IAR__
+#   pragma diag_suppress=Pa089,Pe188,Pe177,Pe174
+#elif __IS_COMPILER_GCC__
+#   pragma GCC diagnostic push
+#   pragma GCC diagnostic ignored "-Wformat="
+#   pragma GCC diagnostic ignored "-Wpedantic"
+#   pragma GCC diagnostic ignored "-Wunused-function"
+#   pragma GCC diagnostic ignored "-Wunused-variable"
+#   pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
+#endif
+
+/*============================ MACROS ========================================*/
+
+#if __GLCD_CFG_COLOUR_DEPTH__ == 8
+
+#   define c_tileCMSISLogo          c_tileCMSISLogoGRAY8
+
+#elif __GLCD_CFG_COLOUR_DEPTH__ == 16
+
+#   define c_tileCMSISLogo          c_tileCMSISLogoRGB565
+
+#elif __GLCD_CFG_COLOUR_DEPTH__ == 32
+
+#   define c_tileCMSISLogo          c_tileCMSISLogoCCCA8888
+#else
+#   error Unsupported colour depth!
+#endif
+
+/*============================ MACROFIED FUNCTIONS ===========================*/
+#undef this
+#define this (*ptThis)
+
+/*============================ TYPES =========================================*/
+/*============================ GLOBAL VARIABLES ==============================*/
+
+extern const arm_2d_tile_t c_tileCMSISLogo;
+extern const arm_2d_tile_t c_tileCMSISLogoMask;
+extern const arm_2d_tile_t c_tileCMSISLogoA2Mask;
+extern const arm_2d_tile_t c_tileCMSISLogoA4Mask;
+/*============================ PROTOTYPES ====================================*/
+/*============================ LOCAL VARIABLES ===============================*/
+/*============================ IMPLEMENTATION ================================*/
+
+
+static void __on_scene_console_window_depose(arm_2d_scene_t *ptScene)
+{
+    user_scene_console_window_t *ptThis = (user_scene_console_window_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+    
+    ptScene->ptPlayer = NULL;
+    
+    arm_foreach(int64_t,this.lTimestamp, ptItem) {
+        *ptItem = 0;
+    }
+
+    console_box_depose(&this.tConsole);
+
+    if (!this.bUserAllocated) {
+        __arm_2d_free_scratch_memory(ARM_2D_MEM_TYPE_UNSPECIFIED, ptScene);
+    }
+}
+
+/*----------------------------------------------------------------------------*
+ * Scene console_window                                                                    *
+ *----------------------------------------------------------------------------*/
+
+static void __on_scene_console_window_background_start(arm_2d_scene_t *ptScene)
+{
+    user_scene_console_window_t *ptThis = (user_scene_console_window_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+
+}
+
+static void __on_scene_console_window_background_complete(arm_2d_scene_t *ptScene)
+{
+    user_scene_console_window_t *ptThis = (user_scene_console_window_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+}
+
+
+static void __on_scene_console_window_frame_start(arm_2d_scene_t *ptScene)
+{
+    user_scene_console_window_t *ptThis = (user_scene_console_window_t *)ptScene;
+    if (arm_2d_helper_is_time_out(100, &this.lTimestamp[1])) {
+        static uint16_t s_hwCount = 0;
+
+        console_box_printf(&this.tConsole, "Hello World! \t[%d]\r\n",s_hwCount++);
+    }
+
+    console_box_on_frame_start(&this.tConsole);
+}
+
+static void __on_scene_console_window_frame_complete(arm_2d_scene_t *ptScene)
+{
+    user_scene_console_window_t *ptThis = (user_scene_console_window_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+
+    if (arm_2d_helper_is_time_out(10000, &this.lTimestamp[0])) {
+        arm_2d_scene_player_switch_to_next_scene(ptScene->ptPlayer);
+    }
+
+}
+
+static void __before_scene_console_window_switching_out(arm_2d_scene_t *ptScene)
+{
+    user_scene_console_window_t *ptThis = (user_scene_console_window_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+
+}
+
+static
+IMPL_PFB_ON_DRAW(__pfb_draw_scene_console_window_handler)
+{
+    ARM_2D_PARAM(pTarget);
+    ARM_2D_PARAM(ptTile);
+    ARM_2D_PARAM(bIsNewFrame);
+
+    user_scene_console_window_t *ptThis = (user_scene_console_window_t *)pTarget;
+    arm_2d_size_t tScreenSize = ptTile->tRegion.tSize;
+
+    ARM_2D_UNUSED(tScreenSize);
+
+    arm_2d_canvas(ptTile, __top_canvas) {
+    /*-----------------------draw the foreground begin-----------------------*/
+
+        /* following code is just a demo, you can remove them */
+
+        /* draw the cmsis logo using mask in the centre of the screen */
+        arm_2d_align_centre(__top_canvas, c_tileCMSISLogo.tRegion.tSize) {
+            arm_2d_fill_colour_with_a4_mask_and_opacity(   
+                                                ptTile, 
+                                                &__centre_region, 
+                                                &c_tileCMSISLogoA4Mask, 
+                                                (__arm_2d_color_t){GLCD_COLOR_BLACK},
+                                                128);
+        }
+
+        arm_2d_align_centre(__top_canvas, 260, 260) {
+            /* draw console background */
+            draw_round_corner_box(  ptTile, 
+                                    &__centre_region, 
+                                    GLCD_COLOR_BLACK, 
+                                    128,
+                                    bIsNewFrame);
+            /* draw console */
+            console_box_show(   &this.tConsole,
+                                ptTile,
+                                &__centre_region,
+                                bIsNewFrame,
+                                255);
+        }
+
+        /* draw text at the top-left corner */
+        arm_lcd_text_set_target_framebuffer((arm_2d_tile_t *)ptTile);
+        arm_lcd_text_set_font(&ARM_2D_FONT_6x8.use_as__arm_2d_font_t);
+        arm_lcd_text_set_draw_region(NULL);
+        arm_lcd_text_set_colour(GLCD_COLOR_RED, GLCD_COLOR_WHITE);
+        arm_lcd_text_location(0,0);
+        arm_lcd_puts("Scene Floating Console");
+
+    /*-----------------------draw the foreground end  -----------------------*/
+    }
+    arm_2d_op_wait_async(NULL);
+
+    return arm_fsm_rt_cpl;
+}
+
+ARM_NONNULL(1)
+user_scene_console_window_t *__arm_2d_scene_console_window_init(
+                                        arm_2d_scene_player_t *ptDispAdapter, 
+                                        user_scene_console_window_t *ptThis)
+{
+    bool bUserAllocated = false;
+    assert(NULL != ptDispAdapter);
+
+    /* get the screen region */
+    arm_2d_region_t tScreen
+        = arm_2d_helper_pfb_get_display_area(
+            &ptDispAdapter->use_as__arm_2d_helper_pfb_t);
+    
+    if (NULL == ptThis) {
+        ptThis = (user_scene_console_window_t *)
+                    __arm_2d_allocate_scratch_memory(   sizeof(user_scene_console_window_t),
+                                                        __alignof__(user_scene_console_window_t),
+                                                        ARM_2D_MEM_TYPE_UNSPECIFIED);
+        assert(NULL != ptThis);
+        if (NULL == ptThis) {
+            return NULL;
+        }
+    } else {
+        bUserAllocated = true;
+    }
+
+    memset(ptThis, 0, sizeof(user_scene_console_window_t));
+
+    *ptThis = (user_scene_console_window_t){
+        .use_as__arm_2d_scene_t = {
+
+            /* the canvas colour */
+            .tCanvas = {GLCD_COLOR_WHITE}, 
+        
+            /* Please uncommon the callbacks if you need them
+             */
+            .fnScene        = &__pfb_draw_scene_console_window_handler,
+            
+            //.fnOnBGStart    = &__on_scene_console_window_background_start,
+            //.fnOnBGComplete = &__on_scene_console_window_background_complete,
+            .fnOnFrameStart = &__on_scene_console_window_frame_start,
+            //.fnBeforeSwitchOut = &__before_scene_console_window_switching_out,
+            .fnOnFrameCPL   = &__on_scene_console_window_frame_complete,
+            .fnDepose       = &__on_scene_console_window_depose,
+        },
+        .bUserAllocated = bUserAllocated,
+    };
+
+    /* ------------   initialize members of user_scene_console_window_t begin ---------------*/
+    do {
+        static uint8_t s_chInputBuffer[256];
+        static uint8_t s_chConsoleBuffer[(240 / 6) * (240 / 8)];
+        console_box_cfg_t tCFG = {
+            .tBoxSize = {240, 240},
+
+            .pchConsoleBuffer = s_chConsoleBuffer,
+            .hwConsoleBufferSize = sizeof(s_chConsoleBuffer),
+
+            .pchInputBuffer = s_chInputBuffer,
+            .hwInputBufferSize = sizeof(s_chInputBuffer),
+            .tColor = GLCD_COLOR_GREEN,
+            .bUseDirtyRegion = true,
+        };
+
+        console_box_init(   &this.tConsole, 
+                            &this.use_as__arm_2d_scene_t, 
+                            &tCFG);
+    } while(0);
+
+    /* ------------   initialize members of user_scene_console_window_t end   ---------------*/
+
+    arm_2d_scene_player_append_scenes(  ptDispAdapter, 
+                                        &this.use_as__arm_2d_scene_t, 
+                                        1);
+
+    return ptThis;
+}
+
+
+#if defined(__clang__)
+#   pragma clang diagnostic pop
+#endif
+
+#endif
+
+

+ 113 - 0
projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_console_window.h

@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2009-2022 Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __ARM_2D_SCENE_CONSOLE_WINDOW_H__
+#define __ARM_2D_SCENE_CONSOLE_WINDOW_H__
+
+/*============================ INCLUDES ======================================*/
+
+#if defined(_RTE_)
+#   include "RTE_Components.h"
+#endif
+
+#if defined(RTE_Acceleration_Arm_2D_Helper_PFB)
+
+#include "arm_2d.h"
+
+#include "arm_2d_helper_scene.h"
+#include "arm_2d_example_controls.h"
+#ifdef   __cplusplus
+extern "C" {
+#endif
+
+#if defined(__clang__)
+#   pragma clang diagnostic push
+#   pragma clang diagnostic ignored "-Wunknown-warning-option"
+#   pragma clang diagnostic ignored "-Wreserved-identifier"
+#   pragma clang diagnostic ignored "-Wmissing-declarations"
+#   pragma clang diagnostic ignored "-Wpadded"
+#elif __IS_COMPILER_ARM_COMPILER_5__
+#elif __IS_COMPILER_GCC__
+#   pragma GCC diagnostic push
+#   pragma GCC diagnostic ignored "-Wformat="
+#   pragma GCC diagnostic ignored "-Wpedantic"
+#   pragma GCC diagnostic ignored "-Wpadded"
+#endif
+
+/*============================ MACROS ========================================*/
+
+/* OOC header, please DO NOT modify  */
+#ifdef __USER_SCENE_CONSOLE_WINDOW_IMPLEMENT__
+#   undef __USER_SCENE_CONSOLE_WINDOW_IMPLEMENT__
+#   define __ARM_2D_IMPL__
+#endif
+#include "arm_2d_utils.h"
+
+/*============================ MACROFIED FUNCTIONS ===========================*/
+
+/*!
+ * \brief initalize scene_console_window and add it to a user specified scene player
+ * \param[in] __DISP_ADAPTER_PTR the target display adapter (i.e. scene player)
+ * \param[in] ... this is an optional parameter. When it is NULL, a new 
+ *            user_scene_console_window_t will be allocated from HEAP and freed on
+ *            the deposing event. When it is non-NULL, the life-cycle is managed
+ *            by user.
+ * \return user_scene_console_window_t* the user_scene_console_window_t instance
+ */
+#define arm_2d_scene_console_window_init(__DISP_ADAPTER_PTR, ...)                    \
+            __arm_2d_scene_console_window_init((__DISP_ADAPTER_PTR), (NULL, ##__VA_ARGS__))
+
+/*============================ TYPES =========================================*/
+/*!
+ * \brief a user class for scene console_window
+ */
+typedef struct user_scene_console_window_t user_scene_console_window_t;
+
+struct user_scene_console_window_t {
+    implement(arm_2d_scene_t);                                                  //! derived from class: arm_2d_scene_t
+
+ARM_PRIVATE(
+    /* place your private member here, following two are examples */
+    int64_t lTimestamp[2];
+    bool bUserAllocated;
+)
+    /* place your public member here */
+    console_box_t tConsole;
+};
+
+/*============================ GLOBAL VARIABLES ==============================*/
+/*============================ PROTOTYPES ====================================*/
+
+ARM_NONNULL(1)
+extern
+user_scene_console_window_t *__arm_2d_scene_console_window_init(   arm_2d_scene_player_t *ptDispAdapter, 
+                                        user_scene_console_window_t *ptScene);
+
+#if defined(__clang__)
+#   pragma clang diagnostic pop
+#elif __IS_COMPILER_GCC__
+#   pragma GCC diagnostic pop
+#endif
+
+#ifdef   __cplusplus
+}
+#endif
+
+#endif
+
+#endif

+ 363 - 0
projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_gas_gauge.c

@@ -0,0 +1,363 @@
+/*
+ * Copyright (c) 2009-2022 Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*============================ INCLUDES ======================================*/
+
+#include "arm_2d.h"
+
+#if defined(RTE_Acceleration_Arm_2D_Helper_PFB)
+
+#define __USER_SCENE_GAS_GAUGE_IMPLEMENT__
+#include "arm_2d_scenes.h"
+
+#include "arm_2d_helper.h"
+#include "arm_2d_example_controls.h"
+
+#include "arm_2d_scene_gas_gauge.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#if defined(__clang__)
+#   pragma clang diagnostic push
+#   pragma clang diagnostic ignored "-Wunknown-warning-option"
+#   pragma clang diagnostic ignored "-Wreserved-identifier"
+#   pragma clang diagnostic ignored "-Wsign-conversion"
+#   pragma clang diagnostic ignored "-Wpadded"
+#   pragma clang diagnostic ignored "-Wcast-qual"
+#   pragma clang diagnostic ignored "-Wcast-align"
+#   pragma clang diagnostic ignored "-Wmissing-field-initializers"
+#   pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
+#   pragma clang diagnostic ignored "-Wmissing-prototypes"
+#   pragma clang diagnostic ignored "-Wunused-variable"
+#   pragma clang diagnostic ignored "-Wgnu-statement-expression"
+#   pragma clang diagnostic ignored "-Wdeclaration-after-statement"
+#   pragma clang diagnostic ignored "-Wunused-function"
+#   pragma clang diagnostic ignored "-Wmissing-declarations"
+#elif __IS_COMPILER_ARM_COMPILER_5__
+#   pragma diag_suppress 64,177
+#elif __IS_COMPILER_IAR__
+#   pragma diag_suppress=Pa089,Pe188,Pe177,Pe174
+#elif __IS_COMPILER_GCC__
+#   pragma GCC diagnostic push
+#   pragma GCC diagnostic ignored "-Wformat="
+#   pragma GCC diagnostic ignored "-Wpedantic"
+#   pragma GCC diagnostic ignored "-Wunused-function"
+#   pragma GCC diagnostic ignored "-Wunused-variable"
+#   pragma GCC diagnostic ignored "-Wunused-value"
+#endif
+
+/*============================ MACROS ========================================*/
+
+#if __GLCD_CFG_COLOUR_DEPTH__ == 8
+
+#   define c_tileCMSISLogo          c_tileCMSISLogoGRAY8
+
+#elif __GLCD_CFG_COLOUR_DEPTH__ == 16
+
+#   define c_tileCMSISLogo          c_tileCMSISLogoRGB565
+
+#elif __GLCD_CFG_COLOUR_DEPTH__ == 32
+
+#   define c_tileCMSISLogo          c_tileCMSISLogoCCCA8888
+#else
+#   error Unsupported colour depth!
+#endif
+
+/*============================ MACROFIED FUNCTIONS ===========================*/
+#undef this
+#define this (*ptThis)
+
+/*============================ TYPES =========================================*/
+/*============================ GLOBAL VARIABLES ==============================*/
+
+extern const arm_2d_tile_t c_tileCMSISLogo;
+extern const arm_2d_tile_t c_tileCMSISLogoMask;
+extern const arm_2d_tile_t c_tileCMSISLogoA2Mask;
+extern const arm_2d_tile_t c_tileCMSISLogoA4Mask;
+
+/*============================ PROTOTYPES ====================================*/
+/*============================ LOCAL VARIABLES ===============================*/
+/*============================ IMPLEMENTATION ================================*/
+
+
+static void __on_scene_gas_gauge_depose(arm_2d_scene_t *ptScene)
+{
+    user_scene_gas_gauge_t *ptThis = (user_scene_gas_gauge_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+    
+    ptScene->ptPlayer = NULL;
+
+    /* reset timestamp */
+    arm_foreach(int64_t,this.lTimestamp, ptItem) {
+        *ptItem = 0;
+    }
+
+    if (!this.bUserAllocated) {
+        __arm_2d_free_scratch_memory(ARM_2D_MEM_TYPE_UNSPECIFIED, ptScene);
+    }
+}
+
+/*----------------------------------------------------------------------------*
+ * Scene 4                                                                    *
+ *----------------------------------------------------------------------------*/
+
+static void __on_scene_gas_gauge_background_start(arm_2d_scene_t *ptScene)
+{
+    user_scene_gas_gauge_t *ptThis = (user_scene_gas_gauge_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+
+}
+
+static void __on_scene_gas_gauge_background_complete(arm_2d_scene_t *ptScene)
+{
+    user_scene_gas_gauge_t *ptThis = (user_scene_gas_gauge_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+
+}
+
+
+static void __on_scene_gas_gauge_frame_start(arm_2d_scene_t *ptScene)
+{
+    user_scene_gas_gauge_t *ptThis = (user_scene_gas_gauge_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+
+    int32_t nResult;
+    
+    /* simulate a full battery charging/discharge cycle */
+    arm_2d_helper_time_cos_slider(0, 1000, 30000, 0, &nResult, &this.lTimestamp[1]);
+    
+    if (this.hwGasgauge < nResult) {
+        this.tStatus = BATTERY_STATUS_CHARGING;
+    } else if (this.hwGasgauge > nResult) {
+        this.tStatus = BATTERY_STATUS_DISCHARGING;
+    }
+    this.hwGasgauge = (uint16_t)nResult;
+
+}
+
+static void __before_scene_gas_gauge_switching_out(arm_2d_scene_t *ptScene)
+{
+    user_scene_gas_gauge_t *ptThis = (user_scene_gas_gauge_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+}
+
+static void __on_scene_gas_gauge_frame_complete(arm_2d_scene_t *ptScene)
+{
+    user_scene_gas_gauge_t *ptThis = (user_scene_gas_gauge_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+    
+    /* switch to next scene after 3s */
+    if (arm_2d_helper_is_time_out(29000, &this.lTimestamp[0])) {
+        arm_2d_scene_player_switch_to_next_scene(ptScene->ptPlayer);
+    }
+}
+
+static
+IMPL_PFB_ON_DRAW(__pfb_draw_scene_gas_gauge_background_handler)
+{
+    user_scene_gas_gauge_t *ptThis = (user_scene_gas_gauge_t *)pTarget;
+    ARM_2D_UNUSED(ptTile);
+    ARM_2D_UNUSED(bIsNewFrame);
+    /*-----------------------draw back ground begin-----------------------*/
+
+
+
+    /*-----------------------draw back ground end  -----------------------*/
+    arm_2d_op_wait_async(NULL);
+
+    return arm_fsm_rt_cpl;
+}
+
+static
+IMPL_PFB_ON_DRAW(__pfb_draw_scene_gas_gauge_handler)
+{
+    user_scene_gas_gauge_t *ptThis = (user_scene_gas_gauge_t *)pTarget;
+    ARM_2D_UNUSED(ptTile);
+    ARM_2D_UNUSED(bIsNewFrame);
+
+    
+    /*-----------------------draw the foreground begin-----------------------*/
+    
+    /* following code is just a demo, you can remove them */
+
+    arm_2d_canvas(ptTile, __canvas) {
+
+        arm_2d_align_centre( __canvas, 128, 130) {
+
+            arm_2d_layout(__centre_region, true) {
+
+                __item_line_horizontal(64, 130) {
+                    battery_gasgauge_nixie_tube_show(   &this.tBatteryNixieTube, 
+                                                        ptTile, 
+                                                        &__item_region, 
+                                                        this.hwGasgauge,
+                                                        this.tStatus,
+                                                        bIsNewFrame);
+                    
+                    arm_2d_op_wait_async(NULL);
+
+                    
+                    arm_2d_size_t tTextSize = arm_lcd_get_string_line_box("00", &ARM_2D_FONT_A4_DIGITS_ONLY);
+                    
+                    arm_2d_align_bottom_centre(__item_region, tTextSize) {
+
+                        arm_lcd_text_set_target_framebuffer((arm_2d_tile_t *)ptTile);
+                        arm_lcd_text_set_font((arm_2d_font_t *)&ARM_2D_FONT_A4_DIGITS_ONLY);
+                        arm_lcd_text_set_draw_region(&__bottom_centre_region);
+                        arm_lcd_text_set_colour(GLCD_COLOR_NIXIE_TUBE, GLCD_COLOR_BLACK);
+                        arm_lcd_text_location(0,0);
+                        arm_lcd_printf("%02d", this.hwGasgauge / 10);
+                        
+                        arm_2d_op_wait_async(NULL);
+                    }
+                }
+                
+                __item_line_horizontal(64, 130) {
+                    battery_gasgauge_liquid_show(   &this.tBatteryLiquid, 
+                                                    ptTile, 
+                                                    &__item_region, 
+                                                    this.hwGasgauge,
+                                                    this.tStatus,
+                                                    bIsNewFrame);
+                    
+                    arm_2d_op_wait_async(NULL);
+                    
+                    arm_2d_size_t tTextSize = arm_lcd_get_string_line_box("00", &ARM_2D_FONT_A4_DIGITS_ONLY);
+                    
+                    arm_2d_align_bottom_centre(__item_region, tTextSize) {
+
+                        arm_lcd_text_set_target_framebuffer((arm_2d_tile_t *)ptTile);
+                        arm_lcd_text_set_font((arm_2d_font_t *)&ARM_2D_FONT_A4_DIGITS_ONLY);
+                        arm_lcd_text_set_draw_region(&__bottom_centre_region);
+                        arm_lcd_text_set_colour(GLCD_COLOR_WHITE, GLCD_COLOR_BLACK);
+                        arm_lcd_text_location(0,0);
+                        arm_lcd_text_set_opacity(128);
+                        arm_lcd_printf("%02d", this.hwGasgauge / 10);
+                        arm_lcd_text_set_opacity(255);
+
+                        arm_2d_op_wait_async(NULL);
+                    }
+                }
+            }
+        }
+    }
+
+    /* draw text at the top-left corner */
+
+    arm_lcd_text_set_target_framebuffer((arm_2d_tile_t *)ptTile);
+    arm_lcd_text_set_font(&ARM_2D_FONT_6x8.use_as__arm_2d_font_t);
+    arm_lcd_text_set_draw_region(NULL);
+    arm_lcd_text_set_colour(GLCD_COLOR_NIXIE_TUBE, GLCD_COLOR_WHITE);
+    arm_lcd_text_location(0,0);
+    arm_lcd_puts("Scene Battery Gas Gauge");
+
+    /*-----------------------draw the foreground end  -----------------------*/
+    arm_2d_op_wait_async(NULL);
+
+    return arm_fsm_rt_cpl;
+}
+
+ARM_NONNULL(1)
+user_scene_gas_gauge_t *__arm_2d_scene_gas_gauge_init(   arm_2d_scene_player_t *ptDispAdapter, 
+                                        user_scene_gas_gauge_t *ptThis)
+{
+    bool bUserAllocated = false;
+    assert(NULL != ptDispAdapter);
+
+    /*! define dirty regions */
+    IMPL_ARM_2D_REGION_LIST(s_tDirtyRegions, static)
+
+        /* a dirty region to be specified at runtime*/
+        ADD_LAST_REGION_TO_LIST(s_tDirtyRegions,
+            .tSize = {
+                128, 130,
+            },
+        ),
+        
+    END_IMPL_ARM_2D_REGION_LIST(s_tDirtyRegions)
+    
+    s_tDirtyRegions[dimof(s_tDirtyRegions)-1].ptNext = NULL;
+
+    /* get the screen region */
+    arm_2d_region_t tScreen
+        = arm_2d_helper_pfb_get_display_area(
+            &ptDispAdapter->use_as__arm_2d_helper_pfb_t);
+    
+    /* initialise dirty region 0 at runtime
+     */
+    arm_2d_align_centre(tScreen, s_tDirtyRegions[0].tRegion.tSize) {
+        s_tDirtyRegions[0].tRegion = __centre_region;
+    }
+    
+    if (NULL == ptThis) {
+        ptThis = (user_scene_gas_gauge_t *)
+                    __arm_2d_allocate_scratch_memory(   sizeof(user_scene_gas_gauge_t),
+                                                        __alignof__(user_scene_gas_gauge_t),
+                                                        ARM_2D_MEM_TYPE_UNSPECIFIED);
+        assert(NULL != ptThis);
+        if (NULL == ptThis) {
+            return NULL;
+        }
+    } else {
+        bUserAllocated = true;
+        memset(ptThis, 0, sizeof(user_scene_gas_gauge_t));
+    }
+
+    *ptThis = (user_scene_gas_gauge_t){
+        .use_as__arm_2d_scene_t = {
+
+        /* the canvas colour */
+        .tCanvas = {GLCD_COLOR_BLACK}, 
+
+        /* Please uncommon the callbacks if you need them
+         */
+        //.fnBackground   = &__pfb_draw_scene_gas_gauge_background_handler,
+        .fnScene        = &__pfb_draw_scene_gas_gauge_handler,
+        .ptDirtyRegion  = (arm_2d_region_list_item_t *)s_tDirtyRegions,
+        
+
+        //.fnOnBGStart    = &__on_scene_gas_gauge_background_start,
+        //.fnOnBGComplete = &__on_scene_gas_gauge_background_complete,
+        .fnOnFrameStart = &__on_scene_gas_gauge_frame_start,
+        .fnBeforeSwitchOut = &__before_scene_gas_gauge_switching_out,
+        .fnOnFrameCPL   = &__on_scene_gas_gauge_frame_complete,
+        .fnDepose       = &__on_scene_gas_gauge_depose,
+        },
+        .bUserAllocated = bUserAllocated,
+    };
+
+    battery_gasgauge_nixie_tube_init(&this.tBatteryNixieTube);
+    battery_gasgauge_liquid_init(&this.tBatteryLiquid);
+
+    arm_2d_scene_player_append_scenes(  ptDispAdapter, 
+                                        &this.use_as__arm_2d_scene_t, 
+                                        1);
+
+    return ptThis;
+}
+
+
+
+
+#if defined(__clang__)
+#   pragma clang diagnostic pop
+#endif
+
+#endif
+

+ 115 - 0
projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_gas_gauge.h

@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2009-2022 Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __ARM_2D_SCENE_GAS_GAUGE_H__
+#define __ARM_2D_SCENE_GAS_GAUGE_H__
+
+/*============================ INCLUDES ======================================*/
+
+#include "arm_2d.h"
+
+#if defined(RTE_Acceleration_Arm_2D_Helper_PFB)
+
+#include "arm_2d_helper_scene.h"
+
+#include "battery_gasgauge.h"
+
+#ifdef   __cplusplus
+extern "C" {
+#endif
+
+#if defined(__clang__)
+#   pragma clang diagnostic push
+#   pragma clang diagnostic ignored "-Wunknown-warning-option"
+#   pragma clang diagnostic ignored "-Wreserved-identifier"
+#   pragma clang diagnostic ignored "-Wmissing-declarations"
+#   pragma clang diagnostic ignored "-Wpadded"
+#elif __IS_COMPILER_ARM_COMPILER_5__
+#elif __IS_COMPILER_GCC__
+#   pragma GCC diagnostic push
+#   pragma GCC diagnostic ignored "-Wformat="
+#   pragma GCC diagnostic ignored "-Wpedantic"
+#   pragma GCC diagnostic ignored "-Wpadded"
+#endif
+
+/*============================ MACROS ========================================*/
+
+/* OOC header, please DO NOT modify  */
+#ifdef __USER_SCENE_GAS_GAUGE_IMPLEMENT__
+#   undef __USER_SCENE_GAS_GAUGE_IMPLEMENT__
+#   define __ARM_2D_IMPL__
+#endif
+#include "arm_2d_utils.h"
+
+/*============================ MACROFIED FUNCTIONS ===========================*/
+
+/*!
+ * \brief initalize scene4 and add it to a user specified scene player
+ * \param[in] __DISP_ADAPTER_PTR the target display adatper (i.e. scene player)
+ * \param[in] ... this is an optional parameter. When it is NULL, a new 
+ *            user_scene_gas_gauge_t will be allocated from HEAP and freed on
+ *            the deposing event. When it is non-NULL, the life-cycle is managed
+ *            by user.
+ * \return user_scene_gas_gauge_t* the user_scene_gas_gauge_t instance
+ */
+#define arm_2d_scene_gas_gauge_init(__DISP_ADAPTER_PTR, ...)                    \
+            __arm_2d_scene_gas_gauge_init((__DISP_ADAPTER_PTR), (NULL, ##__VA_ARGS__))
+
+/*============================ TYPES =========================================*/
+/*!
+ * \brief a user class for scene 4
+ */
+typedef struct user_scene_gas_gauge_t user_scene_gas_gauge_t;
+
+struct user_scene_gas_gauge_t {
+    implement(arm_2d_scene_t);                                                  //! derived from class: arm_2d_scene_t
+
+ARM_PRIVATE(
+    /* place your private member here, following two are examples */
+    int64_t lTimestamp[2];
+    bool bUserAllocated;
+    uint16_t hwGasgauge;
+    battery_nixie_tube_t    tBatteryNixieTube;
+    battery_liquid_t        tBatteryLiquid;
+    battery_status_t tStatus;
+)
+    /* place your public member here */
+    
+};
+
+/*============================ GLOBAL VARIABLES ==============================*/
+/*============================ PROTOTYPES ====================================*/
+
+ARM_NONNULL(1)
+extern
+user_scene_gas_gauge_t *__arm_2d_scene_gas_gauge_init(   arm_2d_scene_player_t *ptDispAdapter, 
+                                        user_scene_gas_gauge_t *ptScene);
+
+#if defined(__clang__)
+#   pragma clang diagnostic pop
+#elif __IS_COMPILER_GCC__
+#   pragma GCC diagnostic pop
+#endif
+
+#ifdef   __cplusplus
+}
+#endif
+
+#endif
+
+#endif

+ 565 - 0
projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_listview.c

@@ -0,0 +1,565 @@
+/*
+ * Copyright (c) 2009-2022 Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*============================ INCLUDES ======================================*/
+
+#include "arm_2d.h"
+
+#if defined(RTE_Acceleration_Arm_2D_Helper_PFB)
+
+#define __USER_SCENE_LISTVIEW_IMPLEMENT__
+
+#include "arm_2d_helper.h"
+#include "arm_2d_example_controls.h"
+
+#include "arm_2d_scene_listview.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#if defined(__clang__)
+#   pragma clang diagnostic push
+#   pragma clang diagnostic ignored "-Wunknown-warning-option"
+#   pragma clang diagnostic ignored "-Wreserved-identifier"
+#   pragma clang diagnostic ignored "-Wsign-conversion"
+#   pragma clang diagnostic ignored "-Wpadded"
+#   pragma clang diagnostic ignored "-Wcast-qual"
+#   pragma clang diagnostic ignored "-Wcast-align"
+#   pragma clang diagnostic ignored "-Wmissing-field-initializers"
+#   pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
+#   pragma clang diagnostic ignored "-Wmissing-prototypes"
+#   pragma clang diagnostic ignored "-Wunused-variable"
+#   pragma clang diagnostic ignored "-Wgnu-statement-expression"
+#   pragma clang diagnostic ignored "-Wdeclaration-after-statement"
+#   pragma clang diagnostic ignored "-Wunused-function"
+#   pragma clang diagnostic ignored "-Wmissing-declarations"  
+#elif __IS_COMPILER_ARM_COMPILER_5__
+#   pragma diag_suppress 64,177
+#elif __IS_COMPILER_GCC__
+#   pragma GCC diagnostic push
+#   pragma GCC diagnostic ignored "-Wformat="
+#   pragma GCC diagnostic ignored "-Wpedantic"
+#   pragma GCC diagnostic ignored "-Wunused-function"
+#   pragma GCC diagnostic ignored "-Wunused-variable"
+#   pragma GCC diagnostic ignored "-Wunused-value"
+#elif __IS_COMPILER_IAR__
+#   pragma diag_suppress=Pa089,Pe188,Pe177,Pe174
+#endif
+
+/*============================ MACROS ========================================*/
+
+#if __GLCD_CFG_COLOUR_DEPTH__ == 8
+
+#   define c_tileCMSISLogo          c_tileCMSISLogoGRAY8
+
+#elif __GLCD_CFG_COLOUR_DEPTH__ == 16
+
+#   define c_tileCMSISLogo          c_tileCMSISLogoRGB565
+
+#elif __GLCD_CFG_COLOUR_DEPTH__ == 32
+
+#   define c_tileCMSISLogo          c_tileCMSISLogoCCCA8888
+#else
+#   error Unsupported colour depth!
+#endif
+
+/*============================ MACROFIED FUNCTIONS ===========================*/
+#undef this
+#define this (*ptThis)
+
+/*============================ TYPES =========================================*/
+
+typedef struct my_list_item_t {
+    implement(arm_2d_list_item_t);
+    
+    /* you can put your own members here */
+} my_list_item_t;
+
+
+/*============================ GLOBAL VARIABLES ==============================*/
+/*============================ PROTOTYPES ====================================*/
+
+static 
+arm_fsm_rt_t __list_view_item_0_draw_item( 
+                                      arm_2d_list_item_t *ptItem,
+                                      const arm_2d_tile_t *ptTile,
+                                      bool bIsNewFrame,
+                                      arm_2d_list_item_param_t *ptParam);
+
+static 
+arm_fsm_rt_t __list_view_item_1_draw_item( 
+                                      arm_2d_list_item_t *ptItem,
+                                      const arm_2d_tile_t *ptTile,
+                                      bool bIsNewFrame,
+                                      arm_2d_list_item_param_t *ptParam);
+
+static 
+arm_fsm_rt_t __list_view_item_2_draw_item( 
+                                      arm_2d_list_item_t *ptItem,
+                                      const arm_2d_tile_t *ptTile,
+                                      bool bIsNewFrame,
+                                      arm_2d_list_item_param_t *ptParam);
+
+static 
+arm_fsm_rt_t __list_view_item_3_draw_item( 
+                                      arm_2d_list_item_t *ptItem,
+                                      const arm_2d_tile_t *ptTile,
+                                      bool bIsNewFrame,
+                                      arm_2d_list_item_param_t *ptParam);
+
+/*============================ LOCAL VARIABLES ===============================*/
+
+enum {
+    MY_LIST_ITEM_ID_0,
+    MY_LIST_ITEM_ID_1,
+    MY_LIST_ITEM_ID_2,
+    MY_LIST_ITEM_ID_3,
+};
+
+static
+my_list_item_t s_tListArray[] = {
+    [MY_LIST_ITEM_ID_0] = {
+        .use_as__arm_2d_list_item_t = {
+            .hwID = MY_LIST_ITEM_ID_0,
+            .bIsEnabled = true,
+            .bIsVisible = true,
+            .bIsReadOnly = true,    /* indicate this is a const item */
+            .Padding = {
+                5,5,
+            },
+            .u4Alignment = ARM_2D_ALIGN_TOP,
+            .tSize = { 100, 80 },
+            .fnOnDrawItem = &__list_view_item_0_draw_item,
+        },
+    },
+
+    [MY_LIST_ITEM_ID_1] = {
+        .use_as__arm_2d_list_item_t = {
+            .hwID = MY_LIST_ITEM_ID_1,
+            .bIsEnabled = true,
+            .bIsVisible = true,
+            .bIsReadOnly = true,    /* indicate this is a const item */
+            
+            .Padding = {
+                5,5,
+            },
+            .tSize = { 100, 100 },
+            .fnOnDrawItem = &__list_view_item_1_draw_item,
+        },
+    },
+
+    [MY_LIST_ITEM_ID_2] = {
+        .use_as__arm_2d_list_item_t = {
+            .hwID = MY_LIST_ITEM_ID_2,
+            .bIsEnabled = true,
+            .bIsVisible = true,
+            .bIsReadOnly = true,    /* indicate this is a const item */
+
+            .Padding = {
+                5,5,
+            },
+            .u4Alignment = ARM_2D_ALIGN_BOTTOM,
+            .tSize = { 100, 90 },
+            .fnOnDrawItem = &__list_view_item_2_draw_item,
+        },
+    },
+
+
+    [MY_LIST_ITEM_ID_3] = {
+        .use_as__arm_2d_list_item_t = {
+            .hwID = MY_LIST_ITEM_ID_3,
+            .bIsEnabled = true,
+            .bIsVisible = true,
+            .bIsReadOnly = true,    /* indicate this is a const item */
+
+            .Padding = {
+                5,5,
+            },
+            .tSize = { 100, 110 },
+            .fnOnDrawItem = &__list_view_item_3_draw_item,
+        },
+    },
+};
+
+/*============================ IMPLEMENTATION ================================*/
+
+
+#define ITEM_BG_OPACITY     (255)
+
+static 
+arm_fsm_rt_t __list_view_item_0_draw_item( 
+                                      arm_2d_list_item_t *ptItem,
+                                      const arm_2d_tile_t *ptTile,
+                                      bool bIsNewFrame,
+                                      arm_2d_list_item_param_t *ptParam)
+{
+    my_list_item_t *ptThis = (my_list_item_t *)ptItem;
+    ARM_2D_UNUSED(ptItem);
+    ARM_2D_UNUSED(bIsNewFrame);
+    ARM_2D_UNUSED(ptTile);
+    ARM_2D_UNUSED(ptParam);
+
+    uint8_t chOpacity = arm_2d_helper_alpha_mix(ITEM_BG_OPACITY, ptParam->chOpacity);
+
+    arm_2d_canvas(ptTile, __canvas) {
+        draw_round_corner_box(ptTile, &__canvas, GLCD_COLOR_WHITE, chOpacity, bIsNewFrame);
+
+        arm_lcd_text_set_target_framebuffer(ptTile);
+        arm_lcd_text_set_colour(__RGB(0x94, 0xd2, 0x52), GLCD_COLOR_BLACK);
+        arm_lcd_text_set_opacity(chOpacity);
+        arm_lcd_text_set_font((arm_2d_font_t *)&ARM_2D_FONT_A4_DIGITS_ONLY);
+        arm_print_banner("0", __canvas);
+        arm_lcd_text_set_opacity(255);
+
+    }
+    
+    return arm_fsm_rt_cpl;
+}
+
+
+static 
+arm_fsm_rt_t __list_view_item_1_draw_item( 
+                                      arm_2d_list_item_t *ptItem,
+                                      const arm_2d_tile_t *ptTile,
+                                      bool bIsNewFrame,
+                                      arm_2d_list_item_param_t *ptParam)
+{
+    my_list_item_t *ptThis = (my_list_item_t *)ptItem;
+    user_scene_listview_t *ptScene = (user_scene_listview_t *)ptItem->pTarget;
+    ARM_2D_UNUSED(ptItem);
+    ARM_2D_UNUSED(bIsNewFrame);
+    ARM_2D_UNUSED(ptTile);
+    ARM_2D_UNUSED(ptParam);
+
+    uint8_t chOpacity = arm_2d_helper_alpha_mix(ITEM_BG_OPACITY, ptParam->chOpacity);
+
+    arm_2d_canvas(ptTile, __canvas) {
+    draw_round_corner_box(ptTile, &__canvas, GLCD_COLOR_WHITE, chOpacity, bIsNewFrame);
+
+        progress_wheel_show(&ptScene->tWheel, 
+                            ptTile, 
+                            &__canvas, 
+                            ptScene->iProgress,   /* progress 0~1000 */
+                            chOpacity, 
+                            bIsNewFrame);
+
+        arm_lcd_text_set_target_framebuffer(ptTile);
+        arm_lcd_text_set_colour(__RGB(0x94, 0xd2, 0x52), GLCD_COLOR_BLACK);
+        arm_lcd_text_set_opacity(chOpacity);
+        arm_lcd_text_set_font((arm_2d_font_t *)&ARM_2D_FONT_A4_DIGITS_ONLY);
+        arm_print_banner("1", __canvas);
+        arm_lcd_text_set_opacity(255);
+    }
+    
+    return arm_fsm_rt_cpl;
+}
+
+static 
+arm_fsm_rt_t __list_view_item_2_draw_item( 
+                                      arm_2d_list_item_t *ptItem,
+                                      const arm_2d_tile_t *ptTile,
+                                      bool bIsNewFrame,
+                                      arm_2d_list_item_param_t *ptParam)
+{
+    my_list_item_t *ptThis = (my_list_item_t *)ptItem;
+    ARM_2D_UNUSED(ptItem);
+    ARM_2D_UNUSED(bIsNewFrame);
+    ARM_2D_UNUSED(ptTile);
+    ARM_2D_UNUSED(ptParam);
+    
+    uint8_t chOpacity = arm_2d_helper_alpha_mix(ITEM_BG_OPACITY, ptParam->chOpacity);
+
+    arm_2d_canvas(ptTile, __canvas) {
+        draw_round_corner_box(ptTile, &__canvas, GLCD_COLOR_WHITE, chOpacity, bIsNewFrame);
+    
+        arm_lcd_text_set_target_framebuffer(ptTile);
+        arm_lcd_text_set_colour(__RGB(0x94, 0xd2, 0x52), GLCD_COLOR_BLACK);
+        arm_lcd_text_set_opacity(chOpacity);
+        arm_lcd_text_set_font((arm_2d_font_t *)&ARM_2D_FONT_A4_DIGITS_ONLY);
+        arm_print_banner("2", __canvas);
+        arm_lcd_text_set_opacity(255);
+
+    }
+
+
+    return arm_fsm_rt_cpl;
+}
+
+static 
+arm_fsm_rt_t __list_view_item_3_draw_item( 
+                                      arm_2d_list_item_t *ptItem,
+                                      const arm_2d_tile_t *ptTile,
+                                      bool bIsNewFrame,
+                                      arm_2d_list_item_param_t *ptParam)
+{
+    my_list_item_t *ptThis = (my_list_item_t *)ptItem;
+    ARM_2D_UNUSED(ptItem);
+    ARM_2D_UNUSED(bIsNewFrame);
+    ARM_2D_UNUSED(ptTile);
+    ARM_2D_UNUSED(ptParam);
+
+    uint8_t chOpacity = arm_2d_helper_alpha_mix(ITEM_BG_OPACITY, ptParam->chOpacity);
+
+    arm_2d_canvas(ptTile, __canvas) {
+
+        draw_round_corner_box(ptTile, &__canvas, GLCD_COLOR_WHITE, chOpacity, bIsNewFrame);
+
+        arm_lcd_text_set_target_framebuffer(ptTile);
+        arm_lcd_text_set_colour(__RGB(0x94, 0xd2, 0x52), GLCD_COLOR_BLACK);
+        arm_lcd_text_set_opacity(chOpacity);
+        arm_lcd_text_set_font((arm_2d_font_t *)&ARM_2D_FONT_A4_DIGITS_ONLY);
+        arm_print_banner("3", __canvas);
+        arm_lcd_text_set_opacity(255);
+
+    }
+    
+    return arm_fsm_rt_cpl;
+}
+
+
+static void __on_scene_listview_depose(arm_2d_scene_t *ptScene)
+{
+    user_scene_listview_t *ptThis = (user_scene_listview_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+    
+    ptScene->ptPlayer = NULL;
+    
+    /* reset timestamp */
+    arm_foreach(int64_t,this.lTimestamp, ptItem) {
+        *ptItem = 0;
+    }
+    
+    progress_wheel_depose(&this.tWheel);
+
+    if (!this.bUserAllocated) {
+        __arm_2d_free_scratch_memory(ARM_2D_MEM_TYPE_UNSPECIFIED, ptScene);
+    }
+}
+
+/*----------------------------------------------------------------------------*
+ * Scene 3                                                                    *
+ *----------------------------------------------------------------------------*/
+
+static void __on_scene_listview_background_start(arm_2d_scene_t *ptScene)
+{
+    user_scene_listview_t *ptThis = (user_scene_listview_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+
+}
+
+static void __on_scene_listview_background_complete(arm_2d_scene_t *ptScene)
+{
+    user_scene_listview_t *ptThis = (user_scene_listview_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+
+}
+
+
+static void __on_scene_listview_frame_start(arm_2d_scene_t *ptScene)
+{
+    user_scene_listview_t *ptThis = (user_scene_listview_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+
+    int nResult;
+    if (arm_2d_helper_time_liner_slider(0, 1000, 10000, &nResult, &this.lTimestamp[2])) {
+        this.lTimestamp[2] = 0;
+    }
+    this.iProgress = (int16_t)nResult;
+
+    progress_wheel_on_frame_start(&this.tWheel);
+
+}
+
+static void __on_scene_listview_frame_complete(arm_2d_scene_t *ptScene)
+{
+    user_scene_listview_t *ptThis = (user_scene_listview_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+    
+    /* switch to next scene after 10s */
+    if (arm_2d_helper_is_time_out(12000, &this.lTimestamp[0])) {
+        arm_2d_scene_player_switch_to_next_scene(ptScene->ptPlayer);
+    }
+    
+    if (arm_2d_helper_is_time_out(1500, &this.lTimestamp[1])) {
+        list_view_move_selection(&this.tListView, 1, 300);
+    }
+}
+
+static
+IMPL_PFB_ON_DRAW(__pfb_draw_scene_listview_background_handler)
+{
+    user_scene_listview_t *ptThis = (user_scene_listview_t *)pTarget;
+    ARM_2D_UNUSED(ptTile);
+    ARM_2D_UNUSED(bIsNewFrame);
+    /*-----------------------draw back ground begin-----------------------*/
+
+
+
+    /*-----------------------draw back ground end  -----------------------*/
+    arm_2d_op_wait_async(NULL);
+
+    return arm_fsm_rt_cpl;
+}
+
+static
+IMPL_PFB_ON_DRAW(__pfb_draw_scene_listview_handler)
+{
+    user_scene_listview_t *ptThis = (user_scene_listview_t *)pTarget;
+    ARM_2D_UNUSED(ptTile);
+    ARM_2D_UNUSED(bIsNewFrame);
+    
+    /*-----------------------draw the foreground begin-----------------------*/
+    
+    /* following code is just a demo, you can remove them */
+
+    while(arm_fsm_rt_cpl != list_view_show(&this.tListView, ptTile, NULL, bIsNewFrame));
+
+    /* draw text at the top-left corner */
+    arm_lcd_text_set_target_framebuffer((arm_2d_tile_t *)ptTile);
+    arm_lcd_text_set_font(&ARM_2D_FONT_6x8.use_as__arm_2d_font_t);
+    arm_lcd_text_set_draw_region(NULL);
+    arm_lcd_text_set_colour(GLCD_COLOR_RED, GLCD_COLOR_WHITE);
+    arm_lcd_text_location(0,0);
+    arm_lcd_printf("Scene Listview");
+
+    /*-----------------------draw the foreground end  -----------------------*/
+    arm_2d_op_wait_async(NULL);
+
+    return arm_fsm_rt_cpl;
+}
+
+ARM_NONNULL(1)
+user_scene_listview_t *__arm_2d_scene_listview_init(   arm_2d_scene_player_t *ptDispAdapter, 
+                                        user_scene_listview_t *ptThis)
+{
+    bool bUserAllocated = false;
+    assert(NULL != ptDispAdapter);
+
+    if (NULL == ptThis) {
+        ptThis = (user_scene_listview_t *)
+                    __arm_2d_allocate_scratch_memory(   sizeof(user_scene_listview_t),
+                                                        __alignof__(user_scene_listview_t),
+                                                        ARM_2D_MEM_TYPE_UNSPECIFIED);
+        assert(NULL != ptThis);
+        if (NULL == ptThis) {
+            return NULL;
+        }
+    } else {
+        memset(ptThis, 0, sizeof(user_scene_listview_t));
+        bUserAllocated = true;
+    }
+
+    /*! define dirty regions */
+    IMPL_ARM_2D_REGION_LIST(s_tDirtyRegions, static)
+
+        /* a dirty region to be specified at runtime*/
+        ADD_LAST_REGION_TO_LIST(s_tDirtyRegions,
+            .tSize = {
+                0, 110,
+            },
+        ),
+        
+    END_IMPL_ARM_2D_REGION_LIST(s_tDirtyRegions)
+    
+    s_tDirtyRegions[dimof(s_tDirtyRegions)-1].ptNext = NULL;
+
+    /* get the screen region */
+    arm_2d_region_t tScreen
+        = arm_2d_helper_pfb_get_display_area(
+            &ptDispAdapter->use_as__arm_2d_helper_pfb_t);
+    
+    /* initialise dirty region 0 at runtime
+     */
+    s_tDirtyRegions[0].tRegion.tLocation = (arm_2d_location_t){
+        .iX = 0,
+        .iY = ((tScreen.tSize.iHeight - 110) >> 1),
+    };
+    s_tDirtyRegions[0].tRegion.tSize.iWidth = tScreen.tSize.iWidth;
+
+    *ptThis = (user_scene_listview_t){
+        .use_as__arm_2d_scene_t = {
+
+        /* the canvas colour */
+        .tCanvas = {GLCD_COLOR_BLACK}, 
+        
+        /* Please uncommon the callbacks if you need them
+         */
+        //.fnBackground   = &__pfb_draw_scene_listview_background_handler,
+        .fnScene        = &__pfb_draw_scene_listview_handler,
+        .ptDirtyRegion  = (arm_2d_region_list_item_t *)s_tDirtyRegions,
+        
+
+        //.fnOnBGStart    = &__on_scene_listview_background_start,
+        //.fnOnBGComplete = &__on_scene_listview_background_complete,
+        .fnOnFrameStart = &__on_scene_listview_frame_start,
+        .fnOnFrameCPL   = &__on_scene_listview_frame_complete,
+        .fnDepose       = &__on_scene_listview_depose,
+        },
+        .bUserAllocated = bUserAllocated,
+    };
+
+
+    do {
+        progress_wheel_cfg_t tCFG = {
+            .tDotColour     = GLCD_COLOR_WHITE,         /* dot colour */
+            .tWheelColour   = GLCD_COLOR_GREEN,         /* arc colour */
+            .iWheelDiameter = 60,                       /* diameter, 0 means use the mask's original size */
+            .bUseDirtyRegions = false,                  /* use dirty regions */
+        };
+
+        progress_wheel_init(&this.tWheel, 
+                            &this.use_as__arm_2d_scene_t,
+                            &tCFG);
+    } while(0);
+
+    do {
+        list_view_cfg_t tCFG = {
+            .fnIterator = &ARM_2D_LIST_ITERATOR_ARRAY,
+            .fnCalculator = &ARM_2D_LIST_CALCULATOR_MIDDLE_ALIGNED_HORIZONTAL,
+            
+            .tListSize = {0, 110},
+            .ptItems = (arm_2d_list_item_t *)s_tListArray,
+            .hwCount = dimof(s_tListArray),
+            .hwItemSizeInByte = sizeof(my_list_item_t),
+            
+            .bIgnoreBackground = true,
+        };
+        
+        list_view_init(&this.tListView, &tCFG);
+        
+        arm_foreach(my_list_item_t, s_tListArray, ptItem) {
+            ptItem->use_as__arm_2d_list_item_t.pTarget = (uintptr_t)ptThis;
+        }
+    } while(0);
+
+    arm_2d_scene_player_append_scenes(  ptDispAdapter, 
+                                        &this.use_as__arm_2d_scene_t, 
+                                        1);
+
+    return ptThis;
+}
+
+
+
+
+#if defined(__clang__)
+#   pragma clang diagnostic pop
+#endif
+
+#endif
+

+ 114 - 0
projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_listview.h

@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2009-2022 Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __ARM_2D__SCENE_LISTVIEW_H__
+#define __ARM_2D__SCENE_LISTVIEW_H__
+
+/*============================ INCLUDES ======================================*/
+
+#include "arm_2d.h"
+
+#if defined(RTE_Acceleration_Arm_2D_Helper_PFB)
+
+#include "arm_2d_helper_scene.h"
+#include "list_view.h"
+#include "progress_wheel.h"
+
+#ifdef   __cplusplus
+extern "C" {
+#endif
+
+#if defined(__clang__)
+#   pragma clang diagnostic push
+#   pragma clang diagnostic ignored "-Wunknown-warning-option"
+#   pragma clang diagnostic ignored "-Wreserved-identifier"
+#   pragma clang diagnostic ignored "-Wmissing-declarations"
+#   pragma clang diagnostic ignored "-Wpadded"
+#elif __IS_COMPILER_ARM_COMPILER_5__
+#elif __IS_COMPILER_GCC__
+#   pragma GCC diagnostic push
+#   pragma GCC diagnostic ignored "-Wformat="
+#   pragma GCC diagnostic ignored "-Wpedantic"
+#   pragma GCC diagnostic ignored "-Wpadded"
+#endif
+
+/*============================ MACROS ========================================*/
+
+/* OOC header, please DO NOT modify  */
+#ifdef __USER_SCENE_LISTVIEW_IMPLEMENT__
+#   undef __USER_SCENE_LISTVIEW_IMPLEMENT__
+#   define __ARM_2D_IMPL__
+#endif
+#include "arm_2d_utils.h"
+
+/*============================ MACROFIED FUNCTIONS ===========================*/
+
+/*!
+ * \brief initalize _listview and add it to a user specified scene player
+ * \param[in] __DISP_ADAPTER_PTR the target display adatper (i.e. scene player)
+ * \param[in] ... this is an optional parameter. When it is NULL, a new 
+ *            user_scene_listview_t will be allocated from HEAP and freed on
+ *            the deposing event. When it is non-NULL, the life-cycle is managed
+ *            by user.
+ * \return user_scene_listview_t* the user_scene_listview_t instance
+ */
+#define arm_2d_scene_listview_init(__DISP_ADAPTER_PTR, ...)                    \
+            __arm_2d_scene_listview_init((__DISP_ADAPTER_PTR), (NULL, ##__VA_ARGS__))
+
+/*============================ TYPES =========================================*/
+/*!
+ * \brief a user class for scene 3
+ */
+typedef struct user_scene_listview_t user_scene_listview_t;
+
+struct user_scene_listview_t {
+    implement(arm_2d_scene_t);                                                  //! derived from class: arm_2d_scene_t
+
+ARM_PRIVATE(
+    /* place your private member here, following two are examples */
+    int64_t             lTimestamp[3];
+    bool                bUserAllocated;
+    list_view_t         tListView;
+    progress_wheel_t    tWheel;
+    int16_t             iProgress;
+)
+    /* place your public member here */
+    
+};
+
+/*============================ GLOBAL VARIABLES ==============================*/
+/*============================ PROTOTYPES ====================================*/
+
+ARM_NONNULL(1)
+extern
+user_scene_listview_t *__arm_2d_scene_listview_init(   arm_2d_scene_player_t *ptDispAdapter, 
+                                        user_scene_listview_t *ptScene);
+
+#if defined(__clang__)
+#   pragma clang diagnostic pop
+#elif __IS_COMPILER_GCC__
+#   pragma GCC diagnostic pop
+#endif
+
+#ifdef   __cplusplus
+}
+#endif
+
+#endif
+
+#endif

+ 659 - 0
projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_menu.c

@@ -0,0 +1,659 @@
+/*
+ * Copyright (c) 2009-2022 Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*============================ INCLUDES ======================================*/
+
+#include "arm_2d.h"
+
+#if defined(RTE_Acceleration_Arm_2D_Helper_PFB)
+
+#define __USER_SCENE_MENU_IMPLEMENT__
+#include "arm_2d_scene_menu.h"
+
+#include "arm_2d_helper.h"
+#include "arm_2d_example_controls.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#if defined(__clang__)
+#   pragma clang diagnostic push
+#   pragma clang diagnostic ignored "-Wunknown-warning-option"
+#   pragma clang diagnostic ignored "-Wreserved-identifier"
+#   pragma clang diagnostic ignored "-Wsign-conversion"
+#   pragma clang diagnostic ignored "-Wpadded"
+#   pragma clang diagnostic ignored "-Wcast-qual"
+#   pragma clang diagnostic ignored "-Wcast-align"
+#   pragma clang diagnostic ignored "-Wmissing-field-initializers"
+#   pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
+#   pragma clang diagnostic ignored "-Wmissing-prototypes"
+#   pragma clang diagnostic ignored "-Wunused-variable"
+#   pragma clang diagnostic ignored "-Wgnu-statement-expression"
+#   pragma clang diagnostic ignored "-Wdeclaration-after-statement"
+#   pragma clang diagnostic ignored "-Wunused-function"
+#   pragma clang diagnostic ignored "-Wmissing-declarations"  
+#elif __IS_COMPILER_ARM_COMPILER_5__
+#   pragma diag_suppress 64,177
+#elif __IS_COMPILER_GCC__
+#   pragma GCC diagnostic push
+#   pragma GCC diagnostic ignored "-Wformat="
+#   pragma GCC diagnostic ignored "-Wpedantic"
+#   pragma GCC diagnostic ignored "-Wunused-function"
+#   pragma GCC diagnostic ignored "-Wunused-variable"
+#   pragma GCC diagnostic ignored "-Wunused-value"
+#elif __IS_COMPILER_IAR__
+#   pragma diag_suppress=Pa089,Pe188,Pe177,Pe174
+#endif
+
+/*============================ MACROS ========================================*/
+
+#if __GLCD_CFG_COLOUR_DEPTH__ == 8
+
+#   define c_tileCMSISLogo          c_tileCMSISLogoGRAY8
+
+#elif __GLCD_CFG_COLOUR_DEPTH__ == 16
+
+#   define c_tileCMSISLogo          c_tileCMSISLogoRGB565
+
+#elif __GLCD_CFG_COLOUR_DEPTH__ == 32
+
+#   define c_tileCMSISLogo          c_tileCMSISLogoCCCA8888
+#else
+#   error Unsupported colour depth!
+#endif
+
+/*============================ MACROFIED FUNCTIONS ===========================*/
+#undef this
+#define this (*ptThis)
+
+/*============================ TYPES =========================================*/
+
+typedef struct my_list_item_t {
+    implement(arm_2d_list_item_t);
+    
+    /* you can put your own members here */
+    int16_t iOffset;
+} my_list_item_t;
+
+
+/*============================ GLOBAL VARIABLES ==============================*/
+/*============================ PROTOTYPES ====================================*/
+
+static 
+arm_fsm_rt_t __list_view_item_0_draw_item( 
+                                      arm_2d_list_item_t *ptItem,
+                                      const arm_2d_tile_t *ptTile,
+                                      bool bIsNewFrame,
+                                      arm_2d_list_item_param_t *ptParam);
+
+static 
+arm_fsm_rt_t __list_view_item_1_draw_item( 
+                                      arm_2d_list_item_t *ptItem,
+                                      const arm_2d_tile_t *ptTile,
+                                      bool bIsNewFrame,
+                                      arm_2d_list_item_param_t *ptParam);
+
+static 
+arm_fsm_rt_t __list_view_item_2_draw_item( 
+                                      arm_2d_list_item_t *ptItem,
+                                      const arm_2d_tile_t *ptTile,
+                                      bool bIsNewFrame,
+                                      arm_2d_list_item_param_t *ptParam);
+
+static 
+arm_fsm_rt_t __list_view_item_3_draw_item( 
+                                      arm_2d_list_item_t *ptItem,
+                                      const arm_2d_tile_t *ptTile,
+                                      bool bIsNewFrame,
+                                      arm_2d_list_item_param_t *ptParam);
+
+/*============================ LOCAL VARIABLES ===============================*/
+
+enum {
+    MY_LIST_ITEM_ID_0,
+    MY_LIST_ITEM_ID_1,
+    MY_LIST_ITEM_ID_2,
+    MY_LIST_ITEM_ID_3,
+};
+
+static
+my_list_item_t s_tListArray[] = {
+    [MY_LIST_ITEM_ID_0] = {
+        .use_as__arm_2d_list_item_t = {
+            .hwID = MY_LIST_ITEM_ID_0,
+            .bIsEnabled = true,
+            .bIsVisible = true,
+            .bIsReadOnly = true,    /* indicate this is a const item */
+            .Padding = {
+                5,5,
+            },
+            //.u4Alignment = ARM_2D_ALIGN_TOP,
+            .tSize = { 100, 200 },
+            .fnOnDrawItem = &__list_view_item_0_draw_item,
+        },
+    },
+
+    [MY_LIST_ITEM_ID_1] = {
+        .use_as__arm_2d_list_item_t = {
+            .hwID = MY_LIST_ITEM_ID_1,
+            .bIsEnabled = true,
+            .bIsVisible = true,
+            .bIsReadOnly = true,    /* indicate this is a const item */
+            
+            .Padding = {
+                5,5,
+            },
+            .tSize = { 100, 200 },
+            .fnOnDrawItem = &__list_view_item_1_draw_item,
+        },
+    },
+
+    [MY_LIST_ITEM_ID_2] = {
+        .use_as__arm_2d_list_item_t = {
+            .hwID = MY_LIST_ITEM_ID_2,
+            .bIsEnabled = true,
+            .bIsVisible = true,
+            .bIsReadOnly = true,    /* indicate this is a const item */
+
+            .Padding = {
+                5,5,
+            },
+            //.u4Alignment = ARM_2D_ALIGN_BOTTOM,
+            .tSize = { 100, 200 },
+            .fnOnDrawItem = &__list_view_item_2_draw_item,
+        },
+    },
+
+
+    [MY_LIST_ITEM_ID_3] = {
+        .use_as__arm_2d_list_item_t = {
+            .hwID = MY_LIST_ITEM_ID_3,
+            .bIsEnabled = true,
+            .bIsVisible = true,
+            .bIsReadOnly = true,    /* indicate this is a const item */
+
+            .Padding = {
+                5,5,
+            },
+            .tSize = { 100, 200 },
+            .fnOnDrawItem = &__list_view_item_3_draw_item,
+        },
+    },
+};
+
+/*============================ IMPLEMENTATION ================================*/
+
+
+#define ITEM_BG_OPACITY     (255)
+
+
+static 
+arm_fsm_rt_t __list_view_item_0_draw_item( 
+                                      arm_2d_list_item_t *ptItem,
+                                      const arm_2d_tile_t *ptTile,
+                                      bool bIsNewFrame,
+                                      arm_2d_list_item_param_t *ptParam)
+{
+    my_list_item_t *ptThis = (my_list_item_t *)ptItem;
+    ARM_2D_UNUSED(ptItem);
+    ARM_2D_UNUSED(bIsNewFrame);
+    ARM_2D_UNUSED(ptTile);
+    ARM_2D_UNUSED(ptParam);
+
+    user_scene_menu_t *ptScene = (user_scene_menu_t *)this.use_as__arm_2d_list_item_t.pTarget;
+
+    arm_2d_region_t tScreen
+        = arm_2d_helper_pfb_get_display_area(
+            &(ptScene->use_as__arm_2d_scene_t.ptPlayer->use_as__arm_2d_helper_pfb_t));
+    
+    int16_t iRadius = tScreen.tSize.iWidth >> 1;
+
+    uint8_t chOpacity = arm_2d_helper_alpha_mix(ITEM_BG_OPACITY, ptParam->chOpacity);
+    int32_t q7ScaleRatio = ((ptParam->chOpacity >> 1) + 128);
+    /* re-use opacity (0~255) as scaling ratio */
+    int32_t nSize = 100 * q7ScaleRatio >> 8;
+
+    arm_2d_canvas(ptTile, __canvas) {
+        arm_2d_align_top_centre(__canvas, nSize, nSize) {
+
+            /* adjust item position around a curve*/
+            do {
+                float fYOffset =  (float)ptParam->hwRatio;
+                fYOffset = iRadius - sqrt(iRadius * iRadius - fYOffset * fYOffset);
+
+                __top_centre_region.tLocation.iY += (int16_t) fYOffset;
+            } while(0);
+            
+            draw_round_corner_box(ptTile, &__top_centre_region, GLCD_COLOR_WHITE, chOpacity, bIsNewFrame);
+
+            arm_lcd_text_set_target_framebuffer(ptTile);
+            arm_lcd_text_set_colour(__RGB(0x94, 0xd2, 0x52), GLCD_COLOR_BLACK);
+            arm_lcd_text_set_opacity(chOpacity);
+            arm_lcd_text_set_scale((float)q7ScaleRatio / 256.0f);
+            arm_lcd_text_set_font((arm_2d_font_t *)&ARM_2D_FONT_A8_DIGITS_ONLY);
+            arm_print_banner("0", __top_centre_region);
+            arm_lcd_text_set_opacity(255);
+        }
+    }
+    
+    return arm_fsm_rt_cpl;
+}
+
+
+static 
+arm_fsm_rt_t __list_view_item_1_draw_item( 
+                                      arm_2d_list_item_t *ptItem,
+                                      const arm_2d_tile_t *ptTile,
+                                      bool bIsNewFrame,
+                                      arm_2d_list_item_param_t *ptParam)
+{
+    my_list_item_t *ptThis = (my_list_item_t *)ptItem;
+    ARM_2D_UNUSED(ptItem);
+    ARM_2D_UNUSED(bIsNewFrame);
+    ARM_2D_UNUSED(ptTile);
+    ARM_2D_UNUSED(ptParam);
+
+    user_scene_menu_t *ptScene = (user_scene_menu_t *)this.use_as__arm_2d_list_item_t.pTarget;
+
+    arm_2d_region_t tScreen
+        = arm_2d_helper_pfb_get_display_area(
+            &(ptScene->use_as__arm_2d_scene_t.ptPlayer->use_as__arm_2d_helper_pfb_t));
+    
+    int16_t iRadius = tScreen.tSize.iWidth >> 1;
+
+    uint8_t chOpacity = arm_2d_helper_alpha_mix(ITEM_BG_OPACITY, ptParam->chOpacity);
+    int32_t q7ScaleRatio = ((ptParam->chOpacity >> 1) + 128);
+    /* re-use opacity (0~255) as scaling ratio */
+    int32_t nSize = 100 * q7ScaleRatio >> 8;
+
+    if (bIsNewFrame) {
+        progress_wheel_set_diameter(&ptScene->tWheel, 60 * q7ScaleRatio >> 8);
+    }
+
+    arm_2d_canvas(ptTile, __canvas) {
+        arm_2d_align_top_centre(__canvas, nSize, nSize) {
+
+            /* adjust item position around a curve*/
+            do {
+                float fYOffset =  (float)ptParam->hwRatio;
+                fYOffset = iRadius - sqrt(iRadius * iRadius - fYOffset * fYOffset);
+
+                __top_centre_region.tLocation.iY += (int16_t) fYOffset;
+            } while(0);
+
+            draw_round_corner_box(ptTile, &__top_centre_region, GLCD_COLOR_WHITE, chOpacity, bIsNewFrame);
+
+            progress_wheel_show(&ptScene->tWheel, 
+                                ptTile, 
+                                &__top_centre_region, 
+                                ptScene->iProgress,   /* progress 0~1000 */
+                                chOpacity, 
+                                bIsNewFrame);
+        
+            arm_lcd_text_set_target_framebuffer(ptTile);
+            arm_lcd_text_set_colour(__RGB(0x94, 0xd2, 0x52), GLCD_COLOR_BLACK);
+            arm_lcd_text_set_opacity(chOpacity);
+            arm_lcd_text_set_scale((float)q7ScaleRatio / 256.0f);
+            arm_lcd_text_set_font((arm_2d_font_t *)&ARM_2D_FONT_A8_DIGITS_ONLY);
+            arm_print_banner("1", __top_centre_region);
+            arm_lcd_text_set_opacity(255);
+        }
+    }
+    
+    return arm_fsm_rt_cpl;
+}
+
+static 
+arm_fsm_rt_t __list_view_item_2_draw_item( 
+                                      arm_2d_list_item_t *ptItem,
+                                      const arm_2d_tile_t *ptTile,
+                                      bool bIsNewFrame,
+                                      arm_2d_list_item_param_t *ptParam)
+{
+    my_list_item_t *ptThis = (my_list_item_t *)ptItem;
+    ARM_2D_UNUSED(ptItem);
+    ARM_2D_UNUSED(bIsNewFrame);
+    ARM_2D_UNUSED(ptTile);
+    ARM_2D_UNUSED(ptParam);
+
+    user_scene_menu_t *ptScene = (user_scene_menu_t *)this.use_as__arm_2d_list_item_t.pTarget;
+
+    arm_2d_region_t tScreen
+        = arm_2d_helper_pfb_get_display_area(
+            &(ptScene->use_as__arm_2d_scene_t.ptPlayer->use_as__arm_2d_helper_pfb_t));
+    
+    int16_t iRadius = tScreen.tSize.iWidth >> 1;
+
+    uint8_t chOpacity = arm_2d_helper_alpha_mix(ITEM_BG_OPACITY, ptParam->chOpacity);
+
+    int32_t q7ScaleRatio = ((ptParam->chOpacity >> 1) + 128);
+    /* re-use opacity (0~255) as scaling ratio */
+    int32_t nSize = 100 * q7ScaleRatio >> 8;
+
+    arm_2d_canvas(ptTile, __canvas) {
+        arm_2d_align_top_centre(__canvas, nSize, nSize) {
+
+            /* adjust item position around a curve*/
+            do {
+                float fYOffset =  (float)ptParam->hwRatio;
+                fYOffset = iRadius - sqrt(iRadius * iRadius - fYOffset * fYOffset);
+
+                __top_centre_region.tLocation.iY += (int16_t) fYOffset;
+            } while(0);
+
+            draw_round_corner_box(ptTile, &__top_centre_region, GLCD_COLOR_WHITE, chOpacity, bIsNewFrame);
+        
+            arm_lcd_text_set_target_framebuffer(ptTile);
+            arm_lcd_text_set_colour(__RGB(0x94, 0xd2, 0x52), GLCD_COLOR_BLACK);
+            arm_lcd_text_set_opacity(chOpacity);
+            arm_lcd_text_set_scale((float)q7ScaleRatio / 256.0f);
+            arm_lcd_text_set_font((arm_2d_font_t *)&ARM_2D_FONT_A8_DIGITS_ONLY);
+            arm_print_banner("2", __top_centre_region);
+            arm_lcd_text_set_opacity(255);
+        }
+    }
+
+
+    return arm_fsm_rt_cpl;
+}
+
+static 
+arm_fsm_rt_t __list_view_item_3_draw_item( 
+                                      arm_2d_list_item_t *ptItem,
+                                      const arm_2d_tile_t *ptTile,
+                                      bool bIsNewFrame,
+                                      arm_2d_list_item_param_t *ptParam)
+{
+    my_list_item_t *ptThis = (my_list_item_t *)ptItem;
+    ARM_2D_UNUSED(ptItem);
+    ARM_2D_UNUSED(bIsNewFrame);
+    ARM_2D_UNUSED(ptTile);
+    ARM_2D_UNUSED(ptParam);
+
+    user_scene_menu_t *ptScene = (user_scene_menu_t *)this.use_as__arm_2d_list_item_t.pTarget;
+
+    arm_2d_region_t tScreen
+        = arm_2d_helper_pfb_get_display_area(
+            &(ptScene->use_as__arm_2d_scene_t.ptPlayer->use_as__arm_2d_helper_pfb_t));
+    
+    int16_t iRadius = tScreen.tSize.iWidth >> 1;
+
+    uint8_t chOpacity = arm_2d_helper_alpha_mix(ITEM_BG_OPACITY, ptParam->chOpacity);
+
+    int32_t q7ScaleRatio = ((ptParam->chOpacity >> 1) + 128);
+    /* re-use opacity (0~255) as scaling ratio */
+    int32_t nSize = 100 * q7ScaleRatio >> 8;
+
+    arm_2d_canvas(ptTile, __canvas) {
+        arm_2d_align_top_centre(__canvas, nSize, nSize) {
+
+            /* adjust item position around a curve*/
+            do {
+                float fYOffset =  (float)ptParam->hwRatio;
+                fYOffset = iRadius - sqrt(iRadius * iRadius - fYOffset * fYOffset);
+
+                __top_centre_region.tLocation.iY += (int16_t) fYOffset;
+            } while(0);
+
+
+            draw_round_corner_box(ptTile, &__top_centre_region, GLCD_COLOR_WHITE, chOpacity, bIsNewFrame);
+
+            arm_lcd_text_set_target_framebuffer(ptTile);
+            arm_lcd_text_set_colour(__RGB(0x94, 0xd2, 0x52), GLCD_COLOR_BLACK);
+            arm_lcd_text_set_opacity(chOpacity);
+            arm_lcd_text_set_scale((float)q7ScaleRatio / 256.0f);
+            arm_lcd_text_set_font((arm_2d_font_t *)&ARM_2D_FONT_A8_DIGITS_ONLY);
+            arm_print_banner("3", __top_centre_region);
+            arm_lcd_text_set_opacity(255);
+        }
+    }
+    
+    return arm_fsm_rt_cpl;
+}
+
+
+static void __on_scene_menu_depose(arm_2d_scene_t *ptScene)
+{
+    user_scene_menu_t *ptThis = (user_scene_menu_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+    
+    ptScene->ptPlayer = NULL;
+    
+    /* reset timestamp */
+    arm_foreach(int64_t,this.lTimestamp, ptItem) {
+        *ptItem = 0;
+    }
+    
+    progress_wheel_depose(&this.tWheel);
+
+    if (!this.bUserAllocated) {
+        __arm_2d_free_scratch_memory(ARM_2D_MEM_TYPE_UNSPECIFIED, ptScene);
+    }
+}
+
+/*----------------------------------------------------------------------------*
+ * Scene 3                                                                    *
+ *----------------------------------------------------------------------------*/
+
+static void __on_scene_menu_background_start(arm_2d_scene_t *ptScene)
+{
+    user_scene_menu_t *ptThis = (user_scene_menu_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+
+}
+
+static void __on_scene_menu_background_complete(arm_2d_scene_t *ptScene)
+{
+    user_scene_menu_t *ptThis = (user_scene_menu_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+
+}
+
+
+static void __on_scene_menu_frame_start(arm_2d_scene_t *ptScene)
+{
+    user_scene_menu_t *ptThis = (user_scene_menu_t *)ptScene;
+
+    int nResult;
+    if (arm_2d_helper_time_liner_slider(0, 1000, 10000, &nResult, &this.lTimestamp[2])) {
+        this.lTimestamp[2] = 0;
+    }
+    this.iProgress = (int16_t)nResult;
+
+    progress_wheel_on_frame_start(&this.tWheel);
+}
+
+static void __on_scene_menu_frame_complete(arm_2d_scene_t *ptScene)
+{
+    user_scene_menu_t *ptThis = (user_scene_menu_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+    
+    /* switch to next scene after 10s */
+    if (arm_2d_helper_is_time_out(12000, &this.lTimestamp[0])) {
+        arm_2d_scene_player_switch_to_next_scene(ptScene->ptPlayer);
+    }
+    
+    if (arm_2d_helper_is_time_out(1500, &this.lTimestamp[1])) {
+        list_view_move_selection(&this.tListView, 1, 300);
+    }
+}
+
+static
+IMPL_PFB_ON_DRAW(__pfb_draw_scene_menu_background_handler)
+{
+    user_scene_menu_t *ptThis = (user_scene_menu_t *)pTarget;
+    ARM_2D_UNUSED(ptTile);
+    ARM_2D_UNUSED(bIsNewFrame);
+    /*-----------------------draw back ground begin-----------------------*/
+
+
+
+    /*-----------------------draw back ground end  -----------------------*/
+    arm_2d_op_wait_async(NULL);
+
+    return arm_fsm_rt_cpl;
+}
+
+static
+IMPL_PFB_ON_DRAW(__pfb_draw_scene_menu_handler)
+{
+    user_scene_menu_t *ptThis = (user_scene_menu_t *)pTarget;
+    ARM_2D_UNUSED(ptTile);
+    ARM_2D_UNUSED(bIsNewFrame);
+    
+    /*-----------------------draw the foreground begin-----------------------*/
+    
+    /* following code is just a demo, you can remove them */
+
+    while(arm_fsm_rt_cpl != list_view_show(&this.tListView, ptTile, NULL, bIsNewFrame));
+
+    /* draw text at the top-left corner */
+    arm_lcd_text_set_target_framebuffer((arm_2d_tile_t *)ptTile);
+    arm_lcd_text_set_font(&ARM_2D_FONT_6x8.use_as__arm_2d_font_t);
+    arm_lcd_text_set_draw_region(NULL);
+    arm_lcd_text_set_colour(GLCD_COLOR_RED, GLCD_COLOR_WHITE);
+    arm_lcd_text_location(0,0);
+    arm_lcd_printf("Scene Menu");
+
+    /*-----------------------draw the foreground end  -----------------------*/
+    arm_2d_op_wait_async(NULL);
+
+    return arm_fsm_rt_cpl;
+}
+
+ARM_NONNULL(1)
+user_scene_menu_t *__arm_2d_scene_menu_init(   arm_2d_scene_player_t *ptDispAdapter, 
+                                        user_scene_menu_t *ptThis)
+{
+    bool bUserAllocated = false;
+    assert(NULL != ptDispAdapter);
+
+    if (NULL == ptThis) {
+        ptThis = (user_scene_menu_t *)
+                    __arm_2d_allocate_scratch_memory(   sizeof(user_scene_menu_t),
+                                                        __alignof__(user_scene_menu_t),
+                                                        ARM_2D_MEM_TYPE_UNSPECIFIED);
+        assert(NULL != ptThis);
+        if (NULL == ptThis) {
+            return NULL;
+        }
+    } else {
+        memset(ptThis, 0, sizeof(user_scene_menu_t));
+        bUserAllocated = true;
+    }
+
+    /*! define dirty regions */
+    IMPL_ARM_2D_REGION_LIST(s_tDirtyRegions, static)
+
+        /* a dirty region to be specified at runtime*/
+        ADD_LAST_REGION_TO_LIST(s_tDirtyRegions,
+            .tSize = {
+                0, 200,
+            },
+        ),
+        
+    END_IMPL_ARM_2D_REGION_LIST(s_tDirtyRegions)
+    
+    s_tDirtyRegions[dimof(s_tDirtyRegions)-1].ptNext = NULL;
+
+    /* get the screen region */
+    arm_2d_region_t tScreen
+        = arm_2d_helper_pfb_get_display_area(
+            &ptDispAdapter->use_as__arm_2d_helper_pfb_t);
+    
+    /* initialise dirty region 0 at runtime
+     */
+    s_tDirtyRegions[0].tRegion.tLocation = (arm_2d_location_t){
+        .iX = 0,
+        .iY = ((tScreen.tSize.iHeight - 200) >> 1),
+    };
+    s_tDirtyRegions[0].tRegion.tSize.iWidth = tScreen.tSize.iWidth;
+
+    *ptThis = (user_scene_menu_t){
+        .use_as__arm_2d_scene_t = {
+
+        /* the canvas colour */
+        .tCanvas = {GLCD_COLOR_BLACK}, 
+        
+        /* Please uncommon the callbacks if you need them
+         */
+        //.fnBackground   = &__pfb_draw_scene_menu_background_handler,
+        .fnScene        = &__pfb_draw_scene_menu_handler,
+        .ptDirtyRegion  = (arm_2d_region_list_item_t *)s_tDirtyRegions,
+        
+
+        //.fnOnBGStart    = &__on_scene_menu_background_start,
+        //.fnOnBGComplete = &__on_scene_menu_background_complete,
+        .fnOnFrameStart = &__on_scene_menu_frame_start,
+        .fnOnFrameCPL   = &__on_scene_menu_frame_complete,
+        .fnDepose       = &__on_scene_menu_depose,
+        },
+        .bUserAllocated = bUserAllocated,
+    };
+
+    do {
+        progress_wheel_cfg_t tCFG = {
+            .tDotColour     = GLCD_COLOR_WHITE,         /* dot colour */
+            .tWheelColour   = GLCD_COLOR_GREEN,         /* arc colour */
+            .iWheelDiameter = 60,                       /* diameter, 0 means use the mask's original size */
+            .bUseDirtyRegions = false,                  /* use dirty regions */
+        };
+
+        progress_wheel_init(&this.tWheel, 
+                            &this.use_as__arm_2d_scene_t,
+                            &tCFG);
+    } while(0);
+
+    do {
+        list_view_cfg_t tCFG = {
+            .fnIterator = &ARM_2D_LIST_ITERATOR_ARRAY,
+            .fnCalculator = &ARM_2D_LIST_CALCULATOR_MIDDLE_ALIGNED_HORIZONTAL,
+            
+            .tListSize = {0, 200},
+            .ptItems = (arm_2d_list_item_t *)s_tListArray,
+            .hwCount = dimof(s_tListArray),
+            .hwItemSizeInByte = sizeof(my_list_item_t),
+            
+            .bIgnoreBackground = true,
+        };
+        
+        list_view_init(&this.tListView, &tCFG);
+        list_view_move_selection(&this.tListView, 1, 0);
+
+        arm_foreach(my_list_item_t, s_tListArray, ptItem) {
+            ptItem->use_as__arm_2d_list_item_t.pTarget = (uintptr_t)ptThis;
+        }
+    } while(0);
+
+    arm_2d_scene_player_append_scenes(  ptDispAdapter, 
+                                        &this.use_as__arm_2d_scene_t, 
+                                        1);
+
+    return ptThis;
+}
+
+
+
+
+#if defined(__clang__)
+#   pragma clang diagnostic pop
+#endif
+
+#endif
+

+ 114 - 0
projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_menu.h

@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2009-2022 Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __ARM_2D_SCENE_MENU_H__
+#define __ARM_2D_SCENE_MENU_H__
+
+/*============================ INCLUDES ======================================*/
+
+#include "arm_2d.h"
+
+#if defined(RTE_Acceleration_Arm_2D_Helper_PFB)
+
+#include "arm_2d_helper_scene.h"
+#include "list_view.h"
+#include "progress_wheel.h"
+
+#ifdef   __cplusplus
+extern "C" {
+#endif
+
+#if defined(__clang__)
+#   pragma clang diagnostic push
+#   pragma clang diagnostic ignored "-Wunknown-warning-option"
+#   pragma clang diagnostic ignored "-Wreserved-identifier"
+#   pragma clang diagnostic ignored "-Wmissing-declarations"
+#   pragma clang diagnostic ignored "-Wpadded"
+#elif __IS_COMPILER_ARM_COMPILER_5__
+#elif __IS_COMPILER_GCC__
+#   pragma GCC diagnostic push
+#   pragma GCC diagnostic ignored "-Wformat="
+#   pragma GCC diagnostic ignored "-Wpedantic"
+#   pragma GCC diagnostic ignored "-Wpadded"
+#endif
+
+/*============================ MACROS ========================================*/
+
+/* OOC header, please DO NOT modify  */
+#ifdef __USER_SCENE_MENU_IMPLEMENT__
+#   undef __USER_SCENE_MENU_IMPLEMENT__
+#   define __ARM_2D_IMPL__
+#endif
+#include "arm_2d_utils.h"
+
+/*============================ MACROFIED FUNCTIONS ===========================*/
+
+/*!
+ * \brief initalize scene5 and add it to a user specified scene player
+ * \param[in] __DISP_ADAPTER_PTR the target display adatper (i.e. scene player)
+ * \param[in] ... this is an optional parameter. When it is NULL, a new 
+ *            user_scene_menu_t will be allocated from HEAP and freed on
+ *            the deposing event. When it is non-NULL, the life-cycle is managed
+ *            by user.
+ * \return user_scene_menu_t* the user_scene_menu_t instance
+ */
+#define arm_2d_scene_menu_init(__DISP_ADAPTER_PTR, ...)                    \
+            __arm_2d_scene_menu_init((__DISP_ADAPTER_PTR), (NULL, ##__VA_ARGS__))
+
+/*============================ TYPES =========================================*/
+/*!
+ * \brief a user class for scene 3
+ */
+typedef struct user_scene_menu_t user_scene_menu_t;
+
+struct user_scene_menu_t {
+    implement(arm_2d_scene_t);                                                  //! derived from class: arm_2d_scene_t
+
+ARM_PRIVATE(
+    /* place your private member here, following two are examples */
+    int64_t             lTimestamp[3];
+    bool                bUserAllocated;
+    list_view_t         tListView;
+    progress_wheel_t    tWheel;
+    int16_t             iProgress;
+)
+    /* place your public member here */
+    
+};
+
+/*============================ GLOBAL VARIABLES ==============================*/
+/*============================ PROTOTYPES ====================================*/
+
+ARM_NONNULL(1)
+extern
+user_scene_menu_t *__arm_2d_scene_menu_init(arm_2d_scene_player_t *ptDispAdapter, 
+                                        user_scene_menu_t *ptScene);
+
+#if defined(__clang__)
+#   pragma clang diagnostic pop
+#elif __IS_COMPILER_GCC__
+#   pragma GCC diagnostic pop
+#endif
+
+#ifdef   __cplusplus
+}
+#endif
+
+#endif
+
+#endif

+ 544 - 0
projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_panel.c

@@ -0,0 +1,544 @@
+/*
+ * Copyright (c) 2009-2022 Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*============================ INCLUDES ======================================*/
+
+#include "arm_2d.h"
+
+#if defined(RTE_Acceleration_Arm_2D_Helper_PFB)
+
+#define __USER_SCENE_PANEL_IMPLEMENT__
+#include "arm_2d_scene_panel.h"
+
+#include "arm_2d_helper.h"
+#include "arm_2d_example_controls.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#if defined(__clang__)
+#   pragma clang diagnostic push
+#   pragma clang diagnostic ignored "-Wunknown-warning-option"
+#   pragma clang diagnostic ignored "-Wreserved-identifier"
+#   pragma clang diagnostic ignored "-Wsign-conversion"
+#   pragma clang diagnostic ignored "-Wpadded"
+#   pragma clang diagnostic ignored "-Wcast-qual"
+#   pragma clang diagnostic ignored "-Wcast-align"
+#   pragma clang diagnostic ignored "-Wmissing-field-initializers"
+#   pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
+#   pragma clang diagnostic ignored "-Wmissing-prototypes"
+#   pragma clang diagnostic ignored "-Wunused-variable"
+#   pragma clang diagnostic ignored "-Wgnu-statement-expression"
+#   pragma clang diagnostic ignored "-Wdeclaration-after-statement"
+#   pragma clang diagnostic ignored "-Wunused-function"
+#   pragma clang diagnostic ignored "-Wmissing-declarations"
+#   pragma clang diagnostic ignored "-Wgnu-variable-sized-type-not-at-end"
+#elif __IS_COMPILER_ARM_COMPILER_5__
+#   pragma diag_suppress 64,177
+#elif __IS_COMPILER_IAR__
+#   pragma diag_suppress=Pa089,Pe188,Pe177,Pe174
+#elif __IS_COMPILER_GCC__
+#   pragma GCC diagnostic push
+#   pragma GCC diagnostic ignored "-Wformat="
+#   pragma GCC diagnostic ignored "-Wpedantic"
+#   pragma GCC diagnostic ignored "-Wunused-function"
+#   pragma GCC diagnostic ignored "-Wunused-variable"
+#   pragma GCC diagnostic ignored "-Wunused-value"
+#endif
+
+/*============================ MACROS ========================================*/
+
+#if __GLCD_CFG_COLOUR_DEPTH__ == 8
+
+#   define c_tileCMSISLogo          c_tileCMSISLogoGRAY8
+
+#elif __GLCD_CFG_COLOUR_DEPTH__ == 16
+
+#   define c_tileCMSISLogo          c_tileCMSISLogoRGB565
+
+#elif __GLCD_CFG_COLOUR_DEPTH__ == 32
+
+#   define c_tileCMSISLogo          c_tileCMSISLogoCCCA8888
+#else
+#   error Unsupported colour depth!
+#endif
+
+/*============================ MACROFIED FUNCTIONS ===========================*/
+#undef this
+#define this (*ptThis)
+
+/*============================ TYPES =========================================*/
+
+
+
+
+/*============================ GLOBAL VARIABLES ==============================*/
+extern 
+const arm_2d_tile_t c_tileListCoverLineMask;
+
+extern
+const arm_2d_tile_t c_tileWhiteDotMask;
+/*============================ PROTOTYPES ====================================*/
+
+
+/*============================ LOCAL VARIABLES ===============================*/
+/*============================ IMPLEMENTATION ================================*/
+
+static void __on_scene_panel_on_load(arm_2d_scene_t *ptScene)
+{
+    user_scene_panel_t *ptThis = (user_scene_panel_t *)ptScene;
+
+    progress_wheel_on_load(&this.tWheel);
+}
+
+static void __on_scene_panel_depose(arm_2d_scene_t *ptScene)
+{
+    user_scene_panel_t *ptThis = (user_scene_panel_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+    
+    ptScene->ptPlayer = NULL;
+    
+    /* reset timestamp */
+    arm_foreach(int64_t,this.lTimestamp, ptItem) {
+        *ptItem = 0;
+    }
+
+    progress_wheel_depose(&this.tWheel);
+
+    /* depose all number lists */
+    arm_foreach(number_list_t,this.tNumberList, ptItem) {
+        number_list_depose(ptItem);
+    }
+
+    if (!this.bUserAllocated) {
+        __arm_2d_free_scratch_memory(ARM_2D_MEM_TYPE_UNSPECIFIED, ptScene);
+    }
+}
+
+/*----------------------------------------------------------------------------*
+ * Scene 2                                                                    *
+ *----------------------------------------------------------------------------*/
+
+static void __on_scene_panel_background_start(arm_2d_scene_t *ptScene)
+{
+    user_scene_panel_t *ptThis = (user_scene_panel_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+
+}
+
+static void __on_scene_panel_background_complete(arm_2d_scene_t *ptScene)
+{
+    user_scene_panel_t *ptThis = (user_scene_panel_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+
+}
+
+
+static void __on_scene_panel_frame_start(arm_2d_scene_t *ptScene)
+{
+    user_scene_panel_t *ptThis = (user_scene_panel_t *)ptScene;
+
+    progress_wheel_on_frame_start(&this.tWheel);
+
+    arm_foreach(number_list_t,this.tNumberList, ptItem) {
+        number_list_on_frame_start(ptItem);
+    }
+}
+
+static void __on_scene_panel_frame_complete(arm_2d_scene_t *ptScene)
+{
+    user_scene_panel_t *ptThis = (user_scene_panel_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+    
+    if (arm_2d_helper_is_time_out(10000, &this.lTimestamp[0])) {
+        numer_list_move_selection(&this.tNumberList[0], 100, 10000);
+    }
+    
+    if (arm_2d_helper_is_time_out(10000, &this.lTimestamp[1])) {
+        numer_list_move_selection(&this.tNumberList[1], 10, 10000);
+    }
+    
+    if (arm_2d_helper_is_time_out(10000, &this.lTimestamp[2])) {
+        numer_list_move_selection(&this.tNumberList[2], 1, 10000);
+    }
+    
+    if (arm_2d_helper_is_time_out(10, &this.lTimestamp[3])) {
+        this.iProgress += 4;
+        if (this.iProgress > 1000) {
+            this.iProgress = 0;
+        }
+    }
+    
+    /* switch to next scene after 20s */
+    if (arm_2d_helper_is_time_out(20000, &this.lTimestamp[4])) {
+        arm_2d_scene_player_switch_to_next_scene(ptScene->ptPlayer);
+    }
+}
+
+static
+IMPL_PFB_ON_DRAW(__pfb_draw_scene_panel_background_handler)
+{
+    user_scene_panel_t *ptThis = (user_scene_panel_t *)pTarget;
+    ARM_2D_UNUSED(ptTile);
+    ARM_2D_UNUSED(bIsNewFrame);
+    /*-----------------------draw back ground begin-----------------------*/
+
+
+
+    /*-----------------------draw back ground end  -----------------------*/
+    arm_2d_op_wait_async(NULL);
+
+    return arm_fsm_rt_cpl;
+}
+
+static void draw_buttom(const arm_2d_tile_t *ptTile, 
+                        arm_2d_region_t *ptRegion,
+                        const char *pchString,
+                        COLOUR_INT tColour,
+                        uint8_t chOpacity,
+                        bool bIsNewFrame)
+{
+
+    arm_2d_container(ptTile, __button, ptRegion) {
+    
+        draw_round_corner_box(&__button, NULL, GLCD_COLOR_WHITE, chOpacity, bIsNewFrame);
+        
+        arm_lcd_text_set_target_framebuffer((arm_2d_tile_t *)&__button);
+        arm_lcd_text_set_font((arm_2d_font_t *)&ARM_2D_FONT_A4_DIGITS_ONLY);
+        arm_lcd_text_set_opacity(chOpacity);
+        arm_lcd_text_set_colour(tColour, GLCD_COLOR_BLACK);
+        arm_print_banner(pchString, __button_canvas);
+        arm_lcd_text_set_opacity(255);
+        
+    }
+}
+
+static
+IMPL_PFB_ON_DRAW(__pfb_draw_scene_panel_handler)
+{
+    user_scene_panel_t *ptThis = (user_scene_panel_t *)pTarget;
+    ARM_2D_UNUSED(ptTile);
+    ARM_2D_UNUSED(bIsNewFrame);
+    
+    /*-----------------------draw the foreground begin-----------------------*/
+
+    /* following code is just a demo, you can remove them */
+
+    arm_2d_canvas(ptTile, __canvas) {
+        arm_2d_align_centre(__canvas, 240, 128) {
+
+            arm_2d_layout(__centre_region, true) {
+
+                __item_line_horizontal(60,80) {
+                    progress_wheel_show(&this.tWheel,
+                                        ptTile, 
+                                        &__item_region,       
+                                        this.iProgress,         /* progress 0~1000 */
+                                        255 - 32,               /* opacity */
+                                        bIsNewFrame);
+                }
+
+                __item_line_horizontal(28, 80) {
+                    while(arm_fsm_rt_cpl != number_list_show(   
+                                                    &this.tNumberList[2], 
+                                                    ptTile, 
+                                                    &__item_region, 
+                                                    bIsNewFrame));
+                }
+
+                __item_line_horizontal(28, 80) {
+                    while(arm_fsm_rt_cpl != number_list_show(   
+                                                    &this.tNumberList[1], 
+                                                    ptTile, 
+                                                    &__item_region, 
+                                                    bIsNewFrame));
+                }
+
+                __item_line_horizontal(28, 80) {
+                    while(arm_fsm_rt_cpl != number_list_show(   
+                                                    &this.tNumberList[0], 
+                                                    ptTile, 
+                                                    &__item_region, 
+                                                    bIsNewFrame));
+                }
+                
+                __item_line_horizontal(96, 128) {
+                
+                    /*
+                     * draw digits panel
+                     *
+                     *  [1][2][3]
+                     *  [4][5][6]
+                     *  [7][8][9]
+                     *     [0]
+                     */
+                
+                    arm_2d_layout(__item_region, true) {
+                        __item_horizontal(28,28,2,2,2,2) {
+                            draw_buttom(ptTile, &__item_region, "1", GLCD_COLOR_WHITE, 128, bIsNewFrame);
+                        }
+                        __item_horizontal(28,28,2,2,2,2) {
+                            draw_buttom(ptTile, &__item_region, "2", GLCD_COLOR_WHITE, 128, bIsNewFrame);
+                        }
+                        __item_horizontal(28,28,2,2,2,2) {
+                            draw_buttom(ptTile, &__item_region, "3", GLCD_COLOR_WHITE, 128, bIsNewFrame);
+                        }
+                        __item_horizontal(28,28,2,2,2,2) {
+                            draw_buttom(ptTile, &__item_region, "4", GLCD_COLOR_WHITE, 128, bIsNewFrame);
+                        }
+                        __item_horizontal(28,28,2,2,2,2) {
+                            draw_buttom(ptTile, &__item_region, "5", GLCD_COLOR_WHITE, 128, bIsNewFrame);
+                        }
+                        __item_horizontal(28,28,2,2,2,2) {
+                            draw_buttom(ptTile, &__item_region, "6", GLCD_COLOR_WHITE, 128, bIsNewFrame);
+                        }
+                        __item_horizontal(28,28,2,2,2,2) {
+                            draw_buttom(ptTile, &__item_region, "7", GLCD_COLOR_WHITE, 128, bIsNewFrame);
+                        }
+                        __item_horizontal(28,28,2,2,2,2) {
+                            draw_buttom(ptTile, &__item_region, "8", GLCD_COLOR_WHITE, 128, bIsNewFrame);
+                        }
+                        __item_horizontal(28,28,2,2,2,2) {
+                            draw_buttom(ptTile, &__item_region, "9", GLCD_COLOR_WHITE, 128, bIsNewFrame);
+                        }
+                        __item_horizontal(28,28,34,34,2,2) {
+                            draw_buttom(ptTile, &__item_region, "0", GLCD_COLOR_WHITE, 128, bIsNewFrame);
+                        }
+                    }
+                }
+            }
+        }
+        
+        arm_2d_align_top_right( __canvas, 
+                                c_tileWhiteDotMask.tRegion.tSize.iWidth + 10,
+                                c_tileWhiteDotMask.tRegion.tSize.iHeight) {
+            
+            if (bIsNewFrame) {
+                int32_t iResult;
+                arm_2d_helper_time_cos_slider(0, 255, 2000, 0, &iResult);
+                this.chOpacity = (uint8_t)iResult;
+            }
+            
+            arm_2d_fill_colour_with_mask_and_opacity(ptTile,
+                                                     &__top_right_region,
+                                                     &c_tileWhiteDotMask,
+                                                     (__arm_2d_color_t){GLCD_COLOR_RED},
+                                                     this.chOpacity);
+        }
+
+        /* draw text at the top-left corner */
+        arm_lcd_text_set_target_framebuffer((arm_2d_tile_t *)ptTile);
+        arm_lcd_text_set_draw_region(NULL);
+        arm_lcd_text_set_font(&ARM_2D_FONT_6x8.use_as__arm_2d_font_t);
+        arm_lcd_text_set_colour(GLCD_COLOR_RED, GLCD_COLOR_WHITE);
+        arm_lcd_text_location(0,0);
+        arm_lcd_printf("Scene Panel");
+    }
+    /*-----------------------draw the foreground end  -----------------------*/
+    arm_2d_op_wait_async(NULL);
+
+    return arm_fsm_rt_cpl;
+}
+
+static 
+IMPL_PFB_ON_DRAW(__arm_2d_number_list_draw_cover)
+{
+    ARM_2D_UNUSED(bIsNewFrame);
+    
+    number_list_t *ptThis = (number_list_t *)pTarget;
+
+    arm_2d_canvas(ptTile, __canvas) {
+
+        arm_2d_dock_vertical(__canvas, c_tileListCoverLineMask.tRegion.tSize.iHeight) {
+            arm_2d_fill_colour_with_vertical_line_mask( ptTile, 
+                                                        &__vertical_region, 
+                                                        &c_tileListCoverLineMask, 
+                                                        (__arm_2d_color_t){GLCD_COLOR_BLACK});
+        }
+    }
+
+    arm_2d_op_wait_async(NULL);
+    
+    return arm_fsm_rt_cpl;
+}
+
+ARM_NONNULL(1)
+user_scene_panel_t *__arm_2d_scene_panel_init(   arm_2d_scene_player_t *ptDispAdapter, 
+                                        user_scene_panel_t *ptScene)
+{
+
+    bool bUserAllocated = true;
+    assert(NULL != ptDispAdapter);
+
+    if (NULL == ptScene) {
+        ptScene = (user_scene_panel_t *)
+                    __arm_2d_allocate_scratch_memory(   sizeof(user_scene_panel_t),
+                                                        __alignof__(user_scene_panel_t),
+                                                        ARM_2D_MEM_TYPE_UNSPECIFIED);
+        assert(NULL != ptScene);
+        if (NULL == ptScene) {
+            return NULL;
+        }
+        bUserAllocated = false;
+    }
+
+    memset(ptScene, 0, sizeof(user_scene_panel_t));
+
+
+    /*! define dirty regions */
+    IMPL_ARM_2D_REGION_LIST(s_tDirtyRegions, static)
+
+        /* add the last region:
+         * it is the top left corner for text display 
+         */
+        ADD_LAST_REGION_TO_LIST(s_tDirtyRegions,
+            .tLocation = {
+                .iX = 0,
+                .iY = 0,
+            },
+            .tSize = {
+                .iWidth = 60,
+                .iHeight = 8,
+            },
+        ),
+    END_IMPL_ARM_2D_REGION_LIST(s_tDirtyRegions)
+    
+    s_tDirtyRegions[dimof(s_tDirtyRegions)-1].ptNext = NULL;
+
+    /* get the screen region */
+    arm_2d_region_t tScreen
+        = arm_2d_helper_pfb_get_display_area(
+            &ptDispAdapter->use_as__arm_2d_helper_pfb_t);
+    
+
+    arm_2d_align_top_right( tScreen, 
+                            c_tileWhiteDotMask.tRegion.tSize.iWidth + 10,
+                            c_tileWhiteDotMask.tRegion.tSize.iHeight) {
+        s_tDirtyRegions[0].tRegion = __top_right_region;
+    }
+
+
+    *ptScene = (user_scene_panel_t){
+        .use_as__arm_2d_scene_t = {
+
+            /* the canvas colour */
+            .tCanvas = {GLCD_COLOR_BLACK}, 
+            
+            /* Please uncommon the callbacks if you need them
+            */
+            .fnOnLoad       = &__on_scene_panel_on_load,
+            .fnScene        = &__pfb_draw_scene_panel_handler,
+            .ptDirtyRegion  = (arm_2d_region_list_item_t *)s_tDirtyRegions,
+            
+
+            //.fnOnBGStart    = &__on_scene_panel_background_start,
+            //.fnOnBGComplete = &__on_scene_panel_background_complete,
+            .fnOnFrameStart = &__on_scene_panel_frame_start,
+            .fnOnFrameCPL   = &__on_scene_panel_frame_complete,
+            .fnDepose       = &__on_scene_panel_depose,
+
+            .bUseDirtyRegionHelper = true,
+        },
+        .bUserAllocated = bUserAllocated,
+    };
+
+    user_scene_panel_t *ptThis = (user_scene_panel_t *)ptScene;
+
+    do {
+        progress_wheel_cfg_t tCFG = {
+            .tDotColour     = GLCD_COLOR_WHITE,         /* dot colour */
+            .tWheelColour   = GLCD_COLOR_GREEN,         /* arc colour */
+            .iWheelDiameter = 60,                       /* diameter, 0 means use the mask's original size */
+            .bUseDirtyRegions = true,                  /* use dirty regions */
+        };
+
+        progress_wheel_init(&this.tWheel, 
+                            &this.use_as__arm_2d_scene_t,
+                            &tCFG);
+    } while(0);
+
+    /* initialize number list */
+    do {
+        number_list_cfg_t tCFG = {
+            .hwCount = 10,
+            .nStart = 0,
+            .iDelta = 1,
+            .tFontColour = GLCD_COLOR_WHITE,
+            .tBackgroundColour = GLCD_COLOR_BLACK,
+            .chNextPadding = 3,
+            .chPrviousePadding = 3,
+            .tListSize = {
+                .iHeight = 80,
+                .iWidth = 28,
+            },
+            .ptFont = (arm_2d_font_t *)&ARM_2D_FONT_A4_DIGITS_ONLY,
+            /* draw list cover */
+            .fnOnDrawListCover = &__arm_2d_number_list_draw_cover,
+
+            .bUseDirtyRegion = true,
+            .ptTargetScene = &this.use_as__arm_2d_scene_t,
+        };
+        number_list_init(&this.tNumberList[0], &tCFG);
+        number_list_init(&this.tNumberList[1], &tCFG);
+    } while(0);
+    
+    /* initialize number list */
+    do {
+        number_list_cfg_t tCFG = {
+            .hwCount = 6,
+            .nStart = 0,
+            .iDelta = 1,
+            .tFontColour = GLCD_COLOR_WHITE,
+            .tBackgroundColour = GLCD_COLOR_BLACK,
+            .chNextPadding = 3,
+            .chPrviousePadding = 3,
+            .tListSize = {
+                .iHeight = 80,
+                .iWidth = 28,
+            },
+            .ptFont = (arm_2d_font_t *)&ARM_2D_FONT_A4_DIGITS_ONLY,
+            /* draw list cover */
+            .fnOnDrawListCover = &__arm_2d_number_list_draw_cover,
+
+            .bUseDirtyRegion = true,
+            .ptTargetScene = &this.use_as__arm_2d_scene_t,
+        };
+        number_list_init(&this.tNumberList[2], &tCFG);
+    } while(0);
+    
+    numer_list_move_selection(&this.tNumberList[0], 100,   10000);
+    numer_list_move_selection(&this.tNumberList[1], 10,    10000);
+    numer_list_move_selection(&this.tNumberList[2], 1,     10000);
+
+
+    arm_2d_scene_player_append_scenes(  ptDispAdapter, 
+                                        &ptScene->use_as__arm_2d_scene_t, 
+                                        1);
+
+    return ptScene;
+}
+
+
+
+
+#if defined(__clang__)
+#   pragma clang diagnostic pop
+#endif
+
+#endif
+

+ 114 - 0
projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_panel.h

@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2009-2022 Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __ARM_2D_SCENE_PANEL_H__
+#define __ARM_2D_SCENE_PANEL_H__
+
+/*============================ INCLUDES ======================================*/
+
+#include "arm_2d.h"
+
+#if defined(RTE_Acceleration_Arm_2D_Helper_PFB)
+
+#include "arm_2d_helper_scene.h"
+#include "arm_2d_example_controls.h"
+
+#ifdef   __cplusplus
+extern "C" {
+#endif
+
+#if defined(__clang__)
+#   pragma clang diagnostic push
+#   pragma clang diagnostic ignored "-Wunknown-warning-option"
+#   pragma clang diagnostic ignored "-Wreserved-identifier"
+#   pragma clang diagnostic ignored "-Wmissing-declarations"
+#   pragma clang diagnostic ignored "-Wpadded"
+#elif __IS_COMPILER_ARM_COMPILER_5__
+#elif __IS_COMPILER_GCC__
+#   pragma GCC diagnostic push
+#   pragma GCC diagnostic ignored "-Wformat="
+#   pragma GCC diagnostic ignored "-Wpedantic"
+#   pragma GCC diagnostic ignored "-Wpadded"
+#endif
+
+/*============================ MACROS ========================================*/
+
+/* OOC header, please DO NOT modify  */
+#ifdef __USER_SCENE_PANEL_IMPLEMENT__
+#   undef __USER_SCENE_PANEL_IMPLEMENT__
+#   define __ARM_2D_IMPL__
+#endif
+#include "arm_2d_utils.h"
+
+/*============================ MACROFIED FUNCTIONS ===========================*/
+
+/*!
+ * \brief initalize scene2 and add it to a user specified scene player
+ * \param[in] __DISP_ADAPTER_PTR the target display adatper (i.e. scene player)
+ * \param[in] ... this is an optional parameter. When it is NULL, a new 
+ *            user_scene_panel_t will be allocated from HEAP and freed on
+ *            the deposing event. When it is non-NULL, the life-cycle is managed
+ *            by user.
+ * \return user_scene_panel_t* the user_scene_panel_t instance
+ */
+#define arm_2d_scene_panel_init(__DISP_ADAPTER_PTR, ...)                    \
+            __arm_2d_scene_panel_init((__DISP_ADAPTER_PTR), (NULL, ##__VA_ARGS__))
+
+/*============================ TYPES =========================================*/
+/*!
+ * \brief a user class for scene 2
+ */
+typedef struct user_scene_panel_t user_scene_panel_t;
+
+struct user_scene_panel_t {
+    implement(arm_2d_scene_t);                                                  //! derived from class: arm_2d_scene_t
+
+ARM_PRIVATE(
+    /* place your private member here, following two are examples */
+    int64_t lTimestamp[5];
+    bool bUserAllocated;
+    uint8_t chOpacity;
+    int16_t iProgress;
+    number_list_t tNumberList[3];
+    progress_wheel_t tWheel;
+)
+    /* place your public member here */
+    
+};
+
+/*============================ GLOBAL VARIABLES ==============================*/
+/*============================ PROTOTYPES ====================================*/
+
+ARM_NONNULL(1)
+extern
+user_scene_panel_t *__arm_2d_scene_panel_init(   arm_2d_scene_player_t *ptDispAdapter, 
+                                        user_scene_panel_t *ptScene);
+
+#if defined(__clang__)
+#   pragma clang diagnostic pop
+#elif __IS_COMPILER_GCC__
+#   pragma GCC diagnostic pop
+#endif
+
+#ifdef   __cplusplus
+}
+#endif
+
+#endif
+
+#endif

+ 408 - 0
projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_progress_status.c

@@ -0,0 +1,408 @@
+/*
+ * Copyright (c) 2009-2022 Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*============================ INCLUDES ======================================*/
+
+#include "arm_2d.h"
+
+#if defined(RTE_Acceleration_Arm_2D_Helper_PFB)
+
+#define __USER_SCENE_PROGRESS_STATUS_IMPLEMENT__
+#include "arm_2d_scene_progress_status.h"
+
+#include "arm_2d_helper.h"
+#include "arm_2d_example_controls.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#if defined(__clang__)
+#   pragma clang diagnostic push
+#   pragma clang diagnostic ignored "-Wunknown-warning-option"
+#   pragma clang diagnostic ignored "-Wreserved-identifier"
+#   pragma clang diagnostic ignored "-Wsign-conversion"
+#   pragma clang diagnostic ignored "-Wpadded"
+#   pragma clang diagnostic ignored "-Wcast-qual"
+#   pragma clang diagnostic ignored "-Wcast-align"
+#   pragma clang diagnostic ignored "-Wmissing-field-initializers"
+#   pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
+#   pragma clang diagnostic ignored "-Wmissing-prototypes"
+#   pragma clang diagnostic ignored "-Wunused-variable"
+#   pragma clang diagnostic ignored "-Wgnu-statement-expression"
+#   pragma clang diagnostic ignored "-Wdeclaration-after-statement"
+#   pragma clang diagnostic ignored "-Wunused-function"
+#   pragma clang diagnostic ignored "-Wmissing-declarations"  
+#elif __IS_COMPILER_ARM_COMPILER_5__
+#   pragma diag_suppress 64,177
+#elif __IS_COMPILER_IAR__
+#   pragma diag_suppress=Pa089,Pe188,Pe177,Pe174
+#elif __IS_COMPILER_GCC__
+#   pragma GCC diagnostic push
+#   pragma GCC diagnostic ignored "-Wformat="
+#   pragma GCC diagnostic ignored "-Wpedantic"
+#   pragma GCC diagnostic ignored "-Wunused-function"
+#   pragma GCC diagnostic ignored "-Wunused-variable"
+#   pragma GCC diagnostic ignored "-Wunused-value"
+#endif
+
+/*============================ MACROS ========================================*/
+
+#if __GLCD_CFG_COLOUR_DEPTH__ == 8
+
+#   define c_tileCMSISLogo          c_tileCMSISLogoGRAY8
+#   define c_tileWIFISignal         c_tileWIFISignalGRAY8
+
+#elif __GLCD_CFG_COLOUR_DEPTH__ == 16
+
+#   define c_tileCMSISLogo          c_tileCMSISLogoRGB565
+#   define c_tileWIFISignal         c_tileWIFISignalRGB565
+
+#elif __GLCD_CFG_COLOUR_DEPTH__ == 32
+
+#   define c_tileCMSISLogo          c_tileCMSISLogoCCCA8888
+#   define c_tileWIFISignal         c_tileWIFISignalCCCA8888
+
+#else
+#   error Unsupported colour depth!
+#endif
+
+/*============================ MACROFIED FUNCTIONS ===========================*/
+#undef this
+#define this (*ptThis)
+
+/*============================ TYPES =========================================*/
+/*============================ GLOBAL VARIABLES ==============================*/
+
+extern const arm_2d_tile_t c_tileCMSISLogo;
+extern const arm_2d_tile_t c_tileCMSISLogoMask;
+
+extern const arm_2d_tile_t c_tileWIFISignal;
+extern const arm_2d_tile_t c_tileWIFISignalMask;
+
+static arm_2d_helper_film_t s_tileWIFISignalFilm = 
+    impl_film(c_tileWIFISignal, 32, 32, 6, 36, 33);
+
+
+static arm_2d_helper_film_t s_tileWIFISignalFilmMask = 
+    impl_film(c_tileWIFISignalMask, 32, 32, 6, 36, 33);
+
+
+/*============================ PROTOTYPES ====================================*/
+/*============================ LOCAL VARIABLES ===============================*/
+/*============================ IMPLEMENTATION ================================*/
+
+
+static void __on_scene_progress_status_depose(arm_2d_scene_t *ptScene)
+{
+    user_scene_progress_status_t *ptThis = (user_scene_progress_status_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+    
+    ptScene->ptPlayer = NULL;
+    
+    /* reset timestamp */
+    arm_foreach(int64_t,this.lTimestamp, ptItem) {
+        *ptItem = 0;
+    }
+
+    if (this.bUserAllocated) {
+        __arm_2d_free_scratch_memory(ARM_2D_MEM_TYPE_UNSPECIFIED, ptScene);
+    }
+}
+
+/*----------------------------------------------------------------------------*
+ * Scene 1                                                                    *
+ *----------------------------------------------------------------------------*/
+
+static void __on_scene_progress_status_background_start(arm_2d_scene_t *ptScene)
+{
+    user_scene_progress_status_t *ptThis = (user_scene_progress_status_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+
+}
+
+static void __on_scene_progress_status_background_complete(arm_2d_scene_t *ptScene)
+{
+    user_scene_progress_status_t *ptThis = (user_scene_progress_status_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+
+}
+
+static void __on_scene_progress_status_frame_start(arm_2d_scene_t *ptScene)
+{
+    user_scene_progress_status_t *ptThis = (user_scene_progress_status_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+
+    if (arm_2d_helper_is_time_out(  s_tileWIFISignalFilm.hwPeriodPerFrame, 
+                                    &this.lTimestamp[2])) {
+
+        arm_2d_helper_film_next_frame(&s_tileWIFISignalFilm);
+        arm_2d_helper_film_next_frame(&s_tileWIFISignalFilmMask);
+    }
+}
+
+static void __on_scene_progress_status_frame_complete(arm_2d_scene_t *ptScene)
+{
+    user_scene_progress_status_t *ptThis = (user_scene_progress_status_t *)ptScene;
+    ARM_2D_UNUSED(ptThis);
+    
+    /* switch to next scene after 3s */
+    if (arm_2d_helper_is_time_out(10000, &this.lTimestamp[0])) {
+        arm_2d_scene_player_switch_to_next_scene(ptScene->ptPlayer);
+    }
+}
+
+
+
+
+static
+IMPL_PFB_ON_DRAW(__pfb_draw_scene_progress_status_background_handler)
+{
+    user_scene_progress_status_t *ptThis = (user_scene_progress_status_t *)pTarget;
+    ARM_2D_UNUSED(bIsNewFrame);
+    ARM_2D_UNUSED(ptTile);
+    /*-----------------------draw back ground begin-----------------------*/
+
+
+
+    /*-----------------------draw back ground end  -----------------------*/
+    arm_2d_op_wait_async(NULL);
+
+    return arm_fsm_rt_cpl;
+}
+
+
+
+static
+IMPL_PFB_ON_DRAW(__pfb_draw_scene_progress_status_handler)
+{
+    user_scene_progress_status_t *ptThis = (user_scene_progress_status_t *)pTarget;
+    arm_2d_size_t tScreenSize = ptTile->tRegion.tSize;
+
+    ARM_2D_UNUSED(ptTile);
+    ARM_2D_UNUSED(bIsNewFrame);
+    ARM_2D_UNUSED(tScreenSize);
+
+    /*-----------------------draw the foreground begin-----------------------*/
+
+    /* following code is just a demo, you can remove them */
+    arm_2d_canvas(ptTile, __canvas) {
+
+        if (bIsNewFrame) {
+            int32_t iResult;
+            if (arm_2d_helper_time_half_cos_slider(0, 1000, 6000, &iResult, &this.lTimestamp[1])) {
+                this.hwProgress = -1;
+            } else {
+                this.hwProgress = (uint16_t)iResult;
+            }
+        }
+        arm_using(arm_2d_size_t tWiFiLogoSize = s_tileWIFISignalFilm .use_as__arm_2d_tile_t.tRegion .tSize) {
+
+            arm_2d_align_centre(__canvas, 
+                                tScreenSize.iWidth, 
+                                120+tWiFiLogoSize.iHeight) {
+                
+                arm_2d_layout(__centre_region, true) {
+                    __item_line_vertical(__centre_region.tSize.iWidth, tWiFiLogoSize.iHeight) {
+                        arm_2d_align_centre(__item_region, tWiFiLogoSize) {
+                            
+                            arm_2d_tile_copy_with_src_mask_only(
+                                    (arm_2d_tile_t *)&s_tileWIFISignalFilm,
+                                    (arm_2d_tile_t *)&s_tileWIFISignalFilmMask,
+                                    ptTile,
+                                    &__centre_region);
+
+                        }
+                    }
+                    __item_line_vertical(tScreenSize.iWidth, 40) {
+                        arm_2d_container(ptTile, __progress_bar, &__item_region) {
+                            progress_bar_simple_show(&__progress_bar, NULL, this.hwProgress, bIsNewFrame);
+                        }
+                    }
+                    __item_line_vertical(tScreenSize.iWidth, 40) {
+                        arm_2d_container(ptTile, __progress_bar, &__item_region) {
+                            progress_bar_drill_show(&__progress_bar, NULL, this.hwProgress, bIsNewFrame);
+                        }
+                    }
+                    __item_line_vertical(tScreenSize.iWidth, 40) {
+                        arm_2d_container(ptTile, __progress_bar, &__item_region) {
+                            progress_bar_flowing_show(&__progress_bar, NULL, this.hwProgress, bIsNewFrame);
+                        }
+                    }
+                }
+            }
+        }
+/*
+        arm_2d_align_top_right( __canvas, 
+                                s_tileWIFISignalFilm
+                                    .use_as__arm_2d_tile_t
+                                        .tRegion
+                                            .tSize) {
+
+            arm_2d_tile_copy_with_src_mask_only(
+                                    (arm_2d_tile_t *)&s_tileWIFISignalFilm,
+                                    (arm_2d_tile_t *)&s_tileWIFISignalFilmMask,
+                                    ptTile,
+                                    &__top_right_region);
+
+        }
+*/
+        /* draw text at the top-left corner */
+        arm_lcd_text_set_target_framebuffer((arm_2d_tile_t *)ptTile);
+        arm_lcd_text_set_colour(GLCD_COLOR_RED, GLCD_COLOR_WHITE);
+        arm_lcd_text_location(0,0);
+        arm_lcd_printf("Scene Progress and Status");
+    }
+
+    /*-----------------------draw the foreground end  -----------------------*/
+    arm_2d_op_wait_async(NULL);
+
+    return arm_fsm_rt_cpl;
+}
+
+#define PROGRESSBAR_WIDTH       (__DISP0_CFG_SCEEN_WIDTH__ * 3 >> 3)
+
+ARM_NONNULL(1)
+user_scene_progress_status_t *__arm_2d_scene_progress_status_init(   arm_2d_scene_player_t *ptDispAdapter, 
+                                        user_scene_progress_status_t *ptScene)
+{
+    bool bUserAllocated = false;
+    assert(NULL != ptDispAdapter);
+
+    /*! define dirty regions */
+    IMPL_ARM_2D_REGION_LIST(s_tDirtyRegions, static)
+
+        /* a dirty region to be specified at runtime*/
+        ADD_REGION_TO_LIST(s_tDirtyRegions),
+
+        ADD_REGION_TO_LIST(s_tDirtyRegions),
+
+       /* add the last region:
+         * it is the top left corner for text display 
+         */
+        ADD_LAST_REGION_TO_LIST(s_tDirtyRegions,
+            .tLocation = {
+                .iX = 0,
+                .iY = 0,
+            },
+            .tSize = {
+                .iWidth = __GLCD_CFG_SCEEN_WIDTH__,
+                .iHeight = 8,
+            },
+        ),
+
+    END_IMPL_ARM_2D_REGION_LIST(s_tDirtyRegions)
+
+    s_tDirtyRegions[dimof(s_tDirtyRegions)-1].ptNext = NULL;
+
+    if (NULL == ptScene) {
+        ptScene = (user_scene_progress_status_t *)
+                    __arm_2d_allocate_scratch_memory(   sizeof(user_scene_progress_status_t),
+                                                        __alignof__(user_scene_progress_status_t),
+                                                        ARM_2D_MEM_TYPE_UNSPECIFIED);
+        assert(NULL != ptScene);
+        if (NULL == ptScene) {
+            return NULL;
+        }
+        bUserAllocated = true;
+    } else {
+        memset(ptScene, 0, sizeof(user_scene_progress_status_t));
+    }
+
+    /* get the screen region */
+    arm_2d_region_t tScreen
+        = arm_2d_helper_pfb_get_display_area(
+            &ptDispAdapter->use_as__arm_2d_helper_pfb_t);
+
+    /* initialise dirty region 0 at runtime
+     */
+    arm_2d_align_centre(tScreen, tScreen.tSize.iWidth, 120) {
+        s_tDirtyRegions[0].tRegion = __centre_region;
+    }
+
+    /* initialise dirty region 1 at runtime
+     */
+    arm_2d_align_top_right( tScreen, 
+                            s_tileWIFISignalFilm
+                                .use_as__arm_2d_tile_t
+                                    .tRegion
+                                        .tSize) {
+        s_tDirtyRegions[1].tRegion = __top_right_region;
+    }
+
+    arm_using(arm_2d_size_t tWiFiLogoSize = s_tileWIFISignalFilm .use_as__arm_2d_tile_t.tRegion .tSize) {
+
+        arm_2d_align_centre(tScreen, 
+                            tScreen.tSize.iWidth, 
+                            120+tWiFiLogoSize.iHeight) {
+            
+            arm_2d_layout(__centre_region) {
+                __item_line_vertical(__centre_region.tSize.iWidth, tWiFiLogoSize.iHeight) {
+                    arm_2d_align_centre(__item_region, tWiFiLogoSize) {
+                        s_tDirtyRegions[1].tRegion = __centre_region;
+                    }
+                }
+                __item_line_vertical(tScreen.tSize.iWidth, 120) {
+                    s_tDirtyRegions[0].tRegion = __item_region;
+                }
+            }
+        }
+    }
+
+    /* set to the last frame */
+    arm_2d_helper_film_set_frame(&s_tileWIFISignalFilm, -1);
+    arm_2d_helper_film_set_frame(&s_tileWIFISignalFilmMask, -1);
+
+
+    *ptScene = (user_scene_progress_status_t){
+        .use_as__arm_2d_scene_t = {
+        
+        /* the canvas colour */
+        .tCanvas = {GLCD_COLOR_WHITE}, 
+        
+        /* Please uncommon the callbacks if you need them
+         */
+        //.fnBackground   = &__pfb_draw_scene_progress_status_background_handler,
+        .fnScene        = &__pfb_draw_scene_progress_status_handler,
+        .ptDirtyRegion  = (arm_2d_region_list_item_t *)s_tDirtyRegions,
+        
+
+        //.fnOnBGStart    = &__on_scene_progress_status_background_start,
+        //.fnOnBGComplete = &__on_scene_progress_status_background_complete,
+        .fnOnFrameStart = &__on_scene_progress_status_frame_start,
+        .fnOnFrameCPL   = &__on_scene_progress_status_frame_complete,
+        .fnDepose       = &__on_scene_progress_status_depose,
+        },
+        .bUserAllocated = bUserAllocated,
+    };
+
+    arm_2d_scene_player_append_scenes(  ptDispAdapter, 
+                                        &ptScene->use_as__arm_2d_scene_t, 
+                                        1);
+
+    return ptScene;
+}
+
+
+
+
+#if defined(__clang__)
+#   pragma clang diagnostic pop
+#endif
+
+#endif
+

+ 114 - 0
projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/arm_2d_scene_progress_status.h

@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2009-2022 Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __ARM_2D_SCENE_PROGRESS_STATUS_H__
+#define __ARM_2D_SCENE_PROGRESS_STATUS_H__
+
+/*============================ INCLUDES ======================================*/
+
+#include "arm_2d.h"
+
+#if defined(RTE_Acceleration_Arm_2D_Helper_PFB)
+
+#include "arm_2d_helper_scene.h"
+
+#ifdef   __cplusplus
+extern "C" {
+#endif
+
+#if defined(__clang__)
+#   pragma clang diagnostic push
+#   pragma clang diagnostic ignored "-Wunknown-warning-option"
+#   pragma clang diagnostic ignored "-Wreserved-identifier"
+#   pragma clang diagnostic ignored "-Wmissing-declarations"
+#   pragma clang diagnostic ignored "-Wpadded"
+#elif __IS_COMPILER_ARM_COMPILER_5__
+#   pragma diag_suppress 64,177
+#elif __IS_COMPILER_GCC__
+#   pragma GCC diagnostic push
+#   pragma GCC diagnostic ignored "-Wformat="
+#   pragma GCC diagnostic ignored "-Wpedantic"
+#   pragma GCC diagnostic ignored "-Wpadded"
+#endif
+
+
+
+/*============================ MACROS ========================================*/
+
+/* OOC header, please DO NOT modify  */
+#ifdef __USER_SCENE_PROGRESS_STATUS_IMPLEMENT__
+#   undef __USER_SCENE_PROGRESS_STATUS_IMPLEMENT__
+#   define __ARM_2D_IMPL__
+#endif
+#include "arm_2d_utils.h"
+
+/*============================ MACROFIED FUNCTIONS ===========================*/
+
+/*!
+ * \brief initalize scene1 and add it to a user specified scene player
+ * \param[in] __DISP_ADAPTER_PTR the target display adatper (i.e. scene player)
+ * \param[in] ... this is an optional parameter. When it is NULL, a new 
+ *            user_scene_progress_status_t will be allocated from HEAP and freed on
+ *            the deposing event. When it is non-NULL, the life-cycle is managed
+ *            by user.
+ * \return user_scene_progress_status_t* the user_scene_progress_status_t instance
+ */
+#define arm_2d_scene_progress_status_init(__DISP_ADAPTER_PTR, ...)                    \
+            __arm_2d_scene_progress_status_init((__DISP_ADAPTER_PTR), (NULL, ##__VA_ARGS__))
+
+/*============================ TYPES =========================================*/
+/*!
+ * \brief a user class for scene 1
+ */
+typedef struct user_scene_progress_status_t user_scene_progress_status_t;
+
+struct user_scene_progress_status_t {
+    implement(arm_2d_scene_t);                                                  //! derived from class: arm_2d_scene_t
+
+ARM_PRIVATE(
+    /* place your private member here, following two are examples */
+    int64_t lTimestamp[3];
+    
+    bool bUserAllocated;
+    uint16_t hwProgress;
+)
+    /* place your public member here */
+    
+};
+
+/*============================ GLOBAL VARIABLES ==============================*/
+/*============================ PROTOTYPES ====================================*/
+
+ARM_NONNULL(1)
+extern
+user_scene_progress_status_t *__arm_2d_scene_progress_status_init(   arm_2d_scene_player_t *ptDispAdapter, 
+                                        user_scene_progress_status_t *ptScene);
+
+#if defined(__clang__)
+#   pragma clang diagnostic pop
+#elif __IS_COMPILER_GCC__
+#   pragma GCC diagnostic pop
+#endif
+
+#ifdef   __cplusplus
+}
+#endif
+
+#endif
+
+#endif

+ 585 - 0
projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/img2c.py

@@ -0,0 +1,585 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# *************************************************************************************************
+#  Arm 2D project
+#  @file        img2c.py
+#  @brief       image to C-array converter
+#
+# *************************************************************************************************
+#
+# * Copyright (C) 2010-2022 ARM Limited or its affiliates. All rights reserved.
+# *
+# * SPDX-License-Identifier: Apache-2.0
+# *
+# * Licensed under the Apache License, Version 2.0 (the License); you may
+# * not use this file except in compliance with the License.
+# * You may obtain a copy of the License at
+# *
+# * www.apache.org/licenses/LICENSE-2.0
+# *
+# * Unless required by applicable law or agreed to in writing, software
+# * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+# * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# * See the License for the specific language governing permissions and
+# * limitations under the License.
+# */
+
+import sys
+from PIL import Image
+import numpy as np
+import time;
+import argparse
+import os
+
+
+
+hdr="""
+/* Generated on {0} from {1} */
+/* Re-sized : {2} */
+/* Rotated : {3} deg */
+
+
+
+#include "arm_2d.h"
+
+#if defined(__clang__)
+#   pragma clang diagnostic push
+#   pragma clang diagnostic ignored "-Wunknown-warning-option"
+#   pragma clang diagnostic ignored "-Wreserved-identifier"
+#   pragma clang diagnostic ignored "-Wmissing-variable-declarations"
+#   pragma clang diagnostic ignored "-Wcast-qual"
+#elif defined(__IS_COMPILER_ARM_COMPILER_5__)
+#   pragma diag_suppress=1296
+#endif
+
+"""
+
+tailDataGRAY8="""
+
+extern const arm_2d_tile_t c_tile{0}GRAY8;
+ARM_SECTION(\"arm2d.tile.c_tile{0}GRAY8\")
+const arm_2d_tile_t c_tile{0}GRAY8 = {{
+    .tRegion = {{
+        .tSize = {{
+            .iWidth = {1},
+            .iHeight = {2},
+        }},
+    }},
+    .tInfo = {{
+        .bIsRoot = true,
+        .bHasEnforcedColour = true,
+        .tColourInfo = {{
+            .chScheme = ARM_2D_COLOUR_GRAY8,
+        }},
+    }},
+    {3}c_bmp{0}GRAY8,
+}};
+
+"""
+
+tailDataRGB565="""
+
+extern const arm_2d_tile_t c_tile{0}RGB565;
+ARM_SECTION(\"arm2d.tile.c_tile{0}RGB565\")
+const arm_2d_tile_t c_tile{0}RGB565 = {{
+    .tRegion = {{
+        .tSize = {{
+            .iWidth = {1},
+            .iHeight = {2},
+        }},
+    }},
+    .tInfo = {{
+        .bIsRoot = true,
+        .bHasEnforcedColour = true,
+        .tColourInfo = {{
+            .chScheme = ARM_2D_COLOUR_RGB565,
+        }},
+    }},
+    {3}c_bmp{0}RGB565,
+}};
+
+"""
+
+tailDataRGB888="""
+
+extern const arm_2d_tile_t c_tile{0}CCCN888;
+
+ARM_SECTION(\"arm2d.tile.c_tile{0}CCCN888\")
+const arm_2d_tile_t c_tile{0}CCCN888 = {{
+    .tRegion = {{
+        .tSize = {{
+            .iWidth = {1},
+            .iHeight = {2},
+        }},
+    }},
+    .tInfo = {{
+        .bIsRoot = true,
+        .bHasEnforcedColour = true,
+        .tColourInfo = {{
+            .chScheme = ARM_2D_COLOUR_RGB888,
+        }},
+    }},
+    {3}c_bmp{0}CCCN888,
+}};
+
+"""
+
+tailDataRGBA8888="""
+
+extern const arm_2d_tile_t c_tile{0}CCCA8888;
+
+ARM_SECTION(\"arm2d.tile.c_tile{0}CCCA8888\")
+const arm_2d_tile_t c_tile{0}CCCA8888 = {{
+    .tRegion = {{
+        .tSize = {{
+            .iWidth = {1},
+            .iHeight = {2},
+        }},
+    }},
+    .tInfo = {{
+        .bIsRoot = true,
+        .bHasEnforcedColour = true,
+        .tColourInfo = {{
+            .chScheme = ARM_2D_COLOUR_BGRA8888,
+        }},
+    }},
+    {3}c_bmp{0}CCCA8888,
+}};
+
+"""
+
+tailAlpha="""
+
+
+extern const arm_2d_tile_t c_tile{0}Mask;
+
+ARM_SECTION(\"arm2d.tile.c_tile{0}Mask\")
+const arm_2d_tile_t c_tile{0}Mask = {{
+    .tRegion = {{
+        .tSize = {{
+            .iWidth = {1},
+            .iHeight = {2},
+        }},
+    }},
+    .tInfo = {{
+        .bIsRoot = true,
+        .bHasEnforcedColour = true,
+        .tColourInfo = {{
+            .chScheme = ARM_2D_COLOUR_8BIT,
+        }},
+    }},
+    .pchBuffer = (uint8_t *)c_bmp{0}Alpha,
+}};
+"""
+
+tail2BitAlpha="""
+
+
+extern const arm_2d_tile_t c_tile{0}A2Mask;
+
+ARM_SECTION(\"arm2d.tile.c_tile{0}A2Mask\")
+const arm_2d_tile_t c_tile{0}A2Mask = {{
+    .tRegion = {{
+        .tSize = {{
+            .iWidth = {1},
+            .iHeight = {2},
+        }},
+    }},
+    .tInfo = {{
+        .bIsRoot = true,
+        .bHasEnforcedColour = true,
+        .tColourInfo = {{
+            .chScheme = ARM_2D_COLOUR_MASK_A2,
+        }},
+    }},
+    .pchBuffer = (uint8_t *)c_bmp{0}A2Alpha,
+}};
+"""
+
+tail4BitAlpha="""
+
+
+extern const arm_2d_tile_t c_tile{0}A4Mask;
+
+ARM_SECTION(\"arm2d.tile.c_tile{0}A4Mask\")
+const arm_2d_tile_t c_tile{0}A4Mask = {{
+    .tRegion = {{
+        .tSize = {{
+            .iWidth = {1},
+            .iHeight = {2},
+        }},
+    }},
+    .tInfo = {{
+        .bIsRoot = true,
+        .bHasEnforcedColour = true,
+        .tColourInfo = {{
+            .chScheme = ARM_2D_COLOUR_MASK_A4,
+        }},
+    }},
+    .pchBuffer = (uint8_t *)c_bmp{0}A4Alpha,
+}};
+"""
+
+
+tailAlpha2="""
+
+
+extern const arm_2d_tile_t c_tile{0}Mask2;
+
+ARM_SECTION(\"arm2d.tile.c_tile{0}Mask2\")
+const arm_2d_tile_t c_tile{0}Mask2 = {{
+    .tRegion = {{
+        .tSize = {{
+            .iWidth = {1},
+            .iHeight = {2},
+        }},
+    }},
+    .tInfo = {{
+        .bIsRoot = true,
+        .bHasEnforcedColour = true,
+        .tColourInfo = {{
+            .chScheme = ARM_2D_CHANNEL_8in32,
+        }},
+    }},
+    .nAddress = ((intptr_t)c_bmp{0}CCCA8888) + 3,
+}};
+"""
+
+
+tail="""
+
+#if defined(__clang__)
+#   pragma clang diagnostic pop
+#elif defined(__IS_COMPILER_ARM_COMPILER_5__)
+#   pragma diag_warning=1296
+#endif
+
+"""
+
+def main(argv):
+
+    parser = argparse.ArgumentParser(description='image to C array converter (v1.2.2)')
+
+    parser.add_argument('-i', nargs='?', type = str,  required=False, help="Input file (png, bmp, etc..)")
+    parser.add_argument('-o', nargs='?', type = str,  required=False, help="output C file containing RGB56/RGB888/Gray8 and alpha values arrays")
+
+    parser.add_argument('--name', nargs='?',type = str, required=False, help="A specified array name")
+    parser.add_argument('--format', nargs='?',type = str, default="all", help="RGB Format (rgb565, rgb32, gray8, all)")
+    parser.add_argument('--dim', nargs=2,type = int, help="Resize the image with the given width and height")
+    parser.add_argument('--rot', nargs='?',type = float, default=0.0, help="Rotate the image with the given angle in degrees")
+    parser.add_argument('--a2', action='store_true', help="Generate 2bit alpha-mask")
+    parser.add_argument('--a4', action='store_true', help="Generate 4bit alpha-mask")
+
+    args = parser.parse_args()
+
+    if args.i == None or args.i == "" :
+        parser.print_help()
+        exit(1)
+    inputfile = args.i;
+    basename = os.path.basename(inputfile).split('.')[0];
+
+
+    outputfile = args.o
+    if outputfile == None or outputfile == "":
+        outputfile = basename + ".c"
+
+    arr_name = args.name
+    if arr_name == None or arr_name == "":
+        arr_name = basename
+
+    if args.format != 'rgb565' and \
+        args.format != 'rgb32' and \
+        args.format != 'gray8' and \
+        args.format != 'all':
+        parser.print_help()
+        exit(1)
+
+    try:
+        image = Image.open(inputfile)
+    except FileNotFoundError:
+        print("Cannot open image file %s" % (inputfile))
+        sys.exit(2)
+
+
+    # rotation
+    if args.rot != 0.0:
+        image = image.rotate(args.rot)
+
+
+    # resizing
+    resized = False
+    if args.dim != None:
+        image = image.resize((args.dim[0], args.dim[1]))
+        resized = True
+
+
+    mode = image.mode
+
+    # Modes supported by Pillow
+
+    # 1 (1-bit pixels, black and white, stored with one pixel per byte), the value is in 0-1.
+    # L (8-bit pixels, black and white), the value is in 0-255.
+    # P (8-bit pixels, mapped to any other mode using a color palette), the value is in 0-255.
+    # RGB (3×8-bit pixels, true color), the value is in [0-255, 0-255, 0-255].
+    # RGBA (4×8-bit pixels, true color with transparency mask), the value is in [0-255, 0-255, 0-255, 0-255]
+    # CMYK (4×8-bit pixels, color separation)
+    # YCbCr (3×8-bit pixels, color video format)
+    # LAB (3×8-bit pixels, the L*a*b color space)
+    # HSV (3×8-bit pixels, Hue, Saturation, Value color space)
+    # I (32-bit signed integer pixels)
+    # F (32-bit floating point pixels)
+    # LA (L with alpha)
+    # PA (P with alpha)
+    # RGBX (true color with padding)
+    # RGBa (true color with premultiplied alpha)
+    # La (L with premultiplied alpha)
+    # I;16 (16-bit unsigned integer pixels)
+    # I;16L (16-bit little endian unsigned integer pixels)
+    # I;16B (16-bit big endian unsigned integer pixels)
+    # I;16N (16-bit native endian unsigned integer pixels)
+    # BGR;15 (15-bit reversed true colour)
+    # BGR;16 (16-bit reversed true colour)
+    # BGR;24 (24-bit reversed true colour)
+    # BGR;32 (32-bit reversed true colour)
+
+    # handle {P, LA, RGB, RGBA} for now
+    if mode == 'P' or mode == 'LA':
+        image = image.convert('RGBA')
+        mode = 'RGBA'
+    if mode == 'L':
+        image = image.convert('RGB')
+        mode = 'RGB'
+    (row, col) = image.size
+    data = np.asarray(image)
+
+    # C Array format width
+    WIDTH_ALPHA = 16
+    WIDTH_GRAY8 = 32
+    WIDTH_RGB565 = 16
+    WIDTH_RGB32 = 16
+
+    with open(outputfile,"w") as o:
+
+        # insert header
+        print(hdr.format(time.asctime( time.localtime(time.time())), argv[0], resized, args.rot), file=o)
+
+        if mode == "RGBA":
+            print('ARM_ALIGN(4) ARM_SECTION(\"arm2d.asset.c_bmp%sAlpha\")' % (arr_name), file=o)
+            # alpha channel array available
+            print('static const uint8_t c_bmp%sAlpha[%d*%d] = {' % (arr_name, row, col),file=o)
+            cnt = 0
+            for eachRow in data:
+                lineWidth=0
+                print("/* -%d- */" % (cnt), file=o)
+                for eachPix in eachRow:
+                    alpha = eachPix[3]
+                    if lineWidth % WIDTH_ALPHA == (WIDTH_ALPHA - 1):
+                        print("0x%02x," %(alpha) ,file=o)
+                    else:
+                        print("0x%02x" %(alpha), end =", ",file=o)
+                    lineWidth+=1
+                cnt+=1
+                print('',file=o)
+            print('};', file=o)
+
+            # 2-bit Alpha channel
+            if args.a2 or args.format == 'all':
+
+                def RevBitPairPerByte(byteArr):
+                    return ((byteArr & 0x03) << 6) |  ((byteArr & 0xc0) >> 6) | ((byteArr & 0x30) >> 2 ) | ((byteArr & 0x0c) << 2)
+
+
+                print('ARM_ALIGN(4) ARM_SECTION(\"arm2d.asset.c_bmp%sA2Alpha\")' % (arr_name), file=o)
+                print('static const uint8_t c_bmp%sA2Alpha[%d*%d] = {' % (arr_name, (row+3)/4, col),file=o)
+                cnt = 0
+                alpha = data[...,3].astype(np.uint8)
+                for eachRow in alpha:
+                    lineWidth=0
+                    print("/* -%d- */" % (cnt), file=o)
+
+                    bitsArr = np.unpackbits(eachRow.astype(np.uint8))
+
+                    # generate indexes for MSB bit pair every byte
+                    idx = np.arange(0, np.size(bitsArr), 8)
+                    idx=np.reshape(np.column_stack((idx+0, idx+1)), (1,-1))
+
+                    # extraction + endianness conversion
+                    packedBytes = RevBitPairPerByte(np.packbits(bitsArr[idx]))
+
+                    for elt in packedBytes:
+                        if lineWidth % WIDTH_ALPHA == (WIDTH_ALPHA-1):
+                            print("0x%02x," %(elt) ,file=o)
+                        else:
+                            print("0x%02x" %(elt), end =", ",file=o)
+                        lineWidth+=1
+                    cnt+=1
+                    print('',file=o)
+                print('};', file=o)
+
+            # 4-bit Alpha channel
+            if args.a4 or args.format == 'all':
+
+                def RevBitQuadPerByte(byteArr):
+                    return ((byteArr & 0x0f) << 4) |  ((byteArr & 0xf0) >> 4)
+
+
+                print('ARM_ALIGN(4) ARM_SECTION(\"arm2d.asset.c_bmp%sA4Alpha\")' % (arr_name), file=o)
+                print('static const uint8_t c_bmp%sA4Alpha[%d*%d] = {' % (arr_name, (row+1)/2, col),file=o)
+                cnt = 0
+                alpha = data[...,3].astype(np.uint8)
+                for eachRow in alpha:
+                    lineWidth=0
+                    print("/* -%d- */" % (cnt), file=o)
+
+                    bitsArr = np.unpackbits(eachRow.astype(np.uint8))
+
+                    # generate indexes for MSB bit quadruplet every byte
+                    idx = np.arange(0, np.size(bitsArr), 8)
+                    idx=np.reshape(np.column_stack(
+                            (np.column_stack((idx+0, idx+1)), np.column_stack((idx+2, idx+3)))),
+                            (1,-1)),
+
+                    # extraction + endianness conversion
+                    packedBytes = RevBitQuadPerByte(np.packbits(bitsArr[idx]))
+
+                    for elt in packedBytes:
+                        if lineWidth % WIDTH_ALPHA == (WIDTH_ALPHA - 1):
+                            print("0x%02x," %(elt) ,file=o)
+                        else:
+                            print("0x%02x" %(elt), end =", ",file=o)
+                        lineWidth+=1
+                    cnt+=1
+                    print('',file=o)
+                print('};', file=o)
+
+
+        # Gray8 channel array
+        if args.format == 'gray8' or args.format == 'all':
+
+            R = (data[...,0]).astype(np.uint16)
+            G = (data[...,1]).astype(np.uint16)
+            B = (data[...,2]).astype(np.uint16)
+            # merge
+            RGB = np.rint((R + G + B)/3).astype(np.uint8)
+
+            print('',file=o)
+            print('ARM_SECTION(\"arm2d.asset.c_bmp%sGRAY8\")' % (arr_name), file=o)
+            print('const uint8_t c_bmp%sGRAY8[%d*%d] = {' % (arr_name, row, col), file=o)
+            cnt = 0
+            for eachRow in RGB:
+                lineWidth=0
+                print("/* -%d- */" % (cnt), file=o)
+                for eachPix in eachRow:
+                    if lineWidth % WIDTH_GRAY8 == (WIDTH_GRAY8 - 1):
+                        print("0x%02x," %(eachPix) ,file=o)
+                    else:
+                        print("0x%02x" %(eachPix), end =", ", file=o)
+                    lineWidth+=1
+                print('',file=o)
+                cnt+=1
+            print('};', file=o)
+            buffStr='pchBuffer'
+            typStr='uint8_t'
+
+        # RGB565 channel array
+        if args.format == 'rgb565' or args.format == 'all':
+            R = (data[...,0]>>3).astype(np.uint16) << 11
+            G = (data[...,1]>>2).astype(np.uint16) << 5
+            B = (data[...,2]>>3).astype(np.uint16)
+            # merge
+            RGB = R | G | B
+
+            print('',file=o)
+            print('ARM_SECTION(\"arm2d.asset.c_bmp%sRGB565\")' % (arr_name), file=o)
+            print('const uint16_t c_bmp%sRGB565[%d*%d] = {' % (arr_name, row, col), file=o)
+            cnt = 0
+            for eachRow in RGB:
+                lineWidth=0
+                print("/* -%d- */" % (cnt), file=o)
+                for eachPix in eachRow:
+                    if lineWidth % WIDTH_RGB565 == (WIDTH_RGB565 - 1):
+                        print("0x%04x," %(eachPix) ,file=o)
+                    else:
+                        print("0x%04x" %(eachPix), end =", ", file=o)
+                    lineWidth+=1
+                print('',file=o)
+                cnt+=1
+            print('};', file=o)
+            buffStr='phwBuffer'
+            typStr='uint16_t'
+
+
+
+        if args.format == 'rgb32' or args.format == 'all':
+            R = data[...,0].astype(np.uint32) << 16
+            G = data[...,1].astype(np.uint32) << 8
+            B = data[...,2].astype(np.uint32)
+            if mode == "RGBA":
+                A = data[...,3].astype(np.uint32) << 24
+            else:
+                # alpha chanel forced to 0xFF
+                A = 0xff << 24
+            # merge
+            RGB = R | G | B | A
+
+            print('',file=o)
+
+            if mode == "RGBA":
+                print('ARM_SECTION(\"arm2d.asset.c_bmp%sCCCA8888\")' % (arr_name), file=o)
+                print('const uint32_t c_bmp%sCCCA8888[%d*%d] = {' % (arr_name, row, col), file=o)
+            else:
+                print('ARM_SECTION(\"arm2d.asset.c_bmp%sCCCN888\")' % (arr_name), file=o)
+                print('const uint32_t c_bmp%sCCCN888[%d*%d]= {' % (arr_name, row, col), file=o)
+
+            cnt = 0
+            for eachRow in RGB:
+                lineWidth=0
+                print("/* -%d- */" % (cnt), file=o)
+                for eachPix in eachRow:
+                    if lineWidth % WIDTH_RGB32 == (WIDTH_RGB32 - 1):
+                        print("0x%08x," %(eachPix) ,file=o)
+                    else:
+                        print("0x%08x" %(eachPix), end =", ", file=o)
+                    lineWidth+=1
+                print('',file=o)
+                cnt+=1
+            print('};', file=o)
+            buffStr='pwBuffer'
+            typStr='uint32_t'
+
+        # insert tail
+        if args.format == 'gray8' or args.format == 'all':
+            buffStr='pchBuffer'
+            typStr='uint8_t'
+            print(tailDataGRAY8.format(arr_name, str(row), str(col), "."+buffStr+" = ("+typStr+"*)"), file=o)
+
+        if args.format == 'rgb565' or args.format == 'all':
+            buffStr='phwBuffer'
+            typStr='uint16_t'
+            print(tailDataRGB565.format(arr_name, str(row), str(col), "."+buffStr+" = ("+typStr+"*)"), file=o)
+
+        if args.format == 'rgb32' or args.format == 'all':
+            buffStr='pwBuffer'
+            typStr='uint32_t'
+            if mode == "RGBA":
+                print(tailDataRGBA8888.format(arr_name, str(row), str(col), "."+buffStr+" = ("+typStr+"*)"), file=o)
+                print(tailAlpha2.format(arr_name, str(row), str(col)), file=o)
+            else :
+                print(tailDataRGB888.format(arr_name, str(row), str(col), "."+buffStr+" = ("+typStr+"*)"), file=o)
+
+
+        if mode == "RGBA":
+            print(tailAlpha.format(arr_name, str(row), str(col)), file=o)
+
+            if args.a2 or args.format == 'all':
+                print(tail2BitAlpha.format(arr_name, str(row), str(col)), file=o)
+
+            if args.a4 or args.format == 'all':
+                print(tail4BitAlpha.format(arr_name, str(row), str(col)), file=o)
+
+
+        print(tail.format(arr_name, str(row), str(col)), file=o)
+
+if __name__ == '__main__':
+    main(sys.argv[1:])

+ 486 - 0
projects/arm2d/vision_board_mipi_2.0inch_arm2d/RTE/Acceleration/ttf2c.py

@@ -0,0 +1,486 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# *************************************************************************************************
+#  Arm 2D project
+#  @file        ttf2c.py
+#  @brief       TrueTypeFont to C-array converter
+#
+# *************************************************************************************************
+#
+# * Copyright (C) 2024 ARM Limited or its affiliates. All rights reserved.
+# *
+# * SPDX-License-Identifier: Apache-2.0
+# *
+# * Licensed under the Apache License, Version 2.0 (the License); you may
+# * not use this file except in compliance with the License.
+# * You may obtain a copy of the License at
+# *
+# * www.apache.org/licenses/LICENSE-2.0
+# *
+# * Unless required by applicable law or agreed to in writing, software
+# * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+# * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# * See the License for the specific language governing permissions and
+# * limitations under the License.
+# */
+
+
+import os
+import sys
+import argparse
+import freetype
+import numpy as np
+import math
+import binascii
+
+c_head_string="""
+
+#include "arm_2d_helper.h"
+
+#include "arm_extra_lcd_printf.h"
+
+#if defined(__clang__)
+#   pragma clang diagnostic push
+#   pragma clang diagnostic ignored "-Wunknown-warning-option"
+#   pragma clang diagnostic ignored "-Wreserved-identifier"
+#   pragma clang diagnostic ignored "-Wmissing-variable-declarations"
+#   pragma clang diagnostic ignored "-Wcast-qual"
+#   pragma clang diagnostic ignored "-Wmissing-declarations"
+#   pragma clang diagnostic ignored "-Wgnu-variable-sized-type-not-at-end"
+#   pragma clang diagnostic ignored "-Wimplicit-int-conversion"
+#   pragma clang diagnostic ignored "-Wdeclaration-after-statement"
+#   pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
+#   pragma clang diagnostic ignored "-Wincompatible-pointer-types-discards-qualifiers"
+#   pragma clang diagnostic ignored "-Wpadded"
+#   pragma clang diagnostic ignored "-Wunused-parameter"
+#   pragma clang diagnostic ignored "-Wunused-variable"
+#   pragma clang diagnostic ignored "-Wsign-conversion"
+#elif defined(__IS_COMPILER_GCC__)
+#   pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
+#   pragma GCC diagnostic ignored "-Wunused-variable"
+#elif defined(__IS_COMPILER_ARM_COMPILER_5__)
+#   pragma diag_suppress=1296
+#endif
+
+typedef struct {
+    uint16_t      hwIndex;
+    arm_2d_size_t tCharSize;
+    int16_t       iAdvance;
+    int16_t       iBearingX;
+    int16_t       iBearingY;
+    uint8_t       chCodeLength;
+    uint8_t       chUTF8[4];
+} __ttf_char_descriptor_t;
+"""
+
+
+c_body_string="""
+
+
+ARM_SECTION(\"arm2d.tile.c_tileUTF8UserFontA{5}Mask\")
+static const arm_2d_tile_t c_tileUTF8UserFontA{5}Mask = {{
+    .tRegion = {{
+        .tSize = {{
+            .iWidth = {1},
+            .iHeight = {4},
+        }},
+    }},
+    .tInfo = {{
+        .bIsRoot = true,
+        .bHasEnforcedColour = true,
+        .tColourInfo = {{
+            .chScheme = ARM_2D_COLOUR_{5}BIT,
+        }},
+    }},
+    .pchBuffer = (uint8_t *)c_bmpUTF8UserA{5}Font,
+}};
+
+#define __UTF8_FONT_SIZE_{5}__
+
+static
+IMPL_FONT_DRAW_CHAR(__utf8_font_a{5}_draw_char)
+{{
+#if defined(__UTF8_FONT_SIZE_8__)
+    static arm_2d_op_fill_cl_msk_opa_trans_t s_tOP;
+    const bool bIsNewFrame = true;
+    static const arm_2d_location_t c_tCentre = {{7,8}};
+
+    if (fScale == 0.0f) {{
+        if (chOpacity == 255) {{
+            return arm_2d_fill_colour_with_mask(
+                                            ptTile,
+                                            ptRegion,
+                                            ptileChar,
+                                            (__arm_2d_color_t){{tForeColour}});
+        }}
+
+        return arm_2d_fill_colour_with_mask_and_opacity(
+                                            ptTile,
+                                            ptRegion,
+                                            ptileChar,
+                                            (__arm_2d_color_t){{tForeColour}},
+                                            chOpacity);
+    }}
+
+    arm_2d_location_t tTargetCenter = ptRegion->tLocation;
+    tTargetCenter.iX += ptRegion->tSize.iWidth >> 1;
+    tTargetCenter.iY += ptRegion->tSize.iHeight >> 1;
+
+    return arm_2dp_fill_colour_with_mask_opacity_and_transform(
+                                            &s_tOP,
+                                            ptileChar,
+                                            ptTile,
+                                            NULL,
+                                            c_tCentre,
+                                            0.0f,
+                                            fScale,
+                                            tForeColour,
+                                            chOpacity,
+                                            &tTargetCenter);
+#elif defined(__UTF8_FONT_SIZE_1__)
+    return arm_2d_draw_pattern(    ptileChar,
+                            ptTile,
+                            ptRegion,
+                            ARM_2D_DRW_PATN_MODE_COPY,
+                            tForeColour,
+                            GLCD_COLOR_BLACK);
+#else
+    return arm_2d_fill_colour_with_a{5}_mask_and_opacity(
+                                        ptTile,
+                                        ptRegion,
+                                        ptileChar,
+                                        (__arm_2d_color_t){{tForeColour}},
+                                        chOpacity);
+#endif
+
+}}
+
+
+
+static
+IMPL_FONT_GET_CHAR_DESCRIPTOR(__utf8_a{5}_font_get_char_descriptor)
+{{
+    assert(NULL != ptFont);
+    assert(NULL != ptDescriptor);
+    assert(NULL != pchCharCode);
+
+    arm_2d_user_font_t *ptThis = (arm_2d_user_font_t *)ptFont;
+
+    memset(ptDescriptor, 0, sizeof(arm_2d_char_descriptor_t));
+
+    ptDescriptor->tileChar.ptParent = (arm_2d_tile_t *)&ptFont->tileFont;
+    ptDescriptor->tileChar.tInfo.bDerivedResource = true;
+
+
+    /* use the white space as the default char */
+    __ttf_char_descriptor_t *ptUTF8Char =
+        (__ttf_char_descriptor_t *)&c_tUTF8LookUpTableA{5}[dimof(c_tUTF8LookUpTableA{5})-1];
+
+    arm_foreach(__ttf_char_descriptor_t, c_tUTF8LookUpTableA{5}, ptChar) {{
+        if (0 == strncmp(   (char *)pchCharCode,
+                            (char *)ptChar->chUTF8,
+                            ptChar->chCodeLength)) {{
+            /* found the UTF8 char */
+            ptUTF8Char = ptChar;
+            break;
+        }}
+    }}
+
+    ptDescriptor->chCodeLength = ptUTF8Char->chCodeLength;
+    ptDescriptor->tileChar.tRegion.tSize = ptUTF8Char->tCharSize;
+    ptDescriptor->tileChar.tRegion.tLocation.iY = (int16_t)ptUTF8Char->hwIndex;
+
+    ptDescriptor->iAdvance = ptUTF8Char->iAdvance;
+    ptDescriptor->iBearingX= ptUTF8Char->iBearingX;
+    ptDescriptor->iBearingY= ptUTF8Char->iBearingY;
+
+    return ptDescriptor;
+}}
+
+const
+struct {{
+    implement(arm_2d_user_font_t);
+    arm_2d_char_idx_t tUTF8Table;
+}} ARM_2D_FONT_{0}_A{5} = {{
+
+    .use_as__arm_2d_user_font_t = {{
+        .use_as__arm_2d_font_t = {{
+            .tileFont = impl_child_tile(
+                c_tileUTF8UserFontA{5}Mask,
+                0,          /* x offset */
+                0,          /* y offset */
+                {1},        /* width */
+                {4}         /* height */
+            ),
+            .tCharSize = {{
+                .iWidth = {1},
+                .iHeight = {2},
+            }},
+            .nCount =  {3},                             //!< Character count
+            .fnGetCharDescriptor = &__utf8_a{5}_font_get_char_descriptor,
+            .fnDrawChar = &__utf8_font_a{5}_draw_char,
+        }},
+        .hwCount = 1,
+        .hwDefaultCharIndex = 1, /* tBlank */
+    }},
+
+    .tUTF8Table = {{
+        .hwCount = {3},
+        .hwOffset = 0,
+    }},
+}};
+
+#undef __UTF8_FONT_SIZE_{5}__
+"""
+
+
+c_tail_string="""
+
+#if defined(__clang__)
+#   pragma clang diagnostic pop
+#elif defined(__IS_COMPILER_ARM_COMPILER_5__)
+#   pragma diag_warning=1296
+#endif
+"""
+
+def generate_glyphs_data(input_file, text, pixel_size, font_bit_size):
+    face = freetype.Face(input_file)
+    face.set_pixel_sizes(0, pixel_size)
+
+    glyphs_data = []
+    current_index = 0
+
+    width_max = 0
+    height_max = 0
+
+    for char in set(text):
+        # Get the glyph bitmap
+        face.load_char(char)
+        bitmap = face.glyph.bitmap
+        utf8_encoding = char.encode('utf-8')
+
+        if len(bitmap.buffer) == 0:
+            continue
+        if list(utf8_encoding) == [0xef, 0xbb, 0xbf]:
+            continue
+
+        width_max = max(bitmap.width, width_max)
+        height_max = max(bitmap.rows, height_max)
+
+
+    for char in sorted(set(text)):
+        face.load_char(char)
+        bitmap = face.glyph.bitmap
+        utf8_encoding = char.encode('utf-8')
+
+        if len(bitmap.buffer) == 0:
+            continue
+        if list(utf8_encoding) == [0xef, 0xbb, 0xbf]:
+            continue
+
+        advance_width = math.ceil(face.glyph.advance.x / 64.0)
+        bearing_x = face.glyph.bitmap_left
+        bearing_y = face.glyph.bitmap_top
+        width = bitmap.width
+        height = bitmap.rows
+
+        bitmap_array = np.array(bitmap.buffer, dtype=np.uint8).reshape((height, width))
+
+        if width < width_max:
+           padding = ((0, 0), (0, width_max - width))
+           bitmap_array = np.pad(bitmap_array, padding, 'constant')
+
+        char_index_advance = len(bitmap_array.flatten());
+
+        if font_bit_size == 4:
+            def RevBitQuadPerByte(byteArr):
+                return ((byteArr & 0x0f) << 4) |  ((byteArr & 0xf0) >> 4)
+
+            # temporary array with 2x reduced width & pad
+            (r, c) = np.shape(bitmap_array)
+            tmp = np.empty((0, int((c+1)/2)), dtype=np.uint8)
+
+            for cur in bitmap_array:
+                bitsArr = np.unpackbits(cur.astype(np.uint8))
+                # generate indexes for MSB bit quadruplet every byte
+                idx = np.arange(0, np.size(bitsArr), 8)
+                idx = np.reshape(np.column_stack(
+                    (np.column_stack((idx+0, idx+1)), np.column_stack((idx+2, idx+3)))),
+                    (1,-1)),
+
+                # extraction + endianness conversion appended in temp array
+                # packbits is taking care of padding
+                tmp = np.vstack([tmp, RevBitQuadPerByte(np.packbits(bitsArr[idx]))])
+
+            bitmap_array = tmp
+
+        elif font_bit_size == 2:
+            def RevBitPairPerByte(byteArr):
+                return ((byteArr & 0x03) << 6) |  ((byteArr & 0xc0) >> 6) | ((byteArr & 0x30) >> 2 ) | ((byteArr & 0x0c) << 2)
+
+            # temporary array with 4x reduced width & pad
+            (r, c) = np.shape(bitmap_array)
+            tmp = np.empty((0, int((c+3)/4)), dtype=np.uint8)
+
+            for cur in bitmap_array:
+                bitsArr = np.unpackbits(cur.astype(np.uint8))
+
+                # generate indexes for MSB bit pair every byte
+                idx = np.arange(0, np.size(bitsArr), 8)
+                idx = np.reshape(np.column_stack((idx+0, idx+1)), (1,-1))
+
+                # extraction + endianness conversion appended in temp array
+                tmp = np.vstack([tmp, RevBitPairPerByte(np.packbits(bitsArr[idx]))])
+
+            bitmap_array = tmp
+
+        elif font_bit_size == 1:
+            def RevBitPerByte(byteArr):
+                return ((byteArr & 0x01) << 7) | ((byteArr & 0x80) >> 7) | \
+                       ((byteArr & 0x02) << 5) | ((byteArr & 0x40) >> 5) | \
+                       ((byteArr & 0x04) << 3) | ((byteArr & 0x20) >> 3) | \
+                       ((byteArr & 0x08) << 1) | ((byteArr & 0x10) >> 1)
+
+            # temporary array with 8x reduced width & pad
+            (r, c) = np.shape(bitmap_array)
+            tmp = np.empty((0, int((c+7)/8)), dtype=np.uint8)
+
+            for cur in bitmap_array:
+                bitsArr = np.unpackbits(cur.astype(np.uint8))
+
+                # generate indexes for MSB bit every byte
+                idx = np.arange(0, np.size(bitsArr), 8)
+
+                # extraction + endianness conversion
+                tmp = np.vstack([tmp, RevBitPerByte(np.packbits(bitsArr[idx]))])
+
+            bitmap_array = tmp
+
+        char_mask_array = bitmap_array.flatten()
+
+        glyphs_data.append((char, char_mask_array, width, height, current_index, advance_width, bearing_x, bearing_y, utf8_encoding))
+
+        current_index += char_index_advance
+
+    return glyphs_data, width_max, height_max
+
+
+def utf8_to_c_array(utf8_bytes):
+    return '{' + ', '.join([f'0x{byte:02x}' for byte in utf8_bytes]) + '}'
+
+def write_c_code(glyphs_data, output_file, name, char_max_width, char_max_height, font_bit_size):
+
+    with open(output_file, "a") as f:
+
+        print("ARM_SECTION(\"arm2d.asset.FONT\")\nconst uint8_t c_bmpUTF8UserA{0}Font[] = {{\n"
+                .format(font_bit_size), file=f)
+
+        for char, data, width, height, index, advance_width, bearing_x, bearing_y, utf8_encoding in glyphs_data:
+            utf8_c_array = utf8_to_c_array(utf8_encoding)
+            f.write(f"\n    // Glyph for character {utf8_c_array}\n")
+            hex_str = binascii.hexlify(data).decode()
+
+            for i in range(0, len(hex_str), char_max_width*2):
+                line = hex_str[i:i+char_max_width*2]
+                spaced_line = ' '.join(f"0x{line[j:j+2]}," for j in range(0, len(line), 2))
+                f.write("    ");
+                f.write(spaced_line)
+                f.write("\n");
+
+        f.write("    // a white space\n    ");
+        f.write("0x00, " * (char_max_width * char_max_height))
+        f.write("\n};\n\n")
+
+        print("ARM_SECTION(\"arm2d.asset.FONT\")\nconst __ttf_char_descriptor_t c_tUTF8LookUpTableA{0}[] = {{\n"
+                .format(font_bit_size), file=f)
+
+        last_index = 0;
+        last_advance = 0;
+        last_height = 0;
+        for char, data, width, height, index, advance_width, bearing_x, bearing_y, utf8_encoding in glyphs_data:
+            utf8_c_array = utf8_to_c_array(utf8_encoding)
+            last_index = index
+            last_advance = advance_width
+            last_height = height;
+            f.write(f"    {{ {round(index / char_max_width)}, {{ {width}, {height}, }}, {advance_width}, {bearing_x}, {bearing_y}, {len(utf8_encoding)}, {utf8_c_array} }},\n")
+
+        last_index += char_max_width * last_height
+        f.write(f"    {{ {round(last_index / char_max_width)}, {{ {char_max_width}, {char_max_height}, }}, {char_max_width}, {0}, {char_max_height}, 1, {{0x20}} }},\n")
+
+        f.write("};\n")
+
+        print(c_body_string.format( name,
+                                    char_max_width,
+                                    char_max_height,
+                                    len(glyphs_data),
+                                    char_max_height*len(glyphs_data),
+                                    font_bit_size), file=f)
+
+
+def main():
+    parser = argparse.ArgumentParser(description='TrueTypeFont to C array converter (v1.1.4)')
+    parser.add_argument("-i", "--input",    type=str,   help="Path to the TTF file",            required=True)
+    parser.add_argument("-t", "--text",     type=str,   help="Path to the text file",           required=True)
+    parser.add_argument("-n", "--name",     type=str,   help="The customized UTF8 font name",   required=False,     default="UTF8")
+    parser.add_argument("-o", "--output",   type=str,   help="Path to the output C file",       required=True)
+    parser.add_argument("-p", "--pixelsize",type=int,   help="Font size in pixels",             required=False,     default=32)
+    parser.add_argument("-s", "--fontbitsize",type=int, help="font bit size (1,2,4,8)",         required=False,     default=0)
+
+    if len(sys.argv)==1:
+        parser.print_help(sys.stderr)
+        sys.exit(1)
+
+    args = parser.parse_args()
+
+    if args.fontbitsize not in [1, 2, 4, 8, 0]:
+        print(f'Invalid alpha size={args.fontbitsize}')
+        sys.exit(1)
+
+
+    with open(args.output, "w") as outputfile:
+        print(c_head_string, file=outputfile)
+
+
+    if args.fontbitsize in [1, 2, 4, 8]:
+        with open(args.text, 'r', encoding='utf-8') as f:
+            text = f.read()
+
+            glyphs_data, char_max_width, char_max_height = generate_glyphs_data(args.input, text, args.pixelsize, args.fontbitsize)
+            write_c_code(glyphs_data, args.output, args.name, char_max_width, char_max_height, args.fontbitsize)
+
+    else:
+        with open(args.text, 'r', encoding='utf-8') as f:
+            text = f.read()
+
+            glyphs_data, char_max_width, char_max_height = generate_glyphs_data(args.input, text, args.pixelsize, 1)
+            write_c_code(glyphs_data, args.output, args.name, char_max_width, char_max_height, 1)
+
+
+        with open(args.text, 'r', encoding='utf-8') as f:
+            text = f.read()
+
+            glyphs_data, char_max_width, char_max_height = generate_glyphs_data(args.input, text, args.pixelsize, 2)
+            write_c_code(glyphs_data, args.output, args.name, char_max_width, char_max_height, 2)
+
+
+        with open(args.text, 'r', encoding='utf-8') as f:
+            text = f.read()
+
+            glyphs_data, char_max_width, char_max_height = generate_glyphs_data(args.input, text, args.pixelsize, 4)
+            write_c_code(glyphs_data, args.output, args.name, char_max_width, char_max_height, 4)
+
+
+        with open(args.text, 'r', encoding='utf-8') as f:
+            text = f.read()
+
+            glyphs_data, char_max_width, char_max_height = generate_glyphs_data(args.input, text, args.pixelsize, 8)
+            write_c_code(glyphs_data, args.output, args.name, char_max_width, char_max_height, 8)
+
+    with open(args.output, "a") as outputfile:
+        print(c_tail_string, file=outputfile)
+
+
+
+if __name__ == '__main__':
+    main()