Jump to content

Component: Simulation Switch Template (Controls): Difference between revisions

From Flowcode Help
No edit summary
m Text replacement - "width="90%" style="background-color:#D8C9D8; color:#4B008D;"" to "width="90%" class="mtx-class-macrohead""
 
(19 intermediate revisions by 2 users not shown)
Line 14: Line 14:
==Simulation Switch Template component==
==Simulation Switch Template component==
A base for building switches that do not download to chip. Mouse interaction can send 'System.User' events with the following data... ID = The handle of the switch component sending the message Message = 1 (on) or 0 (off) Current state can also be read via simulation macros.  
A base for building switches that do not download to chip. Mouse interaction can send 'System.User' events with the following data... ID = The handle of the switch component sending the message Message = 1 (on) or 0 (off) Current state can also be read via simulation macros.  
==Component Source Code==
Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_sim_switch_base.fcfx FC_Comp_Source_sim_switch_base.fcfx]
Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_sim_switch_base.fcfx FC_Comp_Source_sim_switch_base.fcfx]


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




Line 22: Line 50:


==Examples==
==Examples==




Line 29: Line 79:




==Downloadable 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;" | '''GetState'''
|-
| colspan="2" | Read the current state of the switch.  Returns BOOL true when the switch is on, or BOOL false when off. 
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:]] -
| 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;" | '''SetState'''
|-
| colspan="2" | Sets the current state of the switch.  BOOL true when the switch is on, or BOOL false when off. 
|-
|-
| width="10%" align="center" | [[File:]] -
| width="90%" | SwitchState
|-
| colspan="2" | Sets the state of the switch 
|-
| 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;" | '''SetDutyCycle'''
|-
| colspan="2" | Sets the PWM duty cycle in terms of on/off based on the current period setting. E.g. if period = 255 then duty of 128 is equal to 50% on and 50% off. 16-bit PIC users should use the 10bit duty function to access the full range. 
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Duty
|-
| colspan="2" | 8-bit PWM duty 0-255 
|-
| 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;" | '''Enable'''
|-
| colspan="2" | Enables a PWM channel as an output overriding the default output pin state. 
|-
|-
| 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;"
 
 
 
==Macro reference==
 
===GetState===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[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;" | '''SetFrequency'''
| width="90%" class="mtx-class-macrohead" | '''GetState'''
|-
| colspan="2" | Sets a PWM of the specifed frequency at a duty of 50% Ideal use is a  frequency generator 
|-
|-
| colspan="2" | Read the current state of the switch.  Returns BOOL true when the switch is on, or BOOL false when off. 
|-
|-
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
| width="90%" | Frequency
|-
|-
| colspan="2" | Enter frequency in Hz 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-bool-icon.png]] - BOOL
|-
| 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''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===SetState===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[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;" | '''SetDutyCycle10Bit'''
| width="90%" class="mtx-class-macrohead" | '''SetState'''
|-
|-
| colspan="2" | PIC/AVR - Sets the full scale PWM duty cycle based on the current period setting. If period = 255 then Duty of 512 is equal to 50%16-bit PICs have a 16-bit period range available. If period = 65535 then Duty of 32768 is equal to 50%. 
| colspan="2" | Sets the current state of the switchBOOL true when the switch is on, or BOOL false when off. 
|-
|-
|-
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL
| width="90%" | Duty
| width="90%" | SwitchState
|-
|-
| colspan="2" | PWM duty PIC/AVR: 0-1023 16-bit PIC: 0-65535 
| colspan="2" | Sets the state of the switch 
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| 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''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}




==Property reference==
==Property reference==


{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" | [[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'''  
|-
|-
|-
|-
Line 183: Line 178:
|-
|-
| colspan="2" | Default state of the indicator when loading the project or starting the simulation runtime. 
| colspan="2" | Default state of the indicator when loading the project or starting the simulation runtime. 
|-
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Connections'''
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Simulations'''
|-
|}
|}

Latest revision as of 14:23, 13 July 2026

Author Matrix Ltd
Version 1.3
Category Controls


Simulation Switch Template component

A base for building switches that do not download to chip. Mouse interaction can send 'System.User' events with the following data... ID = The handle of the switch component sending the message Message = 1 (on) or 0 (off) Current state can also be read via simulation macros.

Component Source Code

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

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

Detailed description

No detailed description exists yet for this component

Examples

No additional examples








Macro reference

GetState

GetState
Read the current state of the switch. Returns BOOL true when the switch is on, or BOOL false when off. 
- BOOL Return


SetState

SetState
Sets the current state of the switch. BOOL true when the switch is on, or BOOL false when off. 
- BOOL SwitchState
Sets the state of the switch 
- VOID Return


Property reference

Properties
Operation
Latching = Mouse click to turn on, click again to turn off. Momentary = Mouse click to turn on, release to turn off. 
Send Event
Determine when the component will send a User event to its parent. On Change - Whenever the switch state changes. On Click - Only when the mouse clicks the object. On Release - Only when the mouse is released over the object. Never - No events.  
Moving part
Handle of a panel object that will be the moving part of the switch. 
Pivot object
Object around which the moving part will rotate when rotation is selected as the movement tyoe. 
Type
Set whether the moving part will move linearly or by rotation. 
Axis
Axis along which the moving part will move (for push/slide) or around which it will rotate (rotary). 
Movement
Distance or angle by which the mioving part will move. 
Show
Decide what label to show... None - no labels are displayed Name - shows the component's name Property - shows a property value of the component (a field for the property name will appear below) 
Startup State
Default state of the indicator when loading the project or starting the simulation runtime.