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

From Flowcode Help
Jump to navigationJump to search
(XML import)
 
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.
 +
 +
==Detailed description==
  
==[[File:Component Icon 8c4c9db2_8c42_458d_b071_001acd191c49.png|Image]] Wii Nunchuk component==
+
''No detailed description exists yet for this 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.
 
  
 
==Examples==
 
==Examples==
 +
 +
 
''<span style="color:red;">No additional examples</span>''
 
''<span style="color:red;">No additional examples</span>''
  
Line 27: Line 27:
 
==Downloadable macro reference==
 
==Downloadable macro reference==
  
===<span style="font-weight: normal;"><u><tt>ReadJoystick</tt></u></span>===
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
Reads a single joystick axis
+
|-
 +
| 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''
 +
|}
  
'''Parameters'''
 
  
:[[Variable Types|BYTE]] ''Axis''
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
::0=X, 1=Y
+
|-
 +
| 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:]] -
 +
| 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;" | '''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:]] -
 +
| 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;" | '''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''
 +
|}
  
===<span style="font-weight: normal;"><u><tt>ReadSwitch</tt></u></span>===
 
Reads one of the nunchuck switches
 
  
'''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;" | '''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:]] -
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
:[[Variable Types|BYTE]] ''Switch''
 
::0=Z, 1=C
 
  
 +
{| 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.&nbsp;
 +
|-
 +
|-
 +
| 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''
 +
|}
  
'''Return value'''
 
  
:[[Variable Types|BOOL]] : Returns true if the operation is a success, else false
+
{| 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;" | '''WriteRegister'''
 +
|-
 +
| colspan="2" | Writes a byte to a register&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Address
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Data
 +
|-
 +
| colspan="2" | &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''
 +
|}
  
  
===<span style="font-weight: normal;"><u><tt>Sample</tt></u></span>===
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
Reads from the nunchuck and updates the local variables.
+
|-
 +
| 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" | Configures the I2C bus ready for communications.&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''
 +
|}
  
'''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;" | '''Initialise'''
 +
|-
 +
| colspan="2" | Configures each matching sensor on the bus with the specified conversion bits.&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;" | '''WriteRegister'''
 +
|-
 +
| colspan="2" | A simple example showing a generic way to write a register using I2C.&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Address
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Data
 +
|-
 +
| colspan="2" | &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''
 +
|}
  
:''This call does not return a value''
 
  
 
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===<span style="font-weight: normal;"><u><tt>ReadAccelerometer</tt></u></span>===
+
|-
Reads a single Accelerometer axis
+
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
'''Parameters'''
+
|-
 
+
| colspan="2" | &nbsp;
:[[Variable Types|BYTE]] ''Axis''
+
|-
::0=X, 1=Y, 2=Z
+
|-
 
+
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:]] -
 
+
| width="90%" style="border-top: 2px solid #000;" | ''Return''
'''Return value'''
+
|}
 
 
:[[Variable Types|INT]]
 
 
 
 
 
===<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.
 
 
 
'''Parameters'''
 
 
 
:''This macro has no parameters''
 
 
 
 
 
'''Return value'''
 
 
 
:[[Variable Types|BYTE]]
 
 
 
 
 
 
 
==Simulation macro reference==
 
 
 
===<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
 
 
 
sitting completely horizontal.
 
 
 
'''Parameters'''
 
 
 
:''This macro has no parameters''
 
 
 
 
 
'''Return value'''
 
 
 
:''This call does not return a value''
 
  
  
Line 118: Line 208:
  
 
==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" | [[File:Fc9-type-7-icon.png]]
 
+
| width="90%" | Scope Traces
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_i2c::BAUD_LIST''.
+
|-
 
+
| colspan="2" | Selects if the scope traces are automatically generated or not&nbsp;
Baud rate option selector
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
<span style="font-weight: normal;"><u>Baud Rate</u></span>
+
| width="90%" | Console Data
 
+
|-
This property is of type ''Signed integer'' and can be referenced with the variable name ''cal_i2c::BAUD''.
+
| colspan="2" | Selects if the console data is automatically generated or not&nbsp;
 
+
|-
Baud rate to be used
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
+
| width="90%" | API
<span style="font-weight: normal;"><u>SDA</u></span>
+
|-
 
+
| colspan="2" | &nbsp;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_i2c::SDA''.
+
|-
 
+
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-conn-icon.png]]
Pin used for SDA (data signal)
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Connections'''  
 
+
|-
<span style="font-weight: normal;"><u>SCL</u></span>
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_i2c::SCL''.
+
| width="90%" | Channel
 
+
|-
Pin used for SCL (clock signal)
+
| colspan="2" | Channel selection&nbsp;
 
+
|-
<span style="font-weight: normal;"><u>Stop Delay</u></span>
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
+
| width="90%" | Baud Select
This property is of type ''True or false'' and can be referenced with the variable name ''cal_i2c::StopDel''.
+
|-
 
+
| colspan="2" | Baud rate option selector&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-14-icon.png]]
a 10ms delay between an I2C stop event and the next I2C start event.
+
| width="90%" | Baud Rate
 
+
|-
 
+
| colspan="2" | Baud rate to be used&nbsp;
 
+
|-
Most modern microcontrollers will not have a problem so this property can be disabled to speed up the  
+
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
 
+
| width="90%" | SDA
I2C communications.
+
|-
 
+
| colspan="2" | Pin used for SDA (data signal)&nbsp;
<span style="font-weight: normal;"><u>Simulation GUI</u></span>
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
This property is of type ''True or false'' and can be referenced with the variable name ''SimulationGUI''.
+
| width="90%" | SCL
 
+
|-
Yes: Accelerometer data will come from the simulation component sliders.
+
| colspan="2" | Pin used for SCL (clock signal)&nbsp;
 
+
|-
No: Accelerometer data will come from the CAL component - I2C or SPI - Injector etc
+
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
 
+
| width="90%" | Stop Delay
<span style="font-weight: normal;"><u>Scope Traces</u></span>
+
|-
 
+
| 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;
This property is of type ''True or false'' and can be referenced with the variable name ''cal_i2c::ScopeTraces''.
+
|-
 
+
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-conn-icon.png]]
Selects if the scope traces are automatically generated or not
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Simulations'''  
 
+
|-
<span style="font-weight: normal;"><u>Console Data</u></span>
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
This property is of type ''True or false'' and can be referenced with the variable name ''cal_i2c::ConsoleData''.
+
| width="90%" | Simulate Comms
 
+
|-
Selects if the console data is automatically generated or not
+
| 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;
 
+
|}
<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>''
 

Revision as of 20:47, 16 November 2021

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.

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 
[[File:]] - Return


Fc9-comp-macro.png ReadSwitch
Reads one of the nunchuck switches 
Fc9-u8-icon.png - BYTE Switch
0=Z, 1=C 
[[File:]] - 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 
[[File:]] - 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


Fc9-comp-macro.png WriteRegister
Writes a byte to a register 
Fc9-u8-icon.png - BYTE Address
 
Fc9-u8-icon.png - BYTE Data
 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png Initialise
Configures the I2C bus ready for communications. 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png Initialise
Configures each matching sensor on the bus with the specified conversion bits. 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png WriteRegister
A simple example showing a generic way to write a register using I2C. 
Fc9-u8-icon.png - BYTE Address
 
Fc9-u8-icon.png - BYTE Data
 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png Initialise
 
[[File:]] - 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-type-7-icon.png Scope Traces
Selects if the scope traces are automatically generated or not 
Fc9-type-7-icon.png Console Data
Selects if the console data is automatically generated or not 
Fc9-type-16-icon.png API
 
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 Simulations
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