Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Low memory Read All not working #51

Closed
iuliux opened this issue Oct 12, 2021 · 3 comments
Closed

Low memory Read All not working #51

iuliux opened this issue Oct 12, 2021 · 3 comments

Comments

@iuliux
Copy link

iuliux commented Oct 12, 2021

I copied from an example and I get this:

ledWemos:51: error: cannot convert 'PCF8574::DigitalInput' to 'byte {aka unsigned char}' in initialization
   byte d = pcf8574.digitalReadAll();
                                   ^
exit status 1
cannot convert 'PCF8574::DigitalInput' to 'byte {aka unsigned char}' in initialization

I defined PCF8574_LOW_MEMORY too, this is the full code, run on a Wemos D1 Mini (esp8266):

/*
 * PCF8574 GPIO Port Expand
 * http://nopnop2002.webcrow.jp/WeMos/WeMos-25.html
 *
 * PCF8574    ----- WeMos
 * A0         ----- GRD
 * A1         ----- GRD
 * A2         ----- GRD
 * VSS        ----- GRD
 * VDD        ----- 5V/3.3V
 * SDA        ----- GPIO_4(PullUp)
 * SCL        ----- GPIO_5(PullUp)
 *
 * P0     ----------------- LED0
 * P1     ----------------- LED1
 * P2     ----------------- LED2
 * P3     ----------------- LED3
 * P4     ----------------- LED4
 * P5     ----------------- LED5
 * P6     ----------------- LED6
 * P7     ----------------- LED7
 *
 */

#include "Arduino.h"
#include "PCF8574.h"  // https://github.com/xreef/PCF8574_library

#define PCF8574_LOW_MEMORY

// Set i2c address
PCF8574 pcf8574(0x20);

void setup()
{
  Serial.begin(115200);
  delay(1000);

  for(int i=0;i<8;i++) {
    pcf8574.pinMode(i, INPUT);
  }
	Serial.print("Init pcf8574...");
	if (pcf8574.begin()){
		Serial.println("OK");
	} else {
		Serial.println("KO");
	}
}

void loop() {
  byte d = pcf8574.digitalReadAll();
  Serial.print("READ VALUE FROM PCF: ");
  Serial.println(d, BIN);
//  Serial.println(di);
  delay(1000);
}
@xreef
Copy link
Owner

xreef commented Oct 12, 2021

Hi,
you must uncomment the line inside PCF8574.h at this line
https://github.com/xreef/PCF8574_library/blob/master/PCF8574.h#L53

Bye Renzo

@xreef xreef closed this as completed Oct 12, 2021
@iuliux
Copy link
Author

iuliux commented Oct 12, 2021

If you didn't have to modify the library would be better, but works.
Thank you for the library.

@xreef
Copy link
Owner

xreef commented Oct 12, 2021

Try to set the define before include of the library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants