Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. typedef void (*voidFuncPtr)();
  2. class PWMInput {
  3. int inputPin;
  4. public:
  5. PWMInput(int inputPin, voidFuncPtr interruptDispatch);
  6. void doChannelA(){}
  7. volatile int position = 0;
  8. };
  9.  
  10. // Interrupt dispatch forward declaration
  11. void myMotorDispatch();
  12.  
  13. // Declare the object and pass in our global dispatch function
  14. PWMInput myMotor = PWMInput(0, &myMotorDispatch);
  15.  
  16. void setup() {
  17. }
  18.  
  19. void loop() {
  20. }
  21.  
  22. void myMotorDispatch() {
  23. myMotor.doChannelA();
  24. }
  25.  
  26. PWMInput::PWMInput(int channelA, voidFuncPtr interruptDispatch) {
  27. pinMode(channelA, INPUT);
  28. attachInterrupt(channelA, interruptDispatch, RISING);
  29. }
  30.  
  31. void PWMInput::doChannelA() {
  32. position++;
  33. }
  34.  
  35.  
  36. =================
  37. Arduino: 1.6.7 (Windows 10), Board: "Arduino Pro or Pro Mini, ATmega328 (5V, 16 MHz)"
  38.  
  39. pwm4:31: error: redefinition of 'void PWMInput::doChannelA()'
  40.  
  41. void PWMInput::doChannelA() {
  42.  
  43. ^
  44.  
  45. pwm4:6: error: 'void PWMInput::doChannelA()' previously defined here
  46.  
  47. void doChannelA(){}
  48.  
  49. ^
  50.  
  51. exit status 1
  52. redefinition of 'void PWMInput::doChannelA()'
  53.  
  54. This report would have more information with
  55. "Show verbose output during compilation"
  56. enabled in File > Preferences.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement