adafruit / Adafruit_EPD

e-paper display driver for Arduino
141 stars 57 forks source link

Add “ink mode” to ThinkInk classes (needed for ImageReader) #31

Closed PaintYourDragon closed 3 years ago

PaintYourDragon commented 3 years ago

Please review carefully before merging, in case this is Not The Right Way To Go About Things.

All of the ThinkInk classes (in panels directory) are updated to preserve the “ink mode” that was passed to their begin() function, with a corresponding function to query this later. This was done primarily for ImageReader (but maybe others can benefit), so it can do the Right Thing depending on the display configuration…but without having to state this in two different places in a sketch (once when calling the display’s begin() func, another when loading an image, which is just A Recipe For Disaster that these two would get out of sync…now instead the setting from the former can be queried to pass to the latter…it’s a roundabout extra step, but is at least always consistent).

No changes have been made to the core Adafruit_EPD class itself, nor the drivers, only the ThinkInk classes. Some minor table formatting for consistency because you know I’m Just That Way.

Version number in properties file is NOT bumped yet, until this is PR is reviewed.

ladyada commented 3 years ago

hihi this is ok, maybe easier if you put the mode in the parent object so it doenst have to be re-pasted into each new board?

PaintYourDragon commented 3 years ago

Re-pasting seems the simplest thing for now…

  1. The thinkinkmodet enumeration isn’t known to the base class, only the ThinkInk* subclasses.
  2. It could be moved there, or cast to/from a new uint8_t class member, but you were quite adamant about not amending the Adafruit_EPD class.
  3. If this new element were added to the base class, setting/getting the value would either require pasting at least the “setting” line in each subclass anyway, or modifying the begin() function in each of the mid-level “driver” classes plus the EPD base class to accept this as an argument…and any example code/guides for the EPD library would need to be updated. Something, somewhere, would break.

But, on the plus side, such a change…

  1. Would remove the need for ImageReader sketches to query the thinkinkmodet from the ThinkInk* class and pass it as an argument to one of the draw functions…those functions could just directly query the value themselves.
ladyada commented 3 years ago

yah good point. ok mergin!

PaintYourDragon commented 3 years ago

Thx! I’ll do the version bump in the main branch now.