Escolar Documentos
Profissional Documentos
Cultura Documentos
Etiquetas
Extendí el firmware del joystick para presentar un joystick mucho más grande en la PC host. El nuevo firmware tiene:
Esto debería ser útil para construir sistemas de control grandes como los controles de vuelo para un simulador de vuelo, consola Firefly,
consola Viper u otro sistema de control grande.
Fondo
Un pequeño fondo para cualquier persona nueva en la creación de dispositivos USB con Arduino UNO o MEGA2560.
La interfaz USB en las placas UNO y MEGA2560 se implementa en un pequeño AVR. Para las placas R1 y R2, AVR es Atmega8U2, y
para las placas R3 es Atmega16U2. Estos chips están programados con firmware que presenta una interfaz serial USB para la PC host,
y se conectan a la MCU Atmega principal de Arduino a través de su puerto serie TTL (pines digitales 0 y 1).
El 8U2 y 16U2 se pueden reprogramar utilizando DFU (modo de actualización de firmware del dispositivo). Esto significa que el firmware
Serial USB puede ser reemplazado con otro firmware USB para convertir todo el Arduino en dispositivos USB, como un mouse, un
teclado, un joystick o un dispositivo MIDI.
Esta tabla describe el formato del informe de 21 bytes que Arduino envía al 8U2 / 16U2. Esto permite que el Arduino emule un joystick
grande, enviando posiciones de eje y el valor de 40 botones a la PC Host.
Descriptor HID
Este es el descriptor HID para el joystick. Puede obtener más información acerca de ellos en las tablas de uso de USB HID .
http://archive.is/KbXom 1/20
27/4/2018 Arduino UNO Big Joystick HID firmware
Bosquejo de ejemplo
Aquí hay un boceto que demuestra cómo enviar datos de joystick al host.
#define NUM_BUTTONS 40
#define NUM_AXES 8 // 8 ejes, X, Y, Z, etc.
joyReport_t joyReport;
void setup ()
{
Serial.begin (115200);
retraso (200);
http://archive.is/KbXom 2/20
27/4/2018 Arduino UNO Big Joystick HID firmware
{
Serial.write ((uint8_t *) informe, sizeof (joyReport_t));
}
//
activa un botón en void setButton (joyReport_t * joy, uint8_t button)
{
uint8_t index = button / 8;
uint8_t bit = button - 8 * index;
// desactivar un botón
void clearButton (joyReport_t * joy, uint8_t button)
{
uint8_t index = button / 8;
uint8_t bit = button - 8 * index;
Suba primero el boceto al Arduino, luego coloque Arduino-big-joystick.hex en el 8U2 / 16U2. Desenchufa el Arduino y vuelve a
enchufarlo, y se verá como un joystick para el host y el host recibirá las actualizaciones del joystick del boceto.
Si desea cargar otro boceto, primero coloque Arduino-usbserial.hex en el 8U2 / 16U2, desenchufe el Arduino y vuelva a enchufarlo.
Ahora puede cargar el boceto.
Descargas
Aquí hay una aplicación de prueba de Python para verificar que su joystick Arduino se comporte correctamente. Requiere pygame y
ocempgui.
El código fuente está disponible en Github . Consulte mis publicaciones de blog anteriores para obtener instrucciones sobre cómo
construir el firmware.
Cargando el firmware
http://archive.is/KbXom 3/20
27/4/2018 Arduino UNO Big Joystick HID firmware
Para Atmega8u2 (UNO R1, R2, MEGA2560 R1, R2):
Utilice los mismos pasos para cargar Arduino-usbserial.hex cuando desee restaurar la funcionalidad normal a su UNO (por ejemplo, para
cargar un nuevo boceto).
Nota: Necesitará la versión 0.5.5 de dfu-programmer para programar el ATMEGA16U2. Obtenga la última versión aquí .
Comentarios
Darran,
¿Está la fuente disponible para esto? No pude encontrarlo en el enlace de Github que publicaste.
Gracias
Hola Darran,
¡Gracias por un proyecto tan útil! ¿Qué se debe modificar para agregar otros 40 botones y tener 80 en total?
¡Gracias!
Hola Darren
He creado una interfaz de teclado personalizada y quiero agregar dos interfaces de joystick ahora. ¿Cuán posible (y fácil) es
hacer que varios dispositivos funcionen desde un Arduino 2560?
I've seen the double joystick but haven't figured out which part of the code handles the usb device part. Admittedly I don't have a
full handle on the USB HID bootstrap. So fare I've found nobody who has created code that allows more than one type of device
running from an Arduino UNO. I'm thinking the 4kb limit may have something to do with it but it would be awesome to have a hex
file which included a keyboard, joysticks and midi (and mouse I guess) all controlled through one Arduino Mega through one usb
port. I have a feeling the 16mhz is also a limiting factor here.
Hi Alex,
you can increase the number of buttons by modifying the descriptor called JoystickReport in Descriptors.c to add more buttons,
and modifying the USB_JoystickReport_Data_t structure in Arduino-joystick.h to make room for the additional buttons.
Hi Dom,
if you have a newer Arduino 2560 with the 16u2 then you can fit in additional devices in the descriptor and add code to send
data for them. With the older 8u2 its unlikely it will have the code space to support them.
http://archive.is/KbXom 4/20
27/4/2018 Arduino UNO Big Joystick HID firmware
Hi Darran, thanks for your hard work! I am using your firmware on Sparkfun's 32U4 breakout board (not an Arduino). After some
minor modifications to the makefile (changed MCU) I got my board to enumerate in Windows and show up as a game controller.
I am using the Big Joystick demo and my question is, how can I write to the joystick axes? I have several potentiometers hooked
up to various ADC ports and I would like each of them to control a joystick axis.
Thank you!
Hello Darran,
Thank you for all of these great resources. I have flashed the firmware successfully, but I am confused about how to assign pins
to the potentiometers and buttons that I have. I don't see any pin assignments in your Arduino BigJoystick sketch. Should I be
writing those myself? If you have time, could you point me in the right direction on how to do that? Thank you so much.
I have a question tho. If you use the Arduino as a joystick, can you still send back data to it via a serial connection? I mean,
would you still be able to make the Arduino light up led and other device from commands sent from the PC at the sametime it
"emulate" a joystick in Windows?
Thanks!
Hi Gyom,
the 8u2/16u2 firmware replaces the serial function with the new function. This mean when you flash the joystick or keyboard
firmware, the Arduino appears to be a joystick or keyboard and not a serial port.
Thank you for this excellent How To. I've just build a 6DOF joystick for Kerbal Space Program and Minecraft. Maybe even
Descent? I really hope with this I can get it to work. I'll let you know!
Hello again Darran. Can you provide some indication on how to assign pins using your code?
Hi, Darran. Great tutorial. Thank you for writing it and doing all that hard work on your own. I'm trying to follow your example to
flash my MEGA 2560 from OSX Lion. All I get is "dfu-programmer: no device present." Any idea what I'm doing wrong?
Dan, try the latest version of dfu-programmer (http://dfu-programmer.sourceforge.net). It might also be that your mega is not in
DFU mode, this page may help http://arduino.cc/en/Hacking/DFUProgramming8U2 (its the same two pins on the 2560).
Hi Darran, and everyone. I get the same problem as Dan ("dfu-programmer: no device present.") with a arduino Uno R3, using
dfu-programmer-win-0.6.0.
I connected briefly the ground and reset pins as described in the above link (but without the 10Kohm resistor soldered on the
board, because it's a R3 one) to turn it in DFU mode. The "L" LED, as turned "off" then "on", so the manipulation seems to be
efficient.
Did I missed something? Is the 0.6.0 programmer the last version?
Dan, did you solve your own issue?
Hi everyone,
I just solved my problem using Windows 7 drivers from https://code.google.com/p/unojoy/downloads/list
so it seems like my previous drivers didn't work well...
Enjoy, and thanks anyway to those who searched.
Hi Darran,
http://archive.is/KbXom 5/20
27/4/2018 Arduino UNO Big Joystick HID firmware
is it possible to use an arduino MICRO for this?
Hi Darran,
I'm a combat simulation fan and DIY adept. I have an arduino uno and I'm making a combat stick. That possibility sounds
fantastic for the young maker I am.
Would it be possible to add a wiring scheme in order to use these 8 axis + 40 buttons ? That would allow a quick use of your
sketch without digging how to wire bits :o).
Regards.
Hi Darren,
Is there any particular reason that you continue to use 100807 version of LUFA? I see that it's over 2 years old and latest version
130303 is available.
I did attempt to port your previous project (and thirtybuttons one) to use this latest version. I was successful in compilation but I
could never get resultant firmware to run on Arduino UNO.
Hi Darran,
How did u generate the hex file? did u refer it from HID descriptor? and how is it possible?
Im in Windows 7
Fred,
This is not a complete ready-to-wire package, if you'll note the main loop in the code (the lines near the end starting with "void
loop()") just cycles through the buttons turning them all on and off while moving the axes around. It's a demo, for which the user
is expected to fill in the blanks with however they prefer to get the input.
On the plus side the author has done pretty much all the hard work here. You can take example analog/digital I/O code from any
"starting Arduino" type guide, toss it in the loop, and call the setButton/clearButton/joyReport functions as appropriate and get
something that works in a few minutes.
I wonder if the uno can still run other code whilst it is acting as a hid joystick?
My project is a bus ticket machine, i want the 36 keys on it to send joystick button inputs over usb (using a matrix for the keys)
and at the same time i want to run an LCD, so when certain keys are pressed, as well as sending the joystick button input over
usb, it also displays text on the LCD,
http://archive.is/KbXom 6/20
27/4/2018 Arduino UNO Big Joystick HID firmware
Gates, have a look at the earlier posts on the blog for a guide on how to build the hex file: http://hunt.net.nz/users/darran. I'm not
sure how you would build it under windows, but you could install virtualbox and then Ubuntu linux (or your favourite flavour linux
distro) in a VM, then use the linux tools to build the hex file.
Pretty much anyway you want. Check the hardware interface guide on the arduino.cc site. You could use the 6 analog input pins
and an I2C expander to provide two more analog inputs, or you use a chip like the MCP3008
(http://www.adafruit.com/products/856) to get 8 analog inputs via the SPI bus. For the digital inputs, you can construct a matrix
(or grid) using 13 inputs (e.g. 5 x 8). If you're low on input pins, use an expander like the I2C MCP23008
(http://www.adafruit.com/products/593) to add another 8 inputs.
Gazz, yes you can run other code. You can just use the normal 4-bit Arduino LCD library to drive a text LCD, or an SPI library to
drive an TFT graphic LCD, or any of the other displays that the Arduino can handle.
I just got my firs arduino today. I figured out how to get the hex file loaded and stuff but I am lost with programming. I just need
an example of using a hall effect sensor for 1 axis right now. Can anyone help?
I have that part down. I just don't know anything about coding yet! : )
It is possible to start this program on arduino due? If yes, please reply. My email marcepan@hackerspace.pl
Hi Daran,
Seems you did a really nice work here! But I can't figure out how to control an axis. Could you give me an example of scketch?
Thanks a lot for your time.
Hi Daran
I tried to expand the button number from 40 to 48 but failed, according to your instructions I changed Descriptors.c
JoystickReport[] like this :
as you can see the UsageMaximum and Report count has changed to 48,
Then I changed Arduino-big-joystick.c joyReport declaration like this, just appended a zero at the end:
92 USB_JoystickReport_Data_t joyReport = { {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} };
I also changed your test sketch to make the board send 48 buttons data to the serial port, I uploaded the sketch and tested the
serial output by using HTerm, below is a sample output captured:
78 05 D8 0E 38 18 98 21 F8 2A 58 34 B8 3D 18 47 FF FF FF FF FF 0F
the first 16 bytes are the 8 axis, the last 6 bytes are the buttons status.
I'm using Arduino Mega2560 R3, so I set the ARDUINO_MODEL_PID to 0x0010 in makefile then make the firmware
and uploaded it by using dfu-programmer, unplug / replug, windows installed the arduino joystick driver.
But the button and axis doesn't work, in Windows Game controller settings window the button indicator doesn't change, the axis
bar doesn't move.
And I assume the TX indicator light on Mega2560 should always flash indicates there are data send out to USB Host, but it only
flashes for the first few seconds after I plug it in, after that it remains unlighted.
http://archive.is/KbXom 7/20
27/4/2018 Arduino UNO Big Joystick HID firmware
If I revert everything to 40 buttons it works without any problem, please could you shed me some light on this? I have no idea
which part I missed.
Now I encountered a new issue, the button on/off activity is totally out of order.
I'm not sure if this is a bug in the firmware but I'm pretty sure when I changed the button count to 48 the button's on/off are
actually controlled by the the 6 bytes from 3 axis?! This is weird. I can see the button status changes very clearly by using
XPlane button:Adv control panel.
Hey Shawn, nice one. I'm surprised that Windows will support more than 30 buttons. Could you try testing the joystick using
pygame?
Hi Darran,
I am totally new to this field, hardware or coding, but how do you make it happen in UNO supporting 16 bits resolution axis? As I
know, only Arduino Due has the 12 bits ADS input, other boards are all 10 bits.
Hi Darran,
I think I have figured out the reason that the button status changes randomly after change button number from 40 to 48, it's
because the ringbuffer size need to be changed accodringly.
We have 16 bytes for axis and 6 byte for the 48 buttons, so, there are 22 bytes for the report data,
/** Size of each ring buffer, in data elements - must be between 1 and 255. */
47 #define BUFFER_SIZE 110 // 110 = 22 * 5
48
49 /** Maximum number of data elements to buffer before forcing a flush.
50 * Must be less than BUFFER_SIZE
51 */
52 #define BUFFER_NEARLY_FULL 88
//88 = 22 * 4
Apart from this, I think the endpoint buffer size should be updated accordingly in Descriptor.h
Windows can support buttons more then 32, but the game controller setting page can only show the first 32 buttons,
to test more button status, I just use the game, XPlane 10 or others.
Hi Jason, It seems that the code just send out the 16 bit numbers for each axis to the USB host ( computer ), but the AD
resolution is actually 10 bit. So it's still in 10 bit resolution.
Hi Darran, Another question, I tried to use latest LUFA, it compiles success but just won't work. Is there any reason you stick on
LUFA 100807? Thanks
Hi all,
http://archive.is/KbXom 8/20
27/4/2018 Arduino UNO Big Joystick HID firmware
I tried the code in the uno, the demo works well, all buttons lighted and axis moved. When I tried to modified the sketch as below,
the 3 axis were not response to the input:
Anyone can help? how to make the axis and button actually work? Better give some example code.
Many thanks!
Jason
Also I thought the uno read 10bits of precision but had to be sent via 8bits?
Hi Jason,
the HID report specified that the analog range is [-32768, 32767], but analogRead(x) return value's range is [ 0,1023]
so you need to use map() like this:
joyReport.axis[0] = map( analogRead(A0), 0, 1023, -32768, 32767 );
Hi Shawn,
Thank your answer, I figured it out myself today and resolved the jitter problem by average. It's working now in my rudder pedal.
How can i extend from 8 to 14 axis ? Can someone make a tutorial ? to extend axis or buttons with avr-studio ?
;-)
What files have i to change and how values must new calculated in the source code ?
Hi Shawn,
I used LUFA 100807 because that was the only version of LUFA that was supported at the time. Good to see that some of the
newer versions are working.
Hi Darran!
Great job, this is exactly what I need. But I'm having a problem here and I can't figure out what is wrong... I downloaded the HEX
file, submitted it to my Arduino Mega 2560R3 using your instructions, unplugged and plugged in again and windows recognized
it as an Android Joystick... but the buttons simple don't works in games nor in windows controller settings. They are all
connected to Analog ports 0-12 and I'm using Windows 7... there are any port mapping I should do in the source code to put it to
work?
I was wondering if it is possible to use this on a Micro (or Leonardo)? Both have USB baked in and the Micro means that I could
stash the circuit out of the way in a case easier.
Nevermind, I'm doing everything wrong here. I'm just figuring out on how to add pushbuttons on Arduino. Anyway, at least after
*REALLY* following the instructions my buttons stopped pushing like crazy.
Now I will have to wait the end of the hollydays to continue my project due to a $.10c resistor! Hehehe!
http://archive.is/KbXom 9/20
27/4/2018 Arduino UNO Big Joystick HID firmware
Hi,
I can't figure out how to program the joystick. I have tried this, it didn't do anything. What do I have to add to make it work?
#define NUM_BUTTONS 40
#define NUM_AXES 8
joyReport_t joyReport;
long sensorValue = 0;
long sensor = 10;
void setup() {
Serial.begin(115200);
delay(200);
}
void loop() {
sensorValue = analogRead(A0);
sensor = map(sensorValue, 0, 1023, -32768, 32767);
joyReport.axis[3] = sensor;
delay(1);
}
Hi Darran, I'm wanting to make a HID dj controller with a minimum of 24 analogue pots, would it be possible with LUFA and what
device class should I thinking about using?
Can you show me which bits i need to change and how so i can flash my uno to show up as just a 40 button joystick? please....
with cherries on top :)
or even cheat and point me to a finished hex file with the axis removed and all renumerated or what ever needs doing to it.
Hi again Darran, I've been toying with the Unojoy code and have it transmitting a 64 Byte HID report, (48 pots & 128 buttons) I
am now wanting to try the same with your code, could you include the .cproj and the like in your source? As I am now somewhat
familiar editing and building with AVR studio but makefiles and using VM I have no clue about.
Hey Nick, I don't have a .cproj file. I assume that's for Windows? I built the firmware using the makefile that is included. It builds
on Linux and OS X.
Hi darran.
Congratulations for this great project. I am interested in contact with you my mail about a big project. Mine is carcaes1 AT
hotmail.com Cheers.
Hi dears, good tutorial. I updated the demo to my arduino, and all the 8 axes moves. Now i'm interest to read the 8 axes from the
ANALOG port of Arduino. I can't find a Sketch with this code. Somebody have this code or a link ? Big Hugs
I Write a code to use with POT in ANALOG PIN, and BUTTON in DIGITAL PIN of Arduino. With this code, is possible to use with
Joystik Microsoft SideWinder and others. To use with pot, need to use ground, analog pin, 5v of arduino respective, linke this pic
http://archive.is/KbXom 10/20
27/4/2018 Arduino UNO Big Joystick HID firmware
-> http://arduino.cc/en/uploads/Tutorial/joy_sch_480.jpg
#define NUM_BUTTONS 13
#define NUM_AXES 5 // 5 axes, X, Y, Z, etc (UNO)
joyReport_t joyReport;
void setup(void);
void loop(void);
void setButton(joyReport_t *joy, uint8_t button);
void clearButton(joyReport_t *joy, uint8_t button);
void sendJoyReport(joyReport_t *report);
void setup()
{
Serial.begin(115200);
delay(200);
// turn a button on
void setButton(joyReport_t *joy, uint8_t button)
{
uint8_t index = button;
uint8_t bit = button ;
//Inform Botton power ON
http://archive.is/KbXom 11/20
27/4/2018 Arduino UNO Big Joystick HID firmware
Serial.println("POWER BOTTON_");
Serial.println(button);
sendJoyReport(&joyReport);
button++;
if (button >= NUM_BUTTONS ) {
button = 0;
}
delay(100);
}
/* INSTALLATION
Just install POT in each analog port. Using the _GND _Analog _5V Arduino.
Like this image: http://arduino.cc/en/uploads/Tutorial/joy_sch_480.jpg
To setup the buttons, just install you prefered button switch under GND and Port Digital 02~13.
Use Flip to erease and burn this firmware DFU: https://github.com/harlequin-tech/arduino-usb/blob/master/firmwares/Arduino-
big-joystick.hex
I used Arduino R3 with Atmega 16U2.
*/
#undef DEBUG
joyReport_t joyReport;
http://archive.is/KbXom 12/20
27/4/2018 Arduino UNO Big Joystick HID firmware
uint8_t btn[12];
int fulloff = 0;
void setup(void);
void loop(void);
void setButton(joyReport_t *joy, uint8_t button);
void clearButton(joyReport_t *joy, uint8_t button);
void sendJoyReport(joyReport_t *report);
void setup()
{
//set pin to input Button
for( int portId = 02; portId < 13; portId ++ )
{
pinMode( portId, INPUT_PULLUP);
}
Serial.begin(115200);
delay(200);
// turn a button on
void setButton(joyReport_t *joy, uint8_t button)
{
uint8_t index = button/8;
uint8_t bit = button - 8*index;
/*
* Read Digital port for Button
* Read Analog port for axis
*/
void loop()
{
// Create Matriz with value off switch button
for(int bt = 1; bt < 13; bt ++)
{
http://archive.is/KbXom 13/20
27/4/2018 Arduino UNO Big Joystick HID firmware
btn[bt]= digitalRead(bt+1);
}
// Power ON button if it is press. buton 17 at 28
for(int on=01; on < 13; on++)
{
if (btn[on] == LOW)
{
setButton(&joyReport, on+16);
// Serial.println("botao ON");
// Serial.println(on+16);
}else{
fulloff = fulloff++;
} //Power off all Button, if all button are not press
if(fulloff == 13)
{
for(uint8_t cont=0; cont<40; cont++)
{
clearButton(&joyReport, cont);
}
// Serial.println("Every buttons is off");
}
}
delay(100);
fulloff = 0;
}
Cans you tell me what to change to use pulse buttons for the joystick? your code sets only buttons on but never goes off!
Hi IceMakeR, I will test the Buttons, and if detect some problem, i post new CODE. OK ? Big Hugs
Dear Riclamer,
Thanks.
Hi p2, it's correct. My code are set to 3 axis. If you want more axis, you need so set this line: for (uint8_t axis = 0; axis < 3;
axis++) . It's possible to use at 8 axis. Edit to: for (uint8_t axis = 0; axis < 7; axis++).
http://archive.is/KbXom 14/20
27/4/2018 Arduino UNO Big Joystick HID firmware
Also need to coment all not used axis. Edit with simbol "//":
//joyReport.axis[3] = 0;
//joyReport.axis[4] = 0;
//joyReport.axis[5] = 0;
//joyReport.axis[6] = 0;
//joyReport.axis[7] = 0;
//joyReport.axis[8] = 0;
About the buttons, i'm testing and will post a new code.
Big Hugs
Dear Riclamer,
Now analog pins A0, A1, A2 and A3 are reading 4 Axis and ther are working fine.
But my question is, since I am using Arduino Mega 2560 and I have 16 Analog pins, is there any method to active other analog
or digital pins?
how about Roraty Encoder?
That would be nice, If you could add the Rotary Encoder function into your code.
I have seen someone provided a code including Rotary Encoder like this:
/*
Mega2560 R3, digitalPin 22~ 37 used as row0 ~ row 15,
digital pin 38~53 used as column 0 ~ 15,
it's a 16 * 16 matrix,
joyReport_t joyReport;
/*
RotaryEncoder
BA BA BA BA
CW >>> 00 01 11 10 <<< CCW
*/
/*
this value sets the threshold for the CW/CCW drift in milliseconds
any direction drift within this time limit will be ignored, the previous direction will be used.
*/
byte CWCCWDriftTimeLimit = 60;
http://archive.is/KbXom 15/20
27/4/2018 Arduino UNO Big Joystick HID firmware
//store the rotary encoder's AB pin value in last scan
byte prevEncoderValue[ENCODER_COUNT];
const byte CWPattern1 = B00011110, CWPattern2 = B01111000, CWPattern3 = B11100001, CWPattern4 = B10000111;
const byte CCWPattern1 = B00101101, CCWPattern2 = B10110100, CCWPattern3 = B11010010, CCWPattern4 = B01001110;
//store the rotary encoder's last pulse time, this will be used to remove the drift effect
unsigned long prevEncoderMillis[ENCODER_COUNT];
void setup()
{
for( int portId = 22; portId < 38; portId ++ )
{
pinMode( portId, OUTPUT );
}
for( int portId = 38; portId < 54; portId ++ )
{
pinMode( portId, INPUT_PULLUP);
}
PORTD = B10000000;
PORTG = B00000111;
PORTL = B11111111;
PORTB = B00001111;
Serial.begin(115200);
delay(200);
void loop()
{
//Serial.println( millis() - loopTime );
//loopTime = millis();
PORTC = 0xFF;
for ( int rowid = 0; rowid < 4; rowid ++ )
http://archive.is/KbXom 16/20
27/4/2018 Arduino UNO Big Joystick HID firmware
{
//turn on the current row
PORTA = ~( B00000001 << rowid);
//we must have such a delay so the digital pin output can go LOW steadily,
//without this delay, the row PIN will not 100% at LOW during yet,
//so check the first column pin's value will return incorrect result.
delayMicroseconds(3);
byte colResult[16];
if ( encoderValue != prevEncoderValue[encoderId] )
{
//we have a "pulse" from rotary encoder
int direction = 0;
EncoderState[encoderId] = EncoderState[encoderId] << 2 | encoderValue;
http://archive.is/KbXom 17/20
27/4/2018 Arduino UNO Big Joystick HID firmware
{
//the current direction is different with the previous one, let's use the previous direction instead
direction = prevEncoderDirection[encoderId];
}
}
if ( direction == 1 )
{
//set bit to 10
joyReport.button[ rowid * 2 + colid / 8 ] |= 0x1 << ( colid % 8 + 1);
joyReport.button[ rowid * 2 + colid / 8 ] &= ~(0x1 << ( colid % 8 ));
prevEncoderMillis[ encoderId ] = millis();
prevEncoderDirection[ encoderId ] = direction;
}
else if ( direction == -1 )
{
//set bit to 01
joyReport.button[ rowid * 2 + colid / 8 ] &= ~(0x1 << ( colid % 8 + 1));
joyReport.button[ rowid * 2 + colid / 8 ] |= 0x1 << ( colid % 8 );
prevEncoderMillis[ encoderId ] = millis();
prevEncoderDirection[ encoderId ] = direction;
}
}
}
}
byte colResult[16];
//pin 38, PD7
colResult[0] = (PIND & B10000000)== 0 ? 1 : 0;
//pin 39, PG2
colResult[1] = (PING & B00000100)== 0 ? 1 : 0;
//pin 40, PG1
colResult[2] = (PING & B00000010)== 0 ? 1 : 0;
//pin 41, PG0
colResult[3] = (PING & B00000001)== 0 ? 1 : 0;
http://archive.is/KbXom 18/20
27/4/2018 Arduino UNO Big Joystick HID firmware
colResult[14] =(PINB & B00000010) == 0 ? 1 : 0;
//pin 53, PB0
colResult[15] =(PINB & B00000001) == 0 ? 1 : 0;
Hi P2. With firmware arduino_big_joystik.hex, you can use up to 8 axis. Analog Pins 0~7.
About use encoders, i'm not sure if it's possible to use with big_joystik firmware. I believe this code you post, need another
firmware.
About buttons you can use all digital pins of Arduino Mega. 53 Buttons with my code. I will post in some days new version of
code.
Big Hugs
Hi ... Today i tested an the buttons are OK !! I created a store to share the code with everybody. Some quest can by post here.
https://github.com/RICLAMER/Arduino_Big_Joystik
Dear Riclamer, Thanks for your efforts. It should be nice, I will check it and let you know.
Thanks
Dear Riclamer,
Como dije antes, en Mega solo el PIN número 2 ~ 13 funciona como un botón! y otros pines quedaron sin usar!
por cierto, no pude encontrar ninguna diferencia entre el nuevo código y el anterior.
Gracias.
Hola p2, el código está hecho para trabajar con 13 botones porque la limitación de Uno. Ahora estoy escribiendo un código para
usar en todos los pin digitales de MEGA
Grandes abrazos
Hola de nuevo, ¿es posible subir un firmware .hex como joystick / serial juntos?
http://archive.is/KbXom 19/20
27/4/2018 Arduino UNO Big Joystick HID firmware
http://archive.is/KbXom 20/20