I purchased the M4, configured it for the Arduino IDE and loaded my code but the Joystick Library will not compile. I've stripped my code down to the M4 KeyPad demo and the Joystick Library to zero in on the problem which condenses to a bunch of HID stuff not being present. I've looked for the missing files (USBAPI.h, PluggableUSB.h, and DynamicHID.h) with no success.
Error message,
"Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "Adafruit Trellis M4 (SAMD51), Enabled, 120 MHz (standard), Small (-Os) (standard), 50 MHz (standard), Arduino, Off"
Build options changed, rebuilding all
In file included from C:\Users\srcarter\Documents\Arduino\libraries\Joystick\src/Joystick.h:24:0,
from C:\Users\srcarter\Documents\Arduino\My_keypad_test2\My_keypad_test2.ino:2:
C:\Users\srcarter\Documents\Arduino\libraries\Joystick\src/DynamicHID/DynamicHID.h:37:28: fatal error: PluggableUSB.h: No such file or directory
#include "PluggableUSB.h"
^
compilation terminated.
exit status 1
Error compiling for board Adafruit Trellis M4 (SAMD51).
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Sample code:
- Code: Select all | TOGGLE FULL SIZE
#include "Adafruit_NeoTrellisM4.h"
#include <Joystick.h>
// The NeoTrellisM4 object is a keypad and neopixel strip subclass
// that does things like auto-update the NeoPixels and stuff!
//Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID, JOYSTICK_TYPE_JOYSTICK, 32, 0,
// true, true, true, true, true, true,
// false, false, false, false, false);
Adafruit_NeoTrellisM4 trellis = Adafruit_NeoTrellisM4();
boolean *lit_keys;
void setup(){
Serial.begin(115200);
trellis.begin();
trellis.setBrightness(80);
Serial.println("toggle keypad test!");
lit_keys = new boolean[trellis.num_keys()];
for (int i=0; i<trellis.num_keys(); i++) {
lit_keys[i] = false;
}
}
void loop() {
int key;
// put your main code here, to run repeatedly:
trellis.tick();
while (trellis.available()){
keypadEvent e = trellis.read();
if (e.bit.EVENT == KEY_JUST_PRESSED) {
key = e.bit.KEY; // shorthand for what was pressed
Serial.print(key); Serial.println(" pressed");
lit_keys[key] = !lit_keys[key];
if (lit_keys[key]) {
trellis.setPixelColor(key, Wheel(random(255)));
} else {
trellis.setPixelColor(key, 0);
}
} else {
key = e.bit.KEY;
Serial.print(key); Serial.println(" released");
}
}
delay(10);
}
// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return trellis.Color(255 - WheelPos * 3, 0, WheelPos * 3);
}
if(WheelPos < 170) {
WheelPos -= 85;
return trellis.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
WheelPos -= 170;
return trellis.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
##############################
Any help to get HID Joystick via the Joystick Library on the NeoTrellis M4 Express (8x4 buttons) will be greatly appreciated.
-src