-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Boards:shield:added nrf5340 audio display #11909
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
# | ||
|
||
rsource "Kconfig.defaults" | ||
rsource "display/Kconfig" | ||
|
||
menu "Modules" | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# | ||
# Copyright (c) 2023 Nordic Semiconductor ASA | ||
# | ||
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
# | ||
|
||
if (CONFIG_NRF5340_AUDIO_DK_DISPLAY) | ||
target_sources(app PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR}/nrf5340_audio_dk_display.c | ||
${CMAKE_CURRENT_SOURCE_DIR}/tab_menu.c | ||
) | ||
if (CONFIG_NRF5340_AUDIO_DK_DISPLAY_TAB_LOG) | ||
target_sources(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tab_log.c) | ||
endif() | ||
endif() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# | ||
# Copyright (c) 2023 Nordic Semiconductor ASA | ||
# | ||
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
# | ||
|
||
menuconfig NRF5340_AUDIO_DK_DISPLAY | ||
bool "Display for nRF5340 Audio DK [EXPERIMENTAL]" | ||
select EXPERIMENTAL | ||
default n | ||
|
||
if NRF5340_AUDIO_DK_DISPLAY | ||
|
||
rsource "Kconfig.defaults" | ||
|
||
module = NRF5340_AUDIO_DK_DISPLAY | ||
module-str = nrf5340_audio_dk_display | ||
source "subsys/logging/Kconfig.template.log_config" | ||
|
||
config NRF5340_AUDIO_DK_DISPLAY_TAB_LOG | ||
bool "Enable the log tab on the display" | ||
depends on LOG | ||
default y | ||
|
||
if NRF5340_AUDIO_DK_DISPLAY_TAB_LOG | ||
|
||
config NRF5340_AUDIO_DK_DISPLAY_TAB_LOG_LEVEL | ||
int "Log level for message displayed on screen" | ||
default 2 | ||
|
||
config NRF5340_AUDIO_DK_DISPLAY_TAB_LOG_TIMESTAMP | ||
bool "Display timestamp in us in front of log message" | ||
default n | ||
|
||
config NRF5340_AUDIO_DK_DISPLAY_TAB_LOG_MAX_LEN | ||
int "Number of messages to be stored" | ||
default 10 | ||
|
||
endif # NRF5340_AUDIO_DK_DISPLAY_TAB_LOG | ||
|
||
config NRF5340_AUDIO_DK_DISPLAY_TAB_MENU_UPDATE_INTERVAL_MS | ||
int "Update interval for the menu tab, in milliseconds" | ||
default 500 | ||
|
||
endif # NRF5340_AUDIO_DK_DISPLAY |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# | ||
# Copyright (c) 2023 Nordic Semiconductor ASA | ||
# | ||
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
# | ||
|
||
config DISPLAY | ||
default y | ||
|
||
config LVGL | ||
default y | ||
|
||
config LV_Z_MEM_POOL_NUMBER_BLOCKS | ||
int "Number of max size blocks in memory pool" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This type of line should not be in a .defaults file. Same on line 30. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where do you suggest they be set? They are both very necessary for the display module There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm also not sure what is the correct way for these |
||
default 8 | ||
|
||
config LV_FONT_MONTSERRAT_14 | ||
default y | ||
|
||
config LV_FONT_MONTSERRAT_48 | ||
default y | ||
|
||
config LV_FONT_MONTSERRAT_20 | ||
default y | ||
|
||
config LV_Z_VDB_SIZE | ||
int "Virtual display buffer size" | ||
default 32 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* | ||
* Copyright (c) 2023 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Newline after license |
||
|
||
#include <zephyr/device.h> | ||
#include <zephyr/devicetree.h> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Look at other .c files in the nrf5340_audio folder to see how includes are structured There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same for other .c files in this PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these not quite similar to other files? |
||
#include <zephyr/drivers/display.h> | ||
#include <zephyr/drivers/gpio.h> | ||
#include <zephyr/kernel.h> | ||
#include <zephyr/zbus/zbus.h> | ||
#include <zephyr/logging/log.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <stdint.h> | ||
|
||
#include <lvgl.h> | ||
|
||
#include "tab_menu.h" | ||
#include "tab_log.h" | ||
#include "macros_common.h" | ||
|
||
#define DISPLAY_THREAD_PRIORITY 5 | ||
/* Must have lower priority than LVGL init */ | ||
#define DISPLAY_INIT_PRIORITY 91 | ||
#define DISPLAY_THREAD_STACK_SIZE 1800 | ||
|
||
LOG_MODULE_REGISTER(display_log, CONFIG_DISPLAY_LOG_LEVEL); | ||
|
||
static struct k_thread display_data; | ||
static k_tid_t display_thread; | ||
|
||
ZBUS_CHAN_DECLARE(button_chan); | ||
ZBUS_CHAN_DECLARE(le_audio_chan); | ||
|
||
ZBUS_OBS_DECLARE(le_audio_evt_sub_display); | ||
|
||
K_THREAD_STACK_DEFINE(display_thread_STACK, DISPLAY_THREAD_STACK_SIZE); | ||
|
||
static void nrf5340_audio_dk_display_update_thread(void *arg1, void *arg2, void *arg3) | ||
{ | ||
uint64_t prev_tab_update = k_uptime_get(); | ||
|
||
while (1) { | ||
if ((k_uptime_get() - prev_tab_update) > | ||
CONFIG_NRF5340_AUDIO_DK_DISPLAY_TAB_MENU_UPDATE_INTERVAL_MS) { | ||
tab_menu_update(); | ||
prev_tab_update = k_uptime_get(); | ||
} | ||
|
||
uint32_t time_till_next = lv_timer_handler(); | ||
|
||
k_sleep(K_MSEC(time_till_next)); | ||
} | ||
} | ||
|
||
static int nrf5340_audio_dk_display_init(void) | ||
{ | ||
int ret; | ||
const struct device *display_dev; | ||
lv_obj_t *tabview; | ||
lv_obj_t *tab_menu; | ||
#ifdef CONFIG_NRF5340_AUDIO_DK_DISPLAY_TAB_LOG | ||
lv_obj_t *tab_log; | ||
#endif /* CONFIG_NRF5340_AUDIO_DK_DISPLAY_TAB_LOG */ | ||
|
||
display_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_display)); | ||
if (!device_is_ready(display_dev)) { | ||
LOG_ERR("Display not ready"); | ||
return -ENODEV; | ||
} | ||
|
||
ret = zbus_chan_add_obs(&le_audio_chan, &le_audio_evt_sub_display, K_MSEC(200)); | ||
if (ret) { | ||
LOG_ERR("Failed to add ZBus observer (%d)", ret); | ||
return ret; | ||
} | ||
|
||
ret = display_blanking_off(display_dev); | ||
if (ret) { | ||
LOG_ERR("Failed to disable display blanking (%d)", ret); | ||
return ret; | ||
} | ||
|
||
tabview = lv_tabview_create(lv_scr_act(), LV_DIR_TOP, 50); | ||
|
||
tab_menu = lv_tabview_add_tab(tabview, "Menu"); | ||
tab_menu_create(tab_menu); | ||
|
||
#ifdef CONFIG_NRF5340_AUDIO_DK_DISPLAY_TAB_LOG | ||
tab_log = lv_tabview_add_tab(tabview, "Logging"); | ||
tab_log_create(tab_log); | ||
#endif /* CONFIG_NRF5340_AUDIO_DK_DISPLAY_TAB_LOG */ | ||
|
||
lv_obj_clear_flag(lv_tabview_get_content(tabview), LV_OBJ_FLAG_SCROLLABLE); | ||
|
||
display_thread = k_thread_create(&display_data, display_thread_STACK, | ||
K_THREAD_STACK_SIZEOF(display_thread_STACK), | ||
nrf5340_audio_dk_display_update_thread, NULL, NULL, NULL, | ||
K_PRIO_PREEMPT(DISPLAY_THREAD_PRIORITY), 0, K_NO_WAIT); | ||
k_thread_name_set(display_thread, "Nrf5340_audio__dk display thread"); | ||
|
||
return 0; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Newline after } |
||
|
||
SYS_INIT(nrf5340_audio_dk_display_init, APPLICATION, DISPLAY_INIT_PRIORITY); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add back the newline