Difference between revisions of "Component: Wii Nunchuk (General Input)"

From Flowcode Help
Jump to navigationJump to search
(XML import)
 
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
+
{| style="width:50%"
 
 
{| width="50%"
 
 
|-
 
|-
| width="20%" style="color: gray;" | Author
+
| width="20%" style="color:gray;" | Author
 
| Matrix TSL
 
| Matrix TSL
 
|-
 
|-
| width="20%" style="color: gray;" | Version
+
| width="20%" style="color:gray;" | Version
| 2.0 (Release)
+
| 2.0
 
|-
 
|-
| width="20%" style="color: gray;" | Category
+
| width="20%" style="color:gray;" | Category
 
| General Input
 
| General Input
 
|}
 
|}
  
  
 +
==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.
  
==[[File:Component Icon 8c4c9db2_8c42_458d_b071_001acd191c49.png|Image]] Wii Nunchuk component==
+
==Component Pack==
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.
 
  
==Examples==
+
FREE
''<span style="color:red;">No additional examples</span>''
 
  
 +
==Detailed description==
  
==Downloadable macro reference==
 
  
===<span style="font-weight: normal;"><u><tt>ReadJoystick</tt></u></span>===
 
Reads a single joystick axis
 
  
'''Parameters'''
 
  
:[[Variable Types|BYTE]] ''Axis''
 
::0=X, 1=Y
 
  
  
'''Return value'''
 
  
:[[Variable Types|INT]]
 
  
  
===<span style="font-weight: normal;"><u><tt>ReadSwitch</tt></u></span>===
 
Reads one of the nunchuck switches
 
  
'''Parameters'''
 
  
:[[Variable Types|BYTE]] ''Switch''
+
''No detailed description exists yet for this component''
::0=Z, 1=C
 
  
 +
==Examples==
  
'''Return value'''
 
  
:[[Variable Types|BOOL]] : Returns true if the operation is a success, else false
 
  
  
===<span style="font-weight: normal;"><u><tt>Sample</tt></u></span>===
 
Reads from the nunchuck and updates the local variables.
 
  
'''Parameters'''
 
  
:''This macro has no parameters''
 
  
  
'''Return value'''
 
  
:''This call does not return a value''
 
  
  
===<span style="font-weight: normal;"><u><tt>ReadAccelerometer</tt></u></span>===
 
Reads a single Accelerometer axis
 
  
'''Parameters'''
+
''<span style="color:red;">No additional examples</span>''
  
:[[Variable Types|BYTE]] ''Axis''
 
::0=X, 1=Y, 2=Z
 
  
 +
==Downloadable macro reference==
  
'''Return value'''
+
{| 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.&nbsp;
 +
|-
 +
|-
 +
| 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''
 +
|}
  
:[[Variable Types|INT]]
 
  
 +
{| 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&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Axis
 +
|-
 +
| colspan="2" | 0=X, 1=Y&nbsp;
 +
|-
 +
| 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''
 +
|}
  
===<span style="font-weight: normal;"><u><tt>Initialise</tt></u></span>===
 
Sets up up the communication bus and initialises the accelerometer module.
 
  
Returns 1 for success and 0 for fail.
+
{| 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&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Switch
 +
|-
 +
| colspan="2" | 0=Z, 1=C&nbsp;
 +
|-
 +
| 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''
 +
|}
  
'''Parameters'''
 
  
:''This macro has no parameters''
+
{| 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. &nbsp;
 +
|-
 +
|-
 +
| 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''
 +
|}
  
  
'''Return value'''
+
{| 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&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Axis
 +
|-
 +
| colspan="2" | 0=X, 1=Y, 2=Z&nbsp;
 +
|-
 +
| 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''
 +
|}
  
:[[Variable Types|BYTE]]
 
  
 
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
+
|-
==Simulation macro reference==
+
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
===<span style="font-weight: normal;"><u><tt>SimReset1G</tt></u></span>===
+
|-
Resets the simulation to 0.0 on X and Y and 1.0 on Z as if the accelerometer was
+
| colspan="2" | Sets up up the communication bus and initialises the accelerometer module. Returns 1 for success and 0 for fail.&nbsp;
 
+
|-
sitting completely horizontal.
+
|-
 
+
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
'''Parameters'''
+
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
+
|}
:''This macro has no parameters''
 
 
 
 
 
'''Return value'''
 
 
 
:''This call does not return a value''
 
  
  
Line 118: Line 147:
  
 
==Property reference==
 
==Property reference==
<span style="font-weight: normal;"><u>Bit Depth</u></span>
 
  
This property is of type ''Signed integer'' and can be referenced with the variable name ''bit_depth''.
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
+
|-
The number of binary bits used to store the sensor's X,Y,Z readings.
+
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
 
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''  
<span style="font-weight: normal;"><u>Encryption</u></span>
+
|-
 
+
|-
This property is of type ''True or false'' and can be referenced with the variable name ''Encryption''.
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
 
+
| width="90%" | Bit Depth
Decides if encryption should be active or disabled
+
|-
 
+
| colspan="2" | The number of binary bits used to store the sensor's X,Y,Z readings.&nbsp;
<span style="font-weight: normal;"><u>Channel</u></span>
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_i2c::CHANNEL''.
+
| width="90%" | Encryption
 
+
|-
Channel selection
+
| colspan="2" | Decides if encryption should be active or disabled&nbsp;
 
+
|-
<span style="font-weight: normal;"><u>Baud Select</u></span>
+
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
 
+
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Connections
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_i2c::BAUD_LIST''.
+
|-
 
+
|-
Baud rate option selector
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
+
| width="90%" | Channel
<span style="font-weight: normal;"><u>Baud Rate</u></span>
+
|-
 
+
| colspan="2" | Channel selection&nbsp;
This property is of type ''Signed integer'' and can be referenced with the variable name ''cal_i2c::BAUD''.
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
Baud rate to be used
+
| width="90%" | Baud Select
 
+
|-
<span style="font-weight: normal;"><u>SDA</u></span>
+
| colspan="2" | Baud rate option selector&nbsp;
 
+
|-
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_i2c::SDA''.
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
 
+
| width="90%" | Baud Rate
Pin used for SDA (data signal)
+
|-
 
+
| colspan="2" | Baud rate to be used&nbsp;
<span style="font-weight: normal;"><u>SCL</u></span>
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_i2c::SCL''.
+
| width="90%" | SDA
 
+
|-
Pin used for SCL (clock signal)
+
| colspan="2" | Pin used for SDA (data signal)&nbsp;
 
+
|-
<span style="font-weight: normal;"><u>Stop Delay</u></span>
+
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
 
+
| width="90%" | SCL
This property is of type ''True or false'' and can be referenced with the variable name ''cal_i2c::StopDel''.
+
|-
 
+
| colspan="2" | Pin used for SCL (clock signal)&nbsp;
On older microcontroller devices there is a potential for the I2C hardware channel to lock up if there is not  
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
a 10ms delay between an I2C stop event and the next I2C start event.
+
| 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. &nbsp;
 
+
|-
Most modern microcontrollers will not have a problem so this property can be disabled to speed up the  
+
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
 
+
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Simulation
I2C communications.
+
|-
 
+
|-
<span style="font-weight: normal;"><u>Simulation GUI</u></span>
+
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
 
+
| width="90%" | Simulate Comms
This property is of type ''True or false'' and can be referenced with the variable name ''SimulationGUI''.
+
|-
 
+
| 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&nbsp;
Yes: Accelerometer data will come from the simulation component sliders.
+
|}
 
 
No: Accelerometer data will come from the CAL component - I2C or SPI - Injector etc
 
 
 
<span style="font-weight: normal;"><u>Scope Traces</u></span>
 
 
 
This property is of type ''True or false'' and can be referenced with the variable name ''cal_i2c::ScopeTraces''.
 
 
 
Selects if the scope traces are automatically generated or not
 
 
 
<span style="font-weight: normal;"><u>Console Data</u></span>
 
 
 
This property is of type ''True or false'' and can be referenced with the variable name ''cal_i2c::ConsoleData''.
 
 
 
Selects if the console data is automatically generated or not
 
 
 
<span style="font-weight: normal;"><u>Injector</u></span>
 
 
 
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_i2c::Injector''.
 
 
 
''<span style="color:red;">No additional information</span>''
 
 
 
 
 
 
 
<span style="font-weight: normal;"><u>Image</u></span>
 
 
 
This property is of type ''Filename'' and can be referenced with the variable name ''shape1::Image''.
 
 
 
''<span style="color:red;">No additional information</span>''
 

Latest revision as of 17:23, 9 November 2022

Author Matrix TSL
Version 2.0
Category General Input


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 Pack

FREE

Detailed description

No detailed description exists yet for this component

Examples

No additional examples


Downloadable macro reference

Fc9-comp-macro.png SimReset1G
Resets the simulation to 0.0 on X and Y and 1.0 on Z as if the accelerometer was sitting completely horizontal. 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png ReadJoystick
Reads a single joystick axis 
Fc9-u8-icon.png - BYTE Axis
0=X, 1=Y 
Fc9-s16-icon.png - INT Return


Fc9-comp-macro.png ReadSwitch
Reads one of the nunchuck switches 
Fc9-u8-icon.png - BYTE Switch
0=Z, 1=C 
Fc9-bool-icon.png - BOOL Return


Fc9-comp-macro.png Sample
Reads from the nunchuck and updates the local variables.  
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png ReadAccelerometer
Reads a single Accelerometer axis 
Fc9-u8-icon.png - BYTE Axis
0=X, 1=Y, 2=Z 
Fc9-s16-icon.png - INT Return


Fc9-comp-macro.png Initialise
Sets up up the communication bus and initialises the accelerometer module. Returns 1 for success and 0 for fail. 
Fc9-u8-icon.png - BYTE Return



Property reference

Fc9-prop-icon.png Properties
Fc9-type-14-icon.png Bit Depth
The number of binary bits used to store the sensor's X,Y,Z readings. 
Fc9-type-7-icon.png Encryption
Decides if encryption should be active or disabled 
Fc9-conn-icon.png Connections
Fc9-type-16-icon.png Channel
Channel selection 
Fc9-type-16-icon.png Baud Select
Baud rate option selector 
Fc9-type-14-icon.png Baud Rate
Baud rate to be used 
Fc9-type-5-icon.png SDA
Pin used for SDA (data signal) 
Fc9-type-5-icon.png SCL
Pin used for SCL (clock signal) 
Fc9-type-7-icon.png 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.  
Fc9-conn-icon.png Simulation
Fc9-type-7-icon.png 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