Skip to content

Commit

Permalink
updated pins to use the universal mp_hal_pin_obj_t
Browse files Browse the repository at this point in the history
use mp_hal_get_pin_obj instead of the stm32 specific pin_find
use MP_HAL_PIN_FMT for printing the pin objects on all platforms
  • Loading branch information
peterzuger committed Sep 20, 2022
1 parent 653b43e commit 5a84233
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tlc5947/tlc5947.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@

#include "py/obj.h"
#include "py/runtime.h"
#include "pin.h"
#include "spi.h"
#include "py/mphal.h"

#include "color.h"

Expand Down Expand Up @@ -143,8 +143,8 @@ typedef struct _tlc5947_tlc5947_obj_t{
mp_obj_base_t base;

const spi_t* spi; // spi peripheral to use
const pin_obj_t* blank; // blank high -> all outputs off
const pin_obj_t* xlat; // low -> high transition GSR shift
mp_hal_pin_obj_t blank; // blank high -> all outputs off
mp_hal_pin_obj_t xlat; // low -> high transition GSR shift

uint8_t buffer[36]; // buffer for the led colors
uint8_t id_map[8]; // led index to id map
Expand Down Expand Up @@ -938,8 +938,8 @@ mp_obj_t tlc5947_tlc5947_make_new(const mp_obj_type_t *type,
self->base.type = &tlc5947_tlc5947_type;

self->spi = spi_from_mp_obj(args[0]);
self->xlat = pin_find(args[1]);
self->blank = pin_find(args[2]);
self->xlat = mp_hal_get_pin_obj(args[1]);
self->blank = mp_hal_get_pin_obj(args[2]);

memset(self->buffer, 0, 36);
memset(&self->data, 0, sizeof(self->data));
Expand All @@ -965,8 +965,8 @@ mp_obj_t tlc5947_tlc5947_make_new(const mp_obj_type_t *type,
STATIC void tlc5947_tlc5947_print(const mp_print_t *print,
mp_obj_t self_in,mp_print_kind_t kind){
tlc5947_tlc5947_obj_t *self = MP_OBJ_TO_PTR(self_in);
mp_printf(print, "tlc5947(xlat=%d:%d, blank=%d:%d, length=%d)",
self->xlat->port, self->xlat->pin, self->blank->port, self->blank->pin);
mp_printf(print, "tlc5947(xlat=" MP_HAL_PIN_FMT ", blank=" MP_HAL_PIN_FMT ", length=%d)",
self->xlat, self->blank);
}

/**
Expand Down

0 comments on commit 5a84233

Please sign in to comment.