I want to do a custom Joystick project (following Kenton's guide, and maybe referencing some Djinny's work) without the Arduino IDE. I want to dive into more behind-the-scenes C code and get some practice with that world. The problem is of course that things get really complicated quite quickly.
I've got a project built off the teensy template here: https://github.com/apmorton/teensy-template
And I added the Teensy basic code to main.cpp.
But when I try to make, I get an error about the Joystick variable.
My question - what does selecting Tools > USB Type > Joystick actually *do*, and how do I replicate it sans the Arduino IDE?
I've looked through the source for hours without much luck. I tried doing #define USB_HID, thinking that would do it, but no luck so far. Help appreciated.
My main file looks like:
The error I get it is
I've got a project built off the teensy template here: https://github.com/apmorton/teensy-template
And I added the Teensy basic code to main.cpp.
But when I try to make, I get an error about the Joystick variable.
My question - what does selecting Tools > USB Type > Joystick actually *do*, and how do I replicate it sans the Arduino IDE?
I've looked through the source for hours without much luck. I tried doing #define USB_HID, thinking that would do it, but no luck so far. Help appreciated.
My main file looks like:
Code:
#include "WProgram.h"
#define USB_HID
extern "C" int main(void)
{
#ifdef USING_MAKEFILE
// To use Teensy 3.0 without Arduino, simply put your code here.
// For example:
pinMode(13, OUTPUT);
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
while (1)
{
// read analog inputs and set X-Y position
Joystick.X(analogRead(3));
Joystick.Y(analogRead(2));
// read the digital inputs and set the buttons
Joystick.button(1, digitalRead(0));
Joystick.button(2, digitalRead(1));
}
#else
// Arduino's main() function just calls setup() and loop()....
setup();
while (1) {
loop();
yield();
}
#endif
}
The error I get it is
Code:
MacBook-Pro-2:teensy Andrew$ make
[CXX] src/main.cpp
src/main.cpp: In function 'int main()':
src/main.cpp:18:3: error: 'Joystick' was not declared in this scope
Joystick.X(analogRead(3));
^
make: *** [/Users//Dropbox/andrew//teensy/build/src/main.o] Error 1