36
36
#include "shared-module/framebufferio/FramebufferDisplay.h"
37
37
#include "shared-bindings/busio/I2C.h"
38
38
39
- //| class is31fl3741 :
39
+ //| class IS31FL3741 :
40
40
//| """Displays an in-memory framebuffer to a IS31FL3741 drive display."""
41
41
//|
42
42
43
43
//| def __init__(self, *, width: int) -> None:
44
- //| """Create a Is31fl3741 object with the given attributes.
44
+ //| """Create a IS31FL3741 object with the given attributes.
45
45
//|
46
46
//| The framebuffer is in "RGB888" format using 4 bytes per pixel.
47
47
//| Bits 24-31 are ignored. The format is in RGB order.
54
54
//| `framebufferio.FramebufferDisplay`."""
55
55
//|
56
56
57
- STATIC mp_obj_t is31fl3741_is31fl3741_make_new (const mp_obj_type_t * type , size_t n_args , size_t n_kw , const mp_obj_t * all_args ) {
57
+ STATIC mp_obj_t is31fl3741_IS31FL3741_make_new (const mp_obj_type_t * type , size_t n_args , size_t n_kw , const mp_obj_t * all_args ) {
58
58
enum { ARG_width , ARG_height , ARG_i2c , ARG_addr , ARG_framebuffer , ARG_mapping , ARG_scale , ARG_gamma };
59
59
static const mp_arg_t allowed_args [] = {
60
60
{ MP_QSTR_width , MP_ARG_INT | MP_ARG_REQUIRED | MP_ARG_KW_ONLY },
@@ -71,8 +71,8 @@ STATIC mp_obj_t is31fl3741_is31fl3741_make_new(const mp_obj_type_t *type, size_t
71
71
72
72
mp_obj_t i2c = mp_arg_validate_type (args [ARG_i2c ].u_obj , & busio_i2c_type , MP_QSTR_i2c_bus );
73
73
74
- is31fl3741_is31fl3741_obj_t * self = & allocate_display_bus_or_raise ()-> is31fl3741 ;
75
- self -> base .type = & is31fl3741_is31fl3741_type ;
74
+ is31fl3741_IS31FL3741_obj_t * self = & allocate_display_bus_or_raise ()-> is31fl3741 ;
75
+ self -> base .type = & is31fl3741_IS31FL3741_type ;
76
76
77
77
if (args [ARG_width ].u_int <= 0 ) {
78
78
mp_raise_ValueError (translate ("width must be greater than zero" ));
@@ -101,7 +101,7 @@ STATIC mp_obj_t is31fl3741_is31fl3741_make_new(const mp_obj_type_t *type, size_t
101
101
framebuffer = mp_obj_new_bytearray_of_zeros (bufsize );
102
102
}
103
103
104
- common_hal_is31fl3741_is31fl3741_construct (self ,
104
+ common_hal_is31fl3741_IS31FL3741_construct (self ,
105
105
args [ARG_width ].u_int ,
106
106
args [ARG_height ].u_int ,
107
107
framebuffer ,
@@ -115,19 +115,19 @@ STATIC mp_obj_t is31fl3741_is31fl3741_make_new(const mp_obj_type_t *type, size_t
115
115
116
116
//| def deinit(self) -> None:
117
117
//| """Free the resources associated with this
118
- //| is31fl3741 instance. After deinitialization, no further operations
118
+ //| IS31FL3741 instance. After deinitialization, no further operations
119
119
//| may be performed."""
120
120
//| ...
121
121
//|
122
- STATIC mp_obj_t is31fl3741_is31fl3741_deinit (mp_obj_t self_in ) {
123
- is31fl3741_is31fl3741_obj_t * self = (is31fl3741_is31fl3741_obj_t * )self_in ;
124
- common_hal_is31fl3741_is31fl3741_deinit (self );
122
+ STATIC mp_obj_t is31fl3741_IS31FL3741_deinit (mp_obj_t self_in ) {
123
+ is31fl3741_IS31FL3741_obj_t * self = (is31fl3741_IS31FL3741_obj_t * )self_in ;
124
+ common_hal_is31fl3741_IS31FL3741_deinit (self );
125
125
return mp_const_none ;
126
126
}
127
127
128
- STATIC MP_DEFINE_CONST_FUN_OBJ_1 (is31fl3741_is31fl3741_deinit_obj , is31fl3741_is31fl3741_deinit );
128
+ STATIC MP_DEFINE_CONST_FUN_OBJ_1 (is31fl3741_IS31FL3741_deinit_obj , is31fl3741_IS31FL3741_deinit );
129
129
130
- static void check_for_deinit (is31fl3741_is31fl3741_obj_t * self ) {
130
+ static void check_for_deinit (is31fl3741_IS31FL3741_obj_t * self ) {
131
131
if (self -> framebuffer == NULL ) {
132
132
raise_deinited_error ();
133
133
}
@@ -137,35 +137,35 @@ static void check_for_deinit(is31fl3741_is31fl3741_obj_t *self) {
137
137
//| """In the current implementation, 0.0 turns the display off entirely
138
138
//| and any other value up to 1.0 turns the display on fully."""
139
139
//|
140
- STATIC mp_obj_t is31fl3741_is31fl3741_get_brightness (mp_obj_t self_in ) {
141
- is31fl3741_is31fl3741_obj_t * self = (is31fl3741_is31fl3741_obj_t * )self_in ;
140
+ STATIC mp_obj_t is31fl3741_IS31FL3741_get_brightness (mp_obj_t self_in ) {
141
+ is31fl3741_IS31FL3741_obj_t * self = (is31fl3741_IS31FL3741_obj_t * )self_in ;
142
142
check_for_deinit (self );
143
- uint8_t current = common_hal_is31fl3741_is31fl3741_get_global_current (self );
143
+ uint8_t current = common_hal_is31fl3741_IS31FL3741_get_global_current (self );
144
144
145
145
float brightness = (float )current / (float )0xFF ;
146
146
return mp_obj_new_float (brightness );
147
147
}
148
- MP_DEFINE_CONST_FUN_OBJ_1 (is31fl3741_is31fl3741_get_brightness_obj , is31fl3741_is31fl3741_get_brightness );
148
+ MP_DEFINE_CONST_FUN_OBJ_1 (is31fl3741_IS31FL3741_get_brightness_obj , is31fl3741_IS31FL3741_get_brightness );
149
149
150
- STATIC mp_obj_t is31fl3741_is31fl3741_set_brightness (mp_obj_t self_in , mp_obj_t value_in ) {
151
- is31fl3741_is31fl3741_obj_t * self = (is31fl3741_is31fl3741_obj_t * )self_in ;
150
+ STATIC mp_obj_t is31fl3741_IS31FL3741_set_brightness (mp_obj_t self_in , mp_obj_t value_in ) {
151
+ is31fl3741_IS31FL3741_obj_t * self = (is31fl3741_IS31FL3741_obj_t * )self_in ;
152
152
check_for_deinit (self );
153
153
mp_float_t brightness = mp_obj_get_float (value_in );
154
154
if (brightness < 0.0f || brightness > 1.0f ) {
155
155
mp_raise_ValueError (translate ("Brightness must be 0-1.0" ));
156
156
}
157
157
158
158
uint8_t current = (uint8_t )(brightness * 0xFF );
159
- common_hal_is31fl3741_is31fl3741_set_global_current (self , current );
159
+ common_hal_is31fl3741_IS31FL3741_set_global_current (self , current );
160
160
161
161
return mp_const_none ;
162
162
}
163
- MP_DEFINE_CONST_FUN_OBJ_2 (is31fl3741_is31fl3741_set_brightness_obj , is31fl3741_is31fl3741_set_brightness );
163
+ MP_DEFINE_CONST_FUN_OBJ_2 (is31fl3741_IS31FL3741_set_brightness_obj , is31fl3741_IS31FL3741_set_brightness );
164
164
165
- const mp_obj_property_t is31fl3741_is31fl3741_brightness_obj = {
165
+ const mp_obj_property_t is31fl3741_IS31FL3741_brightness_obj = {
166
166
.base .type = & mp_type_property ,
167
- .proxy = {(mp_obj_t )& is31fl3741_is31fl3741_get_brightness_obj ,
168
- (mp_obj_t )& is31fl3741_is31fl3741_set_brightness_obj ,
167
+ .proxy = {(mp_obj_t )& is31fl3741_IS31FL3741_get_brightness_obj ,
168
+ (mp_obj_t )& is31fl3741_IS31FL3741_set_brightness_obj ,
169
169
MP_ROM_NONE },
170
170
};
171
171
@@ -174,118 +174,118 @@ const mp_obj_property_t is31fl3741_is31fl3741_brightness_obj = {
174
174
//| they are shown."""
175
175
//| ...
176
176
//|
177
- STATIC mp_obj_t is31fl3741_is31fl3741_refresh (mp_obj_t self_in ) {
178
- is31fl3741_is31fl3741_obj_t * self = (is31fl3741_is31fl3741_obj_t * )self_in ;
177
+ STATIC mp_obj_t is31fl3741_IS31FL3741_refresh (mp_obj_t self_in ) {
178
+ is31fl3741_IS31FL3741_obj_t * self = (is31fl3741_IS31FL3741_obj_t * )self_in ;
179
179
check_for_deinit (self );
180
- common_hal_is31fl3741_is31fl3741_refresh (self , 0 );
180
+ common_hal_is31fl3741_IS31FL3741_refresh (self , 0 );
181
181
return mp_const_none ;
182
182
}
183
- MP_DEFINE_CONST_FUN_OBJ_1 (is31fl3741_is31fl3741_refresh_obj , is31fl3741_is31fl3741_refresh );
183
+ MP_DEFINE_CONST_FUN_OBJ_1 (is31fl3741_IS31FL3741_refresh_obj , is31fl3741_IS31FL3741_refresh );
184
184
185
185
//| width: int
186
186
//| """The width of the display, in pixels"""
187
187
//|
188
- STATIC mp_obj_t is31fl3741_is31fl3741_get_width (mp_obj_t self_in ) {
189
- is31fl3741_is31fl3741_obj_t * self = (is31fl3741_is31fl3741_obj_t * )self_in ;
188
+ STATIC mp_obj_t is31fl3741_IS31FL3741_get_width (mp_obj_t self_in ) {
189
+ is31fl3741_IS31FL3741_obj_t * self = (is31fl3741_IS31FL3741_obj_t * )self_in ;
190
190
check_for_deinit (self );
191
- return MP_OBJ_NEW_SMALL_INT (common_hal_is31fl3741_is31fl3741_get_width (self ));
191
+ return MP_OBJ_NEW_SMALL_INT (common_hal_is31fl3741_IS31FL3741_get_width (self ));
192
192
}
193
- MP_DEFINE_CONST_FUN_OBJ_1 (is31fl3741_is31fl3741_get_width_obj , is31fl3741_is31fl3741_get_width );
194
- const mp_obj_property_t is31fl3741_is31fl3741_width_obj = {
193
+ MP_DEFINE_CONST_FUN_OBJ_1 (is31fl3741_IS31FL3741_get_width_obj , is31fl3741_IS31FL3741_get_width );
194
+ const mp_obj_property_t is31fl3741_IS31FL3741_width_obj = {
195
195
.base .type = & mp_type_property ,
196
- .proxy = {(mp_obj_t )& is31fl3741_is31fl3741_get_width_obj ,
196
+ .proxy = {(mp_obj_t )& is31fl3741_IS31FL3741_get_width_obj ,
197
197
MP_ROM_NONE ,
198
198
MP_ROM_NONE },
199
199
};
200
200
201
201
//| height: int
202
202
//| """The height of the display, in pixels"""
203
203
//|
204
- STATIC mp_obj_t is31fl3741_is31fl3741_get_height (mp_obj_t self_in ) {
205
- is31fl3741_is31fl3741_obj_t * self = (is31fl3741_is31fl3741_obj_t * )self_in ;
204
+ STATIC mp_obj_t is31fl3741_IS31FL3741_get_height (mp_obj_t self_in ) {
205
+ is31fl3741_IS31FL3741_obj_t * self = (is31fl3741_IS31FL3741_obj_t * )self_in ;
206
206
check_for_deinit (self );
207
- return MP_OBJ_NEW_SMALL_INT (common_hal_is31fl3741_is31fl3741_get_height (self ));
207
+ return MP_OBJ_NEW_SMALL_INT (common_hal_is31fl3741_IS31FL3741_get_height (self ));
208
208
}
209
- MP_DEFINE_CONST_FUN_OBJ_1 (is31fl3741_is31fl3741_get_height_obj , is31fl3741_is31fl3741_get_height );
210
- const mp_obj_property_t is31fl3741_is31fl3741_height_obj = {
209
+ MP_DEFINE_CONST_FUN_OBJ_1 (is31fl3741_IS31FL3741_get_height_obj , is31fl3741_IS31FL3741_get_height );
210
+ const mp_obj_property_t is31fl3741_IS31FL3741_height_obj = {
211
211
.base .type = & mp_type_property ,
212
- .proxy = {(mp_obj_t )& is31fl3741_is31fl3741_get_height_obj ,
212
+ .proxy = {(mp_obj_t )& is31fl3741_IS31FL3741_get_height_obj ,
213
213
MP_ROM_NONE ,
214
214
MP_ROM_NONE },
215
215
};
216
216
217
- STATIC const mp_rom_map_elem_t is31fl3741_is31fl3741_locals_dict_table [] = {
218
- { MP_ROM_QSTR (MP_QSTR_deinit ), MP_ROM_PTR (& is31fl3741_is31fl3741_deinit_obj ) },
219
- { MP_ROM_QSTR (MP_QSTR_brightness ), MP_ROM_PTR (& is31fl3741_is31fl3741_brightness_obj ) },
220
- { MP_ROM_QSTR (MP_QSTR_refresh ), MP_ROM_PTR (& is31fl3741_is31fl3741_refresh_obj ) },
221
- { MP_ROM_QSTR (MP_QSTR_width ), MP_ROM_PTR (& is31fl3741_is31fl3741_width_obj ) },
222
- { MP_ROM_QSTR (MP_QSTR_height ), MP_ROM_PTR (& is31fl3741_is31fl3741_height_obj ) },
217
+ STATIC const mp_rom_map_elem_t is31fl3741_IS31FL3741_locals_dict_table [] = {
218
+ { MP_ROM_QSTR (MP_QSTR_deinit ), MP_ROM_PTR (& is31fl3741_IS31FL3741_deinit_obj ) },
219
+ { MP_ROM_QSTR (MP_QSTR_brightness ), MP_ROM_PTR (& is31fl3741_IS31FL3741_brightness_obj ) },
220
+ { MP_ROM_QSTR (MP_QSTR_refresh ), MP_ROM_PTR (& is31fl3741_IS31FL3741_refresh_obj ) },
221
+ { MP_ROM_QSTR (MP_QSTR_width ), MP_ROM_PTR (& is31fl3741_IS31FL3741_width_obj ) },
222
+ { MP_ROM_QSTR (MP_QSTR_height ), MP_ROM_PTR (& is31fl3741_IS31FL3741_height_obj ) },
223
223
};
224
- STATIC MP_DEFINE_CONST_DICT (is31fl3741_is31fl3741_locals_dict , is31fl3741_is31fl3741_locals_dict_table );
224
+ STATIC MP_DEFINE_CONST_DICT (is31fl3741_IS31FL3741_locals_dict , is31fl3741_IS31FL3741_locals_dict_table );
225
225
226
- STATIC void is31fl3741_is31fl3741_get_bufinfo (mp_obj_t self_in , mp_buffer_info_t * bufinfo ) {
227
- is31fl3741_is31fl3741_obj_t * self = (is31fl3741_is31fl3741_obj_t * )self_in ;
226
+ STATIC void is31fl3741_IS31FL3741_get_bufinfo (mp_obj_t self_in , mp_buffer_info_t * bufinfo ) {
227
+ is31fl3741_IS31FL3741_obj_t * self = (is31fl3741_IS31FL3741_obj_t * )self_in ;
228
228
check_for_deinit (self );
229
229
230
230
* bufinfo = self -> bufinfo ;
231
231
}
232
232
233
- STATIC void is31fl3741_is31fl3741_swapbuffers (mp_obj_t self_in , uint8_t * dirty_row_bitmap ) {
234
- common_hal_is31fl3741_is31fl3741_refresh (self_in , dirty_row_bitmap );
233
+ STATIC void is31fl3741_IS31FL3741_swapbuffers (mp_obj_t self_in , uint8_t * dirty_row_bitmap ) {
234
+ common_hal_is31fl3741_IS31FL3741_refresh (self_in , dirty_row_bitmap );
235
235
}
236
236
237
- STATIC void is31fl3741_is31fl3741_deinit_proto (mp_obj_t self_in ) {
238
- common_hal_is31fl3741_is31fl3741_deinit (self_in );
237
+ STATIC void is31fl3741_IS31FL3741_deinit_proto (mp_obj_t self_in ) {
238
+ common_hal_is31fl3741_IS31FL3741_deinit (self_in );
239
239
}
240
240
241
- STATIC float is31fl3741_is31fl3741_get_brightness_proto (mp_obj_t self_in ) {
242
- return common_hal_is31fl3741_is31fl3741_get_paused (self_in ) ? 0.0f : 1.0f ;
241
+ STATIC float is31fl3741_IS31FL3741_get_brightness_proto (mp_obj_t self_in ) {
242
+ return common_hal_is31fl3741_IS31FL3741_get_paused (self_in ) ? 0.0f : 1.0f ;
243
243
}
244
244
245
- STATIC bool is31fl3741_is31fl3741_set_brightness_proto (mp_obj_t self_in , mp_float_t value ) {
246
- common_hal_is31fl3741_is31fl3741_set_paused (self_in , value <= 0 );
245
+ STATIC bool is31fl3741_IS31FL3741_set_brightness_proto (mp_obj_t self_in , mp_float_t value ) {
246
+ common_hal_is31fl3741_IS31FL3741_set_paused (self_in , value <= 0 );
247
247
return true;
248
248
}
249
249
250
- STATIC int is31fl3741_is31fl3741_get_width_proto (mp_obj_t self_in ) {
251
- return common_hal_is31fl3741_is31fl3741_get_width (self_in );
250
+ STATIC int is31fl3741_IS31FL3741_get_width_proto (mp_obj_t self_in ) {
251
+ return common_hal_is31fl3741_IS31FL3741_get_width (self_in );
252
252
}
253
253
254
- STATIC int is31fl3741_is31fl3741_get_height_proto (mp_obj_t self_in ) {
255
- return common_hal_is31fl3741_is31fl3741_get_height (self_in );
254
+ STATIC int is31fl3741_IS31FL3741_get_height_proto (mp_obj_t self_in ) {
255
+ return common_hal_is31fl3741_IS31FL3741_get_height (self_in );
256
256
}
257
257
258
- STATIC int is31fl3741_is31fl3741_get_color_depth_proto (mp_obj_t self_in ) {
258
+ STATIC int is31fl3741_IS31FL3741_get_color_depth_proto (mp_obj_t self_in ) {
259
259
// The way displayio works depth is used to calculate bytes
260
260
// We use an uint32_t for color already so setting to 24 causes
261
261
// more changes required
262
262
return 32 ;
263
263
}
264
264
265
- STATIC int is31fl3741_is31fl3741_get_bytes_per_cell_proto (mp_obj_t self_in ) {
265
+ STATIC int is31fl3741_IS31FL3741_get_bytes_per_cell_proto (mp_obj_t self_in ) {
266
266
return 1 ;
267
267
}
268
268
269
- STATIC int is31fl3741_is31fl3741_get_native_frames_per_second_proto (mp_obj_t self_in ) {
269
+ STATIC int is31fl3741_IS31FL3741_get_native_frames_per_second_proto (mp_obj_t self_in ) {
270
270
return 60 ; // This was just chosen may vary based on LEDs used?
271
271
}
272
272
273
- STATIC const framebuffer_p_t is31fl3741_is31fl3741_proto = {
273
+ STATIC const framebuffer_p_t is31fl3741_IS31FL3741_proto = {
274
274
MP_PROTO_IMPLEMENT (MP_QSTR_protocol_framebuffer )
275
- .get_bufinfo = is31fl3741_is31fl3741_get_bufinfo ,
276
- .set_brightness = is31fl3741_is31fl3741_set_brightness_proto ,
277
- .get_brightness = is31fl3741_is31fl3741_get_brightness_proto ,
278
- .get_width = is31fl3741_is31fl3741_get_width_proto ,
279
- .get_height = is31fl3741_is31fl3741_get_height_proto ,
280
- .get_color_depth = is31fl3741_is31fl3741_get_color_depth_proto ,
281
- .get_bytes_per_cell = is31fl3741_is31fl3741_get_bytes_per_cell_proto ,
282
- .get_native_frames_per_second = is31fl3741_is31fl3741_get_native_frames_per_second_proto ,
283
- .swapbuffers = is31fl3741_is31fl3741_swapbuffers ,
284
- .deinit = is31fl3741_is31fl3741_deinit_proto ,
275
+ .get_bufinfo = is31fl3741_IS31FL3741_get_bufinfo ,
276
+ .set_brightness = is31fl3741_IS31FL3741_set_brightness_proto ,
277
+ .get_brightness = is31fl3741_IS31FL3741_get_brightness_proto ,
278
+ .get_width = is31fl3741_IS31FL3741_get_width_proto ,
279
+ .get_height = is31fl3741_IS31FL3741_get_height_proto ,
280
+ .get_color_depth = is31fl3741_IS31FL3741_get_color_depth_proto ,
281
+ .get_bytes_per_cell = is31fl3741_IS31FL3741_get_bytes_per_cell_proto ,
282
+ .get_native_frames_per_second = is31fl3741_IS31FL3741_get_native_frames_per_second_proto ,
283
+ .swapbuffers = is31fl3741_IS31FL3741_swapbuffers ,
284
+ .deinit = is31fl3741_IS31FL3741_deinit_proto ,
285
285
};
286
286
287
- STATIC mp_int_t is31fl3741_is31fl3741_get_buffer (mp_obj_t self_in , mp_buffer_info_t * bufinfo , mp_uint_t flags ) {
288
- is31fl3741_is31fl3741_obj_t * self = (is31fl3741_is31fl3741_obj_t * )self_in ;
287
+ STATIC mp_int_t is31fl3741_IS31FL3741_get_buffer (mp_obj_t self_in , mp_buffer_info_t * bufinfo , mp_uint_t flags ) {
288
+ is31fl3741_IS31FL3741_obj_t * self = (is31fl3741_IS31FL3741_obj_t * )self_in ;
289
289
// a readonly framebuffer would be unusual but not impossible
290
290
if ((flags & MP_BUFFER_WRITE ) && !(self -> bufinfo .typecode & MP_OBJ_ARRAY_TYPECODE_FLAG_RW )) {
291
291
return 1 ;
@@ -295,14 +295,14 @@ STATIC mp_int_t is31fl3741_is31fl3741_get_buffer(mp_obj_t self_in, mp_buffer_inf
295
295
return 0 ;
296
296
}
297
297
298
- const mp_obj_type_t is31fl3741_is31fl3741_type = {
298
+ const mp_obj_type_t is31fl3741_IS31FL3741_type = {
299
299
{ & mp_type_type },
300
300
.flags = MP_TYPE_FLAG_EXTENDED ,
301
301
.name = MP_QSTR_is31fl3741 ,
302
- .locals_dict = (mp_obj_dict_t * )& is31fl3741_is31fl3741_locals_dict ,
303
- .make_new = is31fl3741_is31fl3741_make_new ,
302
+ .locals_dict = (mp_obj_dict_t * )& is31fl3741_IS31FL3741_locals_dict ,
303
+ .make_new = is31fl3741_IS31FL3741_make_new ,
304
304
MP_TYPE_EXTENDED_FIELDS (
305
- .buffer_p = { .get_buffer = is31fl3741_is31fl3741_get_buffer , },
306
- .protocol = & is31fl3741_is31fl3741_proto ,
305
+ .buffer_p = { .get_buffer = is31fl3741_IS31FL3741_get_buffer , },
306
+ .protocol = & is31fl3741_IS31FL3741_proto ,
307
307
),
308
308
};
0 commit comments