Page fan
    Attributes
        ID                 : 0
        Scope              : local
        Dragging           : 0
        Send Component ID  : on press and release
        Locked             : no
        Swide up page ID   : disabled
        Swide down page ID : disabled
        Swide left page ID : disabled
        Swide right page ID: disabled
    
    Events
        Preinitialize Event
            if(api==0)
            {
                page home
            }else
            {
                sendme
            }
        
Variable (string) fansetting
    Attributes
        ID            : 7
        Scope         : local
        Text          : 
        Max. Text Size: 255
    
Variable (string) va0
    Attributes
        ID            : 8
        Scope         : local
        Text          : 
        Max. Text Size: 10
    
Text fan_value
    Attributes
        ID                 : 1
        Scope              : local
        Dragging           : 0
        Send Component ID  : on press and release
        Associated Keyboard: none
        Text               : 
        Max. Text Size     : 10
    
Text page_label
    Attributes
        ID                 : 2
        Scope              : local
        Dragging           : 0
        Send Component ID  : on press and release
        Associated Keyboard: none
        Text               : 
        Max. Text Size     : 100
    
Text icon_state
    Attributes
        ID                 : 6
        Scope              : local
        Dragging           : 0
        Send Component ID  : on press and release
        Associated Keyboard: none
        Text               : 
        Max. Text Size     : 10
    
Slider fanslider
    Attributes
        ID               : 3
        Scope            : local
        Dragging         : 0
        Send Component ID: on press and release
        Position         : 0
        Upper range limit: 4
        Lower range limit: 0
    
    Events
        Touch Release Event
            sys0=100*fanslider.val/fanslider.maxval
            covx sys0,va0.txt,0,0
            fan_value.txt=va0.txt+"%"
            if(fanslider.val>fanslider.minval)
            {
                button_off.pco=59164
                button_down.pco=59164
            }else
            {
                button_off.pco=10597
                button_down.pco=10597
            }
            if(fanslider.val<fanslider.maxval)
            {
                button_up.pco=59164
            }else
            {
                button_up.pco=10597
            }
            timer0.en=1
        
Button button_up
    Attributes
        ID               : 9
        Scope            : local
        Dragging         : 0
        Send Component ID: on press and release
        State            : unpressed
        Text             : ï‘­
        Max. Text Size   : 3
    
    Events
        Touch Press Event
            if(fanslider.val<fanslider.maxval)
            {
                fanslider.val++
                sys0=100*fanslider.val/fanslider.maxval
                covx sys0,va0.txt,0,0
                fan_value.txt=va0.txt+"%"
            }
            if(fanslider.val>fanslider.minval)
            {
                button_off.pco=59164
                button_down.pco=59164
            }else
            {
                button_off.pco=10597
                button_down.pco=10597
            }
            if(fanslider.val<fanslider.maxval)
            {
                button_up.pco=59164
            }else
            {
                button_up.pco=10597
            }
        
        Touch Release Event
            timer0.en=1
        
Button button_on
    Attributes
        ID               : 10
        Scope            : local
        Dragging         : 0
        Send Component ID: on press and release
        State            : unpressed
        Text             : îˆ
        Max. Text Size   : 3
    
    Events
        Touch Press Event
            fanslider.val=fanslider.maxval/2
            sys0=fanslider.maxval*5
            sys0%=10
            if(sys0>=5)
            {
                fanslider.val++
            }
            sys0=100*fanslider.val/fanslider.maxval
            covx sys0,va0.txt,0,0
            fan_value.txt=va0.txt+"%"
            if(fanslider.val>fanslider.minval)
            {
                button_off.pco=59164
                button_down.pco=59164
            }else
            {
                button_off.pco=10597
                button_down.pco=10597
            }
            if(fanslider.val<fanslider.maxval)
            {
                button_up.pco=59164
            }else
            {
                button_up.pco=10597
            }
        
        Touch Release Event
            timer0.en=1
        
Button button_down
    Attributes
        ID               : 11
        Scope            : local
        Dragging         : 0
        Send Component ID: on press and release
        State            : unpressed
        Text             : ï‘¬
        Max. Text Size   : 3
    
    Events
        Touch Press Event
            if(fanslider.val>fanslider.minval)
            {
                fanslider.val--
                sys0=100*fanslider.val/fanslider.maxval
                covx sys0,va0.txt,0,0
                fan_value.txt=va0.txt+"%"
            }
            if(fanslider.val>fanslider.minval)
            {
                button_off.pco=59164
                button_down.pco=59164
            }else
            {
                button_off.pco=10597
                button_down.pco=10597
            }
            if(fanslider.val<fanslider.maxval)
            {
                button_up.pco=59164
            }else
            {
                button_up.pco=10597
            }
        
        Touch Release Event
            timer0.en=1
        
Button button_off
    Attributes
        ID               : 12
        Scope            : local
        Dragging         : 0
        Send Component ID: on press and release
        State            : unpressed
        Text             : î œ
        Max. Text Size   : 3
    
    Events
        Touch Press Event
            fanslider.val=fanslider.minval
            sys0=100*fanslider.val/fanslider.maxval
            covx sys0,va0.txt,0,0
            fan_value.txt=va0.txt+"%"
            fansetting.txt="{\"page\": \"fan\", \"key\": \"stop\", \"value\": "+va0.txt+"}"
            printh 92
            prints "localevent",0
            printh 00
            prints fansetting.txt,0
            printh 00
            printh FF FF FF
            if(fanslider.val>fanslider.minval)
            {
                button_off.pco=59164
                button_down.pco=59164
            }else
            {
                button_off.pco=10597
                button_down.pco=10597
            }
            if(fanslider.val<fanslider.maxval)
            {
                button_up.pco=59164
            }else
            {
                button_up.pco=10597
            }
        
        Touch Release Event
            timer0.en=0
        
Button button_back
    Attributes
        ID               : 14
        Scope            : local
        Dragging         : 0
        Send Component ID: on press and release
        State            : unpressed
        Text             : î…˜
        Max. Text Size   : 3
    
    Events
        Touch Press Event
            page back_page_id
        
Timer swipestore
    Attributes
        ID         : 5
        Scope      : local
        Period (ms): 50
        Enabled    : no
    
    Events
        Timer Event
            swipex=tch0
            swipey=tch1
        
Timer timer0
    Attributes
        ID         : 13
        Scope      : local
        Period (ms): 1000
        Enabled    : no
    
    Events
        Timer Event
            timer0.en=0
            sys0=100*fanslider.val/fanslider.maxval
            covx sys0,va0.txt,0,0
            fan_value.txt=va0.txt+"%"
            fansetting.txt="{\"page\": \"fan\", \"key\": \"percentage\", \"value\": "+va0.txt+"}"
            printh 92
            prints "localevent",0
            printh 00
            prints fansetting.txt,0
            printh 00
            printh FF FF FF
        
Timer wakeup_timer
    Attributes
        ID         : 15
        Scope      : local
        Period (ms): 100
        Enabled    : yes
    
    Events
        Timer Event
            if(dim<brightness)
            {
                dimdelta=brightness-dim
                dimdelta/=10
                if(dimdelta<1)
                {
                    dimdelta=1
                }
                dim+=dimdelta
            }else
            {
                wakeup_timer.en=0
            }
        
TouchCap swipe
    Attributes
        ID   : 4
        Scope: local
        Value: 0
    
    Events
        Touch Press Event
            swipestore.en=1 // Start swipestore timer
        
        Touch Release Event
            swipestore.en=0
            // Touch has ended, x
            if(tch0==0)
            {
                swipec=swipex-tch2
                // From Left to Right
                if(swipec>swipedx)
                {
                    //page
                }
                // Right to Left
                swipec2=0-swipedx
                if(swipec<swipec2)
                {
                    //page
                }
            }
            // Touch has ended, y
            if(tch1==0)
            {
                swipec=swipey-tch3
                // From Up to Down
                if(swipec>100)
                {
                    //page
                }
                // Down to Up
                swipec2=0-swipedy
                if(swipec<-100)
                {
                    //page
                }
            }
        
