Cleric-K / vJoySerialFeeder

Feed Virtual Joystick driver with data from a serial port
GNU General Public License v3.0
258 stars 55 forks source link

added example sketch for Arduino Mega boards #40

Closed jpasichnyk closed 4 years ago

Cleric-K commented 4 years ago

Hi,

Before merging, do you by any chance get warning for redefinition of NUM_ANALOG_INPUTS? A word came about this here: https://github.com/Cleric-K/vJoySerialFeeder/issues/38#issuecomment-682035093

I don't have mega so you and @CubicVirtuoso are probably the first ones to test with it. Seems the NUM_..._INPUTS names are already used in Arduino/AVR headers.

Would it be possible to make this commit as follow:

  1. I prefer to use only one sketch - it makes maintenance easier, otherwise changes would have to be replicated in every file.
  2. Let's use the original sketch as base
  3. Leave the analog/digital/bitmapped arrays as they are - they serve as an example, so it's better to have them there and the users should only modify them according to their needs.
  4. Change the analog array to use A0, A1, etc. (I don't remember why I haven't used the A defs in the first place)
  5. Change the #define ANALOG_REFERENCE to DEFAULT. I prefer this #define to stay, because it is a reminder that the analog reference must be changed if needed. It seems it has stayed to EXTERNAL from the times I was using a toy transmitter with Arduino. Since the tx had its own power supply and the pots were using 3.3V I had to wire that to AREF and set the define to EXTERNAL. I have overlooked that - it is better to keep the define at DEFAULT.
  6. Change all NUM... defines to COUNT... or something else if you have better idea.

Thank you!

jpasichnyk commented 4 years ago

I actually am getting that redefinition warning. My lower pane of the Arduino IDE was very small so I didn't even notice it as it was quickly paged out of view.

I'll take a pass at implementing these changes and update the pull.

jpasichnyk commented 4 years ago

This now compiles without any any variable redefinition warnings.

I added a few extra comments to it as well.