collapse

Author Topic: Arduino and C++ like code  (Read 4286 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

"1984 Nixie Time" by 1 what
[May 08, 2020, 01:04:18 AM]


2D Side Scroller Cyberpunk themed by Killer Angel
[February 06, 2020, 06:39:40 AM]


A new wing design for model aircraft / drones by OddBot
[February 06, 2020, 04:42:06 AM]


SDR (Software Defined Radio) by Gareth
[February 02, 2020, 06:15:42 AM]


Circuit Math by ZeroMax
[January 31, 2020, 01:50:18 PM]


NanOMeter by Protowrxs
[January 01, 2020, 12:59:44 PM]


Investigating the VL53L0X Laser Rangefinder by erco
[December 30, 2019, 10:45:44 PM]


PS4 Single Handed Controller Deployed (part 7 of 7) by Gareth
[December 30, 2019, 09:52:29 AM]


"D" -Pad Workio just like Magic (Will Merlin stay or Go) (part 6 of 7) by Gareth
[December 30, 2019, 09:51:27 AM]


PS4 Joystick Digitals 4,5,6,7,10 - Analog's Lx,Ly,Rx,Ry Workio (part 5 of 7) by Gareth
[December 30, 2019, 09:50:37 AM]


Menu Workio ! (part 4 of 7) by Gareth
[December 30, 2019, 09:49:49 AM]


L1 trigger design Workio (Hori controller) (part 3 of 7) by Gareth
[December 30, 2019, 09:48:50 AM]


Hori aka PS4 Joystick Mappings (part 2 of 7) by Gareth
[December 30, 2019, 09:47:17 AM]


PS4 Single Left-Handed Controller (part 1 of 7) by Gareth
[December 30, 2019, 09:44:58 AM]


Time of Flight >>> Rounded Corners !!! by BaldwinK
[December 04, 2019, 05:46:08 PM]

* Recent Posts

Re: "1984 Nixie Time" by 1 what
[May 08, 2020, 01:04:18 AM]


Re: "1984 Nixie Time" by tomasp
[April 13, 2020, 06:03:28 PM]


Re: 2D Side Scroller Cyberpunk themed by Killer Angel
[February 06, 2020, 06:39:40 AM]


A new wing design for model aircraft / drones by OddBot
[February 06, 2020, 04:42:06 AM]


Re: "1984 Nixie Time" by Gareth
[February 02, 2020, 06:23:01 AM]


Re: SDR (Software Defined Radio) by Gareth
[February 02, 2020, 06:15:42 AM]


Re: SDR (Software Defined Radio) by ZeroMax
[January 31, 2020, 01:54:21 PM]


Re: "1984 Nixie Time" by ZeroMax
[January 31, 2020, 01:52:29 PM]


Circuit Math by ZeroMax
[January 31, 2020, 01:50:18 PM]


Re: 2D Side Scroller Cyberpunk themed by ZeroMax
[January 31, 2020, 01:45:33 PM]


NanOMeter by Protowrxs
[January 01, 2020, 12:59:44 PM]


Re: Investigating the VL53L0X Laser Rangefinder by erco
[December 30, 2019, 10:45:44 PM]


PS4 Single Handed Controller Deployed (part 7 of 7) by Gareth
[December 30, 2019, 09:52:29 AM]


"D" -Pad Workio just like Magic (Will Merlin stay or Go) (part 6 of 7) by Gareth
[December 30, 2019, 09:51:27 AM]


PS4 Joystick Digitals 4,5,6,7,10 - Analog's Lx,Ly,Rx,Ry Workio (part 5 of 7) by Gareth
[December 30, 2019, 09:50:37 AM]