Applications/Official/source-OLDER/xMasterX/wii_ec_anal/README.md
This Protocol Analyser offers a full Test and Calibrate system for Wii Extension Controllers.
Disclaimer: Use of this plugin, and notably connecting an Extension Controller to the FlipperZero is performed entirely at your own risk.
This plugin has (todate) only been tested with official Nintendo Nunchucks and Classic Controllers - namely Nunchucks and Classic Controllers.
This plugin has SOME code to handle encryption, but it it unused, untested, and some of it is known to un-work.
This plugin (currently) only works with Extension Controllers which implement the encryption-bypass strategy. IE. i2c_write(0xf0, 0x55) ; i2c_write(0xfb, 0x00)
If you need this functionality, either raise an Issue or, better still, a Pull Request.
The SPLASH Screen is displayed when the Plugin starts. It can be cleared by pressing any key, else it will auto-clear after 3.5 seconds.
The WAIT screen will display which pins you need to connect between the flipper and the Wii Extension Controller.
Disclaimer: Use of this plugin, and notably connecting the Controller to the FlipperZero is performed entirely at your own risk.
Looking in to the exposed side of the Extension Controller plug, with the notch on the bottom
| EC Pin # | EC Position | EC Pin ID | Pin Function | FZ GPIO Pin Name | FZ GPIO Pin # |
|---|---|---|---|---|---|
| 1 | top-left | +3v3 | Power | 3v3 | 9 |
| 2 | bottom-left | SCL | i2c clock | C0 | 16 |
| 3 | top-centre | EN | ¿detect? | ||
| 4 | bottom-centre | -x- | -none- | ||
| 5 | top-right | SDA | i2c data | C1 | 15 |
| 6 | bottom-right | Gnd | Power | Gnd | 18 |
Keys:
The easiest way to connect a Wii Extension Controller to a FlipperZero is arguably with a "WiiChuck" or a "Nunchucky"
<table style="border:none"> <tr><td></td> <td></td></tr> <tr><td align="center"><a href="https://www.ebay.co.uk/sch/?_nkw=wiichuck">WiiChuck</a></td> <td align="center"><a href="https://www.solarbotics.com/product/31040">Nunchucky</a></td></tr> </table>Neither the WiiChuck, nor the Nunchucky have a pin polarisation mechanism.
If you plug the adaptor in the wrong way around you WILL apply voltage to the Controller the wrong way round!!
I have no idea if THIS WILL PERMANENTLY KILL THE CONTROLLER ...Who wants to try it?
On all the WiiChucks I have seen:
+-------------+
| _________ |
| | = = = | |
| |_=_____=_| | <-- notice missing pin
| ___ |
| | | | <-- notice indent
+----+ +----+
...BUT I highly recommend you check the pins on your adaptor to make sure everything goes well.
I believe the unconnected pin on the top is a "presence detect" function, but I have not (yet) verified this.
This feature is NOT required by this plugin, as the detection is performed by means of an i2c handshake.
When a device is connected it will be immediately recognised. If it is not, either:
...This may be as simple as a broken wire.
...Repair of which is beyond the scope of this document.
To get the list of "known" Controllers, run ./info.sh
As of writing this, that returns:
[PID_UNKNOWN ] = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, "Unknown Perhipheral", SCENE_DUMP,
[PID_NUNCHUCK ] = { {0x00, 0x00, 0xA4, 0x20, 0x00, 0x00}, "Nunchuck", SCENE_NUNCHUCK,
[PID_CLASSIC ] = { {0x00, 0x00, 0xA4, 0x20, 0x01, 0x01}, "Classic Controller", SCENE_CLASSIC,
[PID_BALANCE ] = { {0x00, 0x00, 0xA4, 0x20, 0x04, 0x02}, "Balance Board", SCENE_DUMP,
[PID_GH_GUITAR ] = { {0x00, 0x00, 0xA4, 0x20, 0x01, 0x03}, "Guitar Hero Guitar", SCENE_DUMP,
[PID_GH_DRUMS ] = { {0x01, 0x00, 0xA4, 0x20, 0x01, 0x03}, "Guitar Hero World Tour Drums", SCENE_DUMP,
[PID_TURNTABLE ] = { {0x03, 0x00, 0xA4, 0x20, 0x01, 0x03}, "DJ Hero Turntable", SCENE_DUMP,
[PID_TAIKO_DRUMS] = { {0x00, 0x00, 0xA4, 0x20, 0x01, 0x11}, "Taiko Drum Controller)", SCENE_DUMP,
You can see that there are EIGHT known devices. One is the default for an unknown controller; SEVEN devices are known by name; and TWO (of those seven) have bespoke "scenes" (ie. SCENE_NUNCHUCK & SCENE_CLASSIC).
When you connect a Nunchuck, you will see a screen displaying:
Keys:
| Axis | Movement | Lower | Higher |
|---|---|---|---|
| X | Left / Right | Left | Right |
| Y | Fwd / Bkwd | Fwd | Bkwd |
| Z | Down / Up | Down | Up |
Keys:
<sub>NB. Code DOES exist to scroll the display, but the LCD refresh rate is too low, and it looks awful</sub>
When you connect a Classic Controller [Pro], you will see a screen displaying a Classic Controller
Keys:
The Dump screen will show you the raw readings from the device.
If you connect a device which does not have a bespoke _decode() function (etc.), you will see (only) this screen.
info table)Keys:
On any Controller-specific screen with a Peak/Trough menu displayed:
Digital buttons do NOT require Calibration.
Some controllers have Calibration data which is calculated at the factory, and stored in memory (¿OTP?) on the Controller. EG. Classic Controller HAS Calibration data, but Classic Controller Pro does NOT!
Each device has a different way to interpret the Calibration Data.
EG. A Nunchuck has one joystick, and an accelerometer ...whereas a Classic Controller has 2 joysticks and 2 analogue buttons.
I have personally found the calibration data to be inaccurate (when compared to actual readings), I guess Controllers drift over the years‽ If the factory-values LIMIT movement, this is easily resolved - by expanding them on-the-fly.
BUT, I have seen Controllers with factory calibration data that suggests the limits are FURTHER than the joystick can reach ...and this requires a full re-calibration of the Controller!
Probably the best way to calibrate is to:
Nintendo (allegedly) take the 'at rest' reading immediately after the Controller is connected, and a 're-calibration' can be performed at any time by pressing {A, B, +, -} at the same time, for at least 3 seconds. Although I have no details on what this actually does.
On any screen (except SPLASH) you may press Long-Down to enter Debug mode.
You can (at any time) attach to the FlipperZero (via USB) with a serial console {minicom, putty, whatever} and start the log function to see the debug messages.
When you enter the DEBUG screen, the real-time scanner will be stopped. And the following keys made available:
You can limit the messages at compile-time [see ./info.sh], or at runtime [FZ->Settings->System->LogLevel]
[This is probably irrelevant since the introduction of FAP support]
If you have memory issues, limiting the messages at compile-time will make the plugin smaller.
But (¿obviously?) the more you limit the messsages, the less debug information will be sent to the logger.
i2c_workaround.c]