ESP BASIC

System-On-Chip com Wi-Fi embutido, para aplicações IoT

Moderadores: 51, guest2003, Renie, gpenga

ESP BASIC

Mensagempor tcpipchip » 15 Dez 2016 14:33

Aos poucos vamos melhorando o compilador "interpretador" BASIC para o ESP8266...

Recentemente reescrevi e inclui 3 funcoes novas para INFRARED, agora voce pode clonar qualquer controle e reproduzir...sem se preocupar se é NEC, SONY, JVR, etc e reescrevi as rotinas TFT (portabilidade entre arquiteturas)

'infrared receiver connected on GPIO0
ir.send.setup(0)
serialprintln "Ready to program ac sony sequency"
'infrared receiver connected on GPIO5
'ir.recv.raw("sony.cfg",5)
serialprintln "Programmed and sending sony ac sequency"
ir.send.raw("sony.cfg")
serialprintln "OK"
'ir.recv.cmp("sony.cfg",5)

Imagem

Aqui um servidor já rodando os comandos novos :)

Código: Selecionar todos
IR  = "IR"
PID = 0
VLU = 0

tft.setup(16, 4, 3)
tft.touch.setup(15)

tft.cls
tft.fill(tft.rgb(0,255,0))

tft.line(10,10,20,20,tft.rgb(255,0,0))

tft.text.color(tft.rgb(202,172,209))
tft.text.cursor(160,5)
tft.print("RPM")
tft.text.color(tft.rgb(50,34,11))
tft.text.cursor(160,55)
tft.print("TMP")
tft.text.color(tft.rgb(144,137,126))
tft.text.cursor(160,105)
tft.print("VEL")
tft.text.color(tft.rgb(235,78,56))
tft.text.cursor(160,155)
tft.print("MAF")
tft.text.color(tft.rgb(25,89,215))
tft.text.cursor(160,205)
tft.print("POS")

'tft.bmp("/uploads/cat.bmp")

bar1 = tft.obj.bar("RPM",200,0,120,30, 2, 65535, tft.rgb(0,25,255))
bar2 = tft.obj.bar("TEMPERA",130,50,190,30, 2, 65535, tft.rgb(0,25,255))
bar3 = tft.obj.bar("VELOCID",200,100,120,30, 2, 65535, tft.rgb(0,25,255))
bar4 = tft.obj.bar("AIRFLOW",200,150,120,30, 2, 65535, tft.rgb(0,25,255))
bar5 = tft.obj.bar("POSITION",200,200,120,30, 2, 65535, tft.rgb(0,25,255))

for l=1 to 100
tft.obj.setvalue(bar1, l)
tft.obj.setvalue(bar2, l)
tft.obj.setvalue(bar3, l)
tft.obj.setvalue(bar4, l)
tft.obj.setvalue(bar5, l)
next l

lab2 = tft.obj.label("19:41:16",90,120,100,18, 2, tft.rgb(0,255,0))

tft.circle.fill(160,200,50,65535)

tft.rect.round(10,10,100,100,5,tft.rgb(0,0,255))

tft.rect.fill(10,10,20,20,tft.rgb(0,0,255))

tft.circle(160,90,50,65535)

but1 = tft.obj.button("SEL", 5,0,120,70,4)
but2 = tft.obj.button("SEL", 5,175,150,70,4)

tft.obj.setlabel(but1,"0000")
tft.obj.setlabel(but2,"1111")

chk1 = tft.obj.checkbox("Check Me", 5,80,40,1, 3, 65535, 0)

rad1 = tft.obj.radio("Radio", 5,130,50,1, 3)

Telnetbranch [answer]
aaa = telnet.client.connect("192.168.1.111", 1024)

CNT = 0
RCV = 0
OPTION = 1

udpbegin 1025
UdpBranch [received]
Timer 1000, [rpm]
touchbranch [touchme]
msgbranch [mybranch]

ir.send.setup(0)


goto [BACKWEB]

[touchme]
touch_obj = tft.checktouch()

if touch_obj = but1 then

  tft.obj.invert(but1)

  OPTION = OPTION + 1
  if OPTION = 6 then
     OPTION = 1
  end if

  if OPTION = 1 then
     tft.obj.setvalue(bar1, 100)
  else
     tft.obj.setvalue(bar1, 0)
  end if

  if OPTION = 2 then
     tft.obj.setvalue(bar2, 100)
  else
     tft.obj.setvalue(bar2, 0)
  end if

  if OPTION = 3 then
     tft.obj.setvalue(bar3, 100)
  else
     tft.obj.setvalue(bar3, 0)
  end if

  if OPTION = 4 then
     tft.obj.setvalue(bar4, 100)
  else
     tft.obj.setvalue(bar4, 0)
  end if

  if OPTION = 5 then
     tft.obj.setvalue(bar5, 100)
  else
     tft.obj.setvalue(bar5, 0)
  end if

  ir.send.raw("sony.cfg")

end if

if touch_obj = but2 then
  tft.obj.invert(but2)
  s = READ(DEVICE)
  's = left(s, 8)
  serialprintln s
  ir.send(s)
  ir.recv.raw("sony.cfg",5)
end if

if touch_obj = chk1 then
  tft.obj.setlabel(lab1, "checkbox")
  tft.obj.invert(chk1)
end if

if touch_obj = rad1 then
  tft.obj.invert(rad1)
end if

return

[answer]
CNT = CNT + 1
tft.obj.setlabel(but2,str(CNT))
tcp = telnet.client.read.str()
tft.obj.setlabel(lab2, tcp)
wait

[rpm]
PID = PID + 1
tft.obj.setlabel(but1,str(PID))
ccc = telnet.client.write(      "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" & chr(13))
udpwrite "192.168.1.111", 1025, "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV"
tft.obj.setlabel(bar3,mens4)
tft.obj.setlabel(bar4,mens5)
tft.obj.setvalue(bar1, mens3)
mens1 = str(PID)
x = mens3
tft.obj.invert(but1)
wait

[received]
rec = udpread()
RCV = RCV + 1
tft.obj.setlabel(bar1,str(RCV))
tft.obj.setlabel(lab2, rec)
'serialprintln rec
return

[Pressed]
wprint "pressed"
wait

[mybranch]
VLU = VLU + 1
butt = msgget("button")
serialprintln butt
if butt == "newweb" then
   goto [NEWWEB]
end if
if butt == "backweb" then
   goto [BACKWEB]
end if
'msgreturn butt
RETURNGUI
wait

[load]
'wprint "Very cool"
wait

[NEWWEB]
cls
wprint |<HTML>| & chr(13)
wprint |<HEAD>| & chr(13)
wprint |<meta name="apple-mobile-web-app-capable" content="yes" />|
wprint |<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />|
wprint |<link rel="stylesheet" type="text/css" href="http://randomnerdtutorials.com/ethernetcss.css" />|
wprint |<TITLE>NEWWEB</TITLE>| & chr(13)
'wprint |<meta http-equiv="refresh" content="5" />| & chr(13)
wprint |</HEAD>| & chr(13)
wprint |<BODY>| & chr(13)
wprint |<H1>NEWWEB</H1>| & chr(13)
wprint |<hr />| & chr(13)
wprint |<br />| & chr(13)
wprint |<H2>ESP8266</H2>| & chr(13)
wprint |<br />| & chr(13)
wprint |<a href="/msg?button=3on"">Turn On LED</a>| & chr(13)
wprint |<a href="/msg?button=3off"">Turn Off LED</a><br />| & chr(13)
wprint |<br />| & chr(13)
wprint htmlvar(PID)
wprint |<br />| & chr(13)
wprint htmlvar(VLU)
wprint |<br />| & chr(13)
wprint htmlvar(IR)
wprint |<br />| & chr(13)
wprint |<br />| & chr(13)
wprint |<a href="/msg?button=4on"">Rotate Left</a>| & chr(13)
wprint |<a href="/msg?button=4off"">Rotate Right</a><br />| & chr(13)
wprint |<br />| & chr(13)
wprint |<br />| & chr(13)
wprint |<a href="/msg?button=backweb"">BACKWEB</a>| & chr(13)
wprint |<p>Created by Miguel</p>| & chr(13)
wprint |<br />| & chr(13)
wprint |</BODY>| & chr(13)
wprint |</HTML>| & chr(13)   
RETURNGUI
wait               
'---------------------------------

[BACKWEB]
cls
wprint |<HTML>| & chr(13)
wprint |<HEAD>| & chr(13)
wprint |<meta name="apple-mobile-web-app-capable" content="yes" />|
wprint |<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />|
wprint |<link rel="stylesheet" type="text/css" href="http://randomnerdtutorials.com/ethernetcss.css" />|
wprint |<TITLE>TEST WEB ACCESS</TITLE>| & chr(13)
'wprint |<meta http-equiv="refresh" content="5" />| & chr(13)
wprint |</HEAD>| & chr(13)
wprint |<BODY>| & chr(13)
wprint |<H1>TEST WEB ACCESS</H1>| & chr(13)
wprint |<hr />| & chr(13)
wprint |<br />| & chr(13)
wprint |<H2>ESP8266</H2>| & chr(13)
wprint |<br />| & chr(13)
wprint |<a href="/msg?button=1on"">Turn On LED</a>| & chr(13)
wprint |<a href="/msg?button=1off"">Turn Off LED</a><br />| & chr(13)
wprint |<br />| & chr(13)
wprint htmlvar(PID)
wprint |<br />| & chr(13)
wprint htmlvar(VLU)
wprint |<br />| & chr(13)
wprint htmlvar(IR)
wprint |<br />| & chr(13)
wprint |<br />| & chr(13)
wprint |<a href="/msg?button=2on"">Rotate Left</a>| & chr(13)
wprint |<a href="/msg?button=2off"">Rotate Right</a><br />| & chr(13)
wprint |<br />| & chr(13)
rf = ramfree()
wprint htmlvar(rf)
wprint |<br />| & chr(13)
wprint |<br />| & chr(13)
wprint |<a href="/msg?button=newweb"">NEWWEB</a>| & chr(13)
wprint |<p>Created by Miguel</p>| & chr(13)
wprint |<br />| & chr(13)
wprint |</BODY>| & chr(13)
wprint |</HTML>| & chr(13)
RETURNGUI
wait               
'---------------------------------
------------------------------------------
http://www.youtube.com/tcpipchip
Avatar do usuário
tcpipchip
Dword
 
Mensagens: 6560
Registrado em: 11 Out 2006 22:32
Localização: TCPIPCHIPizinho!

Voltar para ESP8266/ESP32

Quem está online

Usuários navegando neste fórum: Nenhum usuário registrado e 1 visitante

x