JammaMia open source firmware, to be used with JammaMia PCB REV.1
Compile with Arduino IDE 2.x.
Arduino libraries needed:
- Arduino's Keyboard
- Arduino's Mouse
- Adafruit MCP23017 (https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library) with dependency Adafruit BusIO (https://github.com/adafruit/Adafruit_BusIO)
- DigitalWriteFast (https://github.com/ArminJo/digitalWriteFast)
- ArduinoJoystickLibrary from Matthew Heironimus (https://github.com/MHeironimus/ArduinoJoystickLibrary)
Specific JammaMia libraies (in this github):
- KeyboardNKey for 24-Key rollover (https://github.com/njz3/jammamia/tree/main/Libs/KeyboardNKey)
- MouseN for 2 mices emulation (https://github.com/njz3/jammamia/tree/main/Libs/MouseN)
The board contains 2xMCP23017 IOs expenders on I2C bus for digital inputs (buttons) and outputs (lamps); The Atmega32u4 IOs are routed to either analog inputs, or PWM enabled outputs. A ULN2003 chip is used for the OUT signals. The OUT pins are meant to be used to set GND to the pin when it is enabled. Maximum current is 500mA and maximum voltage is +5V, taken from the cabinet power supply. The OUTPWM pins have also the additionnal property to be PWM pins that can be used to perform dimming or control a solenoid power transistor.
Example wiring for a bulb LAMP:
+5V
|
LAMP
|
OUT1 (will be pulled to GND when enabled)
The board is viewed as a serial port (COM under windows, or /dev/ttyUSBxx on Linux). When you connect to it, the baudrate is 1000000 baud. Each command is a text command ended by the '\n' (newline) character. Some commands are single char only, other longer forms use a '$' escaping character. When a reply is expected, the reply will start with a 'M' for a standard reply message, a 'S' for the status message, a 'E' for an error message. Each reply line will end with a '\n' character.
o short commands:
v: printboard version.l: list current din (digital in)/ain (analog in) configuration, one per line.u: give inputs value.s: enable streaming of inputs values.h: halt streaming of inputs values.o: set digital outputs value 0..F (only 4 bits). Syntax:oXXwith XX being a value between 0..F that enable/disable an output.p: set pwm block analog out value. SyntaxpXYYwith X being a 4-bit selector and YY being a value between 0..FF.~: reset/restart board.
o long escaped commands:
$resetcfg: reset board configuration to its default (not saving to eprom).$savecfg: save board configuration to eprom.$loadcfg: load board configuration from eprom.$get param: get the value of a parameter, value will be printed as an HEX(adecimal) value likeFF. List of parameters given below.$set param=HEX: set the value of a parameter, value must be an HEX(adecimal) value likeFFF. List of parameters given below.$setdin DIN TYPE MAP SHIFTEDMAP NAME: set the configuration of a digital input DIN. See below for more details.$setain AIN TYPE POS NEG DMIN DMAX NAME: set the configuration of an analog input AIN. See below for more details.
delay: add a loop delay in microseconds to lower the refresh rate and save USB resources.kblay: keyboard layout. 0=USA, 1=FR, 2=DE, 3=IT, 4=ES. Default value is 1 (FR).emode: emulation modes. 0=no emulation, 1=keyboard only, 2=joystick only, 3=joystick and keyboard, 4=mouse, 5=mouse and keyboard. Default value is 3.axes: number of emulated axes for each gamepad. Default value 2.btns: number of emulated boutons for each gamepad. Default value is 0xA (=10)hats: number of emulated HAT switch for each gamepad. Default value is 2.shift: digital input used for shifted mapping. Default value is 0.
For digital inputs, din configuration value are in the following order:
DIN TYPE MAP SHIFTEDMAP NAME
Meaning is:
Digital input number in HEX format (no 0x prefix needed)
Type value in HEX format (no 0x prefix needed).
Here is the enumerated values:
- 0=Nothing,
- 1=Emulation of a keyboard key (a,z,w,q,e,etc.),
- 2=X/Y/Z analog axes, NOT SUPPORTED for DIN,
- 3=HAT 8 directions HAT (see HATDirections),
- 4=Joystick buttons,
- 5=mouse axes X/Y/Wheel from analog or digital,
- 6=mouse button left/right/middle/prev/next.
Mapping value in HEX format (no 0x prefix needed)
Value is index of keyscan code (0 being none), joy or mouse axis, joy or mouse button. For axis and buttons, the 7th MSB (0b10000000) gives the player selection P1-P2, bits 6 to 0 are axis or button index. For HAT switch, the 7th MSB gives the player selection P1-P2, 5&6th gives the hat switch number, 3 to 0 gives the direction.
Shifted mapping value (0 for none), in HEX format (no 0x prefix needed).
Index of keyscan code when using shifted/alternative map (0 being not used/none).
Optionnal name of input (limited to 3 char).
For analog inputs, ain configuration value are in the following order:
AIN TYPE POS NEG DMIN DMAX NAME
Meaning is:
Digital input number in HEX format (no 0x prefix needed)
Type value in HEX format (no 0x prefix needed).
Here is the enumerated values:
- 0=Nothing,
- 1=Emulation of a keyboard key (a,z,w,q,e,etc.), NOT SUPPORTED for AIN,
- 2=X/Y/Z analog axes,
- 3=HAT 8 directions HAT (see HATDirections),
- 4=Joystick buttons,
- 5=mouse axes X/Y/Wheel from analog or digital,
- 6=mouse button left/right/middle/prev/next.
Mapping value when going in positive direction, in HEX format (no 0x prefix needed)
Value is index of keyscan code (0 being none), joy or mouse axis, joy or mouse button. For axis and buttons, the 7th MSB (0b10000000) gives the player selection P1-P2, bits 6 to 0 are axis or button index. For HAT switch, the 7th MSB gives the player selection P1-P2, 5&6th gives the hat switch number, 3 to 0 gives the direction.
Mapping value when going in negative direction, in HEX format (no 0x prefix needed)
Value is index of keyscan code (0 being none), joy or mouse axis, joy or mouse button. For axis and buttons, the 7th MSB (0b10000000) gives the player selection P1-P2, bits 6 to 0 are axis or button index. For HAT switch, the 7th MSB gives the player selection P1-P2, 5&6th gives the hat switch number, 3 to 0 gives the direction.
Dead zone min value if hat or button, usually 60, in HEX format (no 0x prefix needed)
Dead zone max value if hat or button, usually 80, in HEX format (no 0x prefix needed)
Optionnal name of input (limited to 3 char).