drivers: display: mb_display: Add internal reset helper
Add a helper function to reset the state of the display, and make use of it from the various public functions. This also ensures that the timer is stopped before starting a new display routine. Change-Id: I8a916b5b13c18b41b7fc3593e6d97e874ef117af Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
e129699a50
commit
0260af6372
1 changed files with 15 additions and 6 deletions
|
@ -202,21 +202,26 @@ static struct mb_display display = {
|
|||
.timer = K_TIMER_INITIALIZER(display.timer, show_row, clear_display),
|
||||
};
|
||||
|
||||
static void reset_display(struct mb_display *disp)
|
||||
{
|
||||
k_timer_stop(&disp->timer);
|
||||
|
||||
disp->str = NULL;
|
||||
disp->scroll = SCROLL_OFF;
|
||||
}
|
||||
|
||||
void mb_display_image(struct mb_display *disp, const struct mb_image *img,
|
||||
int32_t duration)
|
||||
{
|
||||
disp->str = NULL;
|
||||
disp->scroll = SCROLL_OFF;
|
||||
disp->duration = duration;
|
||||
reset_display(disp);
|
||||
|
||||
disp->duration = duration;
|
||||
start_image(disp, img);
|
||||
}
|
||||
|
||||
void mb_display_stop(struct mb_display *disp)
|
||||
{
|
||||
k_timer_stop(&disp->timer);
|
||||
disp->str = NULL;
|
||||
disp->scroll = SCROLL_OFF;
|
||||
reset_display(disp);
|
||||
}
|
||||
|
||||
void mb_display_char(struct mb_display *disp, char chr, int32_t duration)
|
||||
|
@ -237,6 +242,8 @@ void mb_display_string(struct mb_display *disp, int32_t duration,
|
|||
return;
|
||||
}
|
||||
|
||||
reset_display(disp);
|
||||
|
||||
disp->str = &disp->str_buf[1];
|
||||
disp->duration = duration;
|
||||
disp->scroll = SCROLL_OFF;
|
||||
|
@ -256,6 +263,8 @@ void mb_display_print(struct mb_display *disp, const char *fmt, ...)
|
|||
return;
|
||||
}
|
||||
|
||||
reset_display(disp);
|
||||
|
||||
if (disp->str_buf[1] == '\0') {
|
||||
disp->str = NULL;
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue