#defines & USB-HID - how to vary the RAWHID_USAGE value so I can identify Teensys?
I think this is a kind of compiler question more than anything else: I've got several Teensys connected, and I've got them talking to my Mac by just using the RawHID function:
Seemingly no need to open or initialise anything on the Teensy - this just immediately works. Super.
The Vendor / Product / Usage page / usage values are set by #defines in ... /hardware/teensy/avr/cores/usb_rawhid/usb_private.h as far as I can tell. I think all I need to do is change the RAWHID_USAGE number to something different on each Teensy (maybe set it with jumpers), and then have my Mac app call
with the new value for each Teensy.
Is that an appropriate way to differentiate between different Teensys? Just having each one have a different RAWHID_USAGE value? This is just for my use, not for a product for sale?
But what would be the best way for me to change these values for different sketches?
- Should I put #ifndef / #endif around the #define in the core file, and then #define my own RAWHID_USAGE in my sketch?
- Is there a way to do it that doesn't involve those "core" files - can I copy them into my sketch folder and alter them there instead?
(I hate the idea of having to depend on alterations to files in the Arduino / Teensyduino folder structure as I know I'll forget to do it next time I install new versions of things)
I think this is a kind of compiler question more than anything else: I've got several Teensys connected, and I've got them talking to my Mac by just using the RawHID function:
Code:
RawHID.send( myBuffer, 0 );
Seemingly no need to open or initialise anything on the Teensy - this just immediately works. Super.
The Vendor / Product / Usage page / usage values are set by #defines in ... /hardware/teensy/avr/cores/usb_rawhid/usb_private.h as far as I can tell. I think all I need to do is change the RAWHID_USAGE number to something different on each Teensy (maybe set it with jumpers), and then have my Mac app call
Code:
rawhid_open(...)
Is that an appropriate way to differentiate between different Teensys? Just having each one have a different RAWHID_USAGE value? This is just for my use, not for a product for sale?
But what would be the best way for me to change these values for different sketches?
- Should I put #ifndef / #endif around the #define in the core file, and then #define my own RAWHID_USAGE in my sketch?
- Is there a way to do it that doesn't involve those "core" files - can I copy them into my sketch folder and alter them there instead?
(I hate the idea of having to depend on alterations to files in the Arduino / Teensyduino folder structure as I know I'll forget to do it next time I install new versions of things)
Last edited: