I am really stuck at this problem for two days now. I know I am missing some crutial information but I don't know what.
I am programming an ESP32 using vscode and platformio.
I have imported ezButton and ezOutput. They both work fine when I call them from main.cpp. I assume this is because I am not calling them from inside a different class. Now I wrote a custom class which does some stuff and I want to read inputs from ezButton and write outputs to ezOutput.
Where my head is stuck at at this point is that I don't now how to correctly initialize the classes correctly.
I imagine it working like in my main.cpp where I for example just type inputPinName.isPressed();
and I get my information. This should also work the other way like outputPinName.high();
.
I would really appreciate someone explaining this to me or providing a link to a resource that explains this issue.
Here are some code snippets:
main.cpp
#include <ezButton.h>
#include <ezOutput.h>
// INPUTS
ezButton inputPinUp(34, INPUT_PULLDOWN);
//... same for all other inputs
// OUTPUTS
ezOutput outputPinUp(4);
ezOutput outputPinDown(0);
#define DEBOUNCE_TIME 50
void setup()
{
inputPinUp.setDebounceTime(DEBOUNCE_TIME);
//... same for all other pins
}
void loop()
{
inputPinUp.loop();
//... same for all other pins
}
shutter.h
#include <ezButton.h>
#include <ezOutput.h>
class shutter
{
private:
int inputPinUp;
//...
int _outUp;
int _outDown;
ezButton Button_;
ezOutput Output_;
public:
shutter(ezOutput& outputPin) : Output_(outputPin) {} //ERROR: no default constructor exists for class "ezButton"
shutter(ezButton& Pin) : Button_(Pin) {} //ERROR: no default constructor exists for class "ezOutput"
void shutterInput(
int inputPinUp,...);
void shutterOutput(
int outputPinUp,
int outputPinDown);
void stop(void);
void driveUp(void);
void driveDown(void);
};
I didn't switch the error messages above. They are actually reversed somehow.
shutter.cpp
#include "shutter.h"
//...
void shutter::shutterOutput(
int outputPinUp,
int outputPinDown)
{
int _outUp = outputPinUp; //I am not sure if I even have to do this
}
void shutter::stop(void)
{
ezOutput _outUp.low(); //ERROR: no default constructor exists for class "ezOutput"
digitalWrite(_outDown, LOW);
_moving = false;
}