Jump to content

Component: Wii Nunchuk (Movement Orientation): Difference between revisions

From Flowcode Help
No edit summary
No edit summary
Line 17: Line 17:
==Component Source Code==
==Component Source Code==


Please click here to download the component source project: [https://www.flowcode.co.uk/wikicopy/componentsource/FC_Comp_Source_WiiNunchuck.fcfx FC_Comp_Source_WiiNunchuck.fcfx]
Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_WiiNunchuck.fcfx FC_Comp_Source_WiiNunchuck.fcfx]


Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_WiiNunchuck.fcfx FC_Comp_Source_WiiNunchuck.fcfx]
Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_WiiNunchuck.fcfx FC_Comp_Source_WiiNunchuck.fcfx]


==Detailed description==
==Detailed description==




Line 44: Line 46:


==Examples==
==Examples==




Line 68: Line 72:


==Macro reference==
==Macro reference==
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SimReset1G'''
|-
| colspan="2" | Resets the simulation to 0.0 on X and Y and 1.0 on Z as if the accelerometer was sitting completely horizontal. 
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadJoystick'''
|-
| colspan="2" | Reads a single joystick axis 
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Axis
|-
| colspan="2" | 0=X, 1=Y 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-s16-icon.png]] - INT
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadSwitch'''
|-
| colspan="2" | Reads one of the nunchuck switches 
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Switch
|-
| colspan="2" | 0=Z, 1=C 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-bool-icon.png]] - BOOL
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Sample'''
|-
| colspan="2" | Reads from the nunchuck and updates the local variables.  
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadAccelerometer'''
|-
| colspan="2" | Reads a single Accelerometer axis 
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Axis
|-
| colspan="2" | 0=X, 1=Y, 2=Z 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-s16-icon.png]] - INT
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
|-
| colspan="2" | Sets up up the communication bus and initialises the accelerometer module.  Returns 1 for success and 0 for fail. 
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
==Property reference==
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''
|-
|-
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
| width="90%" | Bit Depth
|-
| colspan="2" | The number of binary bits used to store the sensor's X,Y,Z readings. 
|-
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
| width="90%" | Encryption
|-
| colspan="2" | Decides if encryption should be active or disabled 
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Connections
|-
|-
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| width="90%" | Channel
|-
| colspan="2" | Channel selection 
|-
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| width="90%" | Baud Select
|-
| colspan="2" | Baud rate option selector 
|-
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
| width="90%" | Baud Rate
|-
| colspan="2" | Baud rate to be used 
|-
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
| width="90%" | SDA
|-
| colspan="2" | Pin used for SDA (data signal) 
|-
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
| width="90%" | SCL
|-
| colspan="2" | Pin used for SCL (clock signal) 
|-
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
| width="90%" | Stop Delay
|-
| colspan="2" | On older microcontroller devices there is a potential for the I2C hardware channel to lock up if there is not  a 10ms delay between an I2C stop event and the next I2C start event.  Most modern microcontrollers will not have a problem so this property can be disabled to speed up the  I2C communications.  
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Simulation
|-
|-
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
| width="90%" | Simulate Comms
|-
| colspan="2" | Yes: Accelerometer data will come from the simulation component sliders. No: Accelerometer data will come from the CAL component - I2C or SPI - API etc 
|}==Macro reference==


{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"

Revision as of 10:00, 27 January 2023

Author Matrix TSL
Version 2.0
Category Movement Orientation


Wii Nunchuk component

A component to interface the Wii Nunchuck which features a 3-axis 10-bit Accelerometer A 2-axis 8-bit joystick and two digital button inputs. Interfaced using a standard I2C bus at 100KHz. Nunchuk must be powered at 3V3 to avoid damage.

Component Source Code

Please click here to download the component source project: FC_Comp_Source_WiiNunchuck.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_WiiNunchuck.fcfx

Detailed description

No detailed description exists yet for this component

Examples

No additional examples


Macro reference

SimReset1G
Resets the simulation to 0.0 on X and Y and 1.0 on Z as if the accelerometer was sitting completely horizontal. 
- VOID Return


ReadJoystick
Reads a single joystick axis 
- BYTE Axis
0=X, 1=Y 
- INT Return


ReadSwitch
Reads one of the nunchuck switches 
- BYTE Switch
0=Z, 1=C 
- BOOL Return


Sample
Reads from the nunchuck and updates the local variables.  
- VOID Return


ReadAccelerometer
Reads a single Accelerometer axis 
- BYTE Axis
0=X, 1=Y, 2=Z 
- INT Return


Initialise
Sets up up the communication bus and initialises the accelerometer module. Returns 1 for success and 0 for fail. 
- BYTE Return



Property reference

Properties
Bit Depth
The number of binary bits used to store the sensor's X,Y,Z readings. 
Encryption
Decides if encryption should be active or disabled 
Connections
Channel
Channel selection 
Baud Select
Baud rate option selector 
Baud Rate
Baud rate to be used 
SDA
Pin used for SDA (data signal) 
SCL
Pin used for SCL (clock signal) 
Stop Delay
On older microcontroller devices there is a potential for the I2C hardware channel to lock up if there is not a 10ms delay between an I2C stop event and the next I2C start event. Most modern microcontrollers will not have a problem so this property can be disabled to speed up the I2C communications.  
Simulation
Simulate Comms
Yes: Accelerometer data will come from the simulation component sliders. No: Accelerometer data will come from the CAL component - I2C or SPI - API etc 

==Macro reference==

SimReset1G
Resets the simulation to 0.0 on X and Y and 1.0 on Z as if the accelerometer was sitting completely horizontal. 
- VOID Return


ReadJoystick
Reads a single joystick axis 
- BYTE Axis
0=X, 1=Y 
- INT Return


ReadSwitch
Reads one of the nunchuck switches 
- BYTE Switch
0=Z, 1=C 
- BOOL Return


Sample
Reads from the nunchuck and updates the local variables.  
- VOID Return


ReadAccelerometer
Reads a single Accelerometer axis 
- BYTE Axis
0=X, 1=Y, 2=Z 
- INT Return


Initialise
Sets up up the communication bus and initialises the accelerometer module. Returns 1 for success and 0 for fail. 
- BYTE Return



Property reference

Properties
Bit Depth
The number of binary bits used to store the sensor's X,Y,Z readings. 
Encryption
Decides if encryption should be active or disabled 
Connections
Channel
Channel selection 
Baud Select
Baud rate option selector 
Baud Rate
Baud rate to be used 
SDA
Pin used for SDA (data signal) 
SCL
Pin used for SCL (clock signal) 
Stop Delay
On older microcontroller devices there is a potential for the I2C hardware channel to lock up if there is not a 10ms delay between an I2C stop event and the next I2C start event. Most modern microcontrollers will not have a problem so this property can be disabled to speed up the I2C communications.  
Simulation
Simulate Comms
Yes: Accelerometer data will come from the simulation component sliders. No: Accelerometer data will come from the CAL component - I2C or SPI - API etc 

==Macro reference==

SimReset1G
Resets the simulation to 0.0 on X and Y and 1.0 on Z as if the accelerometer was sitting completely horizontal. 
- VOID Return


ReadJoystick
Reads a single joystick axis 
- BYTE Axis
0=X, 1=Y 
- INT Return


ReadSwitch
Reads one of the nunchuck switches 
- BYTE Switch
0=Z, 1=C 
- BOOL Return


Sample
Reads from the nunchuck and updates the local variables.  
- VOID Return


ReadAccelerometer
Reads a single Accelerometer axis 
- BYTE Axis
0=X, 1=Y, 2=Z 
- INT Return


Initialise
Sets up up the communication bus and initialises the accelerometer module. Returns 1 for success and 0 for fail. 
- BYTE Return



Property reference

Properties
Bit Depth
The number of binary bits used to store the sensor's X,Y,Z readings. 
Encryption
Decides if encryption should be active or disabled 
Connections
Channel
Channel selection 
Baud Select
Baud rate option selector 
Baud Rate
Baud rate to be used 
SDA
Pin used for SDA (data signal) 
SCL
Pin used for SCL (clock signal) 
Stop Delay
On older microcontroller devices there is a potential for the I2C hardware channel to lock up if there is not a 10ms delay between an I2C stop event and the next I2C start event. Most modern microcontrollers will not have a problem so this property can be disabled to speed up the I2C communications.  
Simulation
Simulate Comms
Yes: Accelerometer data will come from the simulation component sliders. No: Accelerometer data will come from the CAL component - I2C or SPI - API etc 

==Macro reference==

SimReset1G
Resets the simulation to 0.0 on X and Y and 1.0 on Z as if the accelerometer was sitting completely horizontal. 
- VOID Return


ReadJoystick
Reads a single joystick axis 
- BYTE Axis
0=X, 1=Y 
- INT Return


ReadSwitch
Reads one of the nunchuck switches 
- BYTE Switch
0=Z, 1=C 
- BOOL Return


Sample
Reads from the nunchuck and updates the local variables.  
- VOID Return


ReadAccelerometer
Reads a single Accelerometer axis 
- BYTE Axis
0=X, 1=Y, 2=Z 
- INT Return


Initialise
Sets up up the communication bus and initialises the accelerometer module. Returns 1 for success and 0 for fail. 
- BYTE Return



Property reference

Properties
Bit Depth
The number of binary bits used to store the sensor's X,Y,Z readings. 
Encryption
Decides if encryption should be active or disabled 
Connections
Channel
Channel selection 
Baud Select
Baud rate option selector 
Baud Rate
Baud rate to be used 
SDA
Pin used for SDA (data signal) 
SCL
Pin used for SCL (clock signal) 
Stop Delay
On older microcontroller devices there is a potential for the I2C hardware channel to lock up if there is not a 10ms delay between an I2C stop event and the next I2C start event. Most modern microcontrollers will not have a problem so this property can be disabled to speed up the I2C communications.  
Simulation
Simulate Comms
Yes: Accelerometer data will come from the simulation component sliders. No: Accelerometer data will come from the CAL component - I2C or SPI - API etc