diff --git a/docs/documentation.md b/docs/documentation.md index dc5297ed66fb76ed1cbb21a3e5be7db509e33248..91e1064e256d98a0dbec01fe5a63f4cdc8cce8fa 100644 --- a/docs/documentation.md +++ b/docs/documentation.md @@ -211,7 +211,6 @@ hal ├── CMakeLists.txt ├── include │ ├── hal.h -│ ├── hal_lcd.h │ └── hal_pmu.h ├── readme.md └── source @@ -219,7 +218,7 @@ hal │ ├── audio │ ├── camera │ ├── cmsis_device - │ ├── lcd + │ ├── display │ ├── npu │ ├── npu_ta │ ├── platform_pmu diff --git a/docs/sections/customizing.md b/docs/sections/customizing.md index 2fa24641a4ee06bec5d9c234231bc7ca64bd9b4d..6be77a8db91006d5307689b20829ee5041c2c4c1 100644 --- a/docs/sections/customizing.md +++ b/docs/sections/customizing.md @@ -545,8 +545,8 @@ However, for clarity, here is the full list of available functions: The HAL exposes LCD functions to print text or an image to the board LCD. For example: -- `hal_lcd_display_text` -- `hal_lcd_display_image` +- `hal_display_show_text` +- `hal_display_show_image` Text presentation function has the following signature: @@ -563,7 +563,7 @@ Here is an example that prints "Hello world" on the LCD screen: ```C++ std::string hello("Hello world"); -hal_lcd_display_text(hello.c_str(), hello.size(), 10, 35, 0); +hal_display_show_text(hello.c_str(), hello.size(), 10, 35, 0); ``` The image presentation function has the following signature: @@ -580,7 +580,7 @@ For example, the following code snippet visualizes an input tensor data for `Mob by a factor of two: ```C++ -hal_lcd_display_image((uint8_t *) inputTensor->data.data, 224, 224, 3, 10, 35, 2); +hal_display_show_image((uint8_t *) inputTensor->data.data, 224, 224, 3, 10, 35, 2); ``` Please refer to the [Hardware Abstraction Layer API](./customizing.md#hardware-abstraction-layer-api) section for more @@ -720,13 +720,13 @@ the MPS3 platform implementation has: ```cmake target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC - lcd_mps3) + hal_display_mps3) ``` The implementation for simple platform on the other hand has: ```cmake target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC - lcd_stubs) + hal_display_stubs) ``` The standard output (stdout) component follows the same convention. It can expose three targets: diff --git a/source/application/main/UseCaseCommonUtils.cc b/source/application/main/UseCaseCommonUtils.cc index c788a739341115446369a84d323fb6c77266b581..f72f821ef98e3349fefc9dd50fe9bd091a0958b3 100644 --- a/source/application/main/UseCaseCommonUtils.cc +++ b/source/application/main/UseCaseCommonUtils.cc @@ -34,7 +34,7 @@ namespace app { constexpr uint32_t dataPsnTxtYIncr = 16; /* Row index increment. */ - hal_lcd_set_text_color(COLOR_GREEN); + hal_display_set_text_color(COLOR_GREEN); /* Display each result. */ uint32_t rowIdx1 = dataPsnTxtStartY1 + 2 * dataPsnTxtYIncr; @@ -48,12 +48,12 @@ namespace app { std::to_string(results[i].m_labelIdx) + " (" + std::to_string(results[i].m_normalisedVal) + ")"; - hal_lcd_display_text( + hal_display_show_text( resultStr.c_str(), resultStr.size(), dataPsnTxtStartX1, rowIdx1, false); rowIdx1 += dataPsnTxtYIncr; resultStr = std::to_string(i + 1) + ") " + results[i].m_label; - hal_lcd_display_text(resultStr.c_str(), resultStr.size(), dataPsnTxtStartX2, rowIdx2, 0); + hal_display_show_text(resultStr.c_str(), resultStr.size(), dataPsnTxtStartX2, rowIdx2, 0); rowIdx2 += dataPsnTxtYIncr; info("%" PRIu32 ") %" PRIu32 " (%f) -> %s\n", diff --git a/source/hal/CMakeLists.txt b/source/hal/CMakeLists.txt index 220dbeb7da5e95e09c5f31e5dda9ae4ddd2e13a0..4472826d3cea94241e81ae4588278b6f4e438255 100644 --- a/source/hal/CMakeLists.txt +++ b/source/hal/CMakeLists.txt @@ -58,7 +58,7 @@ add_subdirectory(${PLATFORM_DRIVERS_DIR} ${CMAKE_BINARY_DIR}/platform_driver) target_link_libraries(${HAL_TARGET} PUBLIC mlek_log # Logging functions - lcd_iface # LCD interface + hal_display_iface # Display interface platform_drivers # Platform drivers implementing the required interfaces ) diff --git a/source/hal/include/hal.h b/source/hal/include/hal.h index ec8532a36ccbebcc5a03decac1d426841ef7fa7d..994f70858dd9c51b85f416285ec6333c5752699b 100644 --- a/source/hal/include/hal.h +++ b/source/hal/include/hal.h @@ -31,7 +31,7 @@ extern "C" { #include "platform_drivers.h" /* Platform drivers */ #include "hal_pmu.h" /* Timer/profiler API */ -#include "hal_lcd.h" /* LCD functions */ +#include "hal_display.h" /* Display interface */ #include "hal_audio.h" /* Audio interface */ #include "hal_camera.h" /* Camera interface */ diff --git a/source/hal/include/hal_lcd.h b/source/hal/include/hal_lcd.h deleted file mode 100644 index de465be7c387b85e44ea0f0930dc5430a19111f6..0000000000000000000000000000000000000000 --- a/source/hal/include/hal_lcd.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright 2021-2022 Arm Limited and/or its affiliates - * 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 - * - * http://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 HAL_LCD_H -#define HAL_LCD_H -/** - * This file is the top level abstraction for the LCD related functions - **/ - -#include "lcd_img.h" - -#include -#include -#include - -/** - * See lcd_img.h for function docstrings. - * In the following macro definitions: - * d = data (pointer) - * w = width - * h = height - * c = channels - * x = x position - * y = y position - * s = down-sample factor (images) - * m = allow multiple lines (text) - * cl = colour - */ -#define hal_lcd_init() lcd_init() -#define hal_lcd_display_image(d,w,h,c,x,y,s) lcd_display_image(d,w,h,c,x,y,s) -#define hal_lcd_display_text(s,l,x,y,m) lcd_display_text(s,l,x,y,m) -#define hal_lcd_display_box(x,y,w,h,cl) lcd_display_box(x,y,w,h,cl) -#define hal_lcd_clear(cl) lcd_clear(cl) -#define hal_lcd_set_text_color(cl) lcd_set_text_color(cl) - -#endif /* HAL_LCD_H */ diff --git a/source/hal/source/components/lcd/CMakeLists.txt b/source/hal/source/components/display/CMakeLists.txt similarity index 59% rename from source/hal/source/components/lcd/CMakeLists.txt rename to source/hal/source/components/display/CMakeLists.txt index d87c4d9ecc0476bba4fe8aefae75228ac87e0153..109bf4bbf4b3a14e7c42dfac28e89318906183c0 100644 --- a/source/hal/source/components/lcd/CMakeLists.txt +++ b/source/hal/source/components/display/CMakeLists.txt @@ -22,42 +22,41 @@ cmake_minimum_required(VERSION 3.21.0) -project(lcd_component - DESCRIPTION "LCD support library" +project(display_component + DESCRIPTION "Display support library" LANGUAGES C CXX ASM) # Add top level interface library -set(LCD_IFACE_TARGET lcd_iface) -add_library(${LCD_IFACE_TARGET} INTERFACE) -target_include_directories(${LCD_IFACE_TARGET} INTERFACE include) +set(DISPLAY_IFACE_TARGET hal_display_iface) +add_library(${DISPLAY_IFACE_TARGET} INTERFACE) +target_include_directories(${DISPLAY_IFACE_TARGET} INTERFACE include) # Create static library for MPS3 LCD -set(LCD_MPS3_COMPONENT_TARGET lcd_mps3) -add_library(${LCD_MPS3_COMPONENT_TARGET} STATIC) +set(DISPLAY_MPS3_TARGET hal_display_mps3) +add_library(${DISPLAY_MPS3_TARGET} STATIC) set(CLCD_CONFIG_BASE "0x4930A000" CACHE STRING "LCD configuration base address") -option(LCD_TITLE_EN "Enables display of title string on LCD" ON) +option(DISPLAY_TITLE_EN "Enables display of title string on LCD" ON) -if (LCD_TITLE_EN) - set(LCD_TITLE_STRING "Arm ML Embedded Evaluation Kit" CACHE STRING "Title string") +if (DISPLAY_TITLE_EN) + set(DISPLAY_TITLE_STRING "Arm ML Embedded Evaluation Kit" CACHE STRING "Title string") endif() ## Include directories - private -target_include_directories(${LCD_MPS3_COMPONENT_TARGET} - PRIVATE - source) +target_include_directories(${DISPLAY_MPS3_TARGET} PRIVATE + source + source/glcd_mps3) ## Component sources -target_sources(${LCD_MPS3_COMPONENT_TARGET} - PRIVATE +target_sources(${DISPLAY_MPS3_TARGET} PRIVATE source/glcd_mps3/glcd_mps3.c - source/lcd_img.c) + source/glcd_mps3/hal_display_mps3.c) # Compile definitions -target_compile_definitions(${LCD_MPS3_COMPONENT_TARGET} +target_compile_definitions(${DISPLAY_MPS3_TARGET} PRIVATE CLCD_CONFIG_BASE=${CLCD_CONFIG_BASE} - $<$:LCD_TITLE_STRING=\"${LCD_TITLE_STRING}\">) + $<$:DISPLAY_TITLE_STRING=\"${DISPLAY_TITLE_STRING}\">) ## Logging utilities: if (NOT TARGET mlek_log) @@ -68,38 +67,31 @@ if (NOT TARGET mlek_log) endif() ## Add dependencies -target_link_libraries(${LCD_MPS3_COMPONENT_TARGET} PUBLIC - ${LCD_IFACE_TARGET} +target_link_libraries(${DISPLAY_MPS3_TARGET} PUBLIC + ${DISPLAY_IFACE_TARGET} mlek_log) # Display status message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR}) message(STATUS "*******************************************************") -message(STATUS "Library : " ${LCD_MPS3_COMPONENT_TARGET}) +message(STATUS "Library: " ${DISPLAY_MPS3_TARGET}) message(STATUS "*******************************************************") # Create static library for LCD Stubs -set(LCD_STUBS_COMPONENT_TARGET lcd_stubs) -add_library(${LCD_STUBS_COMPONENT_TARGET} STATIC) - -## Include directories - private -target_include_directories(${LCD_STUBS_COMPONENT_TARGET} - PRIVATE - source) +set(DISPLAY_STUBS_TARGET hal_display_stubs) +add_library(${DISPLAY_STUBS_TARGET} STATIC) ## Component sources -target_sources(${LCD_STUBS_COMPONENT_TARGET} - PRIVATE - source/glcd_stubs/glcd_stubs.c - source/lcd_img.c) +target_sources(${DISPLAY_STUBS_TARGET} PRIVATE + source/hal_display_stubs.c) ## Add dependencies -target_link_libraries(${LCD_STUBS_COMPONENT_TARGET} PUBLIC - ${LCD_IFACE_TARGET} +target_link_libraries(${DISPLAY_STUBS_TARGET} PUBLIC + ${DISPLAY_IFACE_TARGET} mlek_log) # Display status -message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR}) +message(STATUS "CMAKE_CURRENT_SOURCE_DIR:" ${CMAKE_CURRENT_SOURCE_DIR}) message(STATUS "*******************************************************") -message(STATUS "Library : " ${LCD_STUBS_COMPONENT_TARGET}) +message(STATUS "Library: " ${DISPLAY_STUBS_TARGET}) message(STATUS "*******************************************************") diff --git a/source/hal/source/components/lcd/include/lcd_img.h b/source/hal/source/components/display/include/hal_display.h similarity index 65% rename from source/hal/source/components/lcd/include/lcd_img.h rename to source/hal/source/components/display/include/hal_display.h index f6f9e6409259a00f3b0926d22e3bbc59de5422ec..d647ad36d8ae8d5b3e7dc80ffb5e02fa58451924 100644 --- a/source/hal/source/components/lcd/include/lcd_img.h +++ b/source/hal/source/components/display/include/hal_display.h @@ -1,5 +1,6 @@ /* - * SPDX-FileCopyrightText: Copyright 2021-2022 Arm Limited and/or its affiliates + * SPDX-FileCopyrightText: Copyright 2021-2022, 2025 Arm Limited and/or + * its affiliates * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17,15 +18,57 @@ #ifndef LCD_IMG_H #define LCD_IMG_H +#if defined(__cplusplus) +extern "C" { +#endif + #include #include #include +/**< Image colour formats supported by this interface */ +typedef enum hal_display_colour_format_ { + HAL_DISPLAY_COLOUR_FORMAT_ARGB8888 = 0, + HAL_DISPLAY_COLOUR_FORMAT_RGB888, + HAL_DISPLAY_COLOUR_FORMAT_RGB565, + HAL_DISPLAY_COLOUR_FORMAT_INVALID +} hal_display_clr_format; + +typedef struct hal_display_device { + const char name[16]; + uint32_t hor_res; + uint32_t ver_res; + uint32_t bytes_per_pixel; + hal_display_clr_format colour_format; + bool initialized; +} hal_display_dev; + /** * @brief Initialise the LCD * @return 0 if successful, error code otherwise. **/ -int lcd_init(void); +int hal_display_init(void); + +/** + * @brief Configures the display + * @param[in] width Horizontal resolution + * @param[in] height Vertical resolution + * @param[in] format Colour format + * @return 0 if successful, error code otherwise. + */ +int hal_display_configure(uint32_t width, uint32_t height, hal_display_clr_format format); + +/** + * @brief Gets horizontal resolution of the display + * @return Width of display + */ +uint32_t hal_display_get_width(void); + +/** + * @brief Gets vertical resolution of the display + * @return Height of display + */ +uint32_t hal_display_get_height(void); /** * @brief Display a given image on the LCD. This allows displaying 8 bit @@ -40,7 +83,7 @@ int lcd_init(void); * downsampled. * @return 0 if successful, non-zero otherwise. **/ -int lcd_display_image(const uint8_t* data, const uint32_t width, +int hal_display_show_image(const uint8_t* data, const uint32_t width, const uint32_t height, const uint32_t channels, const uint32_t pos_x, const uint32_t pos_y, const uint32_t downsample_factor); @@ -57,7 +100,7 @@ int lcd_display_image(const uint8_t* data, const uint32_t width, * they don't fit in one. * @return 0 if successful, non-zero otherwise. **/ -int lcd_display_text(const char* str, const size_t str_sz, +int hal_display_show_text(const char* str, const size_t str_sz, const uint32_t pos_x, const uint32_t pos_y, const bool allow_multiple_lines); @@ -70,7 +113,7 @@ int lcd_display_text(const char* str, const size_t str_sz, * @param[in] color Fill color. * @return 0 if successful, non-zero otherwise. **/ -int lcd_display_box(const uint32_t pos_x, const uint32_t pos_y, +int hal_display_show_box(const uint32_t pos_x, const uint32_t pos_y, const uint32_t width, const uint32_t height, const uint16_t color); /** @@ -78,13 +121,17 @@ int lcd_display_box(const uint32_t pos_x, const uint32_t pos_y, * @param[in] color Fill color. * @return 0 if successful, non-zero otherwise. **/ -int lcd_clear(const uint16_t color); +int hal_display_clear(const uint16_t color); /** * @brief Set text color. * @param[in] color Fill color. * @return 0 if successful, non-zero otherwise. **/ -int lcd_set_text_color(const uint16_t color); +int hal_display_set_text_color(const uint16_t color); + +#if defined(__cplusplus) +} +#endif #endif /* LCD_IMG_H */ diff --git a/source/hal/source/components/lcd/source/glcd_mps3/font_9x15_h.h b/source/hal/source/components/display/source/font_9x15_h.h similarity index 99% rename from source/hal/source/components/lcd/source/glcd_mps3/font_9x15_h.h rename to source/hal/source/components/display/source/font_9x15_h.h index 9474f0b8d50e32cddd9e6a23d7d74812043c5ae1..81a51069f30e21d0752afa95f60bce43a38e2889 100644 --- a/source/hal/source/components/lcd/source/glcd_mps3/font_9x15_h.h +++ b/source/hal/source/components/display/source/font_9x15_h.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright 2021 Arm Limited and/or its affiliates + * SPDX-FileCopyrightText: Copyright 2021, 2025 Arm Limited and/or its affiliates * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/source/hal/source/components/lcd/source/glcd.h b/source/hal/source/components/display/source/glcd_mps3/glcd.h similarity index 98% rename from source/hal/source/components/lcd/source/glcd.h rename to source/hal/source/components/display/source/glcd_mps3/glcd.h index 2cde0e773aefda5fa1a3679d63561be2af39c61d..9e8a57e7706dbf517468828ba0c0987a2992304f 100644 --- a/source/hal/source/components/lcd/source/glcd.h +++ b/source/hal/source/components/display/source/glcd_mps3/glcd.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright 2021-2022 Arm Limited and/or its affiliates + * SPDX-FileCopyrightText: Copyright 2021-2022, 2025 Arm Limited and/or its affiliates * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/source/hal/source/components/lcd/source/glcd_mps3/glcd_mps3.c b/source/hal/source/components/display/source/glcd_mps3/glcd_mps3.c similarity index 100% rename from source/hal/source/components/lcd/source/glcd_mps3/glcd_mps3.c rename to source/hal/source/components/display/source/glcd_mps3/glcd_mps3.c diff --git a/source/hal/source/components/display/source/glcd_mps3/hal_display_mps3.c b/source/hal/source/components/display/source/glcd_mps3/hal_display_mps3.c new file mode 100644 index 0000000000000000000000000000000000000000..a794efcb19cbd0cae3e4b03f4f7ce63a3394a336 --- /dev/null +++ b/source/hal/source/components/display/source/glcd_mps3/hal_display_mps3.c @@ -0,0 +1,223 @@ +/* + * SPDX-FileCopyrightText: Copyright 2022-2025 Arm Limited and/or + * its affiliates + * 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 + * + * http://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. + */ +#include "hal_display.h" +#include "log_macros.h" +#include "glcd.h" + +#include +#include + +static hal_display_dev dev = { + .name = "MPS3 GLCD", + .hor_res = 0, + .ver_res = 0, + .bytes_per_pixel = 0, + .colour_format = HAL_DISPLAY_COLOUR_FORMAT_INVALID, + .initialized = false, +}; + +static hal_display_dev* get_display_device(void) +{ + return &dev; +} + +static int show_title(void) +{ + int ret = 0; +#if defined(DISPLAY_TITLE_STRING) + const char *title = DISPLAY_TITLE_STRING; + if (get_display_device()->initialized) { + hal_display_set_text_color(White); + ret = hal_display_show_text(title, strlen(title), 10, 0, false); + } +#endif /* DISPLAY_TITLE_STRING */ + return ret; +} + +int hal_display_init(void) +{ + GLCD_Initialize(); + get_display_device()->initialized = true; + hal_display_configure(GLCD_WIDTH, GLCD_HEIGHT, HAL_DISPLAY_COLOUR_FORMAT_RGB565); + GLCD_Clear(Black); + return show_title(); +} + +int hal_display_configure(uint32_t width, uint32_t height, hal_display_clr_format format) +{ + hal_display_dev* dev = get_display_device(); + if (!dev->initialized) { + return -1; + } + + dev->hor_res = width; + dev->ver_res = height; + + char fmt_str[16]; + memset(fmt_str, 0, sizeof(fmt_str)); + + switch (format) { + case HAL_DISPLAY_COLOUR_FORMAT_RGB565: + strncpy(fmt_str, "RGB565", sizeof(fmt_str) - 1); + dev->bytes_per_pixel = 2; + break; + case HAL_DISPLAY_COLOUR_FORMAT_RGB888: + strncpy(fmt_str, "RGB888", sizeof(fmt_str) - 1); + dev->bytes_per_pixel = 3; + break; + case HAL_DISPLAY_COLOUR_FORMAT_ARGB8888: + strncpy(fmt_str, "ARGB8888", sizeof(fmt_str) - 1); + dev->bytes_per_pixel = 4; + break; + default: + printf_err("Unsupported colour format\n"); + return -3; + } + + dev->colour_format = format; + dev->initialized = true; + + info("Device %s configured\n", dev->name); + info("Resolution: %" PRIu32 " x %" PRIu32 "\n", dev->hor_res, dev->ver_res); + info("Colour format: %s\n", fmt_str); + return 0; +} + +uint32_t hal_display_get_width(void) +{ + hal_display_dev* dev = get_display_device(); + if (dev->initialized) { + return dev->hor_res; + } + return 0; +} + +uint32_t hal_display_get_height(void) +{ + hal_display_dev* dev = get_display_device(); + if (dev->initialized) { + return dev->ver_res; + } + return 0; +} + +int hal_display_show_image(const uint8_t* data, const uint32_t width, + const uint32_t height, const uint32_t channels, + const uint32_t pos_x, const uint32_t pos_y, + const uint32_t downsample_factor) +{ + /* Health checks */ + hal_display_dev* dev = get_display_device(); + assert(dev->initialized); + if ((pos_x + width/downsample_factor > dev->hor_res) || + (pos_y + height/downsample_factor > dev->ver_res)) { + printf_err("Invalid image size for given location!\n"); + return 1; + } + + if (1 == channels || 3 == channels) { + GLCD_Image(data, width, height, channels, pos_x, pos_y, + downsample_factor); + } else { + printf_err("Only single and three channel images are supported!\n"); + return 1; + } + + return 0; +} + +int hal_display_show_text(const char* str, const size_t str_sz, + const uint32_t pos_x, const uint32_t pos_y, + const bool allow_multiple_lines) +{ + hal_display_dev* dev = get_display_device(); + assert(dev->initialized); + + /* We use a font 0 which is 9x15. */ + const uint32_t x_span = 9; /* Each character is this 9 pixels "wide". */ + const uint32_t y_span = 15; /* Each character is this 15 pixels "high". */ + + if (str_sz == 0) { + return 1; + } + + /* If not within the LCD bounds, return error. */ + if (pos_x + x_span > dev->hor_res || pos_y + y_span > dev->ver_res) { + return 1; + } else { + const unsigned char font_idx = 0; /* We are using the custom font = 0 */ + + const uint32_t col = pos_x/x_span; + const uint32_t max_cols = dev->hor_res/x_span - 1; + const uint32_t max_lines = dev->ver_res/y_span - 1; + + uint32_t i = 0; + uint32_t current_line = pos_y/y_span; + uint32_t current_col = col; + + /* Display the string on the LCD. */ + for (i = 0; i < str_sz; ++i) { + + if (allow_multiple_lines) { + + /* If the next character won't fit. */ + if (current_col > max_cols) { + current_col = col; + + /* If the next line won't fit. */ + if (++current_line > max_lines) { + return 1; + } + } + } + + GLCD_DisplayChar(current_line, current_col++, font_idx, str[i]); + } + } + return 0; +} + +int hal_display_show_box(const uint32_t pos_x, const uint32_t pos_y, + const uint32_t width, const uint32_t height, const uint16_t color) +{ + hal_display_dev* dev = get_display_device(); + assert(dev->initialized); + + /* If not within the LCD bounds, return error. */ + if (pos_x > dev->hor_res || pos_y > dev->ver_res) { + return 1; + } + GLCD_Box(pos_x, pos_y, width, height, color); + return 0; +} + +int hal_display_clear(const uint16_t color) +{ + assert(get_display_device()->initialized); + GLCD_Clear(color); + GLCD_SetBackColor(color); + GLCD_SetTextColor(White); + return show_title(); +} + +int hal_display_set_text_color(const uint16_t color) +{ + assert(get_display_device()->initialized); + GLCD_SetTextColor(color); + return 0; +} diff --git a/source/hal/source/components/display/source/hal_display_stubs.c b/source/hal/source/components/display/source/hal_display_stubs.c new file mode 100644 index 0000000000000000000000000000000000000000..b66ac60610d3fce3c2e33586c91a672c2b5385cb --- /dev/null +++ b/source/hal/source/components/display/source/hal_display_stubs.c @@ -0,0 +1,112 @@ +/* + * SPDX-FileCopyrightText: Copyright 2022-2025 Arm Limited and/or + * its affiliates + * 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 + * + * http://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. + */ +#include "hal_display.h" +#include "log_macros.h" + +static hal_display_dev dev = { + .name = "display stub", + .hor_res = 0, + .ver_res = 0, + .bytes_per_pixel = 0, + .colour_format = HAL_DISPLAY_COLOUR_FORMAT_INVALID, + .initialized = false, +}; + +__attribute__((weak)) int hal_display_init(void) +{ + dev.initialized = true; + return 0; +} + +__attribute__((weak)) int hal_display_configure(uint32_t width, + uint32_t height, + hal_display_clr_format format) +{ + dev.hor_res = width; + dev.ver_res = height; + dev.colour_format = format; + return 0; +} + +__attribute__((weak)) uint32_t hal_display_get_width(void) +{ + return dev.hor_res; +} + +__attribute__((weak)) uint32_t hal_display_get_height(void) +{ + return dev.ver_res; +} + +__attribute__((weak)) int hal_display_show_image( + const uint8_t* data, const uint32_t width, + const uint32_t height, const uint32_t channels, + const uint32_t pos_x, const uint32_t pos_y, + const uint32_t downsample_factor) +{ + UNUSED(data); + UNUSED(pos_x); + UNUSED(pos_y); + UNUSED(width); + UNUSED(height); + UNUSED(channels); + UNUSED(downsample_factor); + debug("image display: (x, y, w, h) = " + "(%" PRIu32 ", %" PRIu32 ", %" PRIu32 ", %" PRIu32 ")\n", + pos_x, pos_y, width, height); + debug("image display: channels = %" PRIu32 ", downsample factor = %" PRIu32 "\n", + channels, downsample_factor); + + return 0; +} + +__attribute__((weak)) int hal_display_show_text(const char* str, const size_t str_sz, + const uint32_t pos_x, const uint32_t pos_y, + const bool allow_multiple_lines) +{ + UNUSED(str); + UNUSED(pos_x); + UNUSED(pos_y); + UNUSED(allow_multiple_lines); + UNUSED(str_sz); + debug("text display: %s\n", str); + return 0; +} + +__attribute__((weak)) int hal_display_show_box(const uint32_t pos_x, const uint32_t pos_y, + const uint32_t width, const uint32_t height, const uint16_t color) +{ + UNUSED(pos_x); + UNUSED(pos_y); + UNUSED(width); + UNUSED(height); + UNUSED(color); + return 0; +} + +__attribute__((weak)) int hal_display_clear(const uint16_t color) +{ + UNUSED(color); + return 0; +} + +__attribute__((weak)) int hal_display_set_text_color(const uint16_t color) +{ + UNUSED(color); + return 0; +} diff --git a/source/hal/source/components/lcd/source/glcd_stubs/glcd_stubs.c b/source/hal/source/components/lcd/source/glcd_stubs/glcd_stubs.c deleted file mode 100644 index 5c77fe2193e2045f7e265e9468a5c03e6d6d2cf2..0000000000000000000000000000000000000000 --- a/source/hal/source/components/lcd/source/glcd_stubs/glcd_stubs.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright 2021-2022, 2024 Arm Limited and/or - * its affiliates - * 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 - * - * http://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. - */ -#include "glcd.h" -#include "log_macros.h" - -#include - -void GLCD_Initialize(void) {} - -void GLCD_Bitmap(unsigned int x, unsigned int y, - unsigned int w, unsigned int h, unsigned short *bitmap) -{ - UNUSED(x); - UNUSED(y); - UNUSED(w); - UNUSED(h); - UNUSED(bitmap); -} - -void GLCD_Image(const void *data, const uint32_t width, - const uint32_t height, const uint32_t channels, - const uint32_t pos_x, const uint32_t pos_y, - const uint32_t downsample_factor) -{ - UNUSED(data); - UNUSED(pos_x); - UNUSED(pos_y); - UNUSED(width); - UNUSED(height); - UNUSED(channels); - UNUSED(downsample_factor); - debug("image display: (x, y, w, h) = " - "(%" PRIu32 ", %" PRIu32 ", %" PRIu32 ", %" PRIu32 ")\n", - pos_x, pos_y, width, height); - debug("image display: channels = %" PRIu32 ", downsample factor = %" PRIu32 "\n", - channels, downsample_factor); -} - -void GLCD_Clear(unsigned short color) -{ - UNUSED(color); -} - -void GLCD_SetTextColor(unsigned short color) -{ - UNUSED(color); -} - -void GLCD_SetBackColor(unsigned short color) -{ - UNUSED(color); -} - -void GLCD_DisplayChar (unsigned int ln, unsigned int col, unsigned char fi, - unsigned char c) -{ - UNUSED(ln); - UNUSED(col); - UNUSED(fi); - UNUSED(c); -} - -void GLCD_DisplayString(unsigned int ln, unsigned int col, unsigned char fi, - char *s) -{ - UNUSED(ln); - UNUSED(col); - UNUSED(fi); - UNUSED(s); - debug("text display: %s\n", s); -} - -void GLCD_Box(unsigned int x, unsigned int y, unsigned int w, unsigned int h, - unsigned short color) -{ - UNUSED(x); - UNUSED(y); - UNUSED(w); - UNUSED(h); - UNUSED(color); -} diff --git a/source/hal/source/components/lcd/source/lcd_img.c b/source/hal/source/components/lcd/source/lcd_img.c deleted file mode 100644 index 628e980f113346b2ffa9a017e777d89c77c4b375..0000000000000000000000000000000000000000 --- a/source/hal/source/components/lcd/source/lcd_img.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or - * its affiliates - * 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 - * - * http://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. - */ -#include "lcd_img.h" - -#include "log_macros.h" -#include "glcd.h" - -#include -#include - -static int show_title(void) -{ - int ret = 0; -#if defined(LCD_TITLE_STRING) - const char *title = LCD_TITLE_STRING; - lcd_set_text_color(White); - ret = lcd_display_text(title, strlen(title), 10, 0, false); -#endif /* LCD_TITLE_STRING */ - return ret; -} - -int lcd_init(void) -{ - GLCD_Initialize(); - GLCD_Clear(Black); - return show_title(); -} - -int lcd_display_image(const uint8_t* data, const uint32_t width, - const uint32_t height, const uint32_t channels, - const uint32_t pos_x, const uint32_t pos_y, - const uint32_t downsample_factor) -{ - /* Health checks */ - assert(data); - if ((pos_x + width/downsample_factor > GLCD_WIDTH) || - (pos_y + height/downsample_factor > GLCD_HEIGHT)) { - printf_err("Invalid image size for given location!\n"); - return 1; - } - - if (1 == channels || 3 == channels) { - GLCD_Image(data, width, height, channels, pos_x, pos_y, - downsample_factor); - } else { - printf_err("Only single and three channel images are supported!\n"); - return 1; - } - - return 0; -} - -int lcd_display_text(const char* str, const size_t str_sz, - const uint32_t pos_x, const uint32_t pos_y, - const bool allow_multiple_lines) -{ - /* We use a font 0 which is 9x15. */ - const uint32_t x_span = 9; /* Each character is this 9 pixels "wide". */ - const uint32_t y_span = 15; /* Each character is this 15 pixels "high". */ - - if (str_sz == 0) { - return 1; - } - - /* If not within the LCD bounds, return error. */ - if (pos_x + x_span > GLCD_WIDTH || pos_y + y_span > GLCD_HEIGHT) { - return 1; - } else { - const unsigned char font_idx = 0; /* We are using the custom font = 0 */ - - const uint32_t col = pos_x/x_span; - const uint32_t max_cols = GLCD_WIDTH/x_span - 1; - const uint32_t max_lines = GLCD_HEIGHT/y_span - 1; - - uint32_t i = 0; - uint32_t current_line = pos_y/y_span; - uint32_t current_col = col; - - /* Display the string on the LCD. */ - for (i = 0; i < str_sz; ++i) { - - if (allow_multiple_lines) { - - /* If the next character won't fit. */ - if (current_col > max_cols) { - current_col = col; - - /* If the next line won't fit. */ - if (++current_line > max_lines) { - return 1; - } - } - } - - GLCD_DisplayChar(current_line, current_col++, font_idx, str[i]); - } - } - return 0; -} - -int lcd_display_box(const uint32_t pos_x, const uint32_t pos_y, - const uint32_t width, const uint32_t height, const uint16_t color) -{ - /* If not within the LCD bounds, return error. */ - if (pos_x > GLCD_WIDTH || pos_y > GLCD_HEIGHT) { - return 1; - } - else { - GLCD_Box(pos_x, pos_y, width, height, color); - } - return 0; -} - -int lcd_clear(const uint16_t color) -{ - GLCD_Clear(color); - GLCD_SetBackColor(color); - GLCD_SetTextColor(White); - return show_title(); -} - -int lcd_set_text_color(const uint16_t color) -{ - GLCD_SetTextColor(color); - return 0; -} diff --git a/source/hal/source/hal.c b/source/hal/source/hal.c index f2f4df9035849a3e706948ab3389655e23507080..9760de352a022733f195cbfd5b71344b9ac66904 100644 --- a/source/hal/source/hal.c +++ b/source/hal/source/hal.c @@ -29,15 +29,15 @@ bool hal_platform_init(void) return false; } + /* Initialise PMU */ + hal_pmu_init(); + /* Initialise LCD */ - if (0 != hal_lcd_init()) { - printf_err("hal_lcd_init failed\n"); + if (0 != hal_display_init()) { + printf_err("hal_display_init failed\n"); return false; } - /* Initialise PMU */ - hal_pmu_init(); - return true; } diff --git a/source/hal/source/platform/mps3/CMakeLists.txt b/source/hal/source/platform/mps3/CMakeLists.txt index c895beee062b523eb73b16ab13a1af4c46bd79ed..daf1f3f1e4feabf78185e39d507f64085c917d33 100644 --- a/source/hal/source/platform/mps3/CMakeLists.txt +++ b/source/hal/source/platform/mps3/CMakeLists.txt @@ -118,8 +118,8 @@ add_subdirectory(${COMPONENTS_DIR}/cmsis_device ${CMAKE_BINARY_DIR}/cmsis_device ## Platform component: stdout add_subdirectory(${COMPONENTS_DIR}/stdout ${CMAKE_BINARY_DIR}/stdout) -## Platform component: lcd -add_subdirectory(${COMPONENTS_DIR}/lcd ${CMAKE_BINARY_DIR}/lcd) +## Platform component: display +add_subdirectory(${COMPONENTS_DIR}/display ${CMAKE_BINARY_DIR}/display) ## Platform component: PMU add_subdirectory(${COMPONENTS_DIR}/platform_pmu ${CMAKE_BINARY_DIR}/platform_pmu) @@ -148,7 +148,7 @@ target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC mlek_log cmsis_device platform_pmu - lcd_mps3 + hal_display_mps3 hal_audio_static_streams $,hal_camera_vsi,hal_camera_static_images> $<$>:stdout_retarget_cmsdk>) diff --git a/source/hal/source/platform/mps3/include/platform_drivers.h b/source/hal/source/platform/mps3/include/platform_drivers.h index eab22db62747333dbc6ba80e1945f37818a5da3f..32b90c5440bdbc96a07d43a40ba7464e4c0c0663 100644 --- a/source/hal/source/platform/mps3/include/platform_drivers.h +++ b/source/hal/source/platform/mps3/include/platform_drivers.h @@ -24,7 +24,6 @@ /* Platform components */ #include "RTE_Components.h" /* For CPU related defintiions */ #include "timer_mps3.h" /* Timer functions. */ -#include "lcd_img.h" /* LCD functions. */ /** * @brief Initialises the platform components. diff --git a/source/hal/source/platform/mps4/CMakeLists.txt b/source/hal/source/platform/mps4/CMakeLists.txt index 6d527a0240a2c354182e08f6ee5bb2fafec92ef7..6af95af5c72fe2b34e720d6050d288da79e36325 100644 --- a/source/hal/source/platform/mps4/CMakeLists.txt +++ b/source/hal/source/platform/mps4/CMakeLists.txt @@ -96,8 +96,8 @@ add_subdirectory(${COMPONENTS_DIR}/cmsis_device ${CMAKE_BINARY_DIR}/cmsis_device ## Platform component: stdout add_subdirectory(${COMPONENTS_DIR}/stdout ${CMAKE_BINARY_DIR}/stdout) -## Platform component: lcd -add_subdirectory(${COMPONENTS_DIR}/lcd ${CMAKE_BINARY_DIR}/lcd) +## Platform component: display +add_subdirectory(${COMPONENTS_DIR}/display ${CMAKE_BINARY_DIR}/display) ## Platform component: PMU add_subdirectory(${COMPONENTS_DIR}/platform_pmu ${CMAKE_BINARY_DIR}/platform_pmu) @@ -126,7 +126,7 @@ target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC mlek_log cmsis_device platform_pmu - lcd_stubs + hal_display_stubs hal_audio_static_streams $,hal_camera_vsi,hal_camera_static_images> $<$>:stdout_retarget_cmsdk>) diff --git a/source/hal/source/platform/mps4/include/platform_drivers.h b/source/hal/source/platform/mps4/include/platform_drivers.h index a28b90e45674b36c5dcd7eeb5fd4dd2a81358d8c..7ea4febdbaca1d69360c10c7235e9305c3488c8e 100644 --- a/source/hal/source/platform/mps4/include/platform_drivers.h +++ b/source/hal/source/platform/mps4/include/platform_drivers.h @@ -24,7 +24,6 @@ /* Platform components */ #include "RTE_Components.h" /* For CPU related defintiions */ #include "timer_mps4.h" /* Timer functions. */ -#include "lcd_img.h" /* LCD functions. */ /** * @brief Initialises the platform components. diff --git a/source/hal/source/platform/native/CMakeLists.txt b/source/hal/source/platform/native/CMakeLists.txt index 512fb490152345ab844cbee5f072d0a9f3a74e74..8cb6a31407f2d8233f4c2fe81eeecafea199208b 100644 --- a/source/hal/source/platform/native/CMakeLists.txt +++ b/source/hal/source/platform/native/CMakeLists.txt @@ -55,8 +55,8 @@ endif() ## Platform component: stdout add_subdirectory(${COMPONENTS_DIR}/stdout ${CMAKE_BINARY_DIR}/stdout) -## Platform component: lcd -add_subdirectory(${COMPONENTS_DIR}/lcd ${CMAKE_BINARY_DIR}/lcd) +## Platform component: display +add_subdirectory(${COMPONENTS_DIR}/display ${CMAKE_BINARY_DIR}/display) ## Platform component: PMU add_subdirectory(${COMPONENTS_DIR}/platform_pmu ${CMAKE_BINARY_DIR}/platform_pmu) @@ -72,7 +72,7 @@ target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC mlek_log platform_pmu - lcd_stubs + hal_display_stubs hal_audio_static_streams hal_camera_static_images) diff --git a/source/hal/source/platform/native/include/platform_drivers.h b/source/hal/source/platform/native/include/platform_drivers.h index 25f96601d731549218baecf9773b0d9fb7977777..a56b4ae6a8983d72ddcdb1bb3e320380f11ecc7c 100644 --- a/source/hal/source/platform/native/include/platform_drivers.h +++ b/source/hal/source/platform/native/include/platform_drivers.h @@ -20,7 +20,6 @@ #define PLATFORM_DRIVERS_H #include "log_macros.h" /* Logging related helpers. */ -#include "lcd_img.h" /* LCD functions */ #include "timer_native.h" /* Native platform timer/profiler support */ /** diff --git a/source/hal/source/platform/simple/CMakeLists.txt b/source/hal/source/platform/simple/CMakeLists.txt index 83a328d7170869dc73d5ae162a1ade14104d80ba..1b432594e36e6f0113ba5af7c6b04b4e12c73f80 100644 --- a/source/hal/source/platform/simple/CMakeLists.txt +++ b/source/hal/source/platform/simple/CMakeLists.txt @@ -70,8 +70,8 @@ add_subdirectory(${COMPONENTS_DIR}/cmsis_device ${CMAKE_BINARY_DIR}/cmsis_device ## Platform component: stdout add_subdirectory(${COMPONENTS_DIR}/stdout ${CMAKE_BINARY_DIR}/stdout) -## Platform component: lcd -add_subdirectory(${COMPONENTS_DIR}/lcd ${CMAKE_BINARY_DIR}/lcd) +## Platform component: display +add_subdirectory(${COMPONENTS_DIR}/display ${CMAKE_BINARY_DIR}/display) ## Platform component: PMU add_subdirectory(${COMPONENTS_DIR}/platform_pmu ${CMAKE_BINARY_DIR}/platform_pmu) @@ -100,7 +100,7 @@ target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC cmsis_device mlek_log platform_pmu - lcd_stubs + hal_display_stubs hal_audio_static_streams hal_camera_static_images $<$>:stdout_retarget_pl011>) diff --git a/source/hal/source/platform/simple/include/platform_drivers.h b/source/hal/source/platform/simple/include/platform_drivers.h index 7aab29cb410b2068b73eaefc5dcdb048fdb5d739..c5ca2a4623df32f47469a28edc4b7c870b0c546b 100644 --- a/source/hal/source/platform/simple/include/platform_drivers.h +++ b/source/hal/source/platform/simple/include/platform_drivers.h @@ -25,7 +25,6 @@ #include "RTE_Components.h" /* For CPU related defintiions */ #include "timer_simple_platform.h" /* timer implementation */ #include "platform_pmu.h" /* PMU definitions and API */ -#include "lcd_img.h" /* LCD functions */ /** * @brief Initialises the platform components. diff --git a/source/use_case/ad/src/UseCaseHandler.cc b/source/use_case/ad/src/UseCaseHandler.cc index 31f0cf4086a8e49b1cb0656aad0e74f35e6c4c60..65f5d36a869af15b64dc37254252e8dadb4c9968 100644 --- a/source/use_case/ad/src/UseCaseHandler.cc +++ b/source/use_case/ad/src/UseCaseHandler.cc @@ -85,7 +85,7 @@ namespace app { AwaitUserInput(); // Wait for user input before moving forward. #endif /* INTERACTIVE_MODE */ - hal_lcd_clear(COLOR_BLACK); + hal_display_clear(COLOR_BLACK); uint32_t nElements = 0; hal_audio_start(); auto audioData = hal_audio_get_captured_frame(&nElements); @@ -106,7 +106,7 @@ namespace app { /* Display message on the LCD - inference running. */ std::string str_inf{"Running inference... "}; - hal_lcd_display_text( + hal_display_show_text( str_inf.c_str(), str_inf.size(), dataPsnTxtInfStartX, dataPsnTxtInfStartY, 0); /* Start sliding through audio clip. */ @@ -138,7 +138,7 @@ namespace app { /* Erase. */ str_inf = std::string(str_inf.size(), ' '); - hal_lcd_display_text( + hal_display_show_text( str_inf.c_str(), str_inf.size(), dataPsnTxtInfStartX, dataPsnTxtInfStartY, 0); ctx.Set("result", result); @@ -158,7 +158,7 @@ namespace app { constexpr uint32_t dataPsnTxtStartY1 = 30; constexpr uint32_t dataPsnTxtYIncr = 16; /* Row index increment */ - hal_lcd_set_text_color(COLOR_GREEN); + hal_display_set_text_color(COLOR_GREEN); /* Display each result */ uint32_t rowIdx1 = dataPsnTxtStartY1 + 2 * dataPsnTxtYIncr; @@ -175,7 +175,7 @@ namespace app { anomalyResult += std::string("Everything fine, no anomaly detected!"); } - hal_lcd_display_text( + hal_display_show_text( anomalyScore.c_str(), anomalyScore.size(), dataPsnTxtStartX1, rowIdx1, false); info("%s\n", anomalyScore.c_str()); diff --git a/source/use_case/asr/src/UseCaseHandler.cc b/source/use_case/asr/src/UseCaseHandler.cc index 01eac3d3a3333fe852cf6d579125f9f7f2a526e7..4436db0192f33ffd56b4fa6443cb390f03a79b5e 100644 --- a/source/use_case/asr/src/UseCaseHandler.cc +++ b/source/use_case/asr/src/UseCaseHandler.cc @@ -103,7 +103,7 @@ namespace app { AwaitUserInput(); // Wait for user input before moving forward. #endif /* INTERACTIVE_MODE */ - hal_lcd_clear(COLOR_BLACK); + hal_display_clear(COLOR_BLACK); /* Get the current audio buffer and respective size. */ uint32_t audioArrSize = 0; @@ -130,7 +130,7 @@ namespace app { /* Display message on the LCD - inference running. */ std::string str_inf{"Running inference... "}; - hal_lcd_display_text( + hal_display_show_text( str_inf.c_str(), str_inf.size(), dataPsnTxtInfStartX, dataPsnTxtInfStartY, 0); size_t inferenceWindowLen = audioDataWindowLen; @@ -183,7 +183,7 @@ namespace app { /* Erase. */ str_inf = std::string(str_inf.size(), ' '); - hal_lcd_display_text( + hal_display_show_text( str_inf.c_str(), str_inf.size(), dataPsnTxtInfStartX, dataPsnTxtInfStartY, 0); ctx.Set>("results", finalResults); @@ -204,7 +204,7 @@ namespace app { constexpr uint32_t dataPsnTxtStartY1 = 60; constexpr bool allow_multiple_lines = true; - hal_lcd_set_text_color(COLOR_GREEN); + hal_display_set_text_color(COLOR_GREEN); info("Final results:\n"); info("Total number of inferences: %zu\n", results.size()); @@ -228,11 +228,11 @@ namespace app { /* Get the decoded result for the combined result. */ std::string finalResultStr = audio::asr::DecodeOutput(combinedResults); - hal_lcd_display_text(finalResultStr.c_str(), - finalResultStr.size(), - dataPsnTxtStartX1, - dataPsnTxtStartY1, - allow_multiple_lines); + hal_display_show_text(finalResultStr.c_str(), + finalResultStr.size(), + dataPsnTxtStartX1, + dataPsnTxtStartY1, + allow_multiple_lines); info("Complete recognition: %s\n", finalResultStr.c_str()); return true; diff --git a/source/use_case/img_class/src/UseCaseHandler.cc b/source/use_case/img_class/src/UseCaseHandler.cc index b886fc9603a9e1ba7e8e771ae4a100b712ffdcc4..09808f765e24707f3fa6931f8fe75c48a4f02082 100644 --- a/source/use_case/img_class/src/UseCaseHandler.cc +++ b/source/use_case/img_class/src/UseCaseHandler.cc @@ -94,7 +94,7 @@ namespace app { AwaitUserInput(); // Wait for user input before moving forward. #endif /* INTERACTIVE_MODE */ - hal_lcd_clear(COLOR_BLACK); + hal_display_clear(COLOR_BLACK); hal_camera_start(); /* Strings for presentation/logging. */ @@ -107,16 +107,16 @@ namespace app { } /* Display this image on the LCD. */ - hal_lcd_display_image(imgSrc, - nCols, - nRows, - nChannels, - dataPsnImgStartX, - dataPsnImgStartY, - dataPsnImgDownscaleFactor); + hal_display_show_image(imgSrc, + nCols, + nRows, + nChannels, + dataPsnImgStartX, + dataPsnImgStartY, + dataPsnImgDownscaleFactor); /* Display message on the LCD - inference running. */ - hal_lcd_display_text( + hal_display_show_text( str_inf.c_str(), str_inf.size(), dataPsnTxtInfStartX, dataPsnTxtInfStartY, false); const size_t imgSz = @@ -140,7 +140,7 @@ namespace app { /* Erase. */ str_inf = std::string(str_inf.size(), ' '); - hal_lcd_display_text( + hal_display_show_text( str_inf.c_str(), str_inf.size(), dataPsnTxtInfStartX, dataPsnTxtInfStartY, false); /* Add results to context for access outside handler. */ diff --git a/source/use_case/inference_runner/src/UseCaseHandler.cc b/source/use_case/inference_runner/src/UseCaseHandler.cc index f876f88a2aaf7515e29e23a9736c18d40d9a0d6b..14047b688245207d4979166394a716e2ebeb18fb 100644 --- a/source/use_case/inference_runner/src/UseCaseHandler.cc +++ b/source/use_case/inference_runner/src/UseCaseHandler.cc @@ -142,8 +142,8 @@ bool RunInferenceHandler(ApplicationContext& ctx) std::string str_inf{"Running inference... "}; /* Display message on the LCD - inference running. */ - hal_lcd_display_text(str_inf.c_str(), str_inf.size(), - dataPsnTxtInfStartX, dataPsnTxtInfStartY, 0); + hal_display_show_text(str_inf.c_str(), str_inf.size(), + dataPsnTxtInfStartX, dataPsnTxtInfStartY, 0); if (!RunInference(model, profiler)) { return false; @@ -151,9 +151,8 @@ bool RunInferenceHandler(ApplicationContext& ctx) /* Erase. */ str_inf = std::string(str_inf.size(), ' '); - hal_lcd_display_text( - str_inf.c_str(), str_inf.size(), - dataPsnTxtInfStartX, dataPsnTxtInfStartY, 0); + hal_display_show_text(str_inf.c_str(), str_inf.size(), + dataPsnTxtInfStartX, dataPsnTxtInfStartY, 0); info("Final results:\n"); info("Total number of inferences: 1\n"); diff --git a/source/use_case/kws/src/UseCaseHandler.cc b/source/use_case/kws/src/UseCaseHandler.cc index e8da502ad422d2281d1c1d401dad1be44e611b77..69f72bc07dd1e15fa0e09ff1101e294fdd2de217 100644 --- a/source/use_case/kws/src/UseCaseHandler.cc +++ b/source/use_case/kws/src/UseCaseHandler.cc @@ -105,7 +105,7 @@ namespace app { AwaitUserInput(); // Wait for user input before moving forward. #endif /* INTERACTIVE_MODE */ - hal_lcd_clear(COLOR_BLACK); + hal_display_clear(COLOR_BLACK); uint32_t nElements = 0; hal_audio_start(); @@ -127,7 +127,7 @@ namespace app { /* Display message on the LCD - inference running. */ std::string str_inf{"Running inference... "}; - hal_lcd_display_text( + hal_display_show_text( str_inf.c_str(), str_inf.size(), dataPsnTxtInfStartX, dataPsnTxtInfStartY, 0); /* Start sliding through audio clip. */ @@ -168,7 +168,7 @@ namespace app { /* Erase. */ str_inf = std::string(str_inf.size(), ' '); - hal_lcd_display_text( + hal_display_show_text( str_inf.c_str(), str_inf.size(), dataPsnTxtInfStartX, dataPsnTxtInfStartY, false); ctx.Set>("results", finalResults); @@ -189,7 +189,7 @@ namespace app { constexpr uint32_t dataPsnTxtStartY1 = 30; constexpr uint32_t dataPsnTxtYIncr = 16; /* Row index increment. */ - hal_lcd_set_text_color(COLOR_GREEN); + hal_display_set_text_color(COLOR_GREEN); info("Final results:\n"); info("Total number of inferences: %zu\n", results.size()); @@ -210,7 +210,7 @@ namespace app { std::to_string(static_cast(score * 100)) + std::string{"%)"}; - hal_lcd_display_text( + hal_display_show_text( resultStr.c_str(), resultStr.size(), dataPsnTxtStartX1, rowIdx1, false); rowIdx1 += dataPsnTxtYIncr; diff --git a/source/use_case/kws_asr/src/UseCaseHandler.cc b/source/use_case/kws_asr/src/UseCaseHandler.cc index 244d5234e0a5c6f0dcfa6f0b63da60c06d31f024..e508b6cc924fa655ba4b99d9d7463722842035a6 100644 --- a/source/use_case/kws_asr/src/UseCaseHandler.cc +++ b/source/use_case/kws_asr/src/UseCaseHandler.cc @@ -137,7 +137,7 @@ namespace app { /* Display message on the LCD - inference running. */ std::string str_inf{"Running KWS inference... "}; - hal_lcd_display_text( + hal_display_show_text( str_inf.c_str(), str_inf.size(), dataPsnTxtInfStartX, dataPsnTxtInfStartY, false); /* Start sliding through audio clip. */ @@ -191,7 +191,7 @@ namespace app { /* Erase. */ str_inf = std::string(str_inf.size(), ' '); - hal_lcd_display_text( + hal_display_show_text( str_inf.c_str(), str_inf.size(), dataPsnTxtInfStartX, dataPsnTxtInfStartY, false); if (!PresentInferenceResult(finalResults)) { @@ -228,7 +228,7 @@ namespace app { return false; } - hal_lcd_clear(COLOR_BLACK); + hal_display_clear(COLOR_BLACK); /* Get Input and Output tensors for pre/post processing. */ auto asrInputTensor = asrModel.GetInputTensor(0); @@ -280,7 +280,7 @@ namespace app { /* Display message on the LCD - inference running. */ std::string str_inf{"Running ASR inference... "}; - hal_lcd_display_text( + hal_display_show_text( str_inf.c_str(), str_inf.size(), dataPsnTxtInfStartX, dataPsnTxtInfStartY, false); size_t asrInferenceWindowLen = asrAudioDataWindowLen; @@ -359,7 +359,7 @@ namespace app { /* Erase */ str_inf = std::string(str_inf.size(), ' '); - hal_lcd_display_text( + hal_display_show_text( str_inf.c_str(), str_inf.size(), dataPsnTxtInfStartX, dataPsnTxtInfStartY, false); } if (!PresentInferenceResult(asrResults)) { @@ -374,7 +374,7 @@ namespace app { /* KWS and ASR inference handler. */ bool ClassifyAudioHandler(ApplicationContext& ctx) { - hal_lcd_clear(COLOR_BLACK); + hal_display_clear(COLOR_BLACK); hal_audio_init(); if (!hal_audio_configure(HAL_AUDIO_MODE_SINGLE_BURST, HAL_AUDIO_FORMAT_16KHZ_MONO_16BIT)) { @@ -415,7 +415,7 @@ namespace app { constexpr uint32_t dataPsnTxtStartY1 = 30; constexpr uint32_t dataPsnTxtYIncr = 16; /* Row index increment. */ - hal_lcd_set_text_color(COLOR_GREEN); + hal_display_set_text_color(COLOR_GREEN); /* Display each result. */ uint32_t rowIdx1 = dataPsnTxtStartY1 + 2 * dataPsnTxtYIncr; @@ -434,7 +434,7 @@ namespace app { std::to_string(static_cast(score * 100)) + std::string{"%)"}; - hal_lcd_display_text( + hal_display_show_text( resultStr.c_str(), resultStr.size(), dataPsnTxtStartX1, rowIdx1, 0); rowIdx1 += dataPsnTxtYIncr; @@ -459,7 +459,7 @@ namespace app { constexpr uint32_t dataPsnTxtStartY1 = 80; constexpr bool allow_multiple_lines = true; - hal_lcd_set_text_color(COLOR_GREEN); + hal_display_set_text_color(COLOR_GREEN); /* Results from multiple inferences should be combined before processing. */ std::vector combinedResults; @@ -478,7 +478,7 @@ namespace app { std::string finalResultStr = audio::asr::DecodeOutput(combinedResults); - hal_lcd_display_text(finalResultStr.c_str(), + hal_display_show_text(finalResultStr.c_str(), finalResultStr.size(), dataPsnTxtStartX1, dataPsnTxtStartY1, diff --git a/source/use_case/noise_reduction/src/UseCaseHandler.cc b/source/use_case/noise_reduction/src/UseCaseHandler.cc index 2675f1ade688c4efa052b6063fe9b1175fcf7592..60eae7ed874c7c652cdd31444b6c35977358ee1e 100644 --- a/source/use_case/noise_reduction/src/UseCaseHandler.cc +++ b/source/use_case/noise_reduction/src/UseCaseHandler.cc @@ -97,7 +97,7 @@ namespace app { break; } - hal_lcd_clear(COLOR_BLACK); + hal_display_clear(COLOR_BLACK); auto startDumpAddress = memDumpBaseAddr + memDumpBytesWritten; @@ -151,7 +151,7 @@ namespace app { std::string str_inf{"Running inference... "}; /* Display message on the LCD - inference running. */ - hal_lcd_display_text(str_inf.c_str(), + hal_display_show_text(str_inf.c_str(), str_inf.size(), dataPsnTxtInfStartX, dataPsnTxtInfStartY, @@ -176,7 +176,7 @@ namespace app { /* Erase. */ str_inf = std::string(str_inf.size(), ' '); - hal_lcd_display_text(str_inf.c_str(), + hal_display_show_text(str_inf.c_str(), str_inf.size(), dataPsnTxtInfStartX, dataPsnTxtInfStartY, @@ -207,7 +207,7 @@ namespace app { profiler.PrintProfilingResult(); std::string clearString{' '}; - hal_lcd_display_text(clearString.c_str(), + hal_display_show_text(clearString.c_str(), clearString.size(), dataPsnTxtInfStartX, dataPsnTxtInfStartY, @@ -216,7 +216,7 @@ namespace app { std::string completeMsg{"Inference complete!"}; /* Display message on the LCD - inference complete. */ - hal_lcd_display_text(completeMsg.c_str(), + hal_display_show_text(completeMsg.c_str(), completeMsg.size(), dataPsnTxtInfStartX, dataPsnTxtInfStartY, diff --git a/source/use_case/object_detection/src/UseCaseHandler.cc b/source/use_case/object_detection/src/UseCaseHandler.cc index e960839b9153ed9b268ba3d5360789ddaaa8d90b..fe5c1db16942060cc6a0079ffbba906625a6a8e2 100644 --- a/source/use_case/object_detection/src/UseCaseHandler.cc +++ b/source/use_case/object_detection/src/UseCaseHandler.cc @@ -61,7 +61,7 @@ namespace app { constexpr uint32_t dataPsnTxtInfStartX = 20; constexpr uint32_t dataPsnTxtInfStartY = 28; - hal_lcd_clear(COLOR_BLACK); + hal_display_clear(COLOR_BLACK); auto& model = ctx.Get("model"); if (!model.IsInited()) { @@ -138,7 +138,7 @@ namespace app { } /* Display image on the LCD. */ - hal_lcd_display_image( + hal_display_show_image( (arm::app::object_detection::channelsImageDisplayed == 3) ? currImage : dstPtr, inputImgCols, inputImgRows, @@ -148,7 +148,7 @@ namespace app { dataPsnImgDownscaleFactor); /* Display message on the LCD - inference running. */ - hal_lcd_display_text( + hal_display_show_text( str_inf.c_str(), str_inf.size(), dataPsnTxtInfStartX, dataPsnTxtInfStartY, false); if (!RunInference(model, profiler)) { @@ -163,7 +163,7 @@ namespace app { /* Erase. */ str_inf = std::string(str_inf.size(), ' '); - hal_lcd_display_text( + hal_display_show_text( str_inf.c_str(), str_inf.size(), dataPsnTxtInfStartX, dataPsnTxtInfStartY, false); /* Draw boxes. */ @@ -188,7 +188,7 @@ namespace app { static bool PresentInferenceResult(const std::vector& results) { - hal_lcd_set_text_color(COLOR_GREEN); + hal_display_set_text_color(COLOR_GREEN); /* If profiling is enabled, and the time is valid. */ info("Final results:\n"); @@ -217,32 +217,32 @@ namespace app { for (const auto& result : results) { /* Top line. */ - hal_lcd_display_box(imgStartX + result.m_x0 / imgDownscaleFactor, - imgStartY + result.m_y0 / imgDownscaleFactor, - result.m_w / imgDownscaleFactor, - lineThickness, - COLOR_GREEN); + hal_display_show_box(imgStartX + result.m_x0 / imgDownscaleFactor, + imgStartY + result.m_y0 / imgDownscaleFactor, + result.m_w / imgDownscaleFactor, + lineThickness, + COLOR_GREEN); /* Bot line. */ - hal_lcd_display_box(imgStartX + result.m_x0 / imgDownscaleFactor, - imgStartY + (result.m_y0 + result.m_h) / imgDownscaleFactor - - lineThickness, - result.m_w / imgDownscaleFactor, - lineThickness, - COLOR_GREEN); + hal_display_show_box(imgStartX + result.m_x0 / imgDownscaleFactor, + imgStartY + (result.m_y0 + result.m_h) / imgDownscaleFactor - + lineThickness, + result.m_w / imgDownscaleFactor, + lineThickness, + COLOR_GREEN); /* Left line. */ - hal_lcd_display_box(imgStartX + result.m_x0 / imgDownscaleFactor, - imgStartY + result.m_y0 / imgDownscaleFactor, - lineThickness, - result.m_h / imgDownscaleFactor, - COLOR_GREEN); + hal_display_show_box(imgStartX + result.m_x0 / imgDownscaleFactor, + imgStartY + result.m_y0 / imgDownscaleFactor, + lineThickness, + result.m_h / imgDownscaleFactor, + COLOR_GREEN); /* Right line. */ - hal_lcd_display_box(imgStartX + (result.m_x0 + result.m_w) / imgDownscaleFactor - - lineThickness, - imgStartY + result.m_y0 / imgDownscaleFactor, - lineThickness, - result.m_h / imgDownscaleFactor, - COLOR_GREEN); + hal_display_show_box(imgStartX + (result.m_x0 + result.m_w) / imgDownscaleFactor - + lineThickness, + imgStartY + result.m_y0 / imgDownscaleFactor, + lineThickness, + result.m_h / imgDownscaleFactor, + COLOR_GREEN); } } diff --git a/source/use_case/vww/src/UseCaseHandler.cc b/source/use_case/vww/src/UseCaseHandler.cc index dd8b30b1d152760124677012bd20c3dc1d48380b..f939c3adcffcab532c6228939bbb9ee2b3c28a91 100644 --- a/source/use_case/vww/src/UseCaseHandler.cc +++ b/source/use_case/vww/src/UseCaseHandler.cc @@ -94,7 +94,7 @@ namespace app { AwaitUserInput(); // Wait for user input before moving forward. #endif /* INTERACTIVE_MODE */ - hal_lcd_clear(COLOR_BLACK); + hal_display_clear(COLOR_BLACK); hal_camera_start(); /* Strings for presentation/logging. */ @@ -106,16 +106,16 @@ namespace app { } /* Display this image on the LCD. */ - hal_lcd_display_image(imgSrc, - nCols, - nRows, - displayChannels, - dataPsnImgStartX, - dataPsnImgStartY, - dataPsnImgDownscaleFactor); + hal_display_show_image(imgSrc, + nCols, + nRows, + displayChannels, + dataPsnImgStartX, + dataPsnImgStartY, + dataPsnImgDownscaleFactor); /* Display message on the LCD - inference running. */ - hal_lcd_display_text( + hal_display_show_text( str_inf.c_str(), str_inf.size(), dataPsnTxtInfStartX, dataPsnTxtInfStartY, 0); const size_t imgSz = @@ -139,7 +139,7 @@ namespace app { /* Erase. */ str_inf = std::string(str_inf.size(), ' '); - hal_lcd_display_text( + hal_display_show_text( str_inf.c_str(), str_inf.size(), dataPsnTxtInfStartX, dataPsnTxtInfStartY, 0); /* Add results to context for access outside handler. */