General area when it fits no where else

Moderator: Mmiscool

User avatar
By Ecoli-557
#51735 Apologies for the non-formatted text from the doc. Here it is:
Code: Select allIf then statements can now be split between multiple lines. The format shown below can be used.
If bla = 5 then
   Print “Bla is 5”
Else
   Print “bla is not 5”
End if
The if can be nested as below :
if a > b then
  print "a > b"
  if b >c then
    print "b > c"
  else
    print "b < c"
  end if
else
  print "a < b"
end if
User avatar
By forlotto
#51736 Ahhh I see what you are trying to do is this your full code if so it is incorrect.

io(laststat,pinno) this is for pins only..

I wish they had a laststat for registers really to be honest that would be sweet but you need something monitoring button presses

let NOBP = 0 'Let number of button presses equal zero
button "moveup" [moveitup]
wait

[moveitup]
NOBP = NOBP + 1
if NOBP > 4 then
NOBP = 0

now use NOBP to try and move your radial button from here possibly?
Last edited by forlotto on Fri Jul 29, 2016 9:19 pm, edited 1 time in total.
User avatar
By Ecoli-557
#51737 No problem Forlotto-
Here it is, was going to be a tutorial for a couple of commands:
Code: Select all'Series of fragments in order to better understand the IO and command structure of ESP8266 Basic
'UDP received message goes after the MSG label at 5,110
'Pressing the checkbox will toggle it being selected/non-selected
'Pressing the UP button (D3) will move the selected radio button UP
'Pressing the DOWN button (D4) will move the selected radio button DOWN
'Pressing the ENTER button (D0) will select the currently selected radion button after using UP/DOWN

'INIT ---------------------------------------------------------------
memclear                                             'Clears vars
Selected = 0                                          'Provides the offset for the menu selection

'Variables here, trying ways to alias a pin -------------------------
UP = D3                                                'UP menu button aliased to D3
DOWN = D4                                             'DOWN menu button aliased to D4

rec = ""                                             'Clears the received UDP data
Udpbegin 5001                                          'UDP port which is pretty cool
tft.setup(15, 4, 2)                                       'CS on GPIO15 w/10k pull-down to GND, D/C on GPIO4, Landscape mode.  USE A SEPARATE PS!
tft.touch.setup(5)                                       'CS for touch screen on display
[Start]'=============================================================
let clear = 0
tft.text.color(tft.rgb(255,0,255))
tft.text.cursor(5,110)
tft.print("MSG-" & rec)
tft.text.color(tft.rgb(0,255,0))
tft.text.cursor(5,50)
tft.text.size(2)
tft.print("This is 1st Line")                              'Basic line ordinate and print
tft.text.cursor(5,70)
tft.print("This is 2nd Line")
tft.text.cursor(5,90)
tft.print("This is 3rd Line")
but1 = tft.obj.button(" Item1 ", 5,5,80,40)                     'Button graphic - cool
ClearBut = tft.obj.button("CLR MSG", 135,5,100,40)               'Button to clear the text msg from UDP
'chk1 = tft.obj.checkbox(" Checkbox", 10,180,20,0, 2, 65535, 0)      'Example of a textbox
rad1 = tft.obj.radio(" Option One", 10,180,20,0,2,tft.rgb(255,0,0))      'Example of a radio button
rad2 = tft.obj.radio(" Option Two", 10,210,20,0,2,tft.rgb(255,0,0))      'Example of a radio button
rad3 = tft.obj.radio(" Option Three", 10,240,20,0,2,tft.rgb(255,0,0))      'Example of a radio button
rad4 = tft.obj.radio(" Option Four", 10,270,20,0,2,tft.rgb(255,0,0))      'Example of a radio button
lab1 = tft.obj.label("OK to Select", 10,290,200,24,2)            'Status msg bar
touchbranch [touchme]                                    'If screen is touched, goto touchme
'wait
udpbranch [udp.received]                                 'If UDP msg received goto udp.received
'wait
interrupt UP, [Menu.Up]                                    'Pin being pulled up by a 11k
interrupt DOWN, [Menu.Down]                                 'Pin beiing pulled up by a 11k
wait
goto [Start]                                          'Do it all over again!

'Subs go here -------------------------------------------------------
[touchme]
touch_obj = tft.checktouch()
serialprintln "checktouch " & touch_obj
If touch_obj = ClearBut then
    tft.obj.invert(ClearBut)
    tft.text.color(tft.rgb(255,0,255))
   tft.text.cursor(5,120)
    tft.print("                            ")
    rec = ""
    tft.fill(0)
    tft.obj.setlabel(lab1, "MESSAGE CLEARED")
'    UdpReply "message cleared"
'    goto [Start]
End if
If touch_obj = but1 then
     tft.obj.invert(but1)
    tft.obj.setlabel(lab1, "Button")
End if
return
   
[udp.received]
let rec = UdpRead()
let rem = UdpRemote()
tft.text.color(tft.rgb(255,0,255))
tft.text.cursor(5,120)
tft.print("MSG-" & rec)
'UdpReply "Message Received"
return

[Menu.Up]
If io(laststat,UP) = 0 Then
        Selected = Selected + 1
    If Selected = 4 Then Selected = 0
        If Selected = 0 Then
            rad1sel = 1
        Else
            rad1sel = 0
        End If
        If Selected = 1 Then
            rad2sel = 1
        Else
            rad2sel = 0
        End If
        If Selected = 2 Then
            rad3sel = 1
        Else
            rad3sel = 0
        End If
        If Selected = 3 Then
            rad4sel = 1
        Else
            rad4sel =  0
        End If
        rad1 = tft.obj.radio(" Option One", 10,180,20,rad1sel,2,tft.rgb(255,0,0))      'Example of a radio button
        rad2 = tft.obj.radio(" Option Two", 10,210,20,rad2sel,2,tft.rgb(255,0,0))      'Example of a radio button
        rad3 = tft.obj.radio(" Option Three", 10,240,20,rad3sel,2,tft.rgb(255,0,0))      'Example of a radio button
        rad4 = tft.obj.radio(" Option Four", 10,270,20,rad4sel,2,tft.rgb(255,0,0))      'Example of a radio button
End if
wait'don't know why I need these but it works
return

[Menu.Down]
'if io(laststat,DOWN) = 0 then
'        Selected = Selected - 1
'        if Selected = -1 then Selected = 3
'        If Selected = 0 then rad1 = tft.obj.radio(" Option One", 10,180,20,1,2,tft.rgb(255,0,0))      'Example of a radio button
'        if Selected = 1 then rad2 = tft.obj.radio(" Option Two", 10,210,20,1,2,tft.rgb(255,0,0))      'Example of a radio button
'        if Selected = 2 then rad3 = tft.obj.radio(" Option Three", 10,240,20,1,2,tft.rgb(255,0,0))      'Example of a radio button
'        if Selected = 3 then rad4 = tft.obj.radio(" Option Four", 10,270,20,1,2,tft.rgb(255,0,0))      'Example of a radio button
'endif   
wait'don't know why I need these here but it works
return
                       
end




Some of the DOWN stuff is Remmd out as I can't get the UP routine to work.
Hope this helps you help me <grin>.
Regards.
User avatar
By forlotto
#51738 Try this: Errr sorry edited a couple of times had the wrong lines edited hope this helps 9:40 here Central Time USA...

Code: Select all'Series of fragments in order to better understand the IO and command structure of ESP8266 Basic
'UDP received message goes after the MSG label at 5,110
'Pressing the checkbox will toggle it being selected/non-selected
'Pressing the UP button (D3) will move the selected radio button UP
'Pressing the DOWN button (D4) will move the selected radio button DOWN
'Pressing the ENTER button (D0) will select the currently selected radion button after using UP/DOWN

'INIT ---------------------------------------------------------------
memclear                                             'Clears vars
Selected = 0                                          'Provides the offset for the menu selection

'Variables here, trying ways to alias a pin -------------------------
UP = D3                                                'UP menu button aliased to D3
DOWN = D4                                             'DOWN menu button aliased to D4

rec = ""                                             'Clears the received UDP data
Udpbegin 5001                                          'UDP port which is pretty cool
tft.setup(15, 4, 2)                                       'CS on GPIO15 w/10k pull-down to GND, D/C on GPIO4, Landscape mode.  USE A SEPARATE PS!
tft.touch.setup(5)                                       'CS for touch screen on display
[Start]'=============================================================
let clear = 0
tft.text.color(tft.rgb(255,0,255))
tft.text.cursor(5,110)
tft.print("MSG-" & rec)
tft.text.color(tft.rgb(0,255,0))
tft.text.cursor(5,50)
tft.text.size(2)
tft.print("This is 1st Line")                              'Basic line ordinate and print
tft.text.cursor(5,70)
tft.print("This is 2nd Line")
tft.text.cursor(5,90)
tft.print("This is 3rd Line")
but1 = tft.obj.button(" Item1 ", 5,5,80,40)                     'Button graphic - cool
ClearBut = tft.obj.button("CLR MSG", 135,5,100,40)               'Button to clear the text msg from UDP
'chk1 = tft.obj.checkbox(" Checkbox", 10,180,20,0, 2, 65535, 0)      'Example of a textbox
rad1 = tft.obj.radio(" Option One", 10,180,20,0,2,tft.rgb(255,0,0))      'Example of a radio button
rad2 = tft.obj.radio(" Option Two", 10,210,20,0,2,tft.rgb(255,0,0))      'Example of a radio button
rad3 = tft.obj.radio(" Option Three", 10,240,20,0,2,tft.rgb(255,0,0))      'Example of a radio button
rad4 = tft.obj.radio(" Option Four", 10,270,20,0,2,tft.rgb(255,0,0))      'Example of a radio button
lab1 = tft.obj.label("OK to Select", 10,290,200,24,2)            'Status msg bar
touchbranch [touchme]                                    'If screen is touched, goto touchme
'wait
udpbranch [udp.received]                                 'If UDP msg received goto udp.received
'wait
interrupt UP, [Menu.Up]                                    'Pin being pulled up by a 11k
interrupt DOWN, [Menu.Down]                                 'Pin beiing pulled up by a 11k
wait
goto [Start]                                          'Do it all over again!

'Subs go here -------------------------------------------------------
[touchme]
touch_obj = tft.checktouch()
serialprintln "checktouch " & touch_obj
If touch_obj = ClearBut then
    tft.obj.invert(ClearBut)
    tft.text.color(tft.rgb(255,0,255))
   tft.text.cursor(5,120)
    tft.print("                            ")
    rec = ""
    tft.fill(0)
    tft.obj.setlabel(lab1, "MESSAGE CLEARED")
'    UdpReply "message cleared"
'    goto [Start]
End if
If touch_obj = but1 then
     tft.obj.invert(but1)
    tft.obj.setlabel(lab1, "Button")
End if
return
   
[udp.received]
let rec = UdpRead()
let rem = UdpRemote()
tft.text.color(tft.rgb(255,0,255))
tft.text.cursor(5,120)
tft.print("MSG-" & rec)
'UdpReply "Message Received"
return

[Menu.Up]
If io(laststat,UP) = 0 Then
        Selected = Selected + 1
end if
    If Selected > 3 Then
   Selected = 0
   end if
        If Selected = 0 Then
            rad1sel = 1
        Else
            rad1sel = 0
        End If
        If Selected = 1 Then
            rad2sel = 1
        Else
            rad2sel = 0
        End If
        If Selected = 2 Then
            rad3sel = 1
        Else
            rad3sel = 0
        End If
        If Selected = 3 Then
            rad4sel = 1
        Else
            rad4sel =  0
        End If
        rad1 = tft.obj.radio(" Option One", 10,180,20,rad1sel,2,tft.rgb(255,0,0))      'Example of a radio button
        rad2 = tft.obj.radio(" Option Two", 10,210,20,rad2sel,2,tft.rgb(255,0,0))      'Example of a radio button
        rad3 = tft.obj.radio(" Option Three", 10,240,20,rad3sel,2,tft.rgb(255,0,0))      'Example of a radio button
        rad4 = tft.obj.radio(" Option Four", 10,270,20,rad4sel,2,tft.rgb(255,0,0))      'Example of a radio button
End if
wait'don't know why I need these but it works
return

[Menu.Down]
'if io(laststat,DOWN) = 0 then
'        Selected = Selected - 1
'        if Selected = -1 then Selected = 3
'        If Selected = 0 then rad1 = tft.obj.radio(" Option One", 10,180,20,1,2,tft.rgb(255,0,0))      'Example of a radio button
'        if Selected = 1 then rad2 = tft.obj.radio(" Option Two", 10,210,20,1,2,tft.rgb(255,0,0))      'Example of a radio button
'        if Selected = 2 then rad3 = tft.obj.radio(" Option Three", 10,240,20,1,2,tft.rgb(255,0,0))      'Example of a radio button
'        if Selected = 3 then rad4 = tft.obj.radio(" Option Four", 10,270,20,1,2,tft.rgb(255,0,0))      'Example of a radio button
'endif   
wait'don't know why I need these here but it works
return
                       
end