Cov txheej txheem:

ESP32 VGA Arcade Games thiab Joystick: 6 Kauj Ruam (nrog Duab)
ESP32 VGA Arcade Games thiab Joystick: 6 Kauj Ruam (nrog Duab)

Video: ESP32 VGA Arcade Games thiab Joystick: 6 Kauj Ruam (nrog Duab)

Video: ESP32 VGA Arcade Games thiab Joystick: 6 Kauj Ruam (nrog Duab)
Video: ESP32 VGA four games & joystick 2024, Hlis ntuj nqeg
Anonim
Image
Image
ESP32 VGA Arcade Games thiab Joystick
ESP32 VGA Arcade Games thiab Joystick
ESP32 VGA Arcade Games thiab Joystick
ESP32 VGA Arcade Games thiab Joystick

Hauv cov lus qhia no kuv yuav qhia yuav ua li cas tsim dua plaub lub arcade zoo li kev ua si - Tetris - Snake - Breakout - Bomber - siv ESP32, nrog cov zis rau VGA saib.

Kev daws teeb meem yog 320 x 200 pixels, hauv 8 xim. Kuv tau ua yav dhau los nrog Arduino Uno (saib ntawm no), tab sis kev daws teeb meem tsuas yog 120 x 60 pixels, 4 xim, thiab Arduino nco tau yuav luag tag nrho. Ua tsaug rau qhov ua tau zoo dua ntawm ESP32, ob qho kev daws teeb meem thiab kev ua si tau zoo dua. Tsis tas li ntawd, tseem tshuav ntau lub cim xeeb muaj, yog li ntxiv cov kev ua si tshiab yav tom ntej yuav ncaj.

Kuv tseem yuav qhia qhov kub los txuas qhov yooj yim joystick hla tus kab RS232. Kuv siv tib tus pinout ntawm Commodore 64 ib qho.

Txoj haujlwm no ua tau los ntawm txaus ESP32 VGA lub tsev qiv ntawv sau los ntawm Fabrizio Di Vittorio. Saib ntawm no kom paub meej ntxiv.

Kauj Ruam 1: ESP32 Boards, Arduino IDE Installation thiab VGA Library Configuration

ESP32 Boards, Arduino IDE Installation thiab VGA Library Configuration
ESP32 Boards, Arduino IDE Installation thiab VGA Library Configuration
ESP32 Boards, Arduino IDE Installation thiab VGA Library Configuration
ESP32 Boards, Arduino IDE Installation thiab VGA Library Configuration
ESP32 Boards, Arduino IDE Installation thiab VGA Library Configuration
ESP32 Boards, Arduino IDE Installation thiab VGA Library Configuration

Ua ntej tshaj plaws koj yuav tsum yuav ESP32 kev kho dua 1 lossis siab dua. Muaj ntau ntau yam muaj, tab sis kuv pom zoo kom xaiv ib qho nrog ntau tus pin, nyiam ua qauv xws li ib qho hauv daim duab no, nrog 38 tus pin. Kuv siv cov ntawv no, tab sis kuv xav tias ntau lwm yam zoo ib yam. Ntawm ebay koj tuaj yeem pom tus qauv no tsawg dua 7 Euro, suav nrog kev xa khoom.

Thaum koj tau txais lub rooj tsavxwm, koj yuav tsum tau ua tiav nrog peb qib hauv qab no:

  1. Nruab qhov kawg Arduino IDE
  2. Kho ESP32 hauv IDE thiab
  3. Rub tawm thiab teeb tsa VGA lub tsev qiv ntawv

Cov theem qis 1. Muaj ntau txoj hauv kev los ua haujlwm rau ESP32, tab sis ntawm no koj yuav tsum siv Arduino IDE (Kuv tab tom siv version 1.8.9, los ntawm txoj kev). Txhawm rau nruab nws, koj tuaj yeem mus rau nplooj ntawv Arduino IDE thiab ua raws cov lus qhia.

Cov theem qis 2. Thaum ua haujlwm dhau los ua tiav, koj yuav tsum teeb tsa koj li ESP32 hauv Arduino IDE. Qhov no tsis tseem ceeb, vim tias ESP32 tsis yog (tseem yog?) Ib txwm nyob hauv nws. Koj tuaj yeem ua raws qhov kev qhia no, lossis cov kauj ruam hauv qab no.

1) qhib Arduino IDE

2) qhib lub qhov rai nyiam, Cov Ntaub Ntawv/Nyiam, hloov pauv "Ctrl+comma"

3) mus rau "Tus Thawj Saib Xyuas Haujlwm Ntxiv URLs", luam thiab muab cov ntawv hauv qab no:

https://dl.espressif.com/dl/package_esp32_index.js…

thiab nyem lub pob OK.

4) Qhib pawg thawj coj saib xyuas. Mus rau Cov Cuab Yeej/Pawg Thawj Coj/Cov Thawj Tswj …

5) Tshawb nrhiav ESP32 thiab nias lub pob teeb tsa rau "ESP32 los ntawm Espressif Systems":

6) Txij ntawm no mus, thaum koj txuas thawj zaug koj ESP32, koj yuav tsum xaiv tus qauv raug nyob hauv cov npe ntev ntawm ESP32 cov laug cam (saib daim duab hauv cov kauj ruam no). Nyob rau hauv cov ntaub ntawv ntawm kev ua xyem xyav txog tus qauv, tsuas yog xaiv qhov dav, piv txwv li thawj tus. Nws ua haujlwm rau kuv.

7) lub kaw lus yuav tsum xaiv qhov yog USB (COM) qhov chaw nres nkoj thiab Upload Speed (ib txwm 921600). Txog tam sim no kev sib txuas ntawm koj lub PC thiab ESP32 pawg thawj coj yuav tsum tsim.

Cov kauj ruam 3. Thaum kawg koj yuav tsum nruab FabGL VGA lub tsev qiv ntawv. Nyem rau qhov no kom rub tawm cov ntaub ntawv ua tiav. Uncompress nws thiab theej cov ntawv tais ceev tseg (FabGL-master) hauv Arduino IDE cov tsev qiv ntawv qhib, uas zoo li:

"… / arduino-1.8.12 / cov tsev qiv ntawv".

Kauj ruam 2: Hloov "ESP32_VGA_Tetris_Snake_Breakout_Bomber_V1.0"

Rub tawm ESP32_VGA_Tetris_Snake_Breakout_Bomber_V1.0.zip hauv qab ntawm cov kauj ruam no. Unzip thiab qhib nws nrog Arduino IDE, tom qab ntawd rub nws mus rau koj ESP32. Yog tias koj tsis muaj lus yuam kev, tus lej yuav tsum tau ua haujlwm thiab koj tsuas yog xav tau txuas VGA chaw nres nkoj thiab cov nyees khawm (lossis joystick).

Kauj Ruam 3: Txuas VGA Port

Txuas VGA Port
Txuas VGA Port

Koj xav tau cov hauv qab no:

  • DSUB15 Connector, piv txwv li yog VGA poj niam txuas lossis VGA cable kom raug txiav.
  • peb 270 Ohm resistors.

Txuas ESP32 GPIO tus pin 2, 15 thiab 21 rau VGA Liab, Ntsuab thiab Xiav feem, dhau ntawm 270 Ohm resistors.

Txuas VGA Hsync thiab Vsync rau ESP32 GPIO pins 17 thiab 4 feem.

Txuas DSUB15 tus pin 5, 6, 7, 8 thiab 10 rau ESP32 GND.

Txog VGA DSUB15 tus lej txuas tus lej txhais, saib daim duab hauv qib no. NB, qhov no yog sab laug ntawm tus poj niam txuas.

Kauj Ruam 4: Txuas Plaub Plaub Khawm

Txuas Plaub Plaub
Txuas Plaub Plaub
Txuas Plaub Plaub
Txuas Plaub Plaub
Txuas Plaub Plaub
Txuas Plaub Plaub

Yog tias koj tsis muaj C64 joystick koj tuaj yeem txuas plaub lub khawm hauv qab cov kauj ruam no. Yog tias koj muaj tus joystick, koj tuaj yeem hla cov kauj ruam no thiab dhia mus rau lwm qhov ntxiv, tab sis koj tuaj yeem txuas ob lub khawm thiab tus joystick (lawv ib txwm "sib luag").

Cov txheej txheem hauv theem no qhia yuav ua li cas txuas ib lub pob (Ib txwm Qhib) los ntawm +5V rau ESP32 muab tus pin.

Nco ntsoov tias koj kuj yuav tsum txuas ESP muab tus pin rau GND hla 1 txog 5 kOhm resistor. Txoj hauv kev no thaum lub pob raug tso tawm (qhib) ESP tus pin nyob ntawm pes tsawg Volts. Tshwj xeeb tshaj yog, koj yuav tsum txuas plaub lub khawm nrog cov lus txib hauv qab no:

  • Pin 12 rau Txoj Cai khawm
  • Pin 25 to Up button
  • Pin 14 rau Sab laug
  • Pin 35 rau khawm Down

Kauj Ruam 5: Txuas Joystick

Txuas Joystick
Txuas Joystick
Txuas Joystick
Txuas Joystick
Txuas Joystick
Txuas Joystick

C64 joystick muaj tus pinout pom hauv thawj daim duab ntawm theem no. Txhawm rau txuas nws rau ESP32, koj xav tau 9 tus pin DSUB txiv neej txuas (piv txwv li, lub qhov), raws li qhia hauv daim duab thib ob. Kuv tshem tawm ib qho nrog cov pins nthuav tawm los ntawm lub tshuab hluav taws xob qub. Koj tuaj yeem siv rab phom kub kom tshem nws (tab sis ua nws sab nraum zoov!).

Koj yuav tsum txuas tus pin tom qab tus lej xaj hauv cov duab no. Nco ntsoov tias cov txheej txheem hais txog sab joystick, yog li nws sawv cev rau kev sib txuas ntawm nws tus poj niam ntsaws. Lub qhov (txiv neej) txhawm rau txuas rau ESP32 muaj tus pin nrog "daim iav" pov tseg. Yog tias tsis ntseeg, nco ntsoov tias tus lej tus lej ib txwm qhia rau tus txiv neej thiab poj niam txuas, raws li qhia hauv daim duab thib peb.

Yog tias koj xav tswj cov kev ua si nrog tus joystick nkaus xwb, txuas nws tus lej sib xws (9) rau ESP32 +5V, thiab tus lej xov tooj joystick 1, 2, 3, 4 thiab 6 rau ESP muab tus lej hauv qab cov npe hauv qab no.

  • ESP tus pin 12 rau Txoj Cai khawm (RS232 tus pin 4)
  • ESP tus pin 14 mus rau sab laug khawm (RS232 tus pin 3)
  • ESP tus pin 35 mus rau khawm (RS232 tus pin 2)
  • ESP tus pin 25 mus rau khawm (RS232 tus pin 1 thiab 6, piv txwv li joystick hluav taws)

NB ESP tus pin 12, 14, 25 thiab 35 yuav tsum tau txuas nrog GND hla 1 txog 5 kOhm resistor. Txoj hauv kev no thaum lub pob raug tso tawm (qhib) ESP tus pin nyob ntawm pes tsawg Volts.

NB2 joystick UP txoj haujlwm thiab khawm hluav taws tau txuas ua ke rau ESP tus pin 25-

Kuv tau txuas plaub lub nyees khawm ntawm PC lub rooj tsavxwm, hauv txoj kev no kuv tsis xav tau lub joystick los ua si (txawm hais tias nrog tus joystick yog qhov lom zem dua). Ib zaug ntxiv, RS232 tus pin 9 yuav tsum txuas nrog +5 V thiab cov joystick pins tsuas yog sib dhos rau cov nyees khawm.

Kauj Ruam 6: Xaus thiab Txais Kev Pom Zoo

Xaus thiab lees paub
Xaus thiab lees paub

Yog tias txhua yam ua haujlwm tau zoo, tsuas yog txuas VGA saib thiab koj yuav tsum muaj peev xwm txaus siab rau qee qhov kev ua si qub!

Koj tseem tuaj yeem kos Mandelbrot teeb nrog daws teeb meem ntawm 640 x 350 pixels, tsuas yog sim VGA lub tsev qiv ntawv muaj peev xwm.

Nco ntsoov tias cov cai tau sau kuv txoj hauv kev uas lwm cov kev ua si tuaj yeem yooj yim ntxiv rau yav tom ntej (ESP32 muaj chaw txaus!). Kuv txoj haujlwm no tau txais txiaj ntsig txaus, Kuv tuaj yeem ua qhov ntawd …

Thaum kawg, Kuv xav qhia kuv lub tso tsheb hlau luam rau Fabrizio Di Vittorio rau nws txaus ESP32 VGA tsev qiv ntawv. Yog xav paub ntau ntxiv, piv txwv, thiab… Space Invaders, mus saib nws lub xaib.

Pom zoo: