Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef void (*voidFuncPtr)();
- class PWMInput {
- int inputPin;
- public:
- PWMInput(int inputPin, voidFuncPtr interruptDispatch);
- void doChannelA(){}
- volatile int position = 0;
- };
- // Interrupt dispatch forward declaration
- void myMotorDispatch();
- // Declare the object and pass in our global dispatch function
- PWMInput myMotor = PWMInput(0, &myMotorDispatch);
- void setup() {
- }
- void loop() {
- }
- void myMotorDispatch() {
- myMotor.doChannelA();
- }
- PWMInput::PWMInput(int channelA, voidFuncPtr interruptDispatch) {
- pinMode(channelA, INPUT);
- attachInterrupt(channelA, interruptDispatch, RISING);
- }
- void PWMInput::doChannelA() {
- position++;
- }
- =================
- Arduino: 1.6.7 (Windows 10), Board: "Arduino Pro or Pro Mini, ATmega328 (5V, 16 MHz)"
- pwm4:31: error: redefinition of 'void PWMInput::doChannelA()'
- void PWMInput::doChannelA() {
- ^
- pwm4:6: error: 'void PWMInput::doChannelA()' previously defined here
- void doChannelA(){}
- ^
- exit status 1
- redefinition of 'void PWMInput::doChannelA()'
- This report would have more information with
- "Show verbose output during compilation"
- enabled in File > Preferences.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement