Go Down

Topic: Just wrote my first library. A driver for the L298 chip (Read 1 time) previous topic - next topic

PaulS

Quote
At least point me in a relevant direction. I can't find anything to have it work.
You are trying to get the preprocessor to do something that it is not designed to do. It can not tell what value is stored in variables in the code. That approach will never work.

All that you can do is use any valid data that is supplied, and quietly ignore any bad data.
The art of getting good answers lies in asking good questions.

spacedementia87

OK, why did you bring it up then? It was only at your suggestion that I went down the rabbit hole.

The code already ignores any I put for num > 2.

Also I spied your suggestion of:

private:
    int aPins[2];
    int bPins[2];
    int dirPins[2];

Is a bit pointless, as they are private variables for the instance of the class they don't need to be arrays.

PaulS

Quote
It was only at your suggestion that I went down the rabbit hole.
I suggested that you check the user input. I did NOT suggest that you try to get the pre-processor or compiler to that checking for you.

Quote
Is a bit pointless, as they are private variables for the instance of the class they don't need to be arrays.
The code is simpler for using the data when you use arrays. You are welcome to write code that is more complicated than needed.
The art of getting good answers lies in asking good questions.

Go Up