i am not so much expirienced to change the library.
This is just simple example ... but my code gets realy complicated without this. Its not just about speed.
There's absolutely no reason to do that.
You need an array of object of the class defined in the library. You need to share the library, we can't see your computer screen.
i just dont understand what to do ... if there is something more to know ... can you please direct me in direction what should i learn? ... now i am just confused what should i do.
sorry, but i dont know what TestSetup library is and i dont know whats are you planing to test ... thank you for your time ... seems i am not even on the level of knowlege to be helped ... thank you
bye bye
The TestSetup sketch comes with the library that you linked to
#include <Arduino.h>
#include <TMC2209.h>
HardwareSerial & serial_stream = Serial1;
const long SERIAL_BAUD_RATE = 115200;
const int DELAY = 3000;
// Instantiate TMC2209
TMC2209 stepper_driver;
void setup()
{
Serial.begin(SERIAL_BAUD_RATE);
stepper_driver.setup(serial_stream);
}
void loop()
{
if (stepper_driver.isSetupAndCommunicating())
{
Serial.println("Stepper driver is setup and communicating!");
Serial.println("Try turning driver power off to see what happens.");
}
else if (stepper_driver.isCommunicatingButNotSetup())
{
Serial.println("Stepper driver is communicating but not setup!");
Serial.println("Running setup again...");
stepper_driver.setup(serial_stream);
}
else
{
Serial.println("Stepper driver is not communicating!");
Serial.println("Try turning driver power on to see what happens.");
}
Serial.println("");
delay(DELAY);
}
Here is a version using an array of objects. In practice it uses only one of them so should behave the same way as the original
If it works for you then I will explain the changes that I made
#include <Arduino.h>
#include <TMC2209.h>
HardwareSerial & serial_stream = Serial1;
const long SERIAL_BAUD_RATE = 115200;
const int DELAY = 3000;
// Instantiate TMC2209
TMC2209 stepper_driver[2];
void setup()
{
Serial.begin(SERIAL_BAUD_RATE);
stepper_driver[0].setup(serial_stream);
}
void loop()
{
if (stepper_driver[0].isSetupAndCommunicating())
{
Serial.println("Stepper driver is setup and communicating!");
Serial.println("Try turning driver power off to see what happens.");
}
else if (stepper_driver[0].isCommunicatingButNotSetup())
{
Serial.println("Stepper driver is communicating but not setup!");
Serial.println("Running setup again...");
stepper_driver[0].setup(serial_stream);
}
else
{
Serial.println("Stepper driver is not communicating!");
Serial.println("Try turning driver power on to see what happens.");
}
Serial.println("");
delay(DELAY);
}
Don't forget that you can use a variable as the index to the array of objects to cut down on repetitive code if it is appropriate to do so in your sketch
I don't want any money, but if you feel like it you could put a few crowns in a charity box when you next see one