Closed dglaude closed 1 year ago
I much prefer the table. You could make it even more compact and faster by turning it into a bytes
and indexing into it "by hand" (compute the offset yourself), but that is probably unnecessary here.
To prevent pylint from complaining about duplicate code, or anything in particular, you should be able to do a # pylint: disable=...
for the check in question. I don't know how to fix that for duplicate code. Don't go to extremes just to satisfy its whims; override it if it's being unreasonable.
Previously @ladyada said: "please at least make this a tuple, or a bytearray, - at best please algorithize as this table will take up valuable ram on small devices": https://github.com/adafruit/Adafruit_CircuitPython_IS31FL3731/pull/26#discussion_r403727405
I guess I did not get the "tuple" nor the "bytearray" part of the answer and went algorithm... and that was a nightmare result. Also that remark was before the library was split in module, so the memory issue was different.
I'll give this another try and pylint will not detect that as duplicate.
bytes or bytearrays are the smallest option because they won't have tuple overhead and every element will be 1 byte instead of 4 like all Python objects are.
The question came in the implementation of #41 and 5x5 support was added with #45 . Not sure about the implementation details, but this issue is not useful anymore.
I want to write the code for Pimoroni 5x5 LED Matrix. The table and algorithm is very similar is for led_shim. Except that led_shim has 28 entries and 5x5 has 25 entries.
Q1: What is prefered way of writing the mapping
(see below for code extract)
Q2: How do I convince pylint that this duplicate code is OK? Or should I put the table/algo in a separate file and import? (it is very similar but maybe with 3 entries less, but having 3 extra entries is not hurting much.
Lookup used in keybow2040:
Algorithm used in led_shim (not exactly the same table):