Tsev > Xov xwm > Ntsiab lus

Sij Hawm Sij Hawm

Apr 26, 2019

2.2.4 Teem sij hawm: 480x272 ntawm 60Hz

Rau ib daim duab muab kho dua ntawm 60Hz, muaj 48000000/60 = 800000 ceev ceev pob zeb ib ntu.

Qhov chaw hauv PCLK cais REG_PCLK mus rau 5 muab lub PCLK zaus ntawm 9.6 MHz thiab

800000/5 = 160000PCLKs ib qhov duab.

Rau 480 x 272 zaub, lub sij hawm tav toj yog 525 teev, thiab lub sij hawm ntsig yog

286 kab. Kev tshawb nrhiav me me qhia tau tias 548 x 292 me me muab ib lub sij hawm ntawm 160016 moos,

ze ntawm lub hom phiaj. Yog li nrog REG_HCYCLE = 548 thiab REG_VCYCLE = 292 cov lus

zaus yog yuav luag 60Hz. Lwm qhov chaw sau npe tuaj yeem teev ncaj nraim los ntawm

zaub ntawv datasheet.


2.2.5 Sib faib ua ntej

Ntu lus no piav qhia qhov pib sib txawv hauv qhov txawv scenario.

 Kev Sib Sib Ntsig thaum pib khau raj:

1. Siv MCU SPI moos tsis tshaj 11MHz

2. Xa Tshooj Chaw Tiv Thaiv "CLKEXT" rau FT800

3. Xa Lub Tswv Yim Kom Nceeg "ACTIVE" los pab kom moos mus rau FT800.

4. Kho cov sijhawm teev tseg cov vev xaib, tshwj tsis yog tias REG_PCLK

5. Sau cov npe thawj zaug

6. Sau ntawv REG_DLSWAP, FT800 swaps zaub sau npe tam sim ntawd

7. Txhim kho lub teeb ci rov qab rau cov khoom

8. Sau ntawv REG_PCLK, cov zis video pib nrog thawj daim ntawv teev khoom

9. Siv MCU SPI moos tsis tshaj 30MHz


MCU_SPI_CLK_Freq (<11 mhz);="" siv="" mcu="" spi="" moos="" tsawg="" tshaj="">

host_command (CLKEXT); // xa cov lus txib kom "CLKEXT" rau FT800

host_command (ACTIVE); / / xa cov lus txib kom ua "ACTIVE" rau FT800

/ * Configure display registers - ua qauv qhia rau WQVGA daws teeb meem * /

wr16 (REG_HCYCLE, 548);

wr16 (REG_HOFFSET, 43);

wr16 (REG_HSYNC0, 0);

wr16 (REG_HSYNC1, 41);

wr16 (REG_VCYCLE, 292);

wr16 (REG_VOFFSET, 12);

wr16 (REG_VSYNC0, 0);

wr16 (REG_VSYNC1, 10);

wr8 (REG_SWIZZLE, 0);

wr8 (REG_PCLK_POL, 1);

wr8 (REG_CSPREAD, 1);

wr16 (REG_HSIZE, 480);

wr16 (REG_VSIZE, 272);

/ * sau cov npe thawj zaug * /

wr32 (RAM_DL + 0, CLEAR_COLOR_RGB (0,0,0));

wr32 (RAM_DL + 4, CLEAR (1,1,1));

wr32 (RAM_DL + 8, DISPLAY ());

wr8 (REG_DLSWAP, DLSWAP_FRAME); // zaub daim ntawv sib pauv

wr8 (REG_GPIO_DIR, 0x80 | Ft_Gpu_Hal_Rd8 (phost, REG_GPIO_DIR));

wr8 (REG_GPIO, 0x080 | Ft_Gpu_Hal_Rd8 (phost, REG_GPIO)); // enable zaub me ntsis

wr8 (REG_PCLK, 5); // tom qab cov duab no pom hauv LCD

MCU_SPI_CLK_Freq (<30mhz); siv="" lub="" mcu="" spi="" moos="" upto="" 30="">

Code snippet 1 Initialization ib theem zuj zus



 Initialization Sequence from Power Down siv PD_N nawj:

1. Tsav tus PD_N tus nai siab

2. Tos li 20 xuab moos

3. "Execute Initialization Sequence thaum lub sij hawm Boot" ntawm cov kauj ruam 1 txog 9

 Initialization Sequence los ntawm kev pw tsaug zog hom:

1. Xa Hauv Chaw Piv Txwv "ACTIVE" los pab kom moos mus rau FT800

2. Tos li 20 xuab moos

3. "Execute Initialization Sequence thaum lub caij rho menyuam" ntawm theem 5 txog 8

 Initialization ib theem zuj zus los ntawm kev npaj siab hom:

Tawm tag nrho cov kauj ruam hais hauv "Initialization Sequence From Sleep Mode"

tshwj tsis yog tos tsawg kawg 20ms hauv kauj ruam 2.

Lus cim: Xa mus rau FT800 ntawv xov xwm rau cov lus qhia txog lub hwj chim hom. Ua raws seem 2.3 rau

kev tswj lub suab thaum lub hwj chim thiab pib ua haujlwm.


2.3 Sound Synthesizer

Sample code ua si C8 ntawm xylophone:

wr8 (REG_VOL_SOUND, 0xFF); // set lub ntim kom siab tshaj

wr16 (REG_SOUND, (0x6C < 8)="" |=""> // C8 MIDI faj seeb txog xylophone

wr8 (REG_PLAY, 1); // ua si lub suab

Code snippet 2 suab synthesizer ua si C8 ntawm xylophone


Cov qauv code ntsuam xyuas cov xwm txheej ntawm lub suab ua si:

Sound_status = rd8 (REG_PLAY); // 1-kev ua si yog yuav mus, 0-kev ua si tau tiav lawm

Code snippet 3 suab synthesizer kos cov xwm txheej ntawm lub suab ua si



Cov qauv code nres suab ua si:

wr16 (REG_SOUND, 0x0); // configure silence li suab ua si

wr8 (REG_PLAY, 1); // ua si suab

Sound_status = rd8 (REG_PLAY); // 1-kev ua si yog yuav mus, 0-kev ua si tau tiav lawm

Code snippet 4 suab synthesizer nres ua si suab


Yuav kom tsis txhob muaj lub suab nrov nrov ntawm kev hloov lossis hloov lub zog hauv lub xeev, ua rau lub suab "suab hais lus"

thiab tos nws kom tiav (tiav ntawm lub suab ua si yog thaum REG_PLAY muaj tus nqi

ntawm 0). Qhov no teev tus nqi tso zis rau 0 theem. Txog reboot, lub suab cav plays rov qab rau

"Unmute" suab tsav lub qhov tso tawm mus rau ib nrab ntawm txoj kev.

Ceebtoom: Xa mus rau FT800 ntawv xov xwm rau cov lus qhia ntxiv txog cov suab synthesizer thiab lub suab

playback.


2.4 Lub suab playback

FT800 txhawb peb hom suab hom: 4 Yooj yim IMA ADPCM, 8 ntsis kos npe rau PCM, 8 ntsis uLaw. Rau hom IMA ADPCM hom ntawv, thov nco ntsoov cov lus txib byte: hauv ib byte, qauv ua ntej

(4 pob) yuav tsum nrhiav ntawm ntsis 0 mus rau me ntsis 3, thaum zaum ob (4 khoom) yuav tsum nrhiav los ntawm

ntsis 4 rau ntsis 7.

Rau cov ntaub ntawv suab hauv FT800 RAM ua si, FT800 yuav tsum pib qhov chaw nyob hauv

REG_PLAYBACK_START kom tau 64 npij (8 Bytes). Ntxiv mus, qhov ntev ntawm lub suab

cov ntaub ntawv teev qhia los ntawm REG_PLAYBACK_LENGTH yuav tsum yog 64 npij (8 Bytes).

Yog xav paub txog kev ua si rov qab rau cov ntaub ntawv tawm suab, thov saib cov qauv hauv qab no:

wr8 (REG_VOL_PB, 0xFF); // configure audio playback ntim

wr32 (REG_PLAYBACK_START, 0); // configure suab tsis pib qhov chaw nyob

wr32 (REG_PLAYBACK_LENGTH, 100 * 1024); // configure suab tsis ntev

wr16 (REG_PLAYBACK_FREQ, 44100); // configure audio sampling zaus

wr8 (REG_PLAYBACK_FORMAT, ULAW_SAMPLES); // configure suab hom

wr8 (REG_PLAYBACK_LOOP, 0); // configure ib zaug los nruam playback

wr8 (REG_PLAYBACK_PLAY, 1); // pib lub suab playback

Code snippet 5 Lub suab playback



AudioPlay_Status = rd8 (REG_PLAYBACK_PLAY); // 1-audio playback mus,

0-lub suab playback lawm

Code snippet 6 Kos lub status ntawm lub suab playback

wr32 (REG_PLAYBACK_LENGTH, 0); // configure playback ntev mus 0

wr8 (REG_PLAYBACK_PLAY, 1); // pib audio playback

Code snippet 7 Nres lub suab playback


2.5 Cov kev ua txhua yam

Tshooj lus no piav qhia cov nta thiab siv ntau yam piv txwv.

2.5.1 Kev pib

Tus piv txwv luv luv no tsim ib qho kev tshuaj ntsuam nrog cov ntawv "FTDI" rau nws, nrog rau lub teeb liab.

image

Cov cai kos rau qhov screen:

wr32 (RAM_DL + 0, CLEAR (1, 1, 1)); / / ntshiab npo

wr32 (RAM_DL + 4, BEGIN (BITMAPS)); // pib kos duab bitmaps

wr32 (RAM_DL + 8, VERTEX2II (220, 110, 31, 'F'))); // ascii F hauv font 31

wr32 (RAM_DL + 12, VERTEX2II (244, 110, 31, 'T')); // ascii T

wr32 (RAM_DL + 16, VERTEX2II (270, 110, 31, 'D')); // ascii D

wr32 (RAM_DL + 20, VERTEX2II (299, 110, 31, 'Kuv'))); // ascii kuv

wr32 (RAM_DL + 24, END ());

wr32 (RAM_DL + 28, COLOR_RGB (160, 22, 22)); // hloov xim rau liab

wr32 (RAM_DL + 32, POINT_SIZE (320)); // set taw tes me me rau 20 pixels nyob rau hauv

vojvoog

wr32 (RAM_DL + 36, BEGIN (POINTS)); // pib kos cov ntsiab lus

wr32 (RAM_DL + 40, VERTEX2II (192, 133, 0, 0)); // liab taw tes

wr32 (RAM_DL + 44, END ());

wr32 (RAM_DL + 48, DISPLAY ()); // tso saib cov duab

Code snippet 8 Tau pib


Tom qab cov lus teev saum toj no yog loaded rau hauv daim ntawv sau RAM, sau npe

REG_DLSWAP yuav tsum teem caij rau 0x02 thiaj ua tau daim ntawv teev cov npe tshiab

ntawm tus ncej tshiab tom ntej tshiab.

Nco Ntsoov:

 Cov lus teev npe pib ntawm qhov chaw nyob RAM_DL

 Qhov chaw nyob yeej ib txwm nce siab ntawm 4 (bytes) raws li txhua nqe lus txib 32 ntsis dav.

 Hais kom CLEAR raug pom zoo kom siv ua ntej lwm daim duab

kev lag luam, thiaj li muab FT800 graphics cav hauv lub xeev paub.

 Qhov kawg ntawm daim ntawv teev cov npe yeej ib txwm flagged nrog cov lus txib DISPLAY

2.5.2 Coordinate Plane

Daim duab hauv qab no qhia txog cov duab kos lub dav hlau thiab thaj chaw pom.

Txoj kev siv X thiab Y ua haujlwm ntawm -1024 txog 1023 nyob rau hauv kev txiav txim siab pixel, xws li, los ntawm

-16384 rau 16383 nyob rau hauv 1/16th pixel precision.


image

2.5.3 Teeb duab txawv

Tus qauv ntawm kev kos duab yog:

 CEV nrog ib hom kev ua qauv zoo

 Tso tawm ib los sis ntau qhov ib qho, uas qhia meej txog qhov kev tso kawm ntawm txheej thaum ub

qhov screen

 KAWG khij qhov kawg ntawm txheej thaum ub

(faj seeb: Hauv ntau cov piv txwv ntawm END cov lus txib tsis ntsees sau)

Cov txheej txheem txheej thaum ub cov kev txhawb zog hauv tshuab graphics:

 BITMAPS - cov duab qes pixel, ntau hom xim

 POINTS - cov ntsiab lus ntawm cov ntsiab lus uas tsis raug cai, taw tes vojvoog yog 1-256 pixels

 LINES - cov kab los tiv thaiv kabmob, nrog dav ntawm 0 txog 4095 1 / 16th ntawm pixel units.

(dav yog qhov chaw ntawm txoj kab rau ciam teb)

 LINE_STRIP - cov kab los tiv thaiv kabmob, txuas nrog lub taub hau-rau-tw

 RECTS - round-cornered rectangles, curvature ntawm cov ces kaum yuav hloov

siv LINE_WIDTH.

 EDGE_STRIP_A / B / L / R - ntug strips

Piv txwv


Taw cov ntsiab lus nrog ua lub vojvoog ntawm 5 pixels mus rau 13 pixels nrog cov xim sib txawv:

dl (COLOR_RGB (128, 0, 0));

dl (POINT_SIZE (5 * 16));

dl (BEGIN (POINTS));

dl (VERTEX2F (30 * 16,17 * 16));

dl (COLOR_RGB (0, 128, 0));

dl (POINT_SIZE (8 * 16));

dl (VERTEX2F (90 * 16, 17 * 16));

dl (COLOR_RGB (0, 0, 128));

dl (POINT_SIZE (10 * 16));

dl (VERTEX2F (30 * 16, 51 * 16));

dl (COLOR_RGB (128, 128, 0));

dl (POINT_SIZE (13 * 16));

dl (VERTEX2F (90 * 16, 51 * 16));

image

VERTEX2F cov lus txib muab qhov chaw ntawm lub voj voog qhov chaw.

Kos kab nrog qhov sib txawv ntawm qhov ntau ntawm 2 pixels rau 6 pixels nrog cov xim sib txawv (kab dav

loj yog los ntawm qhov chaw ntawm txoj kab txog ciam teb):

dl (COLOR_RGB (128, 0, 0));

dl (LINE_WIDTH (2 * 16));

dl (BEGIN (LINES));

dl (VERTEX2F (30 * 16,38 * 16));

dl (VERTEX2F (30 * 16,63 * 16));

dl (COLOR_RGB (0, 128, 0));

dl (LINE_WIDTH (4 * 16));

dl (VERTEX2F (60 * 16,25 * 16));

dl (VERTEX2F (60 * 16,63 * 16));

dl (COLOR_RGB (128, 128, 0));

dl (LINE_WIDTH (6 * 16));

dl (VERTEX2F (90 * 16, 13 * 16));

dl (VERTEX2F (90 * 16, 63 * 16));

Cov VERTEX2F cov lus txib muaj khub ua ke kom txhais tau qhov pib thiab qhov kawg ntawm txoj kab.



Kos duab qis nrog qhov ntau thiab tsawg ntawm 5 x 25, 10x38 thiab 15x50 (kab qhov dav dav siv

rau ces kaum curvature, LINE_WIDTH pixels ntxiv rau ob qho tib si qhia ntxiv rau

voos qhov ntev):

image

dl (COLOR_RGB (128, 0, 0));

dl (LINE_WIDTH (1 * 16));

dl (YUAV SIV (RECTS));

dl (VERTEX2F (28 * 16,38 * 16));

dl (VERTEX2F (33 * 16,63 * 16));

dl (COLOR_RGB (0, 128, 0));

dl (LINE_WIDTH (5 * 16));

dl (VERTEX2F (50 * 16,25 * 16));

dl (VERTEX2F (60 * 16,63 * 16));

dl (COLOR_RGB (128, 128, 0));

dl (LINE_WIDTH (10 * 16));

dl (VERTEX2F (83 * 16, 13 * 16));

dl (VERTEX2F (98 * 16, 63 * 16));

VERTEX2F cov lus txib muaj khub ua ke kom txhais tau cov sab saum toj thiab sab qab ntawm cov ces kaum ntawm

lub duab plaub.

image

image

image

image

2.5.4 Sau cov ntawv teev npe

Sau cov duab sau nkag nrog wr32 () yog siv sijhawm thiab yuam kev-yuam, thiaj li a

muaj peev xwm siv tau:

image

image

image

COLOR_RGB hais kom ua pauv cov xim tam sim no, uas yog xim qhov bitmap.

COLOR_A cov lus txib hloov cov kev kos duab tam sim no, hloov daim ntawv nkauj

ntawm daim duab: ib qho alpha ntawm 0 txhais tau tias yog pob tshab thiab ib qho alpha ntawm 255 tag nrho

opaque. Ntawm no yog ib qho txiaj ntsim ntawm 150 muab ib cov nyhuv seem.

image

2.5.7 VERTEX2II thiab VERTEX2F

VERTEX2II cov lus hais saum toj no tsuas tso cai ua haujlwm zoo xwb. Yog hais tias tus

bitmap yog ib qho tawm ntawm kev tshuaj ntsuam, piv txwv thaum lub vijtsam hloov, ces nws tsim nyog

qhia kom meej tias qhov kev ntsuam xyuas tsis pom kev. VERTEX2F tau hais kom tso cai

koomhaum. Nws kuj tso cai rau qhov chaw fractional, vim hais tias nws qhia txog kev ntsuas (x, y) nyob rau hauv

units ntawm 1/16 ntawm ib qho pixel.

Piv txwv, teeb duab tib qhov kawg ntawm qhov chaw npo (-10, -10) siv VERTEX2F:

image

image

image

2.5.9 Kev Ua Tau

Lub cav graphics tsis muaj kab ntes tsis txav: nws siv dynamic compositing tsim txhua

zaub kab thaum luam luam tawm. Vim li no, muaj qhov kawg ntawm lub sijhawm rau

kos txhua kab. Lub sij hawm no nyob ntawm qhov luam theej tawm (REG_PCLK thiab

REG_HCYCLE), tiam sis yeej tsis tsawg dua 2048 lub moos mus rau sab nraud.

Qee qhov kev txwv kev ua haujlwm:

 Daim ntawv sau ntev npaum li cas yuav tsum tsawg dua 2048 cov lus qhia, vim hais tias

graphics engine fetches zaub sau commands ib lub moos.

 Qhov kev ua haujlwm ntawm lub tshuab graphics pixels yog 4 pixels ib moos, rau ib qho twg

kab nrog 2048 cov lus pom tag nrho cov pixels kev ua tiav yuav tsum yog

tsawg dua 8192.

 Rau qee cov ntawv me ntsis, cov duab kos yog 1 pixel ib moos. Cov no yog

TEXT8X8, TEXTVGA thiab PALETTED.

 Rau kev paub tsim pixels, cov duab kos yog txo mus rau ¼ pixel ib moos.

Feem ntau cov duab bitmap kos ntawm 1 pixel ib moos, thiab cov qauv saum toj no

(TEXT8X8, TEXTVGA thiab PALETTED) kos ntawm 1 pixel txhua 4 lub sijhawm.

image