RockerSwitch
Posted: Wed 1. Nov 2017, 13:30
How can I assign two signals to one Rockerswitch?
Code: Select all
Sub Toggleswitch()
Dim test1, test2, virtual
Set test1 = Signals("Test1")
Set test2 = Signals("Test2")
Set virtual = Signals("VirtualVar1")
If virtual Is Nothing Then
' Signal not found, create and initialize new one
Set virtual = Signals.Add("VirtualVar1")
End If
While True
test1.Value = virtual.Value
test2.Value = virtual.Value
Wait(10) ' Prevent 100% CPU load
Wend
End Sub
Code: Select all
FormatVersion=5.0 // Do not edit this line!
Title="Symbols file2"
{SENDRECEIVE}
[Symbol1]
ID=100h
DLC=1
Var=Test1 unsigned 0,8
[Symbol2]
ID=200h
DLC=1
Var=Test2 unsigned 0,8
{VIRTUALVARS}
Var=VirtualVar1 unsigned
Code: Select all
'------------------------------------------------------------------------------
'FILE DESCRIPTION: Toeren
'------------------------------------------------------------------------------
Sub VerticalSlider1()
Dim Activeren, overide, Optoeren, Torque, virtual
Set Activeren = Signals("ESCEnable1")
Set Optoeren = Signals("ReqSpeedLimit1")
Set overide = Signals ("OverrideCntrlMode1ESC")
Set Torque = Signals ("RegTorqLimit1")
Set virtual = Signals("Toeren")
If virtual Is Nothing Then
' Signal not found, create and initialize new one
Set virtual = Signals.Add("Toeren")
End If
While True
If virtual.Value > 600 Then
Activeren.Value = 1
Optoeren.Value = virtual.Value
overide.Value = 1
Torque.Value = 100
Else
' Here reset values
Activeren.Value = 0
Optoeren.Value = virtual.Value
overide.Value = 0
Torque.Value = 0
End If
Wait(10) ' Prevent 100% CPU load
Wend
End Sub