#Region Project Attributes
#ApplicationLabel: HC05LightDimmer
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
End Sub
Sub Globals
Private lblStatus As Label
Private btnConnect As Button
Private lblMessage As Label
Private ProgressBar1 As ProgressBar
Private skbDimmer As SeekBar
Private lblDimmer As Label
Private Status As String
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Main")
End Sub
Sub Activity_Resume
SetState
End Sub
Sub Activity_Pause (UserClosed As Boolean)
If UserClosed = True And lblStatus.Text = "connected" Then
CallSub2(Starter, "SendMessage", Array As Object(1, 90))
End If
End Sub
Public Sub SetState
btnConnect.Enabled = Not(Starter.connected)
ProgressBar1.Visible = Starter.connecting
Dim Status As String
If Starter.Connected Then
Status = "connected"
Else If Starter.TryToConnect Then
Status = "trying to connect..."
Else If Starter.Connecting Then
Status = "HC-06 found connecting..."
Else
Status = "disconnected"
End If
lblStatus.Text = $"Status: ${Status}"$
End Sub
Public Sub MessageFromDevice(msg As String)
lblMessage.Text = msg
End Sub
Sub btnConnect_Click
CallSub(Starter, "Connect")
End Sub
Sub skbDimmer_ValueChanged (Value As Int, UserChanged As Boolean)
Dim s As SeekBar = Sender
lblDimmer.Text = Value
Dim data() As Object = Array As Object(s.Tag,Value)
CallSub2(Starter, "SendMessage", data)
End Sub
'STARTER
Public Sub SendMessage(data() As Object)
ast.astreams.Write(ser.ConvertArrayToBytes( data))
End Sub
'AST
Public Sub Initialize (TargetModule As Object, EventName As String, In As InputStream, out As OutputStream)
mTarget = TargetModule
mEventName = EventName
astreams.Initializeprefix(In,True, out, "astreams")
sb.Initialize
End Sub