Cov txheej txheem:

DIY Tsev Khoos Phis Tawj: 4 Kauj Ruam
DIY Tsev Khoos Phis Tawj: 4 Kauj Ruam

Video: DIY Tsev Khoos Phis Tawj: 4 Kauj Ruam

Video: DIY Tsev Khoos Phis Tawj: 4 Kauj Ruam
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Kaum ib hlis
Anonim
DIY Tsev Computer
DIY Tsev Computer

Kuv tau tshaj tawm Cov Lus Qhia ib ntus rov qab siv Espruino Pico los ua lub khoos phis tawj hauv tsev:

Qhov ntawd xav kom koj txuas VGA tus saib xyuas los ntawm kev txiav ib VGA cable, tab sis rau qhov Qhia Kuv tau siv lub rooj tsav xwm hu ua Pixl.js, uas muaj lub vijtsam LCD ua hauv. Nws txhais tau tias txhua yam koj yuav tsum txuas yog ob peb lub xov tooj thiab koj tau txais qhov siv tau me me, lub khoos phis tawj tsis muaj zog.

Yog li koj xav tau dab tsi?

  • Espruino Pixl.js
  • Ib daim yas lossis ntoo los ua lub hauv paus
  • Ib qho Breadboard
  • 4 x 4x4 KeyPads
  • Ntau ntau Stickers rau cov yuam sij
  • 6 teeb ntawm 8x Txiv neej-> Txiv neej Dupont-style Jumper xov hlau (48 kab tag nrho)-sib txuam ntau daim kab xev ua rau lub neej yooj yim dua

Kauj ruam 1: Ua Keyboard

Ua Keyboard
Ua Keyboard
Ua Keyboard
Ua Keyboard
Ua Keyboard
Ua Keyboard
  • Khaws koj 4 KeyPads nyob ib sab ntawm koj lub hauv paus (lawv tau nplaum-rov qab). Koj tuaj yeem xav txiav lawv cov npoo, tab sis ceev faj tsis txhob txiav ntau dhau lossis koj yuav txiav qee qhov kev sib cuag.
  • Khaws koj daim ntawv tais diav hauv nruab nrab - nws yog nplaum -rov qab ib yam nkaus!
  • Faib lub jumper hlau ua 4 qhov ntev ntawm 8 - sim thiab khaws cov xim zoo ib yam ntawm txhua tus.
  • Khaws cov xov hlau rau hauv KeyPads, ua kom ntseeg tau tias cov xim sib phim. Quav cov xov hlau rov qab thiab kaw lawv rau sab nraum qab ntawm koj lub hauv paus. Koj yuav xav ntxiv qee cov taw nplaum los cawm cov xov hlau los ntawm kev khoov ntawm ntau lub kaum sab xis.
  • Tam sim no ntxiv cov ntawv nplaum rau txhua lub khawm hauv Key Pad thiab sau lawv raws li koj xav tau koj cov keyboard. Siv cov duab ua piv txwv, tab sis thaum koj upload koj cov cai koj tuaj yeem hloov qhov 'KEYMAP' sib txawv rau qhov koj muaj.

Kauj ruam 2: Kev thaiv kab

Thaiv
Thaiv

Tam sim no koj yuav tsum tau xaim cov keyboard. Txhua tus 4x4 cov keyboard tau teeb tsa ua kab sib chaws, thiab peb tab tom txuas lawv zoo li lawv yog lawv tus kheej hauv 2x2 kab sib chaws - ua qhov loj 8x8 kab sib chaws ntawm cov nyees khawm.

Hlau raws li qhia hauv daim duab ua 4 pawg ntawm 4 xov hlau hla lub khob cij (kos cov xim ntawm cov xov hlau hauv cov duab), nrog rau sab laug mus rau sab xis:

  • KeyPad 1 Thawj 4 xov hlau -> thawj pab pawg ntawm 4 ntawm daim phiaj -> D0, D1, D2, D3
  • KeyPad 1 Thib Ob 4 xov hlau -> pab pawg thib peb ntawm 4 ntawm daim phiaj -> D8, D9, D10, D11
  • KeyPad 2 Thawj 4 xov hlau -> thawj pab pawg ntawm 4 ntawm lub khob cij -> D0, D1, D2, D3
  • KeyPad 2 Qhov thib ob 4 xov hlau -> pab pawg plaub ntawm 4 ntawm daim phiaj -> D12, D13, SDA, SCL
  • KeyPad 3 Thawj 4 xov hlau -> pab pawg thib ob ntawm 4 ntawm daim phiaj -> D4, D5, D6, D7
  • KeyPad 3 Qhov thib ob 4 xov hlau -> pab pawg thib peb ntawm 4 ntawm daim phiaj -> D8, D9, D10, D11
  • KeyPad 4 Thawj 4 xov hlau -> pab pawg thib ob ntawm 4 ntawm daim phiaj -> D4, D5, D6, D7
  • KeyPad 4 Qhov thib ob 4 xov hlau -> pab pawg plaub ntawm 4 ntawm daim phiaj -> D12, D13, SDA, SCL

Hauv daim duab peb muaj 6 teeb ntawm 8 xov hlau. Thawj 2 yog los ntawm cov keypads 1 thiab 2, qhov thib ob 2 yuav mus rau Pixl.js, thiab qhov thib peb 2 yog rau keypads 4 thiab 3.

Kauj ruam 3: Software

Tam sim no xyuas kom koj Pixl lub khoos phis tawj hloov kho tshiab, txuas nrog nws nrog Espruino IDE, thiab xa cov lej hauv qab no. Disconnect IDE thiab koj ua tiav!

// Keyboard wiringvar KEYROW = [D7, D6, D5, D4, D3, D2, D1, D0]; var KEYCOL = [A5, A4, D13, D12, D11, D10, D9, D8];

// Cov Ntawv Qhia Tseem Ceeb rau Keyboard

var KEYMAPLOWER = ["` 1234567890-= / x08 "," / tqwertyuiop n "," / 0asdfghjkl; '#\ x84 / x82 / x85 "," / x01 / zxcvbnm,./ / x80 / x83 / x81;, ib. var KEYMAPUPPER = ["¬! \" £ $%^&*() _+\ x08 "," / tQWERTYUIOP {} n "," / 0ASDFGHJKL:@~ / x84 / x82 / x85 "," / x01 | ZXCVBNM? / x80 / x83 / x81 ",];

/* Yog tias tus lej hauv qhov tseem ceeb yog> = 128, rho tawm 128 thiab saib hauv kab lus no rau ntau tus cim tus lej cim*/ var KEYEXTRA = [String.fromCharCode (27, 91, 68), // 0x80 sab laug txoj hlua.fromCharCode (27, 91, 67), // 0x81 txoj cai txoj cai.fromCharCode (27, 91, 65), // 0x82 up String.fromCharCode (27, 91, 66), // 0x83 down String.fromCharCode (27, 91, 53, 126), // 0x84 page up String.fromCharCode (27, 91, 54, 126), // 0x85 nplooj ntawv hauv qab]; // Shift status var hasShift = cuav; muaj nuj nqi setShift (s) {hasShift = s; // kos qhov taw qhia ua haujlwm ntawm qhov screen yog (hasShift) {g.setColor (1); g.fillRect (105, 0, 128, 6); g.setColor (0); g.drawString ("SHIFT", 107, 1); g.setColor (1); } lwm {g.setColor (0); g.fillRect (105, 0, 128, 6); g.setColor (1); } g.flip (); }

// Hloov tus yuam sij tiag tiag rau ua ntu zus ntawm cov cim

// Thiab xa mus rau Loopback (qhov console yog) ua haujlwm handleKeyPress (e) {var kx = e >> 3; var ky = e & 7; yog (ky> 3) {// tig mus ua kab ntev kx+= 8; ky-= 4; } var qhov tseem ceeb = hasShift? KEYMAPUPPER [ky] [kx]: KEYMAPLOWER [ky] [kx]; yog (qhov tseem ceeb == "\ x01") {setShift (! hasShift); } lwm {setShift (tsis tseeb); yog (qhov tseem ceeb && key.length) {yog (key.charCodeAt (0)> 127) qhov tseem ceeb = KEYEXTRA [key.charCodeAt (0) -128]; Terminal.inject (qhov tseem ceeb); }}}

// teeb tsa cov keyboard

xav tau ("KeyPad"). txuas (KEYROW, KEYCOL, handleKeyPress);

Kauj ruam 4: Siv Nws

Siv Nws!
Siv Nws!

Tam sim no nws ua haujlwm:

  • Cov keyboard tsuas tuaj yeem tshawb pom ib zaug xwb, yog li Shift toggles uppercase letters (nrog qhov taw qhia nyob rau sab xis saum toj), thiab ntaus ib tsab ntawv rov mus rau cov tsiaj ntawv qis. Tuav Shift thiab lwm tus yuam sij yuav tsis ua haujlwm.
  • Kev ntaus ntawv tuaj yeem ua rau mob heev, yog li siv lub Tab Tab (ntawm sab laug) kom ntau li ntau tau los pib sau cov lus!
  • Cov duab rau lub vijtsam muaj nyob ntawm cov txheej txheem ntawm g hloov pauv - piv txwv li, g.fillRect (20, 20, 40, 40) lossis g.clear ().
  • Ntau tus IO siv rau cov keyboard, tab sis koj tseem muaj tus pin A0, A1, A2 thiab A3 uas koj tuaj yeem siv rau txuas lwm cov khoom siv sab nrauv.
  • pib dua () yuav rov pib dua txhua yam - suav nrog koj cov cai rau kev tuav cov keyboard. Txhawm rau zam qhov no, qhib kev txuag ntawm kev xa, txawm tias tom qab rov pib dua hauv Web IDE cov kev sib txuas lus thiab xa dua.
  • Koj lub khoos phis tawj tau siv lub zog tsis txaus ntseeg - koj tseem tuaj yeem cia siab tias kwv yees li 20 hnub roj teeb lub neej - ib txwm nyob - tawm ntawm ib lub roj teeb CR2032 xwb!

Pom zoo: