Comments (5)
Hi alve89,
use void* pointer.
Bye Renzo
from pcf8574_library.
Thanks for your very quick reply!
I just tried a bit with this but still I don't see how to store the PCF8574
object as a property in a myClass
object and "change" its address afterwards...? So my problem is the line PCF8574 myPCF;
in my first post.
from pcf8574_library.
If you don't want to instantiate the object you have to use a pointer.
`
class myClass {
public:
PCF8574* getMyPCF();
void setMyPCF();
private:
PCF8574* myPCF;
};
`
But I think it's better if you declare first like in this example.
Bye Renzo
from pcf8574_library.
I understand that. The problem with only having the pointer is, that I would need to instantiate the object somewhere else (e.g. in global scope) but I don't want the user to instantiate it by himself, I want to provide an interface (get / set methods), so I thought of instantiating the object in the myClass
object and use it with the getMyPCF()
method.
The example you provided does exactly what I don't want: Declaring / defining the objects in global scope and use them in setup()
(and loop()
).
from pcf8574_library.
I just changed the library by the following things:
- PCF8574.h: Adding default value for
_address
- PCF8574.h: Adding
void setAddress(uint8_t address);
andvoid setI2CPins(uint8_t sda, uint8_t scl);
- PCF8574.cpp: Adding the definitions of the declarations above
If you find this helpful, feel free to use it. Beside this issue I think these changes can be helpful. If you see another way to solve this issue, I'm looking forward to your response!
PCF8574_library_emptyConstructor.zip
@xreef I just noticed an error in my code, I forgot the &Wire
line - I added it and it's working properly now!
from pcf8574_library.
Related Issues (20)
- PCF8574 with HC-SR04 UltraSonic Sensor HOT 5
- Low memory Read All not working HOT 3
- Wont compile at all esp32 HOT 1
- if (pcf8574.begin()) is always ko !!! HOT 2
- digitalWrite(PIN, LOW) changes all pins to LOW HOT 1
- Error when compiling. HOT 2
- Lockup on PCF8574::begin() on ESP32 due to unpaired beginTransmission() call HOT 2
- Got digitalReadAll to work, but digitalRead is not? HOT 4
- Do library examples work with ESP32 2.02 ?? HOT 8
- class PCF8574' has no member named 'pinMode' HOT 3
- Won't compile with ESP8266 DevKit 1 HOT 2
- Both digitalReadAll and digitalRead return same value for all INPUT or INPUT_PULLUP pins HOT 6
- aduino web editor HOT 2
- Raspberry Pi Pico W with multiple PCF8574 HOT 1
- problem with interrupt HOT 1
- OUTPUT SET TO HIGH DURING BEGIN HOT 3
- Compilation error: expected initializer before 'updateEncoder' HOT 3
- Couldn't initialize HOT 1
- Changing Output to Input mid program HOT 1
- Unable to call in ESP32 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pcf8574_library.