No announcement yet.

Dreamscreen HD controll script

  • Filter
  • Time
  • Show
Clear All
new posts

    Dreamscreen HD controll script

    Hi There,

    I have a Dreamscreen HD which can be controlled over IP.
    I made a basic script to control some of its functions.
    Im no professional coder so there probably some improvements possible
    Imports System.IO
    Imports System.Net.Sockets.Socket
    Imports System.Text
    Imports System.Net
    Imports System.Net.Sockets
    'The static var below can be used with the CRC calculated function below
    'Static  uartComm_crc8_table = new byte[]{"&H2A","&H2D","&H70","&H77","&H7E","&H79","&H6C","&H6B","&H62","&H65","&H48","&H4F","&H46","&H41","&H54","&H53","&H5A","&H5D","&HE0","&HE7","&HEE","&HE9","&HFC","&HFB","&HF2","&HF5","&HD8","&HDF","&HD6","&HD1","&HC4","&HC3","&HCA","&HCD","&H90","&H97","&H9E","&H99","&H8C","&H8B","&H82","&H85","&HA8","&HAF","&HA6","&HA1","&HB4","&HB3","&HBA","&HBD","&HC7","&HC0","&HC9","&HCE","&HDB","&HDC","&HD5","&HD2","&HFF","&HF8","&HF1","&HF6","&HE3","&HE4","&HED","&HEA","&HB7","&HB0","&HB9","&HBE","&HAB","&HAC","&HA5","&HA2","&H8F","&H88","&H81","&H86","&H93","&H94","&H9D","&H9A","&H27","&H20","&H29","&H2E","&H3B","&H3C","&H35","&H32","&H1F","&H18","&H11","&H16","&H03","&H04","&H0D","&H0A","&H57","&H50","&H59","&H5E","&H4B","&H4C","&H45","&H42","&H6F","&H68","&H61","&H66","&H73","&H74","&H7D","&H7A","&H89","&H8E","&H87","&H80","&H95","&H92","&H9B","&H9C","&HB1","&HB6","&HBF","&HB8","&HAD","&HAA","&HA3","&HA4","&HF9","&HFE","&HF7","&HF0","&HE5","&HE2","&HEB","&HEC","&HC1","&HC6","&HCF","&HC8","&HDD","&HDA","&HD3","&HD4","&H69","&H6E","&H67","&H60","&H75","&H72","&H7B","&H7C","&H51","&H56","&H5F","&H58","&H4D","&H4A","&H43","&H44","&H19","&H1E","&H17","&H10","&H05","&H02","&H0B","&H0C","&H21","&H26","&H2F","&H28","&H3D","&H3A","&H33","&H34","&H4E","&H49","&H40","&H47","&H52","&H55","&H5C","&H5B","&H76","&H71","&H78","&H7F","&H6A","&H6D","&H64","&H63","&H3E","&H39","&H30","&H37","&H22","&H25","&H2C","&H2B","&H06","&H01","&H08","&H0F","&H1A","&H1D","&H14","&H13","&HAE","&HA9","&HA0","&HA7","&HB2","&HB5","&HBC","&HBB","&H9 ","&H91","&H98","&H9F","&H8A","&H8D","&H84","&H83","&HDE","&HD9","&HD0","&HD7","&HC2","&HC5","&HCC","&HCB","&HE6","&HE1","&HE8","&HEF","&HFA","&HFD","&HF4","&HF3"}
    Function Start  (Byval modus As String )
        Dim GLOIP As IPAddress = System.Net.IPAddress.Parse("") 'use a static DHCP lease!!
        Dim GLOINTPORT As Integer
        Dim bytCommand As Byte() = New Byte(){}' empty array because it will be filled by function ModeToByte
        bytcommand = ModeToByte (modus)
        Dim udpClient As New UdpClient
        Dim pRet As Integer
               GLOINTPORT = 8888
                udpClient.Connect(GLOIP, GLOINTPORT)
                pRet = udpClient.Send(bytCommand, bytCommand.Length)
             Catch ex As Exception
                hs.WriteLog("Dreamscreen error: ",ex.Message)
            End Try
    End Function
    Function ModeToByte (Byval mode as string) As Byte()
    Dim result As Byte() = New Byte() {}
    Dim AmbModes(5) As String  'mode,ambientscene,R,G,B
      If (mode.Length > 5) Then
         AmbModes = mode.Split(New Char() {":"c})
         mode = AmbModes(0)
      End If
      Select Case mode
                Case "Ambient"
                     Select Case AmbModes(1)
                        Case "Random"
                            'result = {"&HFC","06","00","&H21","03","&H0D","&H01,"&H5F"} 'is Random color no group specified (off will not work without group)
                             result = {"&HFC","06","01","&H21","03","&H0D","&H01","&H3D"} 'is Random color group 1
                        Case "Fireside"
                              'result =  {"&HFC","06","00","&H21","03","&H0D","&H02","&H56"} ' is Fireside no group specified (off will not work without group)
                               result = {"&HFC","06","01","&H21","03","&H0D","&H02","&H34"} ' is Fireside group 1
                        Case "Twinkle"
                              'result = {"&HFC","06","00","&H21","03","&H0D","&H03","&H51"} ' is Twinkle no group specified (off will not work without group)
                               result =  {"&HFC","06","01","&H21","03","&H0D","&H03","&H33"} ' is Twinkle group 1
                        Case "Ocean"
                              'result = {"&HFC","06","00","&H21","03","&H0D","&H04","&H44"} ' is Ocean no group specified (off will not work without group)
                               result =  {"&HFC","06","01","&H21","03","&H0D","&H04","&H26"} ' is Ocean group 1
                        Case "July4th"
                             'result = {"&HFC","06","00","&H21","03","&H0D","&H05","&H43"} ' is July 4th no group specified (off will not work without group)
                              result = {"&HFC","06","01","&H21","03","&H0D","&H05","&H21"} ' is July 4th group 1
                        Case "Holiday"
                             'result = {"&HFC","06","00","&H21","03","&H0D","&H06","&H4A"} ' is Holiday no group specified (off will not work without group)
                              result = {"&HFC","06","01","&H21","03","&H0D","&H06","&H28"} ' is Holiday group 1
                         Case "Pop"
                             '{"&HFC","06","00","&H21","03","&H0D","&H07","&H4D"} ' is Pop no group specified (off will not work without group)
                             result = {"&HFC","06","01","&H21","03","&H0D","&H07","&H2F"} ' is Pop group 1
                         Case "EnchantedForest"
                              result = {"&HFC","06","01","&H21","03","&H0D","&H08","&H02"} ' is enchanted forest group 1
                         Case "RGB"
                                hs.writelog("Dreamscreen","RGB isn't supported yet")      
                         Case Else
                                hs.WriteLog("Dreamscreen Ambient scene","Incorrect scene specifief: >>" & AmbModes(1) &"<< Choose from: Random, Fireside, Twinkle, Ocean, July4th, Holiday, Pop, EnchantedForest" )
                      end Select
                Case "Off"
                  ' result = {"&HFC","&H06","&H00","&H21","&H03","&H01","&H00","&HA4"} 'no group specified
                   result = {"&HFC","&H06","&H01","&H21","&H03","&H01","&H00","&HC6"} 'group 1 without group (parameter on 0) this doesn't work
                Case "Video"
                    result = {"&HFC","06","00","&H21","03","01","01","&HA3"} 'no port switch is done
                Case "Music"
                     result = {"&HFC","06","00","&H21","03","01","02","&HAA"} 'no port switch is done
                Case Else
                    hs.WriteLog("Dreamscreen","incorrect mode selected: " & mode)
      End Select
      Return result
    End Function
    'below is java code from rev4 documentation to calculated the CRC byte, For RGB functions this must be implemented
    'Function  uartComm_calculate_crc8(byte[] data) ' still java code
    ' byte size = (byte) (data[1] + 0x01);
    ' byte cntr = 0x00;
    ' byte crc = 0x00;
    ' while (cntr < size) {
    ' crc = uartComm_crc8_table[(byte) (crc ^ (data[cntr])) & 0xFF];
     'return crc;
    'End Function
    To use it see the attached picture.
    Options for the start script:
    For the off function to work you need to have the Dreamscreen device in a group! RGB function isn't implemented because of all the CRC calculations that are possible and i dont have the calculator function working. For that part i could use some help.
    The Rev4 documentation is a bit harder to find but a you can download it from here

    edit: The Off function doesn't always work at all. For now random working. When Sending of and no response. I open the app and send it again and then it works so not really stable...