Cleanup
This commit is contained in:
parent
2f277eba3e
commit
9fa3feffb1
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 Jeff Epler for Adafruit Industries
|
||||
* Copyright (c) 2021 Mark Komus
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 Jeff Epler for Adafruit Industries
|
||||
* Copyright (c) 2021 Mark Komus
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -29,10 +29,9 @@
|
|||
#include "py/runtime.h"
|
||||
#include "py/objarray.h"
|
||||
|
||||
// #include "common-hal/is31fl3741/is31fl3741.h"
|
||||
#include "shared-bindings/is31fl3741/is31fl3741.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "shared-bindings/microcontroller/__init__.h"
|
||||
// #include "shared-bindings/microcontroller/Pin.h"
|
||||
// #include "shared-bindings/microcontroller/__init__.h"
|
||||
#include "shared-bindings/util.h"
|
||||
#include "shared-module/displayio/__init__.h"
|
||||
#include "shared-module/framebufferio/__init__.h"
|
||||
|
@ -40,46 +39,19 @@
|
|||
#include "shared-bindings/busio/I2C.h"
|
||||
|
||||
//| class is31fl3741:
|
||||
//| """Displays an in-memory framebuffer to a HUB75-style RGB LED matrix."""
|
||||
//| """Displays an in-memory framebuffer to a IS31FL3741 drive display."""
|
||||
//|
|
||||
|
||||
// extern Protomatter_core *_PM_protoPtr;
|
||||
|
||||
|
||||
//| def __init__(self, *, width: int) -> None:
|
||||
//| """Create a Is31fl3741 object with the given attributes. The height of
|
||||
//| the display is determined by the number of rgb and address pins and the number of tiles:
|
||||
//| ``len(rgb_pins) // 3 * 2 ** len(address_pins) * abs(tile)``. With 6 RGB pins, 4
|
||||
//| address lines, and a single matrix, the display will be 32 pixels tall. If the optional height
|
||||
//| parameter is specified and is not 0, it is checked against the calculated
|
||||
//| height.
|
||||
//| """Create a Is31fl3741 object with the given attributes.
|
||||
//|
|
||||
//| Up to 30 RGB pins and 8 address pins are supported.
|
||||
//|
|
||||
//| The RGB pins must be within a single "port" and performance and memory
|
||||
//| usage are best when they are all within "close by" bits of the port.
|
||||
//| The clock pin must also be on the same port as the RGB pins. See the
|
||||
//| documentation of the underlying protomatter C library for more
|
||||
//| information. Generally, Adafruit's interface boards are designed so
|
||||
//| that these requirements are met when matched with the intended
|
||||
//| microcontroller board. For instance, the Feather M4 Express works
|
||||
//| together with the RGB Matrix Feather.
|
||||
//|
|
||||
//| The framebuffer is in "RGB565" format.
|
||||
//|
|
||||
//| "RGB565" means that it is organized as a series of 16-bit numbers
|
||||
//| where the highest 5 bits are interpreted as red, the next 6 as
|
||||
//| green, and the final 5 as blue. The object can be any buffer, but
|
||||
//| `array.array` and ``ulab.ndarray`` objects are most often useful.
|
||||
//| To update the content, modify the framebuffer and call refresh.
|
||||
//| The framebuffer is in "RGB888" format using 4 bytes per pixel.
|
||||
//| Bits 24-31 are ignored. The format is in RGB order.
|
||||
//|
|
||||
//| If a framebuffer is not passed in, one is allocated and initialized
|
||||
//| to all black. In any case, the framebuffer can be retrieved
|
||||
//| by passing the Is31fl3741 object to memoryview().
|
||||
//|
|
||||
//| If doublebuffer is False, some memory is saved, but the display may
|
||||
//| flicker during updates.
|
||||
//|
|
||||
//| A Is31fl3741 is often used in conjunction with a
|
||||
//| `framebufferio.FramebufferDisplay`."""
|
||||
//|
|
||||
|
@ -136,7 +108,7 @@ STATIC mp_obj_t is31fl3741_is31fl3741_make_new(const mp_obj_type_t *type, size_t
|
|||
}
|
||||
|
||||
//| def deinit(self) -> None:
|
||||
//| """Free the resources (pins, timers, etc.) associated with this
|
||||
//| """Free the resources associated with this
|
||||
//| is31fl3741 instance. After deinitialization, no further operations
|
||||
//| may be performed."""
|
||||
//| ...
|
||||
|
@ -150,9 +122,9 @@ STATIC mp_obj_t is31fl3741_is31fl3741_deinit(mp_obj_t self_in) {
|
|||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_is31fl3741_deinit_obj, is31fl3741_is31fl3741_deinit);
|
||||
|
||||
static void check_for_deinit(is31fl3741_is31fl3741_obj_t *self) {
|
||||
// if (!self->protomatter.rgbPins) {
|
||||
// raise_deinited_error();
|
||||
// }
|
||||
if (self->framebuffer == NULL) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
|
||||
//| brightness: float
|
||||
|
@ -252,8 +224,6 @@ STATIC void is31fl3741_is31fl3741_get_bufinfo(mp_obj_t self_in, mp_buffer_info_t
|
|||
*bufinfo = self->bufinfo;
|
||||
}
|
||||
|
||||
// These version exists so that the prototype matches the protocol,
|
||||
// avoiding a type cast that can hide errors
|
||||
STATIC void is31fl3741_is31fl3741_swapbuffers(mp_obj_t self_in, uint8_t *dirty_row_bitmap) {
|
||||
common_hal_is31fl3741_is31fl3741_refresh(self_in, dirty_row_bitmap);
|
||||
}
|
||||
|
@ -291,10 +261,9 @@ STATIC int is31fl3741_is31fl3741_get_bytes_per_cell_proto(mp_obj_t self_in) {
|
|||
}
|
||||
|
||||
STATIC int is31fl3741_is31fl3741_get_native_frames_per_second_proto(mp_obj_t self_in) {
|
||||
return 60;
|
||||
return 60; // This was just chosen may vary based on LEDs used?
|
||||
}
|
||||
|
||||
|
||||
STATIC const framebuffer_p_t is31fl3741_is31fl3741_proto = {
|
||||
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuffer)
|
||||
.get_bufinfo = is31fl3741_is31fl3741_get_bufinfo,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 Jeff Epler for Adafruit Industries
|
||||
* Copyright (c) 2021 Mark Komus
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -27,7 +27,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "shared-module/is31fl3741/is31fl3741.h"
|
||||
// #include "lib/protomatter/src/core.h"
|
||||
|
||||
extern const mp_obj_type_t is31fl3741_is31fl3741_type;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 Jeff Epler for Adafruit Industries
|
||||
* Copyright (c) 2021 Mark Komus
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 Jeff Epler for Adafruit Industries
|
||||
* Copyright (c) 2021 Mark Komus
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -96,7 +96,7 @@ void common_hal_is31fl3741_is31fl3741_reconstruct(is31fl3741_is31fl3741_obj_t *s
|
|||
is31fl3741_send_enable(self->i2c, self->device_address);
|
||||
is31fl3741_set_current(self->i2c, self->device_address, 0xFF);
|
||||
|
||||
// set scale to max for all
|
||||
// set scale (brightness) to max for all LEDs
|
||||
for (int i; i < 351; i++) {
|
||||
is31fl3741_set_led(self->i2c, self->device_address, i, 0xFF, 2);
|
||||
}
|
||||
|
@ -111,6 +111,7 @@ void common_hal_is31fl3741_is31fl3741_deinit(is31fl3741_is31fl3741_obj_t *self)
|
|||
|
||||
if (self->i2c == &self->inline_i2c) {
|
||||
common_hal_busio_i2c_deinit(self->i2c);
|
||||
self->i2c = NULL;
|
||||
}
|
||||
|
||||
self->base.type = NULL;
|
||||
|
@ -151,6 +152,7 @@ void common_hal_is31fl3741_is31fl3741_refresh(is31fl3741_is31fl3741_obj_t *self,
|
|||
|
||||
if (!self->paused) {
|
||||
if (self->scale) {
|
||||
// Based on the Arduino IS31FL3741 driver code
|
||||
uint32_t *buffer = self->bufinfo.buf;
|
||||
|
||||
for (int x = 0; x < self->scale_width; x++) {
|
||||
|
@ -165,7 +167,7 @@ void common_hal_is31fl3741_is31fl3741_refresh(is31fl3741_is31fl3741_obj_t *self,
|
|||
gsum += (rgb >> 8) & 0xFF;
|
||||
bsum += rgb & 0xFF;
|
||||
}
|
||||
ptr += self->width; // canvas->width(); // Advance one scan line
|
||||
ptr += self->width; // Advance one scan line
|
||||
}
|
||||
rsum = rsum / 9;
|
||||
gsum = gsum / 9;
|
||||
|
@ -217,6 +219,9 @@ int common_hal_is31fl3741_is31fl3741_get_height(is31fl3741_is31fl3741_obj_t *sel
|
|||
void common_hal_displayio_is31fl3741_begin_transaction(is31fl3741_is31fl3741_obj_t *self) {
|
||||
while (!common_hal_busio_i2c_try_lock(self->i2c)) {
|
||||
RUN_BACKGROUND_TASKS;
|
||||
if (mp_hal_is_interrupted()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -237,6 +242,10 @@ void is31fl3741_is31fl3741_collect_ptrs(is31fl3741_is31fl3741_obj_t *self) {
|
|||
gc_collect_ptr(self->framebuffer);
|
||||
}
|
||||
|
||||
// The following are routines to manipulate the IS31FL3741 chip
|
||||
// They are not meant to be called by user code but only used
|
||||
// internally.
|
||||
|
||||
uint8_t cur_page = 99; // set to invalid page to start
|
||||
|
||||
void is31fl3741_send_unlock(busio_i2c_obj_t *i2c, uint8_t addr) {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 Jeff Epler for Adafruit Industries
|
||||
* Copyright (c) 2021 Mark Komus
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
Loading…
Reference in New Issue