Page pageTest
    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                         : 4226
    
    Events
        Preinitialize Event
            vis p0,0
            recmod=1
            baud=115200
        
Variable (string) strCommand
    Attributes
        ID            : 17
        Scope         : local
        Text          : 
        Max. Text Size: 20
    
Variable (string) strTmp
    Attributes
        ID            : 25
        Scope         : local
        Text          : 
        Max. Text Size: 2
    
Variable (string) tInstruction
    Attributes
        ID            : 16
        Scope         : local
        Text          : 
        Max. Text Size: 30
    
Variable (string) tSend
    Attributes
        ID            : 18
        Scope         : local
        Text          : 
        Max. Text Size: 40
    
Text tBench
    Attributes
        ID                                  : 15
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 288
        y coordinate                        : 90
        Width                               : 152
        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                                  : 24
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 49
        y coordinate                        : 48
        Width                               : 257
        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                                : test123test123
        Max. Text Size                      : 30
        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                        : 0
        Width                               : 479
        Height                              : 319
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Picture ID                          : 0
    
Button b0
    Attributes
        ID                                  : 2
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 0
        y coordinate                        : 0
        Width                               : 100
        Height                              : 50
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : 3D auto
        Font ID                             : 1
        Back. Color                         : 50712
        Back. Picture ID (Pressed)          : 65535
        Back. Color (Pressed)               : 1024
        Font Color (Unpressed)              : 0
        Font Color (Pressed)                : 65535
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        State                               : unpressed
        Text                                : entities
        Max. Text Size                      : 10
        Word wrap                           : disabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
    Events
        Touch Press Event
            page cardEntities
        
Button b1
    Attributes
        ID                                  : 12
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 349
        y coordinate                        : 252
        Width                               : 102
        Height                              : 63
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : 3D auto
        Font ID                             : 1
        Back. Color                         : 50712
        Back. Picture ID (Pressed)          : 0
        Back. Color (Pressed)               : 1024
        Font Color (Unpressed)              : 0
        Font Color (Pressed)                : 65535
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        State                               : unpressed
        Text                                : bauds=115200
        Max. Text Size                      : 20
        Word wrap                           : enabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
    Events
        Touch Press Event
            bauds=115200
        
Button b10
    Attributes
        ID                                  : 10
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 100
        y coordinate                        : 98
        Width                               : 100
        Height                              : 50
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : 3D auto
        Font ID                             : 1
        Back. Color                         : 50712
        Back. Picture ID (Pressed)          : 65535
        Back. Color (Pressed)               : 1024
        Font Color (Unpressed)              : 0
        Font Color (Pressed)                : 65535
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        State                               : unpressed
        Text                                : alarm
        Max. Text Size                      : 10
        Word wrap                           : disabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
    Events
        Touch Press Event
            page cardAlarm
        
Button b11
    Attributes
        ID                                  : 11
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 100
        y coordinate                        : 145
        Width                               : 100
        Height                              : 50
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : 3D auto
        Font ID                             : 1
        Back. Color                         : 50712
        Back. Picture ID (Pressed)          : 65535
        Back. Color (Pressed)               : 1024
        Font Color (Unpressed)              : 0
        Font Color (Pressed)                : 65535
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        State                               : unpressed
        Text                                : grid
        Max. Text Size                      : 10
        Word wrap                           : disabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
    Events
        Touch Press Event
            page cardGrid
        
Button b12
    Attributes
        ID                                  : 19
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 0
        y coordinate                        : 242
        Width                               : 100
        Height                              : 50
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : 3D auto
        Font ID                             : 1
        Back. Color                         : 50712
        Back. Picture ID (Pressed)          : 65535
        Back. Color (Pressed)               : 1024
        Font Color (Unpressed)              : 0
        Font Color (Pressed)                : 65535
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        State                               : unpressed
        Text                                : power
        Max. Text Size                      : 10
        Word wrap                           : disabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
    Events
        Touch Press Event
            page cardPower
        
Button b13
    Attributes
        ID                                  : 20
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 406
        y coordinate                        : 133
        Width                               : 43
        Height                              : 50
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : 3D auto
        Font ID                             : 0
        Back. Color                         : 50712
        Back. Picture ID (Pressed)          : 65535
        Back. Color (Pressed)               : 1024
        Font Color (Unpressed)              : 0
        Font Color (Pressed)                : 65535
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        State                               : unpressed
        Text                                : showqq
        Max. Text Size                      : 10
        Word wrap                           : enabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
    Events
        Touch Press Event
            showqq
        
Button b14
    Attributes
        ID                                  : 21
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 0
        y coordinate                        : 0
        Width                               : 100
        Height                              : 50
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : 3D auto
        Font ID                             : 0
        Back. Color                         : 50712
        Back. Picture ID (Pressed)          : 65535
        Back. Color (Pressed)               : 1024
        Font Color (Unpressed)              : 0
        Font Color (Pressed)                : 65535
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        State                               : unpressed
        Text                                : newtxt
        Max. Text Size                      : 10
        Word wrap                           : disabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
Button b15
    Attributes
        ID                                  : 22
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 236
        y coordinate                        : 263
        Width                               : 100
        Height                              : 50
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : 3D auto
        Font ID                             : 0
        Back. Color                         : 50712
        Back. Picture ID (Pressed)          : 65535
        Back. Color (Pressed)               : 1024
        Font Color (Unpressed)              : 0
        Font Color (Pressed)                : 65535
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        State                               : unpressed
        Text                                : cardLchart
        Max. Text Size                      : 10
        Word wrap                           : disabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
    Events
        Touch Press Event
            page cardLChart
        
Button b16
    Attributes
        ID                                  : 23
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 135
        y coordinate                        : 263
        Width                               : 100
        Height                              : 50
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : 3D auto
        Font ID                             : 0
        Back. Color                         : 50712
        Back. Picture ID (Pressed)          : 65535
        Back. Color (Pressed)               : 1024
        Font Color (Unpressed)              : 0
        Font Color (Pressed)                : 65535
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        State                               : unpressed
        Text                                : chart
        Max. Text Size                      : 10
        Word wrap                           : disabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
    Events
        Touch Press Event
            page cardChart
        
Button b2
    Attributes
        ID                                  : 13
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 0
        y coordinate                        : 195
        Width                               : 100
        Height                              : 50
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : 3D auto
        Font ID                             : 1
        Back. Color                         : 50712
        Back. Picture ID (Pressed)          : 65535
        Back. Color (Pressed)               : 1024
        Font Color (Unpressed)              : 0
        Font Color (Pressed)                : 65535
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        State                               : unpressed
        Text                                : qr
        Max. Text Size                      : 10
        Word wrap                           : disabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
    Events
        Touch Press Event
            page cardQR
        
Button b3
    Attributes
        ID                                  : 3
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 347
        y coordinate                        : 184
        Width                               : 102
        Height                              : 63
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : 3D auto
        Font ID                             : 1
        Back. Color                         : 50712
        Back. Picture ID (Pressed)          : 0
        Back. Color (Pressed)               : 1024
        Font Color (Unpressed)              : 0
        Font Color (Pressed)                : 65535
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        State                               : unpressed
        Text                                : disable recmod
        Max. Text Size                      : 20
        Word wrap                           : enabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
    Events
        Touch Press Event
            recmod=0
        
Button b4
    Attributes
        ID                                  : 5
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 0
        y coordinate                        : 96
        Width                               : 100
        Height                              : 50
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : 3D auto
        Font ID                             : 1
        Back. Color                         : 50712
        Back. Picture ID (Pressed)          : 65535
        Back. Color (Pressed)               : 1024
        Font Color (Unpressed)              : 0
        Font Color (Pressed)                : 65535
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        State                               : unpressed
        Text                                : light
        Max. Text Size                      : 10
        Word wrap                           : disabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
    Events
        Touch Press Event
            page popupLight
        
Button b5
    Attributes
        ID                                  : 6
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 100
        y coordinate                        : 0
        Width                               : 100
        Height                              : 50
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : 3D auto
        Font ID                             : 1
        Back. Color                         : 50712
        Back. Picture ID (Pressed)          : 65535
        Back. Color (Pressed)               : 1024
        Font Color (Unpressed)              : 0
        Font Color (Pressed)                : 65535
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        State                               : unpressed
        Text                                : thermo
        Max. Text Size                      : 10
        Word wrap                           : disabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
    Events
        Touch Press Event
            page cardThermo
        
Button b6
    Attributes
        ID                                  : 4
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 0
        y coordinate                        : 49
        Width                               : 100
        Height                              : 50
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : 3D auto
        Font ID                             : 1
        Back. Color                         : 50712
        Back. Picture ID (Pressed)          : 65535
        Back. Color (Pressed)               : 1024
        Font Color (Unpressed)              : 0
        Font Color (Pressed)                : 65535
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        State                               : unpressed
        Text                                : shutter
        Max. Text Size                      : 10
        Word wrap                           : disabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
    Events
        Touch Press Event
            page popupShutter
        
Button b7
    Attributes
        ID                                  : 7
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 100
        y coordinate                        : 49
        Width                               : 100
        Height                              : 50
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : 3D auto
        Font ID                             : 1
        Back. Color                         : 50712
        Back. Picture ID (Pressed)          : 65535
        Back. Color (Pressed)               : 1024
        Font Color (Unpressed)              : 0
        Font Color (Pressed)                : 65535
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        State                               : unpressed
        Text                                : media
        Max. Text Size                      : 10
        Word wrap                           : disabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
    Events
        Touch Press Event
            page cardMedia
        
Button b8
    Attributes
        ID                                  : 8
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 341
        y coordinate                        : 9
        Width                               : 106
        Height                              : 50
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : 3D auto
        Font ID                             : 1
        Back. Color                         : 50712
        Back. Picture ID (Pressed)          : 65535
        Back. Color (Pressed)               : 1024
        Font Color (Unpressed)              : 0
        Font Color (Pressed)                : 65535
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        State                               : unpressed
        Text                                : screens
        Max. Text Size                      : 10
        Word wrap                           : disabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
    Events
        Touch Press Event
            dimValue=50
            page screensaver
        
Button b9
    Attributes
        ID                                  : 9
        Scope                               : local
        Dragging                            : 0
        Disable release event after dragging: 0
        Send Component ID                   : disabled
        Opacity                             : 127
        x coordinate                        : 0
        y coordinate                        : 146
        Width                               : 100
        Height                              : 50
        Effect                              : load
        Effect Priority                     : 0
        Effect Time                         : 300
        Fill                                : solid color
        Style                               : 3D auto
        Font ID                             : 1
        Back. Color                         : 50712
        Back. Picture ID (Pressed)          : 65535
        Back. Color (Pressed)               : 1024
        Font Color (Unpressed)              : 0
        Font Color (Pressed)                : 65535
        Horizontal Alignment                : center
        Vertical Alignment                  : center
        State                               : unpressed
        Text                                : notify
        Max. Text Size                      : 10
        Word wrap                           : disabled
        Horizontal Spacing                  : 0
        Vertical Spacing                    : 0
    
    Events
        Touch Press Event
            page popupNotify
        
Timer tmSerial
    Attributes
        ID         : 14
        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=="ping")
                                    {
                                        spstr strCommand.txt,tBench.txt,"~",1
                                        tSend.txt="pong,"+tBench.txt
                                        //send calc crc
                                        btlen tSend.txt,sys0
                                        crcrest 1,0xffff // reset CRC
                                        crcputh 55 bb
                                        crcputs sys0,2
                                        crcputs tSend.txt,0
                                        //send cmd
                                        printh 55 bb
                                        prints sys0,2
                                        prints tSend.txt,0
                                        prints crcval,2
                                    }
                                    // end of user code
                                    udelete payloadLength-1
                                    bufferPos=0
                                }
                            }
                        }
                    }
                    // next character
                    bufferPos++
                }
            }
        
