Skip to content

Latest commit

 

History

History
60 lines (46 loc) · 3.97 KB

0004-2019-12-04.md

File metadata and controls

60 lines (46 loc) · 3.97 KB

4 Dec 2019

Installing Arduino Libraries

This might be an old method, but it seems to work, from Adafruit-Trinket-USB repo's README:

Arduino libraries allowing Trinket to act as USB devices

NOTE: This folder contains multiple libraries. Each library must be installed individually. Simply installing the master folder won't work. Move each library folder out of the master after you unzip into your libraries folder.

To this end, I did the following:

  1. Downloaded a ZIP of the repo.
  2. Extracted it.
  3. Recompressed the TrinketHidCombo folder into its own ZIP.
  4. Went into Arduino IDE's menu: Sketch => Include Library => Add .ZIP Library...
  5. Chose the TrinketHidCombo.zip file.
  6. The middle status line of the Arduino IDE reported: Library added to your libraries. Check "Include library" menu.
  7. I was then able to open this example (specifically code.ino) and "Verify" it. It gave this warning, but still seemed to compile:
    In file included from /Users/anton/Documents/Arduino/libraries/TrinketHidCombo/usbdrvasm_includer.S:24:0:
    /Users/anton/Documents/Arduino/libraries/TrinketHidCombo/usbdrv/usbdrvasm.S:17:0: warning: "__SFR_OFFSET" redefined
    #define __SFR_OFFSET 0      /* used by avr-libc's register definitions */
    
    In file included from /Applications/Arduino.app/Contents/Java/hardware/tools/avr/avr/include/avr/io.h:99:0,
                    from /Users/anton/Documents/Arduino/libraries/TrinketHidCombo/cmdline_defs.h:26,
                    from /Users/anton/Documents/Arduino/libraries/TrinketHidCombo/usbdrvasm_includer.S:22:
    /Applications/Arduino.app/Contents/Java/hardware/tools/avr/avr/include/avr/sfr_defs.h:141:0: note: this is the location of the previous definition
    #    define __SFR_OFFSET 0x20
    
    Sketch uses 5448 bytes (90%) of program storage space. Maximum is 6012 bytes.
    Global variables use 123 bytes of dynamic memory.
    
    Note that the "library" has been placed in ~/Documents/Arduino/libraries/TrinketHidCombo, and note also that most of the available program space has been used.
  8. I don't know if it matters, but I didn't then do Sketch => Include Library => TrinketHidCombo -- it seemed to work without doing so. When I actually tried selecting that option, it just added all the .h files (I think) to my Sketch's code, that it could find in the library:
    #include <TrinketHidComboC.h>
    #include <cmdline_defs.h>
    #include <TrinketHidCombo.h>
    #include <usbconfig.h>
    This made no difference to the output of the compilation.
  9. I'm not sure if the warning shown above matters. Discussion about it here and here -- evidently it doesn't matter. "SFR" stands for "Special Function Register". Lots more discussion here but probably not overly relevant. Also this.

Official Arduino guides on: installing libraries.

More USB/HID stuff

  • TrinketHidCombo is like TrinketKeyboard, but can do both keyboard and mouse HID commands in the same library?

Other notes

  • Is it worth learning more about PlatformIO? Is it an Arduino-compatible dev environment that works inside VSCode?

Next goals

  1. Try TrinketKeyboard.
  2. Compare (inc. size and capabilities) with TrinketHidCombo.
  3. Try getting/setting keyboard status LEDs.
  4. Try various USB HID commands/modes.