-
New release: bugfixes, improvements.
03/21/2021 at 02:39 • 0 commentsI have just uploaded a new version of the firmware.
- Some bugs have been corrected, specially the deadlock condition caused by pin change interrupt on pin 9 of 5200 port (Cav control).
- Using Classic controller library >0.8.1 . From version 0.8.1 the axes values are always returned in the range 0-255, even for knockoff controllers that can only operate in low resolution mode.
- Added a non-linear curve, that in practice provides a sort of dead band on the center and gets steep at the extremes. The curve saturate close to the edges to compensate some controllers that can not return in full range, even in high resolution mode.
- Corrected the code that adds the movement of left and right sticks in single controller mode.
The resistor R1 shall be the value changed to 1K ohm so the LED on pin 13 of some Arduino Nanos does not interfere with Cav control.
Thanks @Chris Belcher for the feedbacks!
-
PCB rev A
07/04/2020 at 03:41 • 0 commentsThanks to the feedback from @Chris Belcher I have corrected the mirrored footprint of the Wii connector.
-
Alpha Release
03/24/2020 at 02:06 • 0 commentsJust released an Alpha on github repository. So far I have tested:
- Combined Analog control (either right or left stick control the axes)
- Dual controller auto detection
- Dual controller (left stick control main axes, right stick control secondary axes, buttons X,Y secondary buttons
- D-Pad override over left stick to provide full digital control (like Masterplay)
Keypad emulation is yet to be tested on this prototype but it was verified to work on Megaplay.
-
Adding provision for more features
03/22/2020 at 15:02 • 0 commentsChanged the DETECT logic for one of the extra analog signals (A6) of the Nano board and that let me free 2 IO pins (D0 and D1). Now I can use the remaining space on the board to add a PS/2 mouse connector to be able to use a mouse to emulate a trackball.
-
Nonlinear response to improve usability
03/17/2020 at 23:35 • 0 commentsI should apply a gamma curve to the analog axes read from Classic controller to make the response of the stick more subtle near the center and more steep close to the edges.
Classic controller analog sticks provide position information with a low resolution. Left stick provides 64 steps and Right stick provides 32.
Both axes are combined using the following equations:
index = LeftJoy + (RightJoy * 2) - 32; if (index > 63) index = 63; if (index < 0 ) index = 0 ;
The variable index shoulld assume a value between 0 and 63.
When both sticks are in center position the resulting will be 32, right in the middle of the scale.
Either stick can be pushed or pulled to make the index value swing from 0 to 63. If both sticks are moved in the same direction the resulting value will reach the maximum (or minimum) on the middle of their course (not exactly in the middle because of the gamma curve). On the other hand, when both sticks are thoroughly moved in opposite directions the resulting will be again the middle of the scale.
Whole code to process the joysticks is then:
lx=classic.leftJoyX(); ly=classic.leftJoyY(); rx=(classic.rightJoyX()<<1); ry=(classic.rightJoyY()<<1); combinedXaxis = lx+rx-32; if (combinedXaxis>63) combinedXaxis = 63; if (combinedXaxis<0) combinedXaxis = 0; combinedYaxis = ly+ry-32; if (combinedYaxis>63) combinedYaxis = 63; if (combinedYaxis<0) combinedYaxis = 0; combinedYaxis = 63-combinedYaxis;
The latter statement on code above inverts the way that Y axis behaves so the resulting value grows when the stick is moved down and vice versa.
Gamma
The curve below depicts the values from middle scale to the upper limits (down and right), being a total of 31 counts. The Y axis represents the amount of countings that should be read by the 5200 system.
The whole curve along with a gamma = 2.0 and a linear reference (gamma = 1.0) is depicted below
uint8_t gammaCurve[64] = { // gamma = 2.0 5 , 12 , 18 , 24 , 30 , 36 , 42 , 47 , 52 , 57 , 62 , 66 , 71 , 75 , 78 , 82 , 86 , 89 , 92 , 95 , 97 , 100, 102, 104, 106, 107, 109, 110, 111, 112, 112, 112, 113, 113, 113, 114, 114, 115, 117, 118, 120, 122, 124, 126, 129, 131, 134, 138, 141, 145, 149, 153, 157, 162, 167, 172, 177, 182, 188, 194, 200, 207, 213, 220 }
-
Controller detection logic
03/15/2020 at 12:34 • 0 commentsWorking on controller detection logic. I will support Nunchucks too.
The adapter is now able to detect the presence of either the Classic controller or the Nunchuck and react accordingly (hot-plugging) without adding overhead to the sampling (aka multiple readings).
/* Stingray - Controller Logic */ #include <NintendoExtensionCtrl.h> ExtensionPort controller; Nunchuk::Shared nchuk(controller); // Read Nunchuk formatted data from the port ClassicController::Shared classic(controller); // Read Classic Controller formatted data from the port void setup() { Serial.begin(9600); controller.begin(); } void loop() { if (controller.connect()) { // valid controller was connected while (controller.update()) { ExtensionType conType = controller.getControllerType(); switch (conType) { case (ExtensionType::Nunchuk): mapNunchuckData(); break; case (ExtensionType::ClassicController): mapClassicData(); break; default: Serial.println("Other controller connected!"); disableOutputs(); } // Switch processControllerData(); } // while disableOutputs(); } else { // Controller not connected} Serial.println("No controller found!"); disableOutputs(); } delay(200); } void disableOutputs() { Serial.println("Disable Outputs"); } void processControllerData() { Serial.println("Process Data"); } void mapNunchuckData() { nchuk.printDebug(); } void mapClassicData() { classic.printDebug(); }