Version 1.51.8 - USB devices support

All about the VGA for the ESP32-S3
User avatar
cicciocb
Site Admin
Posts: 2058
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 439 times
Been thanked: 1358 times
Contact:

Version 1.51.8 - USB devices support

Post by cicciocb »

To the (very) few using the VGA, you can now use a mouse / keyboard or Gamepad with the VGA.

This is a little demo program for the mouse / keyboard
image.png

Code: [Local Link Removed for Guests]

usb.setup 640, 480
onMouseClick Mouse_click
onKeyboard Keyboard_Press
active_text_Object = -1
myText$ = ""

vga.pinout 4,5,6, 7,15,16, 17, 18, 8,3
vga.delete
vga.init 2, 4

vga.writepage 0
vgagui.init 40, darkgrey'reserve memory for 20 GUI objects. clears screen to black
tft.loadfont "/fonts/FreeMono9pt7b.bin",10
tft.loadfont "/fonts/FreeMonoBold12pt7b.bin",11
tft.loadfont "/fonts/FreeSansBoldOblique24pt7b.bin",12
vga.image "/img/girl.jpg"
vga.copy 0, 3

ob1 = vgagui.circle(580, 250, 50, blue, yellow, red)
ob2 = vgagui.box(580, 300, 50, 50, red, green, blue)
ob3 = vgagui.line(500, 350, 600, 450, magenta)


t1 = vgagui.Textline(10,50,190,40, "Text Line", 1,yellow, darkgrey,magenta)  'x,y,w,h,text,fontsize

b1 = vgagui.Button(30, 5, 100, 40, "BUTTON!",0, 10, toggle ) 'x,y,w,h,text,fontsize
c1 = vgagui.checkbox(10,10,20,20,1, 2)
s1 = vgagui.slider 250,10,20,100,50,1
g1 = vgagui.gauge 250,200,150,150,0,red


t2 = vgagui.Textline(10,100,190,40, "Text Line", 2,red,yellow,magenta)  'x,y,w,h,text,fontsize
t3 = vgagui.Textline(400,120,200,60, "RED", 12,red,white,red)  'x,y,w,h,text,fontsize
r1 = vgagui.Ramp(400, 200, 160, 160, 50)
p1 = vgagui.ProgressBar(50, 430, 500, 40, 50)


b2 = vgagui.Button(30, 150, 100, 40, "BUTTON2",0, 10 ) 'x,y,w,h,text,fontsize
b3 = vgagui.Button(30, 200, 100, 40, "BUTTON3",0, 10, toggle ) 'x,y,w,h,text,fontsize
s2 = vgagui.slider 300,10,40,150,50,vertical, green


cc1 = vgagui.checkbox(400,10,20,20, 0, RADIO, 2)
cc2 = vgagui.checkbox(450,10,20,20, 0, RADIO, 2)
cc3 = vgagui.checkbox(500,10,20,20, 0, RADIO, 2)
cc4 = vgagui.checkbox(550,10,20,20, 0, RADIO, 2)

cc5 = vgagui.checkbox(400,40,20,20, 0, SQUARED, 3)
cc6 = vgagui.checkbox(450,40,20,20, 0, SQUARED, 3)
cc7 = vgagui.checkbox(500,40,20,20, 0, SQUARED, 3)
cc8 = vgagui.checkbox(550,40,20,20, 0, SQUARED, 3)

cc10 = vgagui.checkbox(400,70,20,20, 0, CROSSED)
cc11 = vgagui.checkbox(450,70,20,20, 0, CROSSED)
cc12 = vgagui.checkbox(500,70,20,20, 0, CROSSED)
cC13 = vgagui.checkbox(550,70,20,20, 0, CROSSED)

bi1 = vgagui.ButtonImage(10, 250, 48, 48, "/icons/48x48/Positive_48x48.bmp", "/icons/48x48/Negative_48x48.bmp", toggle, 4)
bi2 = vgagui.ButtonImage(60, 250, 48, 48, "/icons/48x48/Positive_48x48.bmp", "/icons/48x48/Negative_48x48.bmp", toggle, 4)
bi3 = vgagui.ButtonImage(110, 250, 48, 48, "/icons/48x48/Positive_48x48.bmp", "/icons/48x48/Negative_48x48.bmp", toggle, 4)
bi4 = vgagui.ButtonImage(160, 250, 48, 48, "/icons/48x48/Positive_48x48.bmp", "/icons/48x48/Negative_48x48.bmp", toggle, 4)

bi1 = vgagui.ButtonImage(10, 300, 48, 48, "/icons/48x48/Check_48x48.bmp", "/icons/48x48/Delete_48x48.bmp", toggle, 5)
bi2 = vgagui.ButtonImage(60, 300, 48, 48, "/icons/48x48/Check_48x48.bmp", "/icons/48x48/Delete_48x48.bmp", toggle, 5)
bi3 = vgagui.ButtonImage(110, 300, 48, 48, "/icons/48x48/Check_48x48.bmp", "/icons/48x48/Delete_48x48.bmp", toggle, 5)
bi4 = vgagui.ButtonImage(160, 300, 48, 48, "/icons/48x48/Check_48x48.bmp", "/icons/48x48/Delete_48x48.bmp", toggle, 5)

t4 = vgagui.Textline(10, 380, 250, 40, "MyText123", 1,red,yellow,magenta)  'x,y,w,h,text,fontsize
t5 = vgagui.Textline(300, 380, 250, 40, "Polletto", 1,red,yellow,magenta)  'x,y,w,h,text,fontsize
vgagui.refresh
vga.showpage 0
vga.show

vga.copy 0, 3
vga.showpage 3

VGA.SPRITESHEET "/sprites/mouse-pointers-white.bmp"
vga.setsprite 1, 32, 32, 64, 0, 0, 0

i = 0

backcolor = vga.color(magenta)

vga.writepage 1
vga.fill backcolor 
  
for z = 0 to 100000
  vga.writepage 0
  vgagui.settext t1, str$(z)
  vgagui.settext b1, str$(z)
  vgagui.settext t2, str$(z)
  vgagui.settext t3, str$(z)
  vgagui.setvalue s1, z mod 100
  vgagui.setvalue g1, z mod 100
  vgagui.setvalue r1, z mod 100
  vgagui.setvalue p1, z mod 100
  vgagui.refresh 1, mouseX, mouseY, mouseZ
  'vga.copy 0,act
  vga.writepage 1
  'vga.fill 0
  mx = mouseX : my = mouseY
  vga.next 530, 320, 48, z*180 , red, 7  
  vga.drawSprite 1, mx, my, 6
  vga.merge 0, 1, 3, backcolor
  vga.rect mx, my, 32, 32, backcolor , 1
  vga.rect 480, 270, 100, 100, backcolor, 1
  vga.show
  
next z
end

event:
vgagui.setvalue b1,i mod 2
i = i + 1
vgagui.setvalue c1,i mod 2
return


mouse_move:
print "move", mouseX, mouseY
return

Mouse_click:
print "click", mouseX, mouseY, mouseZ, mouseW
print "Object under Mouse", mouseObj

if (mouseObj = t4) or (mouseObj = t5) then 
  active_text_Object = mouseObj
  vgagui.setcolor active_text_Object , green, black
end if


return

Keyboard_Press:
print kbdcode
if (active_text_Object = -1) then return
vgagui.gettext active_text_Object, myText$
select case kbdcode
  case 0, 160
    ' nothing
  case 8
    if (len(myText$) > 0) then
      myText$ = left$(myText$, len(myText$)-1)
    end if
    vgagui.setText active_text_Object, myText$
  case 13
    vgagui.setcolor active_text_Object, red, yellow
    active_text_Object = -1
  case else
    if (len(myText$) < 20) then
      myText$ = myText$ + chr$(kbdcode)
    end if
    vgagui.setText active_text_Object, myText$
end select

return



And this is for the Gamepad :
image.png

Code: [Local Link Removed for Guests]

usb.setup 640, 480
onGamePad GamePadChange
onMouseClick Mouse_click
onKeyboard Keyboard_Press
active_text_Object = -1
myText$ = ""

vga.pinout 4,5,6, 7,15,16, 17, 18, 8,3
vga.delete
vga.init 2, 4

vga.writepage 0
vgagui.init 40, darkgrey'reserve memory for 20 GUI objects. clears screen to black
tft.loadfont "/fonts/FreeMono9pt7b.bin",10
tft.loadfont "/fonts/FreeMonoBold12pt7b.bin",11
tft.loadfont "/fonts/FreeSansBoldOblique24pt7b.bin",12
'vga.image "/img/Annex_new_logo_640x480.bmp"
vga.copy 0, 3

t1 = vgagui.Textline(10,10,300,40, "Annex ESP32-S3 USB", 2,green, black,red)  'x,y,w,h,text,fontsize
t2 = vgagui.Textline(10,60,300,40, "Enter free Text", 2,green, black,red)  'x,y,w,h,text,fontsize

b1 = vgagui.Button(100, 210, 80, 40, "BUTTON1",0, 10 ) 'x,y,w,h,text,fontsize
s1 = vgagui.slider(10,260,30,200,50,vertical, green)
s2 = vgagui.slider(50,430,200,30,50,horizontal, green)

b2 = vgagui.Button(410, 210, 80, 40, "BUTTON2",0, 10 ) 'x,y,w,h,text,fontsize
s3 = vgagui.slider(320,260,30,200,50,vertical, blue)
s4 = vgagui.slider(360,430,200,30,50,horizontal, blue)

vgagui.setrange s1, 128, -128
vgagui.setrange s2, -128, 128
vgagui.setrange s3, 128, -128
vgagui.setrange s4, -128, 128


b3 = vgagui.Button(60, 150, 50, 40, "SELECT",0, 10 ) 'x,y,w,h,text,fontsize
b4 = vgagui.Button(160, 150, 50, 40, "START",0, 10 ) 'x,y,w,h,text,fontsize


c1 = vgagui.checkbox(350, 110, 20, 20, 0, SQUARED)
c2 = vgagui.checkbox(400, 150, 20, 20, 0, SQUARED)
c3 = vgagui.checkbox(350, 200, 20, 20, 0, SQUARED)
c4 = vgagui.checkbox(300, 150, 20, 20, 0, SQUARED)

c5 = vgagui.checkbox(550, 110, 20, 20, 0, RADIO)
c6 = vgagui.checkbox(600, 150, 20, 20, 0, RADIO)
c7 = vgagui.checkbox(550, 200, 20, 20, 0, RADIO)
c8 = vgagui.checkbox(500, 150, 20, 20, 0, RADIO)

l1 = vgagui.Button(335, 10, 50, 30, "L1",0, 10 )
l2 = vgagui.Button(335, 50, 50, 30, "L2",0, 10 )
r1 = vgagui.Button(535, 10, 50, 30, "R1",0, 10 )
r2 = vgagui.Button(535, 50, 50, 30, "R2",0, 10 )

box1 = vgagui.box 70, 260, 160, 160, black, white
box1 = vgagui.box 380, 260, 160, 160, black, white


vgagui.refresh
vga.showpage 0
vga.show

VGA.SPRITESHEET "/sprites/mouse-pointers-white.bmp"
vga.setsprite 1, 32, 32, 64, 0, 0, 0

i = 0

act = 1
for z = 0 to 100000000
  vga.writepage 0
  'print bin$(KeyPadCodes(5)), bin$(KeyPadCodes(6))
  if GamePadCodes(0) = 1 then
    vgagui.setvalue s1, GamePadCodes(4) - 128
    vgagui.setvalue s2, GamePadCodes(3) - 128
    
    vgagui.setvalue s3, GamePadCodes(2) - 128
    vgagui.setvalue s4, GamePadCodes(1) - 128
    
    k1 = GamePadCodes(5)
    k2 = GamePadCodes(6)
    vgagui.setvalue l1, k2 and &b1
    vgagui.setvalue l2, k2 and &b100
    vgagui.setvalue r1, k2 and &b10
    vgagui.setvalue r2, k2 and &b1000
    
    vgagui.setvalue b1, k2 and &b1000000
    vgagui.setvalue b2, k2 and &b10000000
    
    vgagui.setvalue b3, k2 and &b10000
    vgagui.setvalue b4, k2 and &b100000
    
    
    vgagui.setvalue c1, 0
    vgagui.setvalue c2, 0
    vgagui.setvalue c3, 0
    vgagui.setvalue c4, 0
    
    select case (k1 and &b1111)
      case 0
        vgagui.setvalue c1, 1
      case 1
        vgagui.setvalue c1, 1
        vgagui.setvalue c2, 1
      case 2
        vgagui.setvalue c2, 1
      case 3
        vgagui.setvalue c2, 1
        vgagui.setvalue c3, 1
      case 4
        vgagui.setvalue c3, 1
      case 5
        vgagui.setvalue c3, 1
        vgagui.setvalue c4, 1
      case 6
        vgagui.setvalue c4, 1
      case 7
        vgagui.setvalue c1, 1
        vgagui.setvalue c4, 1
    end select
    
    vgagui.setvalue c5, k1 and &b10000
    vgagui.setvalue c6, k1 and &b100000
    vgagui.setvalue c7, k1 and &b1000000
    vgagui.setvalue c8, k1 and &b10000000
    
    vga.rect 71, 261, 158, 158, black, 1
    vga.circle (GamePadCodes(3) - 128) / 128*60 + 155, (GamePadCodes(4) - 128) / 128*60 + 340, 5, green, 1
    
    vga.rect 381, 261, 158, 158, black, 1
    vga.circle (GamePadCodes(1) - 128) / 128*60 + 460, (GamePadCodes(2) - 128) / 128*60 + 340, 5, blue, 1
  end if
  vgagui.refresh
  'vgagui.refresh 1, mouseX, mouseY, mouseZ
  vga.copy 0,act
  vga.writepage act
  vga.drawSprite 1, mouseX, mouseY, 6
  vga.showpage act
  act = 3-act
  vga.show
  
next z
end

event:
vgagui.setvalue b1,i mod 2
i = i + 1
vgagui.setvalue c1,i mod 2
return


mouse_move:
print "move", mouseX, mouseY
return

Mouse_click:
print "click", mouseX, mouseY, mouseZ, mouseW
vgagui.refresh 1, mouseX, mouseY, mouseZ
print "Object under Mouse", mouseObj

if (mouseObj = t1) or (mouseObj = t2) then
  active_text_Object = mouseObj
  vgagui.setcolor active_text_Object , red, white
end if


return

Keyboard_Press:
print kbdcode
if (active_text_Object = -1) then return
vgagui.gettext active_text_Object, myText$
select case kbdcode
  case 0, 160
    ' nothing
  case 8
    if (len(myText$) > 0) then
      myText$ = left$(myText$, len(myText$)-1)
    end if
    vgagui.setText active_text_Object, myText$
  case 13
    vgagui.setcolor active_text_Object, green, black
    active_text_Object = -1
  case else
    if (len(myText$) < 20) then
      myText$ = myText$ + chr$(kbdcode)
    end if
    vgagui.setText active_text_Object, myText$
end select
return

GamePadChange:
print "gamepad"
return
You do not have the required permissions to view the files attached to this post.
User avatar
Fernando Perez
Posts: 378
Joined: Mon Feb 15, 2021 10:09 pm
Location: Santander (Spain)
Has thanked: 195 times
Been thanked: 267 times

Re: Version 1.51.8 - USB devices support

Post by Fernando Perez »

Although I have several people from my family here during the holidays, I will risk being rude to them and start playing tonight.
And a question, although I suppose it should go in another thread.
If I decide to design and order printed circuit boards that incorporate a VGA female connector, the pins for the ESP32-S3 and the necessary resistors, can someone with experience help me on how to do it?
CircuitMaker, any online PCB designer, any company that makes them well and cheap?

https://es.aliexpress.com/item/32763276691.html
User avatar
cicciocb
Site Admin
Posts: 2058
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 439 times
Been thanked: 1358 times
Contact:

Re: Version 1.51.8 - USB devices support

Post by cicciocb »

You can buy this kind of PCB adapter
You do not have the required permissions to view the files attached to this post.
User avatar
Electroguard
Posts: 860
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 276 times
Been thanked: 323 times

Re: Version 1.51.8 - USB devices support

Post by Electroguard »

Hi Fernando,
I have used easyeda.com in the past, which is a free online circuit designer, plus circuit simulator, plus pcb layout designer, plus optional direct upload of pcb to jlcpcb which I was very impressed by. Any circuit designer and/or pcb layout designer will have a learning curve, but I was creating my personal masterpieces within a week and having 10 delivered 3 weeks later for just over 20 euros.

So I was originally similarly thinking about doing a VGA pcb, but I have since changed my mind in preference for a VGA UNO protoshield shield on an esp32-s3 uno n16r8 which are available for about 7 euros.
Am still creating a Wemos D1 Mini to UNO protoshield adapter first, to let me plug in any wemos footprint shields into the uno clone, but the VGA protoshield will be next on the list.
There are loads of different cheap proto-shields available (including some with mini breadboards).
So can choose to plugin in either a uno SD shield or a wemos SD shield if I wish (also have uno ehernet shield and IR detector/buzzer shields on order).

I got some VGA pcb modules for easy 2.4" pin connection to the protoboard matrix ( EDIT: same as Francesco shows) , which still leaves plenty of room for the VGA resistors, plus room for a relay module than can be used by the s3 to swich a vga KVM switch between the annexVGA and any other VGA source (eg: computer, or CCTV).

The S3 uno clone has dc jack for powering from 7v to 12v mains adapters, and can fit into a cheapo plastic UNO case (about 1 euro) making it super safe and stable, while still allowing external shields to be plugged in through slots on top, and the usb wifi mouse/k/b dongle at the end.


uno.png
You do not have the required permissions to view the files attached to this post.
lyizb
Posts: 101
Joined: Fri Feb 12, 2021 8:23 pm
Has thanked: 43 times
Been thanked: 25 times

Re: Version 1.51.8 - USB devices support

Post by lyizb »

Agree with Electroguard about EasyEDA. It's far more intuitive than Eagle (even after years of experience with that program), and there are many parts available. Most orders end up costing less than $5US for 5 PCBs, shipping included. Slow-boat delivery to the US is usually pretty quick--around 10-14 days.
User avatar
Electroguard
Posts: 860
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 276 times
Been thanked: 323 times

Re: Version 1.51.8 - USB devices support

Post by Electroguard »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Wed Dec 27, 2023 7:30 pm ... any online PCB designer, any company that makes them well and cheap?
Something worth mentioning about EasyEDA and JLCPCB Fernando, is their ability to 'panelise, making it cheaper to fit several smaller PCBs onto a default 100mmx100mm.
The order quantities used to be 2, or 10, or more, each up to 100mmx100mm.
But as you can see from the pic showing my red 100x100 talking Sentry pcb, it is possible to fit three esp32-s3's side by side, giving a total of 6 panelized' snap-offs on just 2 100x100 pcbs.

vcut.png

How to Panelize PCB:



EasyEDA Tutorials:
You do not have the required permissions to view the files attached to this post.
User avatar
Electroguard
Posts: 860
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 276 times
Been thanked: 323 times

Re: Version 1.51.8 - USB devices support

Post by Electroguard »

Just placed an order with JLCPCB, so can give a current update on pricing...
was less than 5€ for 10 UNO size pcb's, plus about 17€ for DHL delivery, plus about 5€ for EU taxes.
Works out less than 3€ per pcb for something which is unique and not available elsewhere
(is intended to be partially populated for use in a variety of different ways with the S3 N16R8 UNO clone to provide many different uses)
The gerber file for the finished design was uploaded directly from EasyEDA to JLCPCB, so the pcb's should be made and delivered in about a week.
jlcpcb.png

UNO2Wemos_s.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
cicciocb
Site Admin
Posts: 2058
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 439 times
Been thanked: 1358 times
Contact:

Re: Version 1.51.8 - USB devices support

Post by cicciocb »

Interesting Robin, maybe this will inspire other people into developing their own pcb.
User avatar
Electroguard
Posts: 860
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 276 times
Been thanked: 323 times

Re: Version 1.51.8 - USB devices support

Post by Electroguard »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Wed Dec 27, 2023 7:30 pm If I decide to design and order printed circuit boards that incorporate a VGA female connector, the pins for the ESP32-S3 and the necessary resistors, can someone with experience help me on how to do it?
CircuitMaker, any online PCB designer, any company that makes them well and cheap?
https://es.aliexpress.com/item/32763276691.html
Hi Fernando, long time no hear, did you get anywhere with your VGA PCB ?
I've ended up having to design one for my purposes, which needs ability to control modded KVM switches for remotely switching the video inputs.
So it needs ability to use Wemos D1 Mini shields for adding relay and/or SD reader etc.
Also added a jumper link for optionally supplying 5v or 3.3v volt via the VGA cable.
I don't have any PCB VGA connectors yet, and probably won't get them till march cos of chinese new year.
So I needed to provide alternative options for RJ45 VGA extender adapter, and VGA breakout PCB, etc.
Also needed to provide options for the resistors, cos am hoping to get surface mount resistors supplied and installed by JLCPCB, but I don't have the eyesight or patience for soldering surface mount myself, so I need ability to use wire-ended resistors if ever needed.
Especially as I settled on different values for the blue resistors after a lot of earlier experimentation.
I also went 'non-standard' by using female headers on my N16R8's instead of the supplied yellow pins, cos it offers some advantages.
So my PCB will have pins underneath to plug down onto the ESP32 female headers.
Which means the PCB will have headroom available underneath, allowing choice of hanging a female VGA connector below or a male connector above, using the same mirrored mounting holes.

Hope some of the info can be useful to you.


pcb_both.jpg

3d_both.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
cicciocb
Site Admin
Posts: 2058
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 439 times
Been thanked: 1358 times
Contact:

Re: Version 1.51.8 - USB devices support

Post by cicciocb »

NIce design, Robin.

p.s.
I think you reversed the indications of the UART and USB indications on the module
Post Reply