summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/2lib/2ui_screens.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/firmware/2lib/2ui_screens.c b/firmware/2lib/2ui_screens.c
index fd1d5d2b..cda9400b 100644
--- a/firmware/2lib/2ui_screens.c
+++ b/firmware/2lib/2ui_screens.c
@@ -60,7 +60,6 @@ static vb2_error_t power_off_action(struct vb2_ui_context *ui)
* current_page is valid in prev and next actions, and the back_item is assigned
* to a correct menu item index.
*/
-/* TODO(b/174127808): Split out enabling/disabling buttons. */
static vb2_error_t log_page_init(struct vb2_ui_context *ui)
{
@@ -68,6 +67,7 @@ static vb2_error_t log_page_init(struct vb2_ui_context *ui)
ui->state->current_page = 0;
+ /* TODO(b/174127808): Split out enabling/disabling buttons. */
if (ui->state->page_count == 1) {
VB2_SET_BIT(ui->state->disabled_item_mask,
screen->page_up_item);
@@ -83,50 +83,50 @@ static vb2_error_t log_page_init(struct vb2_ui_context *ui)
return VB2_SUCCESS;
}
-static vb2_error_t log_page_prev_action(struct vb2_ui_context *ui)
+static vb2_error_t log_page_update(struct vb2_ui_context *ui,
+ const char *new_log_string)
{
const struct vb2_screen_info *screen = ui->state->screen;
- /* Validity check. */
- if (ui->state->current_page == 0)
- return VB2_SUCCESS;
-
- ui->state->current_page--;
-
- /* Clear bits of page down. */
- if (ui->state->current_page != ui->state->page_count - 1)
- VB2_CLR_BIT(ui->state->disabled_item_mask,
- screen->page_down_item);
-
- /* Disable page up at the first page. */
+ if (new_log_string) {
+ ui->state->page_count = vb2ex_prepare_log_screen(
+ screen->id, ui->locale_id, new_log_string);
+ if (ui->state->page_count == 0)
+ return VB2_ERROR_UI_LOG_INIT;
+ if (ui->state->current_page >= ui->state->page_count)
+ ui->state->current_page = ui->state->page_count - 1;
+ ui->force_display = 1;
+ }
+ VB2_CLR_BIT(ui->state->disabled_item_mask, screen->page_up_item);
+ VB2_CLR_BIT(ui->state->disabled_item_mask, screen->page_down_item);
if (ui->state->current_page == 0)
VB2_SET_BIT(ui->state->disabled_item_mask,
screen->page_up_item);
+ if (ui->state->current_page == ui->state->page_count - 1)
+ VB2_SET_BIT(ui->state->disabled_item_mask,
+ screen->page_down_item);
return VB2_SUCCESS;
}
-static vb2_error_t log_page_next_action(struct vb2_ui_context *ui)
+static vb2_error_t log_page_prev_action(struct vb2_ui_context *ui)
{
- const struct vb2_screen_info *screen = ui->state->screen;
-
/* Validity check. */
- if (ui->state->current_page == ui->state->page_count - 1)
+ if (ui->state->current_page == 0)
return VB2_SUCCESS;
- ui->state->current_page++;
-
- /* Clear bits of page up. */
- if (ui->state->current_page != 0)
- VB2_CLR_BIT(ui->state->disabled_item_mask,
- screen->page_up_item);
+ ui->state->current_page--;
+ return log_page_update(ui, NULL);
+}
- /* Disable page down at the last page. */
+static vb2_error_t log_page_next_action(struct vb2_ui_context *ui)
+{
+ /* Validity check. */
if (ui->state->current_page == ui->state->page_count - 1)
- VB2_SET_BIT(ui->state->disabled_item_mask,
- screen->page_down_item);
+ return VB2_SUCCESS;
- return VB2_SUCCESS;
+ ui->state->current_page++;
+ return log_page_update(ui, NULL);
}
#define PAGE_UP_ITEM ((struct vb2_menu_item){ \