I am no software guru, so do not judge if this is a dumb question 
I am trying to make a class for a motor driver chip.
This chip has two direction pins to dictate whether we want to control the motor in Forward or Reverse.
On some designs, people will hook both pins to a micro, in other designs, people will just fan out from an inverter gate to ensure two different states from one pin.
I started making my class like this
I was going to make an overriding class to add the extra pin if it was a design that used two pins on the micro
However,
1. this does not seem elegent
2. It does not seem possible to simply add a variable since I need to add that parameter in the base class anyways. If I wanted to redefine a variable, this would work, but not to add?
Any suggestions on a better way? or maybe some pointers on what I can read on? Maybe I am overlooking the obvious?
I am trying to make a class for a motor driver chip.
This chip has two direction pins to dictate whether we want to control the motor in Forward or Reverse.
On some designs, people will hook both pins to a micro, in other designs, people will just fan out from an inverter gate to ensure two different states from one pin.
I started making my class like this
Code:
class motorDriver
{
uint8_t pwmPin;
uint8_t directionPin;
uint8_t enablePin;
uint8_t enableFWDpin;
uint8_t enableREVpin;
public:
motorDriver(uint8_t pwmpin, uint8_t directionpin, uint8_t enablepin, uint8_t enablefwd, uint8_t enablerev)
{
pwmPin = pwmpin;
directionPin = directionpin;
enablePin = enablepin;
enableFWDpin = enablefwd;
enableREVpin = enablerev;
}
};
Code:
class motorDriverWith2Pins : public motorDriver
{
//add another variable?
}
1. this does not seem elegent
2. It does not seem possible to simply add a variable since I need to add that parameter in the base class anyways. If I wanted to redefine a variable, this would work, but not to add?
Any suggestions on a better way? or maybe some pointers on what I can read on? Maybe I am overlooking the obvious?