adafruit / Adafruit-PCD8544-Nokia-5110-LCD-library

Arduino driver for PC8544, most commonly found in small Nokia 5110's
http://ladyada.net/products/nokia5110/
Other
396 stars 226 forks source link

ESP8266 support #28

Closed lunanigra closed 3 years ago

lunanigra commented 8 years ago

Is the Adafruit-PCD8544-Nokia-5110-LCD lib already fully ESP8266 compatible?

Following lines for example have caused a compiler issue (Adafruit_PCD8544.cpp 193ff.)

clkport     = portOutputRegister(digitalPinToPort(_sclk));
clkpinmask  = digitalPinToBitMask(_sclk);
mosiport    = portOutputRegister(digitalPinToPort(_din));
mosipinmask = digitalPinToBitMask(_din);
bbx10 commented 8 years ago

You are welcome to try this fork modified for the ESP8266.

https://github.com/bbx10/Adafruit-PCD8544-Nokia-5110-LCD-library

lunanigra commented 8 years ago

@bbx10 : Thanks your fork works!

As done with the GFX lib it would be cool if the Adafruit PCD8544 lib could be modified as well.

mcauser commented 8 years ago

@bbx10 works for me too. Thanks!

canislupus11 commented 8 years ago

Hi! I have Arduino v1.6.8 and fork for ESP of Adafruit PDC8544 library (https://github.com/bbx10/Adafruit-PCD85 ... ee/esp8266)

When i compile and upload example code "pcdtest" i get on serial console:

` ets Jan 8 2013,rst cause:4, boot mode:(3,6)

wdt reset load 0x4010f000, len 1264, room 16 tail 0 chksum 0x42 csum 0x42 ~ld`

WereCatf commented 8 years ago

@canislupus11 Did you change the pins in the example?

canislupus11 commented 8 years ago

No. But I should?

WereCatf commented 8 years ago

@canislupus11 Obviously.

bbx10 commented 8 years ago

@canislupus11 I replied to your message on esp8266.com.

moxy-bc commented 8 years ago

When I run you pcdtest sketch it produces a fatal error:

Arduino\libraries\Adafruit_PCD8544\Adafruit_PCD8544.cpp:20:26: fatal error: avr/pgmspace.h: No such file or directory

I changed the pins to match my hardware. Do I have to define something else to make this work on ESP8266?

WereCatf commented 8 years ago

@moxy-bc: did you grab the esp8266 - branch of bbx10's version of the library, or did you just grab the master - branch? (git clone -b esp8266 https://github.com/bbx10/Adafruit-PCD8544-Nokia-5110-LCD-library.git)

moeins commented 8 years ago

The Library https://github.com/bbx10/Adafruit-PCD8544-Nokia-5110-LCD-library.git did not work!

fatal error: avr/pgmspace.h: No such file or directory

when I fixed it with:

#if defined ( ESP8266 )
  #include <pgmspace.h>
#else
  #include <avr/pgmspace.h>
#endif

It comes with this error:

error: cannot convert 'volatile uint32t* {aka volatile unsigned int}' to 'PortReg {aka volatile unsigned char}' in assignment clkport = portOutputRegister(digitalPinToPort(_sclk)); ^ error: cannot convert 'volatile uint32t {aka volatile unsigned int}' to 'PortReg {aka volatile unsigned char*}' in assignment mosiport = portOutputRegister(digitalPinToPort(_din));

WereCatf commented 8 years ago

@moeins You didn't grab the esp8266 - branch, you grabbed the master - branch.

moeins commented 8 years ago

Ok, I got it. For Mac User:

  1. Open Terminal
  2. Input git clone -b esp8266 https://github.com/bbx10/Adafruit-PCD8544-Nokia-5110-LCD-library.git
  3. Search for the Library and move it to: USER/Library/Arduino15/libraries/
witnessmenow commented 7 years ago

Hi All,

I'm using @WereCatf fork, using the correct esp8266 branch and the example works fine when I have it wired up.

When I tried to use it another sketch it was crashing on display.begin(), after a lot of commenting out I narrowed it down to line Wifi.begin(ssid, pass) in my own sketch. If this line is in my sketch (either before or after calling display.begin() the crash happened.

`Exception (9): epc1=0x40203184 epc2=0x00000000 epc3=0x00000000 excvaddr=0x3ffe838d depc=0x00000000

ctx: cont sp: 3fff1920 end: 3fff1b60 offset: 01a0

stack>>> 3fff1ac0: 00000004 00000028 3fff094c 40202f97
3fff1ad0: 3fff094c 3ffe838d 000001f8 402031ec
3fff1ae0: 00000004 00000028 3fff0668 000001f8
3fff1af0: 3ffe838d 00000000 3fff0668 40204d90
3fff1b00: 402010ae 000001f4 3fff0668 3fff0b2c
3fff1b10: 00000004 00000028 3fff0668 40204f26
3fff1b20: 3fffdad0 00000000 3fff0a70 40201f2e
3fff1b30: feefeffe feefeffe feefeffe feefeffe
3fff1b40: 3fffdad0 00000000 3fff0b24 402057fc
3fff1b50: feefeffe feefeffe 3fff0b40 40100718
<<<stack<<< `

Has anyone else ran into this? Esp8266 will try to connect to your last used credentials so removing the Wifi.begin is an option on a board that I have already programmed my credentials on but to use display on a new esp8266 I'm going to first have to write another sketch to it first (which is not the end of the world or anything!)

You can recreate by adding the following to the example:


#include <ESP8266WiFi.h> //to the headers

//including the above seemed to lose reference to min, so here is what i presume the implementation is, not exactly important anyways.
int16_t min(int x, int y){
  if(x < y)
  {
    return x;
  }

  return y;
}

void setup()   {
  Serial.begin(9600);

  //delay(1000);
  WiFi.begin("ssid", "pass");
....

Thanks for the work on the library, other than this it works great!

I'm using an official wemos mini board.

bravenius commented 7 years ago

Nothing worked for me, seems Adafuit library and ESP8266 don't like each other... no workaround let program compile. Finally I switched to other 5110 library (not the best as doesn't support little fonts) but got it compiled and worked. Normally Adafruit libraries are tricky to implement or maybe hardware specific.

witnessmenow commented 7 years ago

@werecatf branch works for me on the esp8266 with the latest release version of esp8266 core

bravenius commented 7 years ago

OK, maybe need to update core library. using NodeMCU 1.0, give it a try again today. Thanks @WereCatf

innesm commented 6 years ago

The link posted above by bbx10 is the wrong link - it isn't modified for the esp8266. Here is a link to his/her esp8266-specific branch (have compiled it, but haven't tried running it):

esp8266 branch

infoyobots commented 6 years ago

@innesm It works!!!!! Thanx a lot.

cihadkck commented 5 years ago

when i run pcdtest example, i am having the NodeMCU 0.9 (ESP-12 Module) compiling error. I've already dowloaded it from board manager. I've used ESP8266WiFi.h library. Where is the problem?

`#include

include

include

Adafruit_PCD8544 display = Adafruit_PCD8544(D0, D1, D2);

define NUMFLAKES 10

define XPOS 0

define YPOS 1

define DELTAY 2

define LOGO16_GLCD_HEIGHT 16

define LOGO16_GLCD_WIDTH 16

static const unsigned char PROGMEM logo16_glcd_bmp[] = { B00000000, B11000000, B00000001, B11000000, B00000001, B11000000, B00000011, B11100000, B11110011, B11100000, B11111110, B11111000, B01111110, B11111111, B00110011, B10011111, B00011111, B11111100, B00001101, B01110000, B00011011, B10100000, B00111111, B11100000, B00111111, B11110000, B01111100, B11110000, B01110000, B01110000, B00000000, B00110000 };

void setup() { Serial.begin(9600);

display.begin();

display.setContrast(50); . . .

testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_WIDTH, LOGO16_GLCD_HEIGHT); }

void loop() {

} . . . ... }`

drak7 commented 5 years ago

ESP8266 support added in #47.

@cihadkck What specific error are you getting?

Yasirkhan1301 commented 3 years ago

Nothing worked for me, errors occurred

error: cannot convert 'volatile uint32_t {aka volatile unsigned int}' to 'PortReg {aka volatile unsigned char}' in assignment clkport = portOutputRegister(digitalPinToPort(_sclk)); ^ error: cannot convert 'volatile uint32_t {aka volatile unsigned int}' to 'PortReg {aka volatile unsigned char}' in assignment mosiport = portOutputRegister(digitalPinToPort(_din)); ^ exit status 1 Error compiling for board NodeMCU 1.0 (ESP-12E Module).

Yasirkhan1301 commented 3 years ago

Error gone by type casting every line clkport = (unsigned char)portOutputRegister(digitalPinToPort(_sclk)); mosiport = (unsigned char)portOutputRegister(digitalPinToPort(_din));

ladyada commented 3 years ago

this should be fixed now with the move to busio!