This project is a replacement for the IR remote control for the SMD3528/5050/5730/5630/3014 RGB LED Strip Lights (see here). Your device needs to support an IR Blaster (such as Samsung S4 mini).
Found the hex codes here:
https://github.com/z3t0/Arduino-IRremote/issues/280
I have added 1 x method to the original wrapper that (partly) wraps this Github project:
https://github.com/timnew/AndroidInfrared
Have tested it with a device that supports an IR Blaster and it is working 100%. Have not added colors to all the buttons in the attached project (Green and Blue). Please do so should you make use of this lib and project. The correct hex codes are however assigned to all the buttons.
Found the hex codes here:
https://github.com/z3t0/Arduino-IRremote/issues/280
I have added 1 x method to the original wrapper that (partly) wraps this Github project:
https://github.com/timnew/AndroidInfrared
Have tested it with a device that supports an IR Blaster and it is working 100%. Have not added colors to all the buttons in the attached project (Green and Blue). Please do so should you make use of this lib and project. The correct hex codes are however assigned to all the buttons.
B4X:
#Region Project Attributes
#ApplicationLabel: b4aRGBLED
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private ssstv As AndroidInfrared
Private vu As VibrateUtilities
'found the below hex codes here: https://github.com/z3t0/Arduino-IRremote/issues/280
Dim pwrOn As Int = 0XF7C03F
Dim pwrOff As Int = 0xF740BF
Dim BRIGHTNESS_UP As Int = 0xF700FF
Dim BRIGHTNESS_DOWN As Int = 0xF7807F
Dim FLASH As Int = 0xF7D02F
Dim STROBE As Int = 0xF7F00F
Dim FADE As Int = 0xF7C837
Dim SMOOTH As Int = 0xF7E817
Dim clrRed As Int = 0xF720DF
Dim clrGreen As Int = 0XF7A05F
Dim clrBlue As Int = 0xF7609F
Dim clrWhite As Int = 0xF7E01F
Dim ORANGE As Int = 0xF710EF
Dim YELLOW_DARK As Int = 0xF730CF
Dim YELLOW_MEDIUM As Int = 0xF708F7
Dim YELLOW_LIGHT As Int = 0xF728D7
Dim GREEN_LIGHT As Int = 0XF7906F
Dim GREEN_BLUE1 As Int = 0XF7B04F
Dim GREEN_BLUE2 As Int = 0XF78877
Dim GREEN_BLUE3 As Int = 0XF7A857
Dim BLUE_RED As Int = 0XF750AF
Dim PURPLE_DARK As Int = 0XF7708F
Dim PURPLE_LIGHT As Int = 0XF748B7
Dim PINK As Int = 0XF76897
Dim stu As StringUtils
Dim ph As PhoneWakeState
Dim smalltext As Int
Private btnPowerOff As Button
Private btnPowerOn As Button
Private btnBrightUp As Button
Private btnBrightDown As Button
Private btnRed As Button
Private btnGreen As Button
Private btnBlue As Button
Private btnWhite As Button
Private btnFlash As Button
Private btnStrobe As Button
Private btnFade As Button
Private btnSmooth As Button
Private btnRed1 As Button
Private btnRed2 As Button
Private btnRed3 As Button
Private btnRed4 As Button
Private btnGreen1 As Button
Private btnGreen2 As Button
Private btnGreen3 As Button
Private btnGreen4 As Button
Private btnBlue1 As Button
Private btnBlue2 As Button
Private btnBlue3 As Button
Private btnBlue4 As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("main")
ssstv.Initialize("")
vu.Initialize
End Sub
Sub Activity_Resume
smalltext = 15
scale_text
ph.KeepAlive(True)
Log(ssstv.hasIrEmitter)
End Sub
Sub Activity_Pause (UserClosed As Boolean)
ph.ReleaseKeepAlive
End Sub
Sub Wait(MilliSekunden As Int)
Dim Ti As Long
Ti = DateTime.Now + MilliSekunden
Do While DateTime.Now < Ti
Sleep(0)
Loop
End Sub
Sub scale_text
For Each v As View In Activity.GetAllViewsRecursive
If v Is Button Then
Dim jo As JavaObject = v
Dim btn As Button
btn=v
SetButtonTextSize(btn,btn.Text)
jo.RunMethod("setPadding",Array As Object(0,0,0,10dip)) 'left, top, right, bottom
End If
If v Is EditText Then
Dim jo As JavaObject = v
Dim et As EditText
et=v
SetEditTextSize(et,et.Text)
jo.RunMethod("setPadding",Array As Object(0,0,0,0))
End If
If v Is Label Then
Dim jo As JavaObject = v
Dim la As Label
la=v
SetLabelTextSize(la,la.Text)
jo.RunMethod("setPadding",Array As Object(0,0,0,0))
End If
Next
For Each v As View In Activity.GetAllViewsRecursive
If v Is Button Then
Dim jo As JavaObject = v
Dim btn As Button
btn=v
btn.TextSize = smalltext
End If
Next
End Sub
Sub SetLabelTextSize(ex1 As Label, txt As String)
Dim dt As Float
Dim limit = 0.95 As Float
Dim h As Int
ex1.Text = txt
ex1.TextSize = 72
dt = ex1.TextSize
h = stu.MeasureMultilineTextHeight(ex1, txt)
Do While dt > limit Or h > ex1.Height
dt = dt / 2
h = stu.MeasureMultilineTextHeight(ex1, txt)
If h > ex1.Height Then
ex1.TextSize = ex1.TextSize - dt
Else
ex1.TextSize = ex1.TextSize + dt
End If
Loop
ex1.TextSize=ex1.textsize * 0.95
If ex1.TextSize < smalltext Then smalltext = ex1.TextSize
End Sub
Sub SetEditTextSize(ex1 As EditText, txt As String)
Dim dt As Float
Dim limit = 0.5 As Float
Dim h As Int
ex1.Text = txt
ex1.TextSize = 72
dt = ex1.TextSize
h = stu.MeasureMultilineTextHeight(ex1, txt)
Do While dt > limit Or h > ex1.Height
dt = dt / 2
h = stu.MeasureMultilineTextHeight(ex1, txt)
If h > ex1.Height Then
ex1.TextSize = ex1.TextSize - dt
Else
ex1.TextSize = ex1.TextSize + dt
End If
Loop
ex1.TextSize=ex1.textsize *0.9
If ex1.TextSize < smalltext Then smalltext = ex1.TextSize
End Sub
Sub SetButtonTextSize(ex1 As Button, txt As String)
Dim dt As Float
Dim limit = 0.95 As Float
Dim h As Int
ex1.Text = txt
ex1.TextSize =72
dt = ex1.TextSize
h = stu.MeasureMultilineTextHeight(ex1, txt)
Do While dt > limit Or h > ex1.Height
dt = dt / 2
h = stu.MeasureMultilineTextHeight(ex1, txt)
If h > ex1.Height Then
ex1.TextSize = ex1.TextSize - dt
Else
ex1.TextSize = ex1.TextSize + dt
End If
Loop
ex1.TextSize = ex1.textsize * 0.95
If ex1.TextSize < smalltext Then smalltext = ex1.TextSize
ex1.TextColor = Colors.White
End Sub
Sub btnPowerOff_Click
vu.vibrateOnce(50)
ssstv.sendCommand(pwrOff)
Wait(100)
End Sub
Sub btnPowerOn_Click
vu.vibrateOnce(50)
ssstv.sendCommand(pwrOn)
Wait(100)
End Sub
Sub btnBrightUp_Click
vu.vibrateOnce(50)
ssstv.sendCommand(BRIGHTNESS_UP)
Wait(100)
End Sub
Sub btnBrightDown_Click
vu.vibrateOnce(50)
ssstv.sendCommand(BRIGHTNESS_DOWN)
Wait(100)
End Sub
Sub btnRed_Click
vu.vibrateOnce(50)
ssstv.sendCommand(clrRed)
Wait(100)
End Sub
Sub btnGreen_Click
vu.vibrateOnce(50)
ssstv.sendCommand(clrGreen)
Wait(100)
End Sub
Sub btnBlue_Click
vu.vibrateOnce(50)
ssstv.sendCommand(clrBlue)
Wait(100)
End Sub
Sub btnWhite_Click
vu.vibrateOnce(50)
ssstv.sendCommand(clrWhite)
Wait(100)
End Sub
Sub btnFlash_Click
vu.vibrateOnce(50)
ssstv.sendCommand(FLASH)
Wait(100)
End Sub
Sub btnStrobe_Click
vu.vibrateOnce(50)
ssstv.sendCommand(STROBE)
Wait(100)
End Sub
Sub btnFade_Click
vu.vibrateOnce(50)
ssstv.sendCommand(FADE)
Wait(100)
End Sub
Sub btnSmooth_Click
vu.vibrateOnce(50)
ssstv.sendCommand(SMOOTH)
Wait(100)
End Sub
Sub btnRed1_Click
vu.vibrateOnce(50)
ssstv.sendCommand(ORANGE)
Wait(100)
End Sub
Sub btnRed2_Click
vu.vibrateOnce(50)
ssstv.sendCommand(YELLOW_DARK)
Wait(100)
End Sub
Sub btnRed3_Click
vu.vibrateOnce(50)
ssstv.sendCommand(YELLOW_MEDIUM)
Wait(100)
End Sub
Sub btnRed4_Click
vu.vibrateOnce(50)
ssstv.sendCommand(YELLOW_LIGHT)
Wait(100)
End Sub
Sub btnGreen1_Click
vu.vibrateOnce(50)
ssstv.sendCommand(GREEN_LIGHT)
Wait(100)
End Sub
Sub btnGreen2_Click
vu.vibrateOnce(50)
ssstv.sendCommand(GREEN_BLUE1)
Wait(100)
End Sub
Sub btnGreen3_Click
vu.vibrateOnce(50)
ssstv.sendCommand(GREEN_BLUE2)
Wait(100)
End Sub
Sub btnGreen4_Click
vu.vibrateOnce(50)
ssstv.sendCommand(GREEN_BLUE3)
Wait(100)
End Sub
Sub btnBlue1_Click
vu.vibrateOnce(50)
ssstv.sendCommand(BLUE_RED)
Wait(100)
End Sub
Sub btnBlue2_Click
vu.vibrateOnce(50)
ssstv.sendCommand(PURPLE_DARK)
Wait(100)
End Sub
Sub btnBlue3_Click
vu.vibrateOnce(50)
ssstv.sendCommand(PURPLE_LIGHT)
Wait(100)
End Sub
Sub btnBlue4_Click
vu.vibrateOnce(50)
ssstv.sendCommand(PINK)
Wait(100)
End Sub
B4X:
'All variants script
'AutoScaleAll
'AutoScaleRate(1.0)
'AutoScaleAll
btnBrightUp.left = 4%x
btnBrightUp.top = 2%y
btnBrightUp.Width = 20%x
btnBrightUp.Height = 20%x
btnBrightDown.left = btnBrightUp.Right + 4%x
btnBrightDown.top = 2%y
btnBrightDown.Width = 20%x
btnBrightDown.Height = 20%x
btnPowerOff.Left = btnBrightDown.Right + 4%x
btnPowerOff.Top = 2%y
btnPowerOff.Width = 20%x
btnPowerOff.Height = 20%x
btnPowerOn.Left = btnPowerOff.Right + 4%x
btnPowerOn.Top = 2%y
btnPowerOn.Width = 20%x
btnPowerOn.Height = 20%x
btnRed.left = 4%x
btnRed.top = btnBrightUp.Bottom + 2%y
btnRed.Width = 20%x
btnRed.Height = 20%x
btnGreen.left = btnRed.Right + 4%x
btnGreen.top = btnBrightUp.Bottom + 2%y
btnGreen.Width = 20%x
btnGreen.Height = 20%x
btnBlue.Left = btnGreen.Right + 4%x
btnBlue.Top = btnPowerOff.Bottom + 2%y
btnBlue.Width = 20%x
btnBlue.Height = 20%x
btnWhite.Left = btnBlue.Right + 4%x
btnWhite.Top = btnPowerOn.Bottom + 2%y
btnWhite.Width = 20%x
btnWhite.Height = 20%x
btnFlash.Left = btnWhite.Left
btnFlash.Top = btnWhite.Bottom + 2%y
btnFlash.Width = 20%x
btnFlash.Height = 20%x
btnStrobe.Left = btnFlash.Left
btnStrobe.Top = btnFlash.Bottom + 2%y
btnStrobe.Width = 20%x
btnStrobe.Height = 20%x
btnFade.Left = btnStrobe.Left
btnFade.Top = btnStrobe.Bottom + 2%y
btnFade.Width = 20%x
btnFade.Height = 20%x
btnSmooth.Left = btnFade.Left
btnSmooth.Top = btnFade.Bottom + 2%y
btnSmooth.Width = 20%x
btnSmooth.Height = 20%x
btnRed1.Left = btnRed.Left
btnRed1.Top = btnFlash.Top
btnRed1.Width = 20%x
btnRed1.Height = 20%x
btnRed2.Left = btnRed.Left
btnRed2.Top = btnStrobe.Top
btnRed2.Width = 20%x
btnRed2.Height = 20%x
btnRed3.Left = btnRed.Left
btnRed3.Top = btnFade.Top
btnRed3.Width = 20%x
btnRed3.Height = 20%x
btnRed4.Left = btnRed.Left
btnRed4.Top = btnSmooth.Top
btnRed4.Width = 20%x
btnRed4.Height = 20%x
btnGreen1.Left = btnGreen.Left
btnGreen1.Top = btnRed1.Top
btnGreen1.Width = 20%x
btnGreen1.Height = 20%x
btnGreen2.Left = btnGreen.Left
btnGreen2.Top = btnRed2.Top
btnGreen2.Width = 20%x
btnGreen2.Height = 20%x
btnGreen3.Left = btnGreen.Left
btnGreen3.Top = btnRed3.Top
btnGreen3.Width = 20%x
btnGreen3.Height = 20%x
btnGreen4.Left = btnGreen.Left
btnGreen4.Top = btnRed4.Top
btnGreen4.Width = 20%x
btnGreen4.Height = 20%x
btnBlue1.Left = btnBlue.Left
btnBlue1.Top = btnFlash.Top
btnBlue1.Width = 20%x
btnBlue1.Height = 20%x
btnBlue2.Left = btnBlue.Left
btnBlue2.Top = btnStrobe.Top
btnBlue2.Width = 20%x
btnBlue2.Height = 20%x
btnBlue3.Left = btnBlue.Left
btnBlue3.Top = btnFade.Top
btnBlue3.Width = 20%x
btnBlue3.Height = 20%x
btnBlue4.Left = btnBlue.Left
btnBlue4.Top = btnSmooth.Top
btnBlue4.Width = 20%x
btnBlue4.Height = 20%x