Skip to content

Commit eacea37

Browse files
laurensvalkschodet
andcommitted
pybricks.parameters.Image: Clear display on first use.
This cancels the animation and clears the screen when the user first accesses a screen method for drawing. Fixes pybricks/support#2585 Co-authored-by: Nicolas Schodet <nico@ni.fr.eu.org>
1 parent fb16a2a commit eacea37

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
## [Unreleased]
66

7+
### Fixed
8+
- Fixed EV3 screen animation not closing on user display actions ([support#2585]).
9+
10+
[support#1382]: https://github.com/pybricks/support/issues/2585
11+
712
## [4.0.0b6] - 2026-02-19
813

914
### Added

pybricks/parameters/pb_type_image.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include <pbio/image.h>
2222
#include <pbio/int_math.h>
23+
#include <pbio/light_animation.h>
2324

2425
#include <pbdrv/display.h>
2526

@@ -63,7 +64,7 @@ static int get_color(mp_obj_t obj) {
6364
mp_obj_t pb_type_Image_display_obj_new(void) {
6465
pb_type_Image_obj_t *self = mp_obj_malloc(pb_type_Image_obj_t, &pb_type_Image);
6566
self->owner = MP_OBJ_NULL;
66-
self->display_type = PB_TYPE_IMAGE_DISPLAY_READY;
67+
self->display_type = PB_TYPE_IMAGE_DISPLAY_UNUSED;
6768
self->image = *pbdrv_display_get_image();
6869

6970
return MP_OBJ_FROM_PTR(self);
@@ -172,6 +173,18 @@ static void pb_type_Image_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
172173
dest[0] = mp_obj_new_int(self->image.height);
173174
return;
174175
}
176+
177+
// If this is the first time the user accesses any screen methods,
178+
// give control to the user and stop system animations.
179+
if (self->display_type == PB_TYPE_IMAGE_DISPLAY_UNUSED) {
180+
// At the moment, platforms with a display have at most one
181+
// animation so we can use the generic stop all method. In the
182+
// future, we could tie animations to a screen or image instance.
183+
pbio_light_animation_stop_all();
184+
pbio_image_fill(&self->image, get_color(MP_OBJ_FROM_PTR(&pb_Color_WHITE_obj)));
185+
pbdrv_display_update();
186+
self->display_type = PB_TYPE_IMAGE_DISPLAY_READY;
187+
}
175188
}
176189
// Attribute not found, continue lookup in locals dict.
177190
dest[1] = MP_OBJ_SENTINEL;

0 commit comments

Comments
 (0)