robodude666 - I absolutely agree that there should be meanignful names for the default values provided by the library. What did I write to cause you to think that?
I wasn't suggest anything as opaque as:
uint8 row_offsets[] = { 0x00, 0x40, 0x10, 0x50 }; // What does this mean???
lcd.begin(&row_offsets, 20, 2);
IMHO, that is tasteless and unhelpful.
is extremely confusing to anyone who doesn't know that those are the beginning address of each row. A user may attempt to change them, and will wonder why the LCD stopped working as expected.
If they understand so little, why would they NOT use a definition provided by the library?
I was thinking along the lines of:
uint16 LCD_WH1604B_ROWS[] = { 0x00, 0x40, 0x10, 0x50 };
which could be syntactically identical to your proposal, or even
uint16 LCD_20x4_WH1604B_ROWS[] = { 0x00, 0x40, 0x10, 0x50 };
to make it more explicit.
I'd consider:
struct _LCD_DEVICE_ {
uint8 width; // number of columns
uint8 height; // number of rows
uint16 row_offsets[0]; // row offset values
};
typedef struct _LCD_DEVICE_ LCD_DEVICE;
LCD_DEVICE LCD_20x4 = { 20, 4, { 0x00, 0x40, 0x10, 0x50 }};
So that it is all wrapped up behind one name.
At least half of the Arduino community doesn't know how to read a datasheet to extract the required offset values
So in your estimation, almost half of Arduino community could find the necessary information, and hence code up something to use an LCD all by themselves if the API gives them that facility?
Excellent.
I am all in favour of making it easy for people to reuse code beyond its original (tested) intent by providing open solutions.
it would only create the circulation of 3 sets of boiler-plate code that will be copy+pasted.
No.
That would only be true if we didn't provide definitions for the default cases, which is NOT what I propose. I think we should provide definitions for the hardware we can test.
The code used for the supported cases would be syntactically identical.
Of course, the user would have to write code for a case not supported, but they have the option to do that if they need to.
other derivatives exist but they're only clones which feature the same instruction set
So, how does someone figure out which clone their LCD uses?
How do they define the properties so that the library works, and so that the parameter to begin
is correct?
On a slightly different tack, if they are all the same controller anyway, and it is only the size and row offsets which vary, why should we make the name of the controller matter at all?