Cannot create stepper object within other class object

Hey all, I was working with the TMCStepper Library (GitHub - teemuatlut/TMCStepper) and wanted to create a helper class to work efficiently with multiple steppers. In this case the helper class would have an object of the stepper motor.
I have attached all files necessary. But the structure is very easy.

I get error messages within StepperHelper.cpp, one in line 3 (no default constructor exists for class "TMC5160Stepper"C/C++(291)), adding an empty constructor for TMC5160Stepper fixes it, the bigger problem is line 5 (function "TMC5160Stepper::operator=(const TMC5160Stepper &)" (declared implicitly) cannot be referenced -- it is a deleted functionC/C++(1776)).
I tried using references instead, but no success. I can create the object within main without a problem though but I am still unable to pass it to the helper class.

Anyone got a clue what the problem is?
Thank you!

main.cpp

#include "StepperHelper.h"
StepperHelper stepper1;

void setup() {
  stepper1 = StepperHelper(10);
}
void loop() {}

StepperHelper.h

#include "TMCStepper.h"

class StepperHelper {

    private:
        TMC5160Stepper stepper;        

    public:
        StepperHelper(uint16_t pinCS);
        
};

StepperHelper.cpp

#include "StepperHelper.h"

StepperHelper::StepperHelper(uint16_t pinCS) {

    stepper = TMC5160Stepper(pinCS, 0.075, 50, 51, 52, -1);

}

StepperHelper.zip (39.2 KB)

Change that to:

#include "StepperHelper.h"
StepperHelper stepper1(10);

void setup() {}
void loop() {}

That not right. You need to use an initializer list if the constructor for the TMC5160Stepper class takes arguments. See Case #3 Here.

Try this instead:

#include "StepperHelper.h"

StepperHelper::StepperHelper(uint16_t pinCS)  : stepper(pinCS, 0.075, 50, 51, 52, -1) {

}

Thanks guys :slight_smile:
Haven't heard of initializer lists before.