Page screensaver
    Attributes
        ID                                  : 0
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        Width                               : 480
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Locked                              : no
        Swide up page ID                    : disabled
        Swide down page ID                  : disabled
        Swide left page ID                  : disabled
        Swide right page ID                 : disabled
        Fill                                : solid color
        Back. Color                         : 0
    
    Events
        Preinitialize Event
            recmod=1
            bauds=115200
            vis originPage,0
            vis tInstruction,0
            vis tTmp,0
            vis p0,0
            //load gloabl time string from pageIcons
            tTime.txt=vaTime.txt
            tDate.txt=vaDate.txt
            dim=dimValue
            vis tSend,0
            //page open event
            // craft command
            tSend.txt="event,screensaverOpen"
            //send calc crc
            btlen tSend.txt,sys0
            crcrest 1,0xffff // reset CRC
            crcputh 55 bb
            crcputs sys0,1
            crcputs tSend.txt,0
            //send cmd
            printh 55 bb
            prints sys0,2
            prints tSend.txt,0
            prints crcval,2
            // clear weather elements, to keep example content in HMI
            tMainIcon.txt=""
            tMainText.txt=""
            tMRIcon.txt=""
            tMR.txt=""
            tForecast1.txt=""
            tF1Icon.txt=""
            tForecast1Val.txt=""
            tForecast2.txt=""
            tF2Icon.txt=""
            tForecast2Val.txt=""
        
Variable (string) strCommand
    Attributes
        ID            : 5
        Scope         : local
        Text          : 
        Max. Text Size: 100
    
Variable (string) vaTime
    Attributes
        ID            : 10
        Scope         : global
        Text          : 
        Max. Text Size: 10
    
Variable (string) vaDate
    Attributes
        ID            : 11
        Scope         : global
        Text          : 
        Max. Text Size: 30
    
Variable (string) tId
    Attributes
        ID            : 24
        Scope         : local
        Text          : 
        Max. Text Size: 25
    
Number originPage
    Attributes
        ID                                  : 3
        Scope                               : global
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 452
        y coordinate                        : 267
        Width                               : 24
        Height                              : 49
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : flat
        Associated Keyboard                 : none
        Font ID                             : 0
        Back. Color                         : 65535
        Font Color                          : 0
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        Value                               : 0
        Significant digits shown            : all
        Format                              : decimal
        Word wrap                           : enabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
Text tInstruction
    Attributes
        ID                                  : 6
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 450
        y coordinate                        : 186
        Width                               : 27
        Height                              : 30
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : flat
        Associated Keyboard                 : none
        Font ID                             : 0
        Back. Color                         : 65535
        Font Color                          : 0
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        Input Type                          : character
        Text                                : 
        Max. Text Size                      : 20
        Word wrap                           : disabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
Text tTmp
    Attributes
        ID                                  : 7
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 451
        y coordinate                        : 228
        Width                               : 25
        Height                              : 30
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : flat
        Associated Keyboard                 : none
        Font ID                             : 0
        Back. Color                         : 65535
        Font Color                          : 0
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        Input Type                          : character
        Text                                : 
        Max. Text Size                      : 20
        Word wrap                           : disabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
Text tTime
    Attributes
        ID                                  : 8
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 0
        y coordinate                        : 0
        Width                               : 451
        Height                              : 150
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : flat
        Associated Keyboard                 : none
        Font ID                             : 5
        Back. Color                         : 0
        Font Color                          : 65535
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        Input Type                          : character
        Text                                : 21:32
        Max. Text Size                      : 10
        Word wrap                           : disabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
Text tDate
    Attributes
        ID                                  : 9
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 0
        y coordinate                        : 150
        Width                               : 451
        Height                              : 38
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : flat
        Associated Keyboard                 : none
        Font ID                             : 1
        Back. Color                         : 0
        Font Color                          : 65535
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        Input Type                          : character
        Text                                : Tuesday, 08. March 2022
        Max. Text Size                      : 30
        Word wrap                           : disabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
Text tSend
    Attributes
        ID                                  : 12
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 451
        y coordinate                        : 9
        Width                               : 29
        Height                              : 30
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : flat
        Associated Keyboard                 : none
        Font ID                             : 0
        Back. Color                         : 65535
        Font Color                          : 0
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        Input Type                          : character
        Text                                : 
        Max. Text Size                      : 25
        Word wrap                           : disabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
Text tMainIcon
    Attributes
        ID                                  : 13
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 6
        y coordinate                        : 223
        Width                               : 100
        Height                              : 66
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : flat
        Associated Keyboard                 : none
        Font ID                             : 3
        Back. Color                         : 0
        Font Color                          : 65535
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        Input Type                          : character
        Text                                : î
        Max. Text Size                      : 10
        Word wrap                           : disabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
Text tMainText
    Attributes
        ID                                  : 14
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 114
        y coordinate                        : 214
        Width                               : 110
        Height                              : 43
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : flat
        Associated Keyboard                 : none
        Font ID                             : 2
        Back. Color                         : 0
        Font Color                          : 65535
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        Input Type                          : character
        Text                                : 2,3 Â°C
        Max. Text Size                      : 10
        Word wrap                           : disabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
Text tMRIcon
    Attributes
        ID                                  : 15
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 115
        y coordinate                        : 268
        Width                               : 40
        Height                              : 35
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : flat
        Associated Keyboard                 : none
        Font ID                             : 1
        Back. Color                         : 0
        Font Color                          : 65535
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        Input Type                          : character
        Text                                : î
        Max. Text Size                      : 10
        Word wrap                           : disabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
Text tMR
    Attributes
        ID                                  : 16
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 157
        y coordinate                        : 275
        Width                               : 67
        Height                              : 22
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : flat
        Associated Keyboard                 : none
        Font ID                             : 0
        Back. Color                         : 0
        Font Color                          : 65535
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        Input Type                          : character
        Text                                : 0 mm
        Max. Text Size                      : 10
        Word wrap                           : disabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
Text tForecast1
    Attributes
        ID                                  : 17
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 228
        y coordinate                        : 210
        Width                               : 108
        Height                              : 26
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : flat
        Associated Keyboard                 : none
        Font ID                             : 0
        Back. Color                         : 0
        Font Color                          : 65535
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        Input Type                          : character
        Text                                : Mi
        Max. Text Size                      : 10
        Word wrap                           : disabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
Text tForecast1Val
    Attributes
        ID                                  : 18
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 228
        y coordinate                        : 277
        Width                               : 108
        Height                              : 26
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : flat
        Associated Keyboard                 : none
        Font ID                             : 0
        Back. Color                         : 0
        Font Color                          : 65535
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        Input Type                          : character
        Text                                : 9,3 Â°C
        Max. Text Size                      : 10
        Word wrap                           : disabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
Text tF1Icon
    Attributes
        ID                                  : 19
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 262
        y coordinate                        : 239
        Width                               : 40
        Height                              : 35
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : flat
        Associated Keyboard                 : none
        Font ID                             : 1
        Back. Color                         : 0
        Font Color                          : 65535
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        Input Type                          : character
        Text                                : î
        Max. Text Size                      : 10
        Word wrap                           : disabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
Text tForecast2
    Attributes
        ID                                  : 20
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 341
        y coordinate                        : 210
        Width                               : 107
        Height                              : 25
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : flat
        Associated Keyboard                 : none
        Font ID                             : 0
        Back. Color                         : 0
        Font Color                          : 65535
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        Input Type                          : character
        Text                                : Do
        Max. Text Size                      : 10
        Word wrap                           : disabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
Text tF2Icon
    Attributes
        ID                                  : 21
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 375
        y coordinate                        : 238
        Width                               : 40
        Height                              : 33
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : flat
        Associated Keyboard                 : none
        Font ID                             : 1
        Back. Color                         : 0
        Font Color                          : 65535
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        Input Type                          : character
        Text                                : î
        Max. Text Size                      : 10
        Word wrap                           : disabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
Text tForecast2Val
    Attributes
        ID                                  : 22
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 341
        y coordinate                        : 277
        Width                               : 107
        Height                              : 25
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : flat
        Associated Keyboard                 : none
        Font ID                             : 0
        Back. Color                         : 0
        Font Color                          : 65535
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        Input Type                          : character
        Text                                : 11,9 Â°C
        Max. Text Size                      : 10
        Word wrap                           : disabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
Text t10
    Attributes
        ID                                  : 23
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 46
        y coordinate                        : 195
        Width                               : 360
        Height                              : 2
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : flat
        Associated Keyboard                 : none
        Font ID                             : 0
        Back. Color                         : 65535
        Font Color                          : 0
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        Input Type                          : character
        Text                                : |
        Max. Text Size                      : 10
        Word wrap                           : disabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
Picture p0
    Attributes
        ID                                  : 1
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 0
        y coordinate                        : 1
        Width                               : 479
        Height                              : 319
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Picture ID                          : 0
    
Timer tmSerial
    Attributes
        ID         : 4
        Scope      : local
        Period (ms): 50
        Enabled    : yes
    
    Events
        Timer Event
            // data available
            if(usize>1)
            {
                bufferPos=0
                while(bufferPos<usize)
                {
                    // check for 0x55 0xBB - Command Init Secuence
                    if(u[bufferPos]==187&&u[bufferPos-1]==85)
                    {
                        //remove garbage at the start of the buffer if there's any to free buffer for command
                        if(u[bufferPos]!=1)
                        {
                            udelete bufferPos-1
                        }
                        //instruction is now aligned with buffer, because we deleted garbage before instrcution
                        //get length after init sequence (check if there are more than to bytes in buffer)
                        if(3<usize)
                        {
                            // check if serial buffer has reached the announced length
                            ucopy payloadLength,2,2,0
                            // we are only checking payload length so we have to skip first 3 bytes (init+payload length) (-1 because of < instead of <=)
                            payloadLength+=3
                            // payload length does also not contain crc, so we are adding another 2 bytes for crc
                            payloadLength+=2
                            if(payloadLength<usize)
                            {
                                // calculate crc
                                crcrest 1,0xFFFF
                                // u[2] contains payload legth at 3rd pos in buffer, we are calculating crc from 3rd pos with number of bytes from payload length
                                //crcputu 3,u[2]
                                // u[2] cotnains payload length, we are calculating a crc over the whole message, so we have to add 3 to the length from u[2]
                                crcputu 0,payloadLength-1
                                // get recived crc to be able to compare it
                                ucopy recvCrc,payloadLength-1,2,0
                                // compare crc with recived value
                                if(crcval==recvCrc)
                                {
                                    // crc is okay
                                    // here is the location where acual code should be
                                    // write command to variable strCommand
                                    ucopy strCommand.txt,4,payloadLength-5,0
                                    // write instruction to tInstuction (debug output, but used as variable here, ui elements will be disabled by default)
                                    spstr strCommand.txt,tInstruction.txt,",",0
                                    if(tInstruction.txt=="wake")
                                    {
                                        dim=100
                                        page originPage.val
                                    }
                                    if(tInstruction.txt=="dimmode")
                                    {
                                        // get value
                                        spstr strCommand.txt,tTmp.txt,",",1
                                        covx tTmp.txt,dimValue,0,0
                                        dim=dimValue
                                    }
                                    if(tInstruction.txt=="time")
                                    {
                                        //get set time to global variable
                                        spstr strCommand.txt,vaTime.txt,",",1
                                        tTime.txt=vaTime.txt
                                    }
                                    if(tInstruction.txt=="date")
                                    {
                                        //get set date to global variable
                                        spstr strCommand.txt,vaDate.txt,"?",1
                                        tDate.txt=vaDate.txt
                                    }
                                    if(tInstruction.txt=="timeout")
                                    {
                                        //set timeout to global var
                                        spstr strCommand.txt,tTmp.txt,",",1
                                        covx tTmp.txt,sleepTimeout,0,0
                                    }
                                    if(tInstruction.txt=="weatherUpdate")
                                    {
                                        //tMainIcon
                                        spstr strCommand.txt,tTmp.txt,"?",1
                                        covx tTmp.txt,sys0,0,0
                                        substr pageIcons.tIcons.txt,tMainIcon.txt,sys0,1
                                        //tMainText
                                        spstr strCommand.txt,tMainText.txt,"?",2
                                        //tMRIcon
                                        spstr strCommand.txt,tTmp.txt,"?",3
                                        covx tTmp.txt,sys0,0,0
                                        substr pageIcons.tIcons.txt,tMRIcon.txt,sys0,1
                                        //tMR
                                        spstr strCommand.txt,tMR.txt,"?",4
                                        //tForecast1
                                        spstr strCommand.txt,tForecast1.txt,"?",5
                                        //tF1Icon
                                        spstr strCommand.txt,tTmp.txt,"?",6
                                        covx tTmp.txt,sys0,0,0
                                        substr pageIcons.tIcons.txt,tF1Icon.txt,sys0,1
                                        //tForecast1Val
                                        spstr strCommand.txt,tForecast1Val.txt,"?",7
                                        //tForecast2
                                        spstr strCommand.txt,tForecast2.txt,"?",8
                                        //tF2Icon
                                        spstr strCommand.txt,tTmp.txt,"?",9
                                        covx tTmp.txt,sys0,0,0
                                        substr pageIcons.tIcons.txt,tF2Icon.txt,sys0,1
                                        //tForecast2Val
                                        spstr strCommand.txt,tForecast2Val.txt,"?",10
                                    }
                                    if(tInstruction.txt=="page")
                                    {
                                        //pagenumber
                                        spstr strCommand.txt,tTmp.txt,",",1
                                        covx tTmp.txt,sys0,0,0
                                        nPage=sys0
                                        //don't send current page number, wake will do
                                    }
                                    if(tInstruction.txt=="pageType")
                                    {
                                        //command format pageType,specialPageName
                                        //write name of speical page to tId
                                        spstr strCommand.txt,tId.txt,",",1
                                        //save second arg if there's one
                                        spstr strCommand.txt,tTmp.txt,",",2
                                        //save third arg if there's one
                                        spstr strCommand.txt,pageIcons.tTmp2.txt,",",3
                                        //we are going to exit this page with this command, so we have to clear the buffer, so we are not getting into a stupid loop ...
                                        udelete u[2]+3
                                        bufferPos=0
                                        if(tId.txt=="popupLight")
                                        {
                                            pageIcons.tTmp1.txt=tTmp.txt
                                            page popupLight
                                        }
                                        if(tId.txt=="pageStartup")
                                        {
                                            page pageStartup
                                        }
                                        if(tId.txt=="cardThermo")
                                        {
                                            page cardThermo
                                        }
                                        if(tId.txt=="cardMedia")
                                        {
                                            page cardMedia
                                        }
                                        if(tId.txt=="pageStartup")
                                        {
                                            page pageStartup
                                        }
                                        if(tId.txt=="pageNotify")
                                        {
                                            page popupNotify
                                        }
                                        if(tId.txt=="cardGrid")
                                        {
                                            page cardGrid
                                        }
                                        if(tId.txt=="cardAlarm")
                                        {
                                            page cardAlarm
                                        }
                                    }
                                    // end of user code
                                    udelete payloadLength-1
                                    bufferPos=0
                                }
                            }
                        }
                    }
                    // next character
                    bufferPos++
                }
            }
        
TouchCap tc0
    Attributes
        ID   : 2
        Scope: local
        Value: 0
    
    Events
        Touch Press Event
            dim=100
            page originPage.val
        
