Rob,
Small thing, IRQ should be int8_t rather than uint8_t for the error handling to work as intended. I also support Paul's macro as a very worthwhile addition to the core (developers) API.
Cheers,
Vic
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.
Hi Rob,
This alone is probably a reason to keep it, even if only internally.
> 2) Easy implementation of attachInterruptToPin(); see proto below
I suspect this is partly because the "valid interrupt / pin" check
> 3) Codesize: as attachInterruptToPin() makes sketch ~30 bytes larger
> [quick 1 call test on UNO]
happens twice now. I expect that the extra size gets reduced if you make
attachInterrupt return a boolean too and in attachInterruptToPin just
call attachInterrupt without any checks and forward the return value.
Same for detach, of course.
> the test >= 0 is needed as attachInterrupt expects an uint8_t, "throwing"This would need to be solved as well, but I guess that simply using 0xff
> in -1 results in a unwanted cast.
as "invalid interrupt / pin" instead of -1 would work just as fine?
That'll remove the need for using ints instead of uint8_t, which also
saves a byte (and the related code for handling 2 bytes).
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAlJFVaUACgkQz0nQ5oovr7xLhQCgmqjpfALALnNSR/1MpSFa7+q5
Sx4An1uA3f9kM+DU9iOjpwFXurx0D1zE
=8PN6
-----END PGP SIGNATURE-----
(testsketch 1 call)
void attachInterrupt: 2946 bytesboolean attachInterrupt: 2954 bytes
Think AITP() was already quite optimized by the compiler.
On Fri, Sep 27, 2013 at 11:53 AM, Matthijs Kooijman <matt...@stdin.nl> wrote:
Hi Rob,
Making it bool is also backwards compatible. Source compatible of
> keeping attachInterrupt void gives me the smallest code. (and by keeping it
> void it will be BWcompatible)
course, but I don't think binary compatible is important for Arduino,
right?
You're saying that attachInterrupt as a void with the duplicate check in
the ToPin versions is smaller than a bool attachInterrupt and the
minimal ToPin version you showed? That would surprise me, really... Or
just that attachInterrupt is smallest when void (which makes sense).
Gr.
Matthijs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAlJFVaUACgkQz0nQ5oovr7xLhQCgmqjpfALALnNSR/1MpSFa7+q5
Sx4An1uA3f9kM+DU9iOjpwFXurx0D1zE
=8PN6
-----END PGP SIGNATURE-----
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAlJHPnsACgkQz0nQ5oovr7xBogCgsnSbF0/p9myZ+KEAAtqn/6Pb
3dYAoONP0CB0Su2zOrilSVEA24XynYwn
=Hl/S
-----END PGP SIGNATURE-----
Think -1 is better as when a board with >256 pins will arrive (someday) the -1 will be mapped upon 0xFFFF
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
I prefer a#define LED_BUILTIN 13 // or whatever
as it would not take memory.
did you post an issue for this @github yet?
On Sun, Sep 29, 2013 at 6:53 PM, Dennis German <DGe...@real-world-systems.com> wrote:
As an aside, can the
static const uint8_t LED_BUILTIN = ?????
be added while these updates are going on?
On 9/28/13 3:56 PM, Cristian Maglie wrote:
hardware/arduino/avr/variants/robot_control ?
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.
C
C
C
Just mark one add deprecated in big red letters in the docs...right?
Vic
But the idea is to continue to have attachInterrupt() around for compatibility right? In which case, either you have an undocumented function (which is confusing) or you have to keep documenting both it and attachInterruptToPin(), which creates duplication and makes it harder for people to know which one to use.
C
I'd like to propose another macro in pins_arduino.h, to allow libraries
to translate digital pins to the interrupt numbers needed for
attachInterrupt(), and detect if a user-specified pin doesn't support
attachInterrupt().
It might look something like this?
// Arduino Uno
#define digitalPinToInterrupt(p) ( (p) == 2 ? 0 : ((p) == 3 ? 1 : -1) )
// Arduino Mega
#define digitalPinToInterrupt(p) ( (p) == 2 ? 0 : ((p) == 3 ? 1 :
((p) >= 18 && (p) <= 21 ? 23 - (p) : -1)) )
// Arduino Leonardo & Yun
#define digitalPinToInterrupt(p) ( (p) == 0 ? 2 : ((p) == 1 ? 3 :
((p) == 2 ? 1 : ((p) == 3 ? 0 : ((p) == 7 ? 4 : -1)))) )
// Arduino Due
#define digitalPinToInterrupt(p) ( (p) < NUM_DIGITAL_PINS ? (p) : -1 )
At least 4 libraries currently have long #ifdef chains for this purpose:
Encoder, PS2Keyboard, Adafruit_VS1053 and Adafruit_CC3000. The GSM3
library also has some hard-coded pin to interrupt stuff. I do not
believe any of these libraries fully supports all official Arduino boards.