0

[Solved] Adafruit_GFX with Huzzah ESP8266 + PCD8544?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

[Solved] Adafruit_GFX with Huzzah ESP8266 + PCD8544?

by Disciple on Fri Jun 09, 2017 2:38 am

Edit: (Formerly "Using Adafruit_GFX with user-defined matrices?")

Hi everyone. I just bought two of the Nokia 5110 LCDs (not from Adafruit, out of stock, sorry), and I'm testing one with my Uno. Based on example code at http://playground.arduino.cc/Code/PCD8544, I've figured out how to set up an array of bytes, set and clear bits at [X,Y], copy letter shapes to make text, and push it all out to the LCD screen. It works.

Why am I doing this the hard and slow way and not using Adafruit's PCD8544 library? Getting to know my new hardware is one reason, but I want to connect it to my ESP8266 HUZZAH and I don't think the library is compatible. So here's my question.

If I could adapt the Adafruit_GFX library to write to my little pixel array, that would save me time and duplicated effort, but I have no clue how to do so. All I know about libraries is how to use 'em as the tutorials show me. My coding skills are pretty elementary. Is there such a guide for beginners? Thanks for reading.

Hallelujah!
Disciple
Last edited by Disciple on Wed Jun 14, 2017 11:43 pm, edited 1 time in total.

Disciple
 
Posts: 411
Joined: Tue Jan 06, 2015 8:13 pm

Re: Using Adafruit_GFX with user-defined matrices?

by adafruit_support_bill on Fri Jun 09, 2017 6:10 am

The header file in github explains it : https://github.com/adafruit/Adafruit-GF ... ruit_GFX.h
At a minimum, you need to implement the drawPixel function for your display.
Code: Select all | TOGGLE FULL SIZE
  // This MUST be defined by the subclass:
  virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0;


To improve performance, you can optionally override one or more of the following to optimize for your configuration or take advantage of any hardware rendering capabilities your display may have.
Code: Select all | TOGGLE FULL SIZE
  // TRANSACTION API / CORE DRAW API
  // These MAY be overridden by the subclass to provide device-specific
  // optimized code.  Otherwise 'generic' versions are used.
  virtual void startWrite(void);
  virtual void writePixel(int16_t x, int16_t y, uint16_t color);
  virtual void writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
  virtual void writeFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
  virtual void writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
  virtual void writeLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color);
  virtual void endWrite(void);

  // CONTROL API
  // These MAY be overridden by the subclass to provide device-specific
  // optimized code.  Otherwise 'generic' versions are used.
  virtual void setRotation(uint8_t r);
  virtual void invertDisplay(boolean i);

  // BASIC DRAW API
  // These MAY be overridden by the subclass to provide device-specific
  // optimized code.  Otherwise 'generic' versions are used.
  virtual void
    // It's good to implement those, even if using transaction API
    drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color),
    drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color),
    fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color),
    fillScreen(uint16_t color),
    // Optional and probably not necessary to change
    drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color),
    drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);

adafruit_support_bill
 
Posts: 59591
Joined: Sat Feb 07, 2009 10:11 am

Re: Using Adafruit_GFX with user-defined matrices?

by bbx10node on Sat Jun 10, 2017 7:43 am

The Adafruit PCD library does not work with ESP8266 but there are two pull requests pending with changes for the ESP8266. Pick one then the Adafruit GFX library should work without changes.

https://github.com/adafruit/Adafruit-PC ... rary/pulls

bbx10node
 
Posts: 102
Joined: Sun Feb 22, 2015 4:14 pm

Re: Using Adafruit_GFX with user-defined matrices?

by Disciple on Wed Jun 14, 2017 2:55 am

I migrated my rough LCD sketch for dummies over to the Huzzah, and it worked! So in theory, I could manage all my display requirements. I feel a bit self-congratulate-y just now. (c:

bbx10node wrote:Pick one then the Adafruit GFX library should work without changes.
I tried them both. One of them worked, the one with your name. Excellent. Even the default contrast value is right on. If I studied to understand all the details needed to properly modify a library that way, it would have taken me longer than simply reinventing the graphics functions. I can now attest that the modified library works well on a Huzzah setup like mine, soft SPI over a 4-pin connection.

Thanks and happy coding.

Hallelujah!
Disciple

Disciple
 
Posts: 411
Joined: Tue Jan 06, 2015 8:13 pm

Re: Using Adafruit_GFX with user-defined matrices?

by adafruit_support_bill on Wed Jun 14, 2017 5:45 am

Good to hear that you've got it working. Thanks for the follow-up. :)

adafruit_support_bill
 
Posts: 59591
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.