From 326bf40779e295f61ef7e7b14956a8a88af152bb Mon Sep 17 00:00:00 2001 From: Gabriel Wang Date: Thu, 19 Dec 2024 23:15:25 +0000 Subject: [PATCH] minor update [template][pico][oled] --- .../project/mdk/template.uvoptx | 2 +- .../RTE/Acceleration/arm_2d.c | 4 +- .../RTE/Acceleration/arm_2d_cfg.h | 1 + .../Acceleration/arm_2d_scene_mono_clock.c | 2 +- .../arm_2d_scene_mono_histogram.c | 4 +- .../arm_2d_scene_mono_icon_menu.c | 136 ++---- .../arm_2d_scene_mono_icon_menu.h | 7 +- .../RTE/Acceleration/arm_2d_scene_mono_list.c | 2 +- .../Acceleration/arm_2d_scene_mono_loading.c | 2 +- .../arm_2d_scene_mono_tracking_list.c | 395 ++++++++++++++++++ .../arm_2d_scene_mono_tracking_list.h | 120 ++++++ .../RTE/Device/RP2040_Core0/rp2040.sct | 2 +- examples/[template][pico][oled]/main.c | 85 +++- .../pico_template.uvoptx | 20 +- .../pico_template.uvprojx | 74 ++-- 15 files changed, 687 insertions(+), 169 deletions(-) create mode 100644 examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_tracking_list.c create mode 100644 examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_tracking_list.h diff --git a/examples/[template][bare-metal]/project/mdk/template.uvoptx b/examples/[template][bare-metal]/project/mdk/template.uvoptx index 15f383a1e..b47a460b9 100644 --- a/examples/[template][bare-metal]/project/mdk/template.uvoptx +++ b/examples/[template][bare-metal]/project/mdk/template.uvoptx @@ -3245,7 +3245,7 @@ ::Utilities - 0 + 1 0 0 1 diff --git a/examples/[template][pico][oled]/RTE/Acceleration/arm_2d.c b/examples/[template][pico][oled]/RTE/Acceleration/arm_2d.c index ba79e386c..3875cff4f 100644 --- a/examples/[template][pico][oled]/RTE/Acceleration/arm_2d.c +++ b/examples/[template][pico][oled]/RTE/Acceleration/arm_2d.c @@ -237,7 +237,7 @@ void __arm_2d_log_printf(int32_t nIndentLevel, s_wLineNumber++; /* start a new line */ - __ARM_2D_PORT_PRINTF__("\r\n[%010" PRIu32 "]\t", s_wLineNumber); + __ARM_2D_PORT_PRINTF__("[%010" PRIu32 "]\t", s_wLineNumber); for (int32_t n = 0; n < nIndentLevel; n++) { __ARM_2D_PORT_PRINTF__("\t"); @@ -276,6 +276,8 @@ void __arm_2d_log_printf(int32_t nIndentLevel, } else { __ARM_2D_PORT_PRINTF__("[Insufficient memory for logging]%s", pchFormatString); } + + __ARM_2D_PORT_PRINTF__("\r\n"); } } diff --git a/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_cfg.h b/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_cfg.h index 1307ae4d4..546896401 100644 --- a/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_cfg.h +++ b/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_cfg.h @@ -123,6 +123,7 @@ extern "C" { | ARM_2D_LOG_CHN_DIRTY_REGION_OPTIMISATION \ | ARM_2D_LOG_CHN_STATISTICS \ | ARM_2D_LOG_CHN_CONTROLS \ + | ARM_2D_LOG_CHN_GUI_STACK \ | ARM_2D_LOG_CHN_APP) #endif diff --git a/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_clock.c b/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_clock.c index 8f2a17928..c7bdbe70d 100644 --- a/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_clock.c +++ b/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_clock.c @@ -242,7 +242,7 @@ static void __on_scene_mono_clock_frame_complete(arm_2d_scene_t *ptScene) user_scene_mono_clock_t *ptThis = (user_scene_mono_clock_t *)ptScene; ARM_2D_UNUSED(ptThis); -#if 1 +#if 0 /* 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); diff --git a/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_histogram.c b/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_histogram.c index 614bfea46..b9a862363 100644 --- a/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_histogram.c +++ b/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_histogram.c @@ -178,9 +178,9 @@ static void __on_scene_mono_histogram_frame_complete(arm_2d_scene_t *ptScene) user_scene_mono_histogram_t *ptThis = (user_scene_mono_histogram_t *)ptScene; ARM_2D_UNUSED(ptThis); -#if 1 +#if 0 /* switch to next scene after 5s */ - if (arm_2d_helper_is_time_out(13000, &this.lTimestamp[0])) { + if (arm_2d_helper_is_time_out(5000, &this.lTimestamp[0])) { arm_2d_scene_player_switch_to_next_scene(ptScene->ptPlayer); } #endif diff --git a/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_icon_menu.c b/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_icon_menu.c index 9d6320f88..14c023925 100644 --- a/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_icon_menu.c +++ b/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_icon_menu.c @@ -221,19 +221,13 @@ static void __on_scene_mono_icon_menu_frame_start(arm_2d_scene_t *ptScene) user_scene_mono_icon_menu_t *ptThis = (user_scene_mono_icon_menu_t *)ptScene; ARM_2D_UNUSED(ptThis); - if (arm_2d_helper_is_time_out(1000, &this.lTimestamp[1])) { + if (arm_2d_helper_is_time_out(1000, &this.lTimestamp[0])) { /* move list */ - icon_list_move_selection(&this.tList, 1, 100); + icon_list_move_selection(&this.tList, 1, 200); + this.bRedrawLabel = true; } - - arm_2d_helper_dirty_region_item_suspend_update( - &this.tDirtyRegionItems[1], - !__arm_2d_list_core_is_list_moving( - &this.tList.use_as____simple_list_t.use_as____arm_2d_list_core_t)); - - icon_list_on_frame_start(&this.tList); } @@ -243,12 +237,6 @@ static void __on_scene_mono_icon_menu_frame_complete(arm_2d_scene_t *ptScene) user_scene_mono_icon_menu_t *ptThis = (user_scene_mono_icon_menu_t *)ptScene; ARM_2D_UNUSED(ptThis); -#if 1 - /* switch to next scene after 12s */ - if (arm_2d_helper_is_time_out(12000, &this.lTimestamp[0])) { - arm_2d_scene_player_switch_to_next_scene(ptScene->ptPlayer); - } -#endif } static void __before_scene_mono_icon_menu_switching_out(arm_2d_scene_t *ptScene) @@ -273,61 +261,11 @@ IMPL_PFB_ON_DRAW(__pfb_draw_scene_mono_icon_menu_handler) arm_2d_canvas(ptTile, __top_canvas) { - arm_2d_dock_vertical(__top_canvas, 56, 8) { - - arm_2d_layout(__vertical_region) { - - /* draw selection indicator */ - __item_line_dock_vertical(3) { - - uint16_t hwListCount = icon_list_get_list_item_count(&this.tList); - uint16_t hwSelectedID = icon_list_get_selected_item_id(&this.tList); - - arm_2d_dock_vertical(__item_region, 1, 24, 24) { - arm_2d_fill_colour(ptTile, &__vertical_region, GLCD_COLOR_WHITE); - + arm_2d_dock_vertical(__top_canvas, 64, 8) { - /* draw selection indicator */ - do { - int16_t iBarWidth = __vertical_region.tSize.iWidth; - q16_t q16Step = div_n_q16(reinterpret_q16_s16(iBarWidth), hwListCount); + arm_2d_layout(__vertical_region, BOTTOM_UP) { - int16_t iIndicatorWidth = reinterpret_s16_q16(q16Step); - iIndicatorWidth = MAX(2, iIndicatorWidth); - - arm_2d_region_t tIndicatorRegion = { - .tSize = { - .iHeight = 3, - .iWidth = iIndicatorWidth, - }, - .tLocation = { - .iY = __vertical_region.tLocation.iY - 1, - .iX = __vertical_region.tLocation.iX - + reinterpret_s16_q16(mul_n_q16(q16Step, hwSelectedID)), - }, - }; - - arm_2d_fill_colour(ptTile, &tIndicatorRegion, GLCD_COLOR_WHITE); - - - /* update dirty region */ - arm_2d_helper_dirty_region_update_item( &this.tDirtyRegionItems[1], - (arm_2d_tile_t *)ptTile, - &__item_region, - &tIndicatorRegion); - - } while(0); - } - } - - __item_line_dock_vertical(32, 0, 0, 4, 0) { - while(arm_fsm_rt_cpl != icon_list_show( &this.tList, - ptTile, - &__item_region, - bIsNewFrame)); - } - - __item_line_dock_vertical(10, 0, 0, 4, 0) { + __item_line_dock_vertical(10, 0, 0, 0, 4) { do { if (__arm_2d_list_core_is_list_moving( @@ -351,15 +289,32 @@ IMPL_PFB_ON_DRAW(__pfb_draw_scene_mono_icon_menu_handler) icon_list_get_selected_item_id(&this.tList)]); - /* update dirty region */ - arm_2d_helper_dirty_region_update_item( - &this.tDirtyRegionItems[0], - (arm_2d_tile_t *)ptTile, - &__item_region, - arm_lcd_text_get_last_display_region()); - + if (this.bRedrawLabel) { + this.bRedrawLabel = false; + + /* update dirty region */ + arm_2d_helper_dirty_region_update_item( + &this.tDirtyRegionItems[0], + (arm_2d_tile_t *)ptTile, + &__item_region, + arm_lcd_text_get_last_display_region()); + } } while(0); } + + __item_line_dock_vertical(0, 0, 4, 0) { + + while(arm_fsm_rt_cpl != icon_list_show( &this.tList, + ptTile, + &__item_region, + bIsNewFrame)); + + arm_2d_align_centre(__item_region, 32, 32) { + arm_2d_filter_reverse_colour(ptTile, &__centre_region); + } + } + + } } @@ -397,21 +352,10 @@ arm_fsm_rt_t __arm_2d_icon_list_draw_list_core_item( arm_2d_align_centre(__item_canvas, ptileIcon->tRegion.tSize) { - if (ptParam->bIsSelected) { - arm_2d_fill_colour(ptTile, &__item_canvas, GLCD_COLOR_WHITE); - //draw_round_corner_box(ptTile, &__item_canvas, GLCD_COLOR_WHITE, 255, bIsNewFrame); - //arm_2d_draw_box(ptTile, &__item_canvas, 1, GLCD_COLOR_WHITE, 255); - - arm_2d_fill_colour_with_a1_mask(ptTile, - &__centre_region, - ptileIcon, - (__arm_2d_color_t){GLCD_COLOR_BLACK}); - } else { - arm_2d_fill_colour_with_a1_mask(ptTile, - &__centre_region, - ptileIcon, - (__arm_2d_color_t){GLCD_COLOR_WHITE}); - } + arm_2d_fill_colour_with_a1_mask(ptTile, + &__centre_region, + ptileIcon, + (__arm_2d_color_t){GLCD_COLOR_WHITE}); } @@ -488,7 +432,14 @@ user_scene_mono_icon_menu_t *__arm_2d_scene_mono_icon_menu_init( arm_2d_scene_ .tFontColour = GLCD_COLOR_WHITE, .tBackgroundColour = GLCD_COLOR_BLACK, - .bIgnoreBackground = true, + //.bIgnoreBackground = true, + + .bUseMonochromeMode = true, + .bShowScrollingBar = true, + .chScrollingBarAutoDisappearTimeX100Ms = 10, + .ScrollingBar.tColour = GLCD_COLOR_WHITE, + .bPlaceScrollingBarOnTopOrLeft = true, + //.bUsePIMode = true, //.bDisableRingMode = true, /* you can disable the list ring mode here */ @@ -505,9 +456,6 @@ user_scene_mono_icon_menu_t *__arm_2d_scene_mono_icon_menu_init( arm_2d_scene_ .tTextAlignment = ARM_2D_ALIGN_MIDDLE_LEFT, .fnOnDrawListItem = &__arm_2d_icon_list_draw_list_core_item, - /* draw list cover */ - //.fnOnDrawListCover = &__arm_2d_list_draw_cover, - .bUseDirtyRegion = true, .ptTargetScene = &this.use_as__arm_2d_scene_t, } diff --git a/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_icon_menu.h b/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_icon_menu.h index 42e62d15c..d34e1506b 100644 --- a/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_icon_menu.h +++ b/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_icon_menu.h @@ -84,11 +84,12 @@ struct user_scene_mono_icon_menu_t { ARM_PRIVATE( /* place your private member here, following two are examples */ - int64_t lTimestamp[2]; - bool bUserAllocated; + int64_t lTimestamp[1]; + uint8_t bUserAllocated : 1; + uint8_t bRedrawLabel : 1; icon_list_t tList; - arm_2d_helper_dirty_region_item_t tDirtyRegionItems[2]; + arm_2d_helper_dirty_region_item_t tDirtyRegionItems[1]; ) /* place your public member here */ diff --git a/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_list.c b/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_list.c index 4092367ef..539fed3f8 100644 --- a/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_list.c +++ b/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_list.c @@ -189,7 +189,7 @@ static void __on_scene_mono_list_frame_complete(arm_2d_scene_t *ptScene) user_scene_mono_list_t *ptThis = (user_scene_mono_list_t *)ptScene; ARM_2D_UNUSED(ptThis); -#if 1 +#if 0 /* switch to next scene after 7s */ if (arm_2d_helper_is_time_out(7000, &this.lTimestamp[0])) { arm_2d_scene_player_switch_to_next_scene(ptScene->ptPlayer); diff --git a/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_loading.c b/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_loading.c index db810ad03..a0df15307 100644 --- a/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_loading.c +++ b/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_loading.c @@ -168,7 +168,7 @@ static void __on_scene_mono_loading_frame_complete(arm_2d_scene_t *ptScene) user_scene_mono_loading_t *ptThis = (user_scene_mono_loading_t *)ptScene; ARM_2D_UNUSED(ptThis); -#if 1 +#if 0 /* switch to next scene after 13s */ if (arm_2d_helper_is_time_out(13000, &this.lTimestamp[0])) { arm_2d_scene_player_switch_to_next_scene(ptScene->ptPlayer); diff --git a/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_tracking_list.c b/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_tracking_list.c new file mode 100644 index 000000000..99453afd2 --- /dev/null +++ b/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_tracking_list.c @@ -0,0 +1,395 @@ +/* + * 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 ======================================*/ + +#define __USER_SCENE_MONO_TRACKING_LIST_IMPLEMENT__ +#include "arm_2d_scene_mono_tracking_list.h" + +#if defined(RTE_Acceleration_Arm_2D_Helper_PFB) + +#include +#include + +#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 "-Wimplicit-int-conversion" +#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 +struct { + implement(arm_2d_user_font_t); + arm_2d_char_idx_t tUTF8Table; +} ARM_2D_FONT_Arial14_A8, + ARM_2D_FONT_Arial14_A4, + ARM_2D_FONT_Arial14_A2, + ARM_2D_FONT_Arial14_A1; + +/*============================ PROTOTYPES ====================================*/ +/*============================ LOCAL VARIABLES ===============================*/ + +/*! 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, + 0 /* initialize at runtime later */ + ), + + /* 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 = 0, + .iHeight = 8, + }, + ), + +END_IMPL_ARM_2D_REGION_LIST(s_tDirtyRegions) + +/*============================ IMPLEMENTATION ================================*/ + +static void __on_scene_mono_tracking_list_load(arm_2d_scene_t *ptScene) +{ + user_scene_mono_tracking_list_t *ptThis = (user_scene_mono_tracking_list_t *)ptScene; + ARM_2D_UNUSED(ptThis); + +} + +static void __after_scene_mono_tracking_list_switching(arm_2d_scene_t *ptScene) +{ + user_scene_mono_tracking_list_t *ptThis = (user_scene_mono_tracking_list_t *)ptScene; + ARM_2D_UNUSED(ptThis); + +} + +static void __on_scene_mono_tracking_list_depose(arm_2d_scene_t *ptScene) +{ + user_scene_mono_tracking_list_t *ptThis = (user_scene_mono_tracking_list_t *)ptScene; + ARM_2D_UNUSED(ptThis); + + ptScene->ptPlayer = NULL; + + arm_foreach(int64_t,this.lTimestamp, ptItem) { + *ptItem = 0; + } + + text_tracking_list_depose(&this.tList); + + if (!this.bUserAllocated) { + __arm_2d_free_scratch_memory(ARM_2D_MEM_TYPE_UNSPECIFIED, ptScene); + } +} + +/*----------------------------------------------------------------------------* + * Scene mono_tracking_list * + *----------------------------------------------------------------------------*/ + +static void __on_scene_mono_tracking_list_background_start(arm_2d_scene_t *ptScene) +{ + user_scene_mono_tracking_list_t *ptThis = (user_scene_mono_tracking_list_t *)ptScene; + ARM_2D_UNUSED(ptThis); + +} + +static void __on_scene_mono_tracking_list_background_complete(arm_2d_scene_t *ptScene) +{ + user_scene_mono_tracking_list_t *ptThis = (user_scene_mono_tracking_list_t *)ptScene; + ARM_2D_UNUSED(ptThis); + +} + + +static void __on_scene_mono_tracking_list_frame_start(arm_2d_scene_t *ptScene) +{ + user_scene_mono_tracking_list_t *ptThis = (user_scene_mono_tracking_list_t *)ptScene; + ARM_2D_UNUSED(ptThis); + + do { + /* generate a new position every 2000 sec */ + if (arm_2d_helper_is_time_out(1000, &this.lTimestamp[1])) { + int32_t nSteps = 0; + this.lTimestamp[1] = 0; + srand(arm_2d_helper_get_system_timestamp()); + nSteps = rand() % 10; + + text_tracking_list_move_selection(&this.tList, nSteps - 5, 200); + } + } while(0); + + text_tracking_list_on_frame_start(&this.tList); +} + +static void __on_scene_mono_tracking_list_frame_complete(arm_2d_scene_t *ptScene) +{ + user_scene_mono_tracking_list_t *ptThis = (user_scene_mono_tracking_list_t *)ptScene; + ARM_2D_UNUSED(ptThis); + +#if 0 + /* switch to next scene after 7s */ + if (arm_2d_helper_is_time_out(7000, &this.lTimestamp[0])) { + arm_2d_scene_player_switch_to_next_scene(ptScene->ptPlayer); + } +#endif +} + +static void __before_scene_mono_tracking_list_switching_out(arm_2d_scene_t *ptScene) +{ + user_scene_mono_tracking_list_t *ptThis = (user_scene_mono_tracking_list_t *)ptScene; + ARM_2D_UNUSED(ptThis); + +} + +static +IMPL_PFB_ON_DRAW(__pfb_draw_scene_mono_tracking_list_handler) +{ + ARM_2D_PARAM(pTarget); + ARM_2D_PARAM(ptTile); + ARM_2D_PARAM(bIsNewFrame); + + user_scene_mono_tracking_list_t *ptThis = (user_scene_mono_tracking_list_t *)pTarget; + arm_2d_size_t tScreenSize = ptTile->tRegion.tSize; + ARM_2D_UNUSED(tScreenSize); + + arm_2d_canvas(ptTile, __top_canvas) { + arm_2d_layout(__top_canvas) { + + __item_line_dock_vertical(10) { + + arm_2d_fill_colour(ptTile, &__item_region, GLCD_COLOR_WHITE); + + /* print label */ + 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(&__item_region); + arm_lcd_text_set_display_mode(ARM_2D_DRW_PATH_MODE_COMP_FG_COLOUR); + + arm_lcd_printf_label(ARM_2D_ALIGN_MIDDLE_LEFT, " Month"); + arm_lcd_printf_label(ARM_2D_ALIGN_MIDDLE_RIGHT, "_x"); + } + + __item_line_dock_vertical(4, /* left margin */ + 4, /* right margin */ + 2, /* top margin */ + 2) { /* bottom margin */ + + /* draw text list */ + arm_2d_dock_with_margin(__item_region, + 0, /* left margin */ + 0, /* right margin */ + 0, /* top margin */ + 0) {/* bottom margin */ + + arm_lcd_text_set_display_mode(ARM_2D_DRW_PATH_MODE_COMP_FG_COLOUR); + while(arm_fsm_rt_cpl != text_tracking_list_show( &this.tList, + ptTile, + &__dock_region, + bIsNewFrame)); + } + } + } + } + ARM_2D_OP_WAIT_ASYNC(); + + return arm_fsm_rt_cpl; +} + +ARM_NONNULL(1) +user_scene_mono_tracking_list_t *__arm_2d_scene_mono_tracking_list_init( + arm_2d_scene_player_t *ptDispAdapter, + user_scene_mono_tracking_list_t *ptThis) +{ + bool bUserAllocated = false; + assert(NULL != ptDispAdapter); + + if (NULL == ptThis) { + ptThis = (user_scene_mono_tracking_list_t *) + __arm_2d_allocate_scratch_memory( sizeof(user_scene_mono_tracking_list_t), + __alignof__(user_scene_mono_tracking_list_t), + ARM_2D_MEM_TYPE_UNSPECIFIED); + assert(NULL != ptThis); + if (NULL == ptThis) { + return NULL; + } + } else { + bUserAllocated = true; + } + + memset(ptThis, 0, sizeof(user_scene_mono_tracking_list_t)); + + *ptThis = (user_scene_mono_tracking_list_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_mono_tracking_list_load, + .fnScene = &__pfb_draw_scene_mono_tracking_list_handler, + //.fnAfterSwitch = &__after_scene_mono_tracking_list_switching, + + /* if you want to use predefined dirty region list, please uncomment the following code */ + //.ptDirtyRegion = (arm_2d_region_list_item_t *)s_tDirtyRegions, + + + //.fnOnBGStart = &__on_scene_mono_tracking_list_background_start, + //.fnOnBGComplete = &__on_scene_mono_tracking_list_background_complete, + .fnOnFrameStart = &__on_scene_mono_tracking_list_frame_start, + //.fnBeforeSwitchOut = &__before_scene_mono_tracking_list_switching_out, + .fnOnFrameCPL = &__on_scene_mono_tracking_list_frame_complete, + .fnDepose = &__on_scene_mono_tracking_list_depose, + + .bUseDirtyRegionHelper = true, + }, + .bUserAllocated = bUserAllocated, + }; + + /* ------------ initialize members of user_scene_mono_tracking_list_t begin ---------------*/ + + /* initialize text list */ + do { + const static __disp_string_t c_strListItemStrings[] = { + " 1 January", " 2 February", " 3 March", " 4 April", " 5 May", " 6 June", + " 7 July", " 8 August", " 9 September", " 10 October", " 11 November", " 12 December", + }; + + text_tracking_list_cfg_t tCFG = { + //.tSettings = { + + .bIndicatorAutoSize = true, + .tIndicator.tColour = GLCD_COLOR_WHITE, + + //}, + + .use_as__text_list_cfg_t = { + .ptStrings = (__disp_string_t *)c_strListItemStrings, + + .use_as____simple_list_cfg_t = { + .hwCount = dimof(c_strListItemStrings), + + .tFontColour = GLCD_COLOR_WHITE, + .tBackgroundColour = GLCD_COLOR_BLACK, + + .bUseMonochromeMode = true, + .bShowScrollingBar = true, + .chScrollingBarAutoDisappearTimeX100Ms = 10, + .ScrollingBar.tColour = GLCD_COLOR_WHITE, + .bUsePIMode = true, + + + //.bIgnoreBackground = true, + + //.bDisableRingMode = true, /* you can disable the list ring mode here */ + + .chNextPadding = 1, + .chPreviousPadding = 1, + .tListSize = { + .iHeight = 0, /* automatically set the height */ + .iWidth = 0, /* automatically set the width */ + }, + .tTextAlignment = ARM_2D_ALIGN_MIDDLE_LEFT, + + .ptFont = (arm_2d_font_t *)&ARM_2D_FONT_6x8, + + .bUseDirtyRegion = true, + .ptTargetScene = &this.use_as__arm_2d_scene_t, + }, + }, + }; + text_tracking_list_init( + &this.tList, + &tCFG, + &ARM_2D_LIST_CALCULATOR_NORMAL_FIXED_SIZED_ITEM_NO_STATUS_CHECK_VERTICAL); + + //text_tracking_list_move_selection(&this.tList, 0, 0); + + } while(0); + + /* ------------ initialize members of user_scene_mono_tracking_list_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 + + diff --git a/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_tracking_list.h b/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_tracking_list.h new file mode 100644 index 000000000..61b28735c --- /dev/null +++ b/examples/[template][pico][oled]/RTE/Acceleration/arm_2d_scene_mono_tracking_list.h @@ -0,0 +1,120 @@ +/* + * 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_MONO_TRACKING_LIST_H__ +#define __ARM_2D_SCENE_MONO_TRACKING_LIST_H__ + +/*============================ INCLUDES ======================================*/ + +#if defined(_RTE_) +# include "RTE_Components.h" +#endif + +#if defined(RTE_Acceleration_Arm_2D_Helper_PFB) + +#include "arm_2d_helper.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_MONO_TRACKING_LIST_IMPLEMENT__ +# define __ARM_2D_IMPL__ +#endif +#ifdef __USER_SCENE_MONO_TRACKING_LIST_INHERIT__ +# define __ARM_2D_INHERIT__ +#endif +#include "arm_2d_utils.h" + +/*============================ MACROFIED FUNCTIONS ===========================*/ + +/*! + * \brief initalize scene_mono_tracking_list 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_mono_tracking_list_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_mono_tracking_list_t* the user_scene_mono_tracking_list_t instance + */ +#define arm_2d_scene_mono_tracking_list_init(__DISP_ADAPTER_PTR, ...) \ + __arm_2d_scene_mono_tracking_list_init((__DISP_ADAPTER_PTR), (NULL, ##__VA_ARGS__)) + +/*============================ TYPES =========================================*/ +/*! + * \brief a user class for scene mono_tracking_list + */ +typedef struct user_scene_mono_tracking_list_t user_scene_mono_tracking_list_t; + +struct user_scene_mono_tracking_list_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; + + text_tracking_list_t tList; +) + + /* place your public member here */ +}; + +/*============================ GLOBAL VARIABLES ==============================*/ +/*============================ PROTOTYPES ====================================*/ + +ARM_NONNULL(1) +extern +user_scene_mono_tracking_list_t *__arm_2d_scene_mono_tracking_list_init( + arm_2d_scene_player_t *ptDispAdapter, + user_scene_mono_tracking_list_t *ptScene); + +#if defined(__clang__) +# pragma clang diagnostic pop +#elif __IS_COMPILER_GCC__ +# pragma GCC diagnostic pop +#endif + +#undef __USER_SCENE_MONO_TRACKING_LIST_IMPLEMENT__ +#undef __USER_SCENE_MONO_TRACKING_LIST_INHERIT__ + +#ifdef __cplusplus +} +#endif + +#endif + +#endif diff --git a/examples/[template][pico][oled]/RTE/Device/RP2040_Core0/rp2040.sct b/examples/[template][pico][oled]/RTE/Device/RP2040_Core0/rp2040.sct index 6906f4aa4..2f272d9b4 100644 --- a/examples/[template][pico][oled]/RTE/Device/RP2040_Core0/rp2040.sct +++ b/examples/[template][pico][oled]/RTE/Device/RP2040_Core0/rp2040.sct @@ -30,7 +30,7 @@ ; *----------------------------------------------------------------------------*/ #define __STACK_SIZE 0x00000C00 -#define __HEAP_SIZE 0x00000800 +#define __HEAP_SIZE 0x00001000 /* ;------------- <<< end of configuration section >>> --------------------------- diff --git a/examples/[template][pico][oled]/main.c b/examples/[template][pico][oled]/main.c index 09c076bc0..b51411504 100644 --- a/examples/[template][pico][oled]/main.c +++ b/examples/[template][pico][oled]/main.c @@ -108,43 +108,86 @@ void scene_mono_icon_menu_loader(void) arm_2d_scene_mono_icon_menu_init(&DISP0_ADAPTER); } -typedef void scene_loader_t(void); - -static scene_loader_t * const c_SceneLoaders[] = { +void scene_mono_tracking_list_loader(void) +{ + arm_2d_scene_mono_tracking_list_init(&DISP0_ADAPTER); +} - scene_mono_loading_loader, - scene_mono_histogram_loader, - scene_mono_clock_loader, - scene_mono_list_loader, - scene_mono_icon_menu_loader, +typedef struct demo_scene_t { + int32_t nLastInMS; + void (*fnLoader)(void); +} demo_scene_t; + +static demo_scene_t const c_SceneLoaders[] = { + + { + 13000, + scene_mono_loading_loader, + }, + { + 5000, + scene_mono_histogram_loader, + }, + { + 5000, + scene_mono_clock_loader, + }, + { + 7000, + scene_mono_list_loader, + }, + { + 15000, + scene_mono_tracking_list_loader, + }, + { + 12000, + scene_mono_icon_menu_loader, + }, }; +static +struct { + int8_t chIndex; + bool bIsTimeout; + int32_t nDelay; + int64_t lTimeStamp; + +} s_tDemoCTRL = { + .chIndex = -1, + .bIsTimeout = true, +}; /* load scene one by one */ void before_scene_switching_handler(void *pTarget, arm_2d_scene_player_t *ptPlayer, arm_2d_scene_t *ptScene) { - static int_fast8_t s_chIndex = -1; switch (arm_2d_scene_player_get_switching_status(&DISP0_ADAPTER)) { case ARM_2D_SCENE_SWITCH_STATUS_MANUAL_CANCEL: - s_chIndex--; + s_tDemoCTRL.chIndex--; break; default: - s_chIndex++; + s_tDemoCTRL.chIndex++; break; } - if (s_chIndex >= dimof(c_SceneLoaders)) { - s_chIndex = 0; - } else if (s_chIndex < 0) { - s_chIndex += dimof(c_SceneLoaders); + if (s_tDemoCTRL.chIndex >= dimof(c_SceneLoaders)) { + s_tDemoCTRL.chIndex = 0; + } else if (s_tDemoCTRL.chIndex < 0) { + s_tDemoCTRL.chIndex += dimof(c_SceneLoaders); } /* call loader */ - c_SceneLoaders[s_chIndex](); - + arm_with(const demo_scene_t, &c_SceneLoaders[s_tDemoCTRL.chIndex]) { + if (_->nLastInMS > 0) { + s_tDemoCTRL.bIsTimeout = false; + s_tDemoCTRL.lTimeStamp = 0; + s_tDemoCTRL.nDelay = _->nLastInMS; + } + _->fnLoader(); + } } int main(void) @@ -189,6 +232,14 @@ int main(void) disp_adapter0_task(); #endif #endif + if (!s_tDemoCTRL.bIsTimeout) { + + if (arm_2d_helper_is_time_out(s_tDemoCTRL.nDelay, &s_tDemoCTRL.lTimeStamp)) { + s_tDemoCTRL.bIsTimeout = true; + + arm_2d_scene_player_switch_to_next_scene(&DISP0_ADAPTER); + } + } } //return 0; } diff --git a/examples/[template][pico][oled]/pico_template.uvoptx b/examples/[template][pico][oled]/pico_template.uvoptx index 324462590..ec1acf706 100644 --- a/examples/[template][pico][oled]/pico_template.uvoptx +++ b/examples/[template][pico][oled]/pico_template.uvoptx @@ -165,22 +165,6 @@ 0x1000F6C6 - - 1 - 0 - 1 - 1 -
0
- 0 - 0 - 0 - 0 - 0 - 0 - .\main.c - - -
C:\Users\gabriel\AppData\Local\Arm\Packs\ARM\CMSIS-View\1.2.0\EventRecorder\EventRecorder.scvd @@ -261,7 +245,7 @@ BSP - 1 + 0 0 0 0 @@ -305,7 +289,7 @@ ::Acceleration - 1 + 0 0 0 1 diff --git a/examples/[template][pico][oled]/pico_template.uvprojx b/examples/[template][pico][oled]/pico_template.uvprojx index 2c76a84a8..20a2bf291 100644 --- a/examples/[template][pico][oled]/pico_template.uvprojx +++ b/examples/[template][pico][oled]/pico_template.uvprojx @@ -443,19 +443,19 @@ - + - + - + @@ -467,31 +467,31 @@ - + - + - + - + - + @@ -527,8 +527,8 @@ - - + + @@ -555,23 +555,23 @@ RTE\Acceleration\SquareDigits.c - + - + RTE\Acceleration\arm_2d.c - + - + RTE\Acceleration\arm_2d_cfg.h - + @@ -619,7 +619,7 @@ RTE\Acceleration\arm_2d_scene_mono_clock.c - + @@ -627,7 +627,7 @@ RTE\Acceleration\arm_2d_scene_mono_clock.h - + @@ -635,7 +635,7 @@ RTE\Acceleration\arm_2d_scene_mono_histogram.c - + @@ -643,23 +643,23 @@ RTE\Acceleration\arm_2d_scene_mono_histogram.h - + - + RTE\Acceleration\arm_2d_scene_mono_icon_menu.c - + - + RTE\Acceleration\arm_2d_scene_mono_icon_menu.h - + @@ -667,7 +667,7 @@ RTE\Acceleration\arm_2d_scene_mono_list.c - + @@ -675,7 +675,7 @@ RTE\Acceleration\arm_2d_scene_mono_list.h - + @@ -683,7 +683,7 @@ RTE\Acceleration\arm_2d_scene_mono_loading.c - + @@ -691,7 +691,23 @@ RTE\Acceleration\arm_2d_scene_mono_loading.h - + + + + + + + + RTE\Acceleration\arm_2d_scene_mono_tracking_list.c + + + + + + + + RTE\Acceleration\arm_2d_scene_mono_tracking_list.h + @@ -699,7 +715,7 @@ RTE\Acceleration\img2c.py - + @@ -707,7 +723,7 @@ RTE\Acceleration\ttf2c.py - +