How combine stepper-control wit usb-hid-control?

Hi people,

i have a little problem. It should be no problem but i cant get it:

  • I know that in the USBHost2 Library in the hidjoystickrptparser.cpp there is this part
void JoystickEvents::OnGamePadChanged(const GamePadEventData *evt)
{
	Serial.print("X: ");
	PrintHex<uint8_t>(evt->X);
	Serial.print("\tY: ");
	PrintHex<uint8_t>(evt->Y);
	Serial.print("\tZ: ");
	PrintHex<uint8_t>(evt->Z1);
	Serial.print("\tZ: ");
	PrintHex<uint8_t>(evt->Z2);
	Serial.print("\tRz: ");
	PrintHex<uint8_t>(evt->Rz);
	Serial.println("");
}

so i can see the HEX datas in the serial monitor when im moving the Joystick. Now i think there should be no problem to use these datas to control a stepper?!

  • When im using the standard Stepper.h library oder the AccelStepper.h library i should change the steps or speed when i could parse the datas from the usbhid-control to the stepper-control.

And now the big “BUT”:

  • When i embedd the stepper stuff in the usbhid thing i get everytime a error message of the implementing of the library or the object.
  • Im confussed what to write, im new in the arduino buisness, i tried
#include <Stepper.h>

#define STEPS 100

Stepper stepper(STEPS, 8, 9, 10, 11);

int previous = 0;

void setup()
{
  stepper.setSpeed(30);
}

void loop()
{
  int val = GamePadEventData (evt->X);

  stepper.step(val - previous);

  previous = val;
}

Unfortunately thats not the right way. Can anybody give me a advice how to get these both things work together?!

How is that sketch supposed to have a clue what a GamePadEventData is?

Thanks, did it will write a tutorial soon.