Jump to content

Component: Switch Template (Switch): Difference between revisions

From Flowcode Help
m Text replacement - "width="10%" align="center" style="background-color:#D8C9D8;"" to "width="10%" align="center" class="mtx-class-macrohead""
m Text replacement - "style="background-color:#EAE1EA;"" to "class="mtx-class-propfolder""
 
(2 intermediate revisions by the same user not shown)
Line 65: Line 65:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadState'''
| width="90%" class="mtx-class-macrohead" | '''ReadState'''
|-
|-
| colspan="2" | Reads the button state as 0 for released or 1 for pressed Performs debounce if required 
| colspan="2" | Reads the button state as 0 for released or 1 for pressed Performs debounce if required 
Line 79: Line 79:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''WaitUntilHigh'''
| width="90%" class="mtx-class-macrohead" | '''WaitUntilHigh'''
|-
|-
| colspan="2" | Waits until the switch is in state 'high' The interpretation of 'high' depends on the polarity 
| colspan="2" | Waits until the switch is in state 'high' The interpretation of 'high' depends on the polarity 
Line 93: Line 93:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''WaitUntilLow'''
| width="90%" class="mtx-class-macrohead" | '''WaitUntilLow'''
|-
|-
| colspan="2" | Waits until the switch is in state 'low' The interpretation of 'high' depends on the polarity 
| colspan="2" | Waits until the switch is in state 'low' The interpretation of 'high' depends on the polarity 
Line 108: Line 108:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-prop-icon.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-prop-icon.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''  
| width="90%" class="mtx-class-macrohead" | '''Properties'''  
|-
|-
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Connections
| width="90%" class="mtx-class-propfolder" | Connections
|-
|-
|-
|-
Line 130: Line 130:
| colspan="2" | Sets the time in milliseconds to allow a pin change to settle into a stable state.  NB)  Debouncing is only used when reading the button state using the component macros.        Chip pins are NOT debounced. 
| colspan="2" | Sets the time in milliseconds to allow a pin change to settle into a stable state.  NB)  Debouncing is only used when reading the button state using the component macros.        Chip pins are NOT debounced. 
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Simulation
| width="90%" class="mtx-class-propfolder" | Simulation
|-
|-
|-
|-

Latest revision as of 14:37, 13 July 2026

Author Matrix Ltd
Version 1.1
Category Switch


Switch Template component

Base single pin switch with no graphical interface Suitable for building your own switches with custom graphics. If the parent component has properties 'pin', 'polarity', 'debounce' and/or 'operation', they will automatically be forwarded to the base component.

Component Source Code

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

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

Detailed description

No detailed description exists yet for this component

Examples

No additional examples






Macro reference

ReadState

ReadState
Reads the button state as 0 for released or 1 for pressed Performs debounce if required 
- BYTE Return


WaitUntilHigh

WaitUntilHigh
Waits until the switch is in state 'high' The interpretation of 'high' depends on the polarity 
- VOID Return


WaitUntilLow

WaitUntilLow
Waits until the switch is in state 'low' The interpretation of 'high' depends on the polarity 
- VOID Return


Property reference

Properties
Connections
Connection
The chip pin to which the switch connects. 
Polarity
Set the polarity of states sent to the chip pin. 'Active High' -> Pressed = On, Released = Off 'Active Low' -> Pressed = Off, Released = On 
Debounce (ms)
Sets the time in milliseconds to allow a pin change to settle into a stable state. NB) Debouncing is only used when reading the button state using the component macros. Chip pins are NOT debounced. 
Simulation
Moving part
Sets a panel object or group to be the moving part of the switch model. Make sure that the object is in the 'Off' position at the time of linking. 
Pivot object
When using the 'Rotary' switch type, the 'Moving part' will rotate about the object set here. The moving part will rotate around its own axes if this property is left 'Unconnected'. 
Type
Sets whether the motion of the 'Moving part' will be 'Push/Slide' (linear motion) or 'Rotary' (e.g. toggle switches). 
Operation
'Latching' = click to turn on, click again to turn off. 'Momentary' = click to turn on, release to turn off. 
Axis
For 'Push/Slide' switches, the axis that the 'Moving part' will move along. For 'Rotary' switches, the axis around which 'Moving part' will rotate. 
Movement
For 'Push/Slide' switches, the distance (in local units) to move along the axis. For 'Rotary' switches, the angle (in degrees) to rotate around the axis. 
Notify on change
When enabled, a 'System.User' event will be sent for each change of switch state. The event is sent to the 'parent' component in which this 'Swict base' instance is used.