3
3
*
4
4
* The MIT License (MIT)
5
5
*
6
- * Copyright (c) 2020 Jeff Epler for Adafruit Industries
6
+ * Copyright (c) 2021 Mark Komus
7
7
*
8
8
* Permission is hereby granted, free of charge, to any person obtaining a copy
9
9
* of this software and associated documentation files (the "Software"), to deal
29
29
#include "py/runtime.h"
30
30
#include "py/objarray.h"
31
31
32
- // #include "common-hal/is31fl3741/is31fl3741.h"
33
32
#include "shared-bindings/is31fl3741/is31fl3741.h"
34
- #include "shared-bindings/microcontroller/Pin.h"
35
- #include "shared-bindings/microcontroller/__init__.h"
33
+ // #include "shared-bindings/microcontroller/Pin.h"
34
+ // #include "shared-bindings/microcontroller/__init__.h"
36
35
#include "shared-bindings/util.h"
37
36
#include "shared-module/displayio/__init__.h"
38
37
#include "shared-module/framebufferio/__init__.h"
39
38
#include "shared-module/framebufferio/FramebufferDisplay.h"
40
39
#include "shared-bindings/busio/I2C.h"
41
40
42
41
//| class is31fl3741:
43
- //| """Displays an in-memory framebuffer to a HUB75-style RGB LED matrix ."""
42
+ //| """Displays an in-memory framebuffer to a IS31FL3741 drive display ."""
44
43
//|
45
44
46
- // extern Protomatter_core *_PM_protoPtr;
47
-
48
-
49
45
//| def __init__(self, *, width: int) -> None:
50
- //| """Create a Is31fl3741 object with the given attributes. The height of
51
- //| the display is determined by the number of rgb and address pins and the number of tiles:
52
- //| ``len(rgb_pins) // 3 * 2 ** len(address_pins) * abs(tile)``. With 6 RGB pins, 4
53
- //| address lines, and a single matrix, the display will be 32 pixels tall. If the optional height
54
- //| parameter is specified and is not 0, it is checked against the calculated
55
- //| height.
56
- //|
57
- //| Up to 30 RGB pins and 8 address pins are supported.
58
- //|
59
- //| The RGB pins must be within a single "port" and performance and memory
60
- //| usage are best when they are all within "close by" bits of the port.
61
- //| The clock pin must also be on the same port as the RGB pins. See the
62
- //| documentation of the underlying protomatter C library for more
63
- //| information. Generally, Adafruit's interface boards are designed so
64
- //| that these requirements are met when matched with the intended
65
- //| microcontroller board. For instance, the Feather M4 Express works
66
- //| together with the RGB Matrix Feather.
46
+ //| """Create a Is31fl3741 object with the given attributes.
67
47
//|
68
- //| The framebuffer is in "RGB565" format.
69
- //|
70
- //| "RGB565" means that it is organized as a series of 16-bit numbers
71
- //| where the highest 5 bits are interpreted as red, the next 6 as
72
- //| green, and the final 5 as blue. The object can be any buffer, but
73
- //| `array.array` and ``ulab.ndarray`` objects are most often useful.
74
- //| To update the content, modify the framebuffer and call refresh.
48
+ //| The framebuffer is in "RGB888" format using 4 bytes per pixel.
49
+ //| Bits 24-31 are ignored. The format is in RGB order.
75
50
//|
76
51
//| If a framebuffer is not passed in, one is allocated and initialized
77
52
//| to all black. In any case, the framebuffer can be retrieved
78
53
//| by passing the Is31fl3741 object to memoryview().
79
54
//|
80
- //| If doublebuffer is False, some memory is saved, but the display may
81
- //| flicker during updates.
82
- //|
83
55
//| A Is31fl3741 is often used in conjunction with a
84
56
//| `framebufferio.FramebufferDisplay`."""
85
57
//|
@@ -136,7 +108,7 @@ STATIC mp_obj_t is31fl3741_is31fl3741_make_new(const mp_obj_type_t *type, size_t
136
108
}
137
109
138
110
//| def deinit(self) -> None:
139
- //| """Free the resources (pins, timers, etc.) associated with this
111
+ //| """Free the resources associated with this
140
112
//| is31fl3741 instance. After deinitialization, no further operations
141
113
//| may be performed."""
142
114
//| ...
@@ -150,9 +122,9 @@ STATIC mp_obj_t is31fl3741_is31fl3741_deinit(mp_obj_t self_in) {
150
122
STATIC MP_DEFINE_CONST_FUN_OBJ_1 (is31fl3741_is31fl3741_deinit_obj , is31fl3741_is31fl3741_deinit );
151
123
152
124
static void check_for_deinit (is31fl3741_is31fl3741_obj_t * self ) {
153
- // if (! self->protomatter.rgbPins ) {
154
- // raise_deinited_error();
155
- // }
125
+ if (self -> framebuffer == NULL ) {
126
+ raise_deinited_error ();
127
+ }
156
128
}
157
129
158
130
//| brightness: float
@@ -252,8 +224,6 @@ STATIC void is31fl3741_is31fl3741_get_bufinfo(mp_obj_t self_in, mp_buffer_info_t
252
224
* bufinfo = self -> bufinfo ;
253
225
}
254
226
255
- // These version exists so that the prototype matches the protocol,
256
- // avoiding a type cast that can hide errors
257
227
STATIC void is31fl3741_is31fl3741_swapbuffers (mp_obj_t self_in , uint8_t * dirty_row_bitmap ) {
258
228
common_hal_is31fl3741_is31fl3741_refresh (self_in , dirty_row_bitmap );
259
229
}
@@ -291,10 +261,9 @@ STATIC int is31fl3741_is31fl3741_get_bytes_per_cell_proto(mp_obj_t self_in) {
291
261
}
292
262
293
263
STATIC int is31fl3741_is31fl3741_get_native_frames_per_second_proto (mp_obj_t self_in ) {
294
- return 60 ;
264
+ return 60 ; // This was just chosen may vary based on LEDs used?
295
265
}
296
266
297
-
298
267
STATIC const framebuffer_p_t is31fl3741_is31fl3741_proto = {
299
268
MP_PROTO_IMPLEMENT (MP_QSTR_protocol_framebuffer )
300
269
.get_bufinfo = is31fl3741_is31fl3741_get_bufinfo ,
0 commit comments