Merge pull request #6789 from DavePutz/issue_6788

Make rotaryio object long-lived
This commit is contained in:
Jeff Epler 2022-08-21 15:31:45 -06:00 committed by GitHub
commit 65ec12afde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -74,7 +74,8 @@ STATIC mp_obj_t rotaryio_incrementalencoder_make_new(const mp_obj_type_t *type,
const mcu_pin_obj_t *pin_a = validate_obj_is_free_pin(args[ARG_pin_a].u_obj);
const mcu_pin_obj_t *pin_b = validate_obj_is_free_pin(args[ARG_pin_b].u_obj);
rotaryio_incrementalencoder_obj_t *self = m_new_obj(rotaryio_incrementalencoder_obj_t);
// Make long-lived because some implementations use a pointer to the object as interrupt-handler data.
rotaryio_incrementalencoder_obj_t *self = m_new_ll_obj(rotaryio_incrementalencoder_obj_t);
self->base.type = &rotaryio_incrementalencoder_type;
common_hal_rotaryio_incrementalencoder_construct(self, pin_a, pin_b);