collapse

Author Topic: Arduino and C++ like code  (Read 3480 times)

MEgg

  • Sr. Member
  • *
  • Posts: 262
Arduino and C++ like code
« on: November 02, 2015, 05:51:16 PM »
I tried to put my code into a more object like manner but when using the
   attachInterrupt();
in my constructor I get all sorts of errors (e.g.: "
Code: [Select]
cannot convert 'Motor::encodercountHR_intproc' from type 'void (Motor::)()' to type 'void (*)()'  ")
and so on.

Is there a version of    attachInterrupt() which can be used in more object like code?
I also found
http://forum.arduino.cc/index.php?topic=41713.0
but the not so good solution that worked was putting the interrupt function outside of the class and make the variables public and then
do the  attachInterrupt(); in setup() again, which somehow breaks the whole concept.
1st project: Dagu 5 Rover + Dagu - 4 Channel DC Motor + Red Back Spider robot controller + Raspberry B+
Chassis + wheels: https://picload.org/image/dggroior/20150831_028.jpg
current: https://www.keepandshare.com/userpics/m/a/r/k/usegg/2016-04/sb/img_3480-79682018.jpg

bdk6

  • Guest
Re: Arduino and C++ like code
« Reply #1 on: May 04, 2016, 08:54:25 PM »
Arduinos (8 bit AVR micros) are a very poor match for C++.  The C++ libraries aren't even close to fully implemented.  This quesiton in the avr-libc FAQ tells a bit about it. http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_cplusplus
One of my biggest complaints with arduino is their mixing in of C++.  The processor just isn't big enough to support it properly and it gives people a false impression.

deshipu

  • Member
  • *
  • Posts: 113
  • Radomir Dopieralski
    • Homepage
Re: Arduino and C++ like code
« Reply #2 on: May 04, 2016, 10:32:24 PM »
Also, I'm pretty sure you cannot use attachInterrupt with class methods. Use regular functions, and call the method from it.

MEgg

  • Sr. Member
  • *
  • Posts: 262
Re: Arduino and C++ like code
« Reply #3 on: May 05, 2016, 07:39:38 AM »
Also, I'm pretty sure you cannot use attachInterrupt with class methods. Use regular functions, and call the method from it.

I am using that half implemented object like strategy now. Pitty that they do not implement it completely. If I get some too slow reaction
I will have to change it again anyway.
1st project: Dagu 5 Rover + Dagu - 4 Channel DC Motor + Red Back Spider robot controller + Raspberry B+
Chassis + wheels: https://picload.org/image/dggroior/20150831_028.jpg
current: https://www.keepandshare.com/userpics/m/a/r/k/usegg/2016-04/sb/img_3480-79682018.jpg

 

* Search


* Recent Topics

2D Side Scroller Cyberpunk themed by Killer Angel
[November 12, 2019, 07:56:15 AM]


The unnamed (yet) quatruped spider project by tinhead
[November 09, 2019, 05:58:16 AM]


Ebot SL by erco
[October 31, 2019, 04:27:36 PM]


Discord anyone? by tinhead
[October 20, 2019, 05:35:59 AM]


MKS Gen L 1.0 by lllloydo
[October 06, 2019, 01:24:26 AM]


Saturn pics anyone by viswesh
[September 28, 2019, 11:55:53 PM]


Hello Robot Rebels by Passixs
[September 15, 2019, 10:19:10 PM]


All Ya'll. And me. by James
[September 09, 2019, 10:35:19 PM]


MSD - Motorized solder dispenser (Work in progress) by James
[September 09, 2019, 08:45:29 PM]


It may be dangerous to work in the virtual realm by ZeroMax
[September 05, 2019, 05:55:16 PM]


"1984 Nixie Time" by Gareth
[August 25, 2019, 12:21:58 PM]


Just wanted to say Hi. by ErwinCanto
[August 18, 2019, 10:11:28 PM]


SDR (Software Defined Radio) by Gareth
[August 14, 2019, 01:12:21 PM]


PLX-DAQ by AmandaG
[August 06, 2019, 01:58:42 PM]


DIY Yellow Servo by AmandaG
[August 06, 2019, 01:08:09 PM]

* Recent Posts

Re: 2D Side Scroller Cyberpunk themed by Killer Angel
[November 12, 2019, 07:56:15 AM]


Re: The unnamed (yet) quatruped spider project by tinhead
[November 09, 2019, 05:58:16 AM]


Re: The unnamed (yet) quatruped spider project by Nemesis
[November 09, 2019, 03:29:02 AM]


Re: Ebot SL by erco
[October 31, 2019, 04:27:36 PM]


Re: 2D Side Scroller Cyberpunk themed by Killer Angel
[October 31, 2019, 09:57:48 AM]


Re: 2D Side Scroller Cyberpunk themed by Killer Angel
[October 31, 2019, 06:01:53 AM]


Re: 2D Side Scroller Cyberpunk themed by maelh
[October 30, 2019, 03:06:28 AM]


Discord anyone? by tinhead
[October 20, 2019, 05:35:59 AM]


The unnamed (yet) quatruped spider project by tinhead
[October 20, 2019, 05:28:14 AM]


Re: 2D Side Scroller Cyberpunk themed by Killer Angel
[October 17, 2019, 09:44:06 AM]


Re: 2D Side Scroller Cyberpunk themed by Killer Angel
[October 17, 2019, 08:16:11 AM]


Re: 2D Side Scroller Cyberpunk themed by Killer Angel
[October 14, 2019, 08:52:20 AM]


2D Side Scroller Cyberpunk themed by Killer Angel
[October 14, 2019, 03:32:40 AM]


Re: MKS Gen L 1.0 by lllloydo
[October 06, 2019, 01:24:26 AM]


Re: Saturn pics anyone by viswesh
[September 28, 2019, 11:55:53 PM]