• Tidak ada hasil yang ditemukan

ALAT PENGUJI LCD HANDPHONE BERBASIS MIKROKONTROLER PIC - Unika Repository

N/A
N/A
Protected

Academic year: 2019

Membagikan "ALAT PENGUJI LCD HANDPHONE BERBASIS MIKROKONTROLER PIC - Unika Repository"

Copied!
13
0
0

Teks penuh

(1)

LAMPIRAN

ource Code

#in

#device adc=8 #includ

#FUSES NOWDT //No Watch Dog Timer #FUSES XT //Crystal Osc (<= 4mhz) #FUSES PUT //Power Up Timer

#FUSES NOPROTECT //Code not protected from reading #FUSES NODEBUG //No Debug mode for ICD

#FUSE

#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) use

#FUSES NOCPD //No EE protection

#FUSE d

#use delay(clock=4000000) #define LCD_RESET PIN_A4 #define LCD_CS PIN_A5 #define SPI_CLK PIN_C3 #define SPI_DI PIN_C4 //unused #define SPI_DO PIN_C5

#define LED PIN_D1 #define LCD_led PIN_C2 #define buzz PIN_D0

#bit SSPEN = 0x14.5 // bit to turn on/off hardware SPI // Epson S1D15G10 Command Set

#define DISON 0xaf #define DISOFF 0xae #define DISNOR 0xa6 #define DISINV 0xa7 #define SLPIN 0x95 #define SLPOUT 0x94 #define COMSCN 0xbb #define DISCTL 0xca #define PASET 0x75 #define CASET 0x15 #define DATCTL 0xbc #define RGBSET8 0xce #define RAMWR 0x5c

S

clude <16F877a.h> e <string.h>

S NOBROWNOUT //Don't Reset when brownout detected d for I/O

(2)

#define RAMRD 0x5d define PTLIN 0xa8

T 0xa9 define RMWIN 0xe0 xee T 0xaa

0xab define OSCON 0xd1 define OSCOFF 0xd2

WR 0xfc

define EPSRRD2 0x7d

define BLUE 0x00F

define YELLOW 0xFF0

SOURCE FILE //// t from above>" 51

9]={ #

#define PTLOU #

#define RMWOUT 0 #define ASCSE

#define SCSTART #

#

#define PWRCTR 0x20 #define VOLCTR 0x81 #define VOLUP 0xd6 #define VOLDOWN 0xd7 #define TMPGRD 0x82 #define EPCTIN 0xcd #define EPCOUT 0xcc #define EPM

#define EPMRD 0xfd #define EPSRRD1 0x7c #

#define NOP 0x25 #define ENDPAGE 132 #define ENDCOL 130 // 12-bit color definitions #define WHITE 0xFFF #define BLACK 0x000 #define RED 0xe00 #define GREEN 0x0F0 #

#define CYAN 0x0FF #define MAGENTA 0xF0F #

#define BROWN 0xB22 #define ORANGE 0xFA0 #define PINK 0xF6A //// START OF MAIN .C //#include "<path to .h file cu #use fast_io(C)

#define STRING_SIZE const unsigned char testcol[ red,green,blue,

(3)

blue,red,green};

const unsigned char TABEL1[16*16] = {

,0x00,0x00,0x00, // space 0x20 x00,0x20,0x00, // !

,0x00,0x00,0x00, // " 0x50,0x50,0x00, // # ,0xF0,0x20,0x00, // $ ,0x98,0x18,0x00, // %

,0x90,0x68,0x00, // & 0x00,0x00,0x00, // ' ,0x20,0x10,0x00, // (

20,0x40,0x00, // ) 0xA8,0x20,0x00, // * 0,0x20,0x00,0x00, // +

,0x30,0x20,0x40, // , ,0x00,0x00,0x00, // - ,0x30,0x30,0x00, // .

0x80,0x00,0x00}; // / (forward slash) 2[16*16] = {

88,0x88,0x70,0x00, // 0 0x30 x20,0x60,0x20,0x20,0x20,0x20,0x70,0x00, // 1

0x80,0xF8,0x00, // 2 ,0x88,0x70,0x00, // 3 8,0x10,0x10,0x00, // 4 08,0x88,0x70,0x00, // 5 88,0x88,0x70,0x00, // 6 0,0x20,0x40,0x80,0x00, // 7 88,0x88,0x70,0x00, // 8 x08,0x10,0xE0,0x00, // 9 x20,0x00,0x00,0x00, // :

x20,0x40,0x00, // ; ,0x10,0x08,0x00, // < 8,0x00,0x00,0x00, // = ,0x20,0x40,0x00, // > 0x20,0x00,0x20,0x00}; // ? onst unsigned char TABEL3[16*16] = {

// @ 0x40 x20,0x50,0x88,0x88,0xF8,0x88,0x88,0x00, // A

// B 0x80,0x80,0x88,0x70,0x00, // C

(4)

0x70,0x20,0x20,0x20,0x20,0x20,0x70,0x00, // I x38,0x10,0x10,0x10,0x10,0x90,0x60,0x00, // J

00, // K M

50

0, // [

lash)

x60

00, // k

0x70 0

0x88,0x90,0xA0,0xC0,0xA0,0x90,0x88,0x 0x80,0x80,0x80,0x80,0x80,0x80,0xF8,0x00, // L 0x88,0xD8,0xA8,0xA8,0xA8,0x88,0x88,0x00, // 0x88,0x88,0xC8,0xA8,0x98,0x88,0x88,0x00, // N 0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x00}; // O const unsigned char TABEL4[16*16] = {

0xF0,0x88,0x88,0xF0,0x80,0x80,0x80,0x00, // P 0x 0x70,0x88,0x88,0x88,0xA8,0x90,0x68,0x00, // Q 0xF0,0x88,0x88,0xF0,0xA0,0x90,0x88,0x00, // R 0x70,0x88,0x80,0x70,0x08,0x88,0x70,0x00, // S 0xF8,0xA8,0x20,0x20,0x20,0x20,0x20,0x00, // T 0x88,0x88,0x88,0x88,0x88,0x88,0x70,0x00, // U 0x88,0x88,0x88,0x88,0x88,0x50,0x20,0x00, // V 0x88,0x88,0x88,0xA8,0xA8,0xA8,0x50,0x00, // W 0x88,0x88,0x50,0x20,0x50,0x88,0x88,0x00, // X 0x88,0x88,0x50,0x20,0x20,0x20,0x20,0x00, // Y 0xF8,0x08,0x10,0x70,0x40,0x80,0xF8,0x00, // Z 0x78,0x40,0x40,0x40,0x40,0x40,0x78,0x0

0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00, // \ (back s 0x78,0x08,0x08,0x08,0x08,0x08,0x78,0x00, // ] 0x20,0x50,0x88,0x00,0x00,0x00,0x00,0x00, // ^ 0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x00}; // _ const unsigned char TABEL5[16*16] = {

0x60,0x60,0x20,0x10,0x00,0x00,0x00,0x00, // ` 0 0x00,0x00,0x60,0x10,0x70,0x90,0x78,0x00, // a 0x80,0x80,0xB0,0xC8,0x88,0xC8,0xB0,0x00, // b 0x00,0x00,0x70,0x88,0x80,0x88,0x70,0x00, // c 0x08,0x08,0x68,0x98,0x88,0x98,0x68,0x00, // d 0x00,0x00,0x70,0x88,0xF8,0x80,0x70,0x00, // e 0x10,0x28,0x20,0x70,0x20,0x20,0x20,0x00, // f 0x00,0x00,0x70,0x98,0x98,0x68,0x08,0x70, // g 0x80,0x80,0xB0,0xC8,0x88,0x88,0x88,0x00, // h 0x20,0x00,0x60,0x20,0x20,0x20,0x70,0x00, // i 0x10,0x00,0x10,0x10,0x10,0x90,0x60,0x00, // j 0x80,0x80,0x90,0xA0,0xC0,0xA0,0x90,0x 0x60,0x20,0x20,0x20,0x20,0x20,0x70,0x00, // l 0x00,0x00,0xD0,0xA8,0xA8,0xA8,0xA8,0x00, // m 0x00,0x00,0xB0,0xC8,0x88,0x88,0x88,0x00, // n 0x00,0x00,0x70,0x88,0x88,0x88,0x70,0x00}; // o const unsigned char TABEL6[16*16] = {

(5)

0x20,0x20,0xF8,0x20,0x20,0x28,0x10,0x00, // t 0x00,0x00,0x88,0x88,0x88,0x98,0x68,0x00, // u 0x00,0x00,0x88,0x88,0x88,0x50,0x20,0x00, // v 0x00,0x00,0x88,0x88,0xA8,0xA8,0x50,0x00, // w

0, // {

DEL

signed char y);

olor); int bColor);

lor); color);

T_L_TO_H|SPI_CLK_DIV_4); );

sk only hardware SPI bits if 0x00,0x00,0x88,0x50,0x20,0x50,0x88,0x00, // x

0x00,0x00,0x88,0x88,0x78,0x08,0x88,0x70, // y 0x00,0x00,0xF8,0x10,0x20,0x40,0xF8,0x00, // z 0x10,0x20,0x20,0x40,0x20,0x20,0x10,0x0 0x20,0x20,0x20,0x00,0x20,0x20,0x20,0x00, // | 0x40,0x20,0x20,0x10,0x20,0x20,0x40,0x00, // } 0x40,0xA8,0x10,0x00,0x00,0x00,0x00,0x00, // ~ 0x70,0xD8,0xD8,0x70,0x00,0x00,0x00,0x00}; // void pset(unsigned char color, unsigned char x, un void spi_command(int);

void spi_data(int);

void LCDClearScreen(int colour); void LCDSetPixel(int x, int y, int color);

void LCDSetLine(int x0, int y0, int x1, int y1, int c void LCDPutChar( char c,int x, int y, int fColor,

void LCDPutStr(char *pString, int x, int y, int fColor, int bCo void init_lcd();

void LCDSetLine(int x0, int y0, int x1, int y1, int void lcdfill(int x0,int y0,int dx,int dy,int color); void testRGB_v();

void testRGB_h(); void on_buz(); void main() {

int picx,picy,countcol; char pesan[30];

char pesan1[1];

setup_adc_ports(NO_ANALOGS); setup_adc(ADC_OFF);

setup_spi(SPI_MASTER|SPI_L_TO_H|SPI_XMI setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1 setup_timer_1(T1_DISABLED);

setup_timer_2(T2_DISABLED, 0, 1); set_tris_a(0x00);

set_tris_c(0x00); // all outputs, can change to ma needed

set_tris_b(0xff); port_b_pullups(true);

(6)

awal:

countcol=0; init_lcd();

LcdClearScreen(red); on_buz();

picy=0;

strcpy(pesan," Yudi HS "); LCDPutstr(pesan,10,0,green,blue); strcpy(pesan," 02.50.0026 "); LCDPutstr(pesan,2,0,green,blue); strcpy(pesan," Created By "); for (picx=0;picx<16;picx++){

san,114,0,green,blue);

est Horizontl"); ,98,0,green,blue);

trcpy(pesan," Yudi HS ");

testcol[countcol],testcol[countcol+1]); 02.50.0026 ");

,2,0,testcol[countcol+1],testcol[countcol+2]);

stRGB_v();

);

LCDPutstr(pesan,18,130-(picy+=8),RED,ORANGE); delay_ms(300);

};

strcpy(pesan,"COLOR LCD TESTER"); LCDPutstr(pesan,122,0,red,green); strcpy(pesan,"Test Display RGB"); LCDPutstr(pe

strcpy(pesan,"1.Test Vertikal "); LCDPutstr(pesan,106,0,green,blue); strcpy(pesan,"2.T

LCDPutstr(pesan

while (1) { s

LCDPutstr(pesan,10,0, strcpy(pesan," LCDPutstr(pesan if (!input(pin_b0)){ on_buz();

te

while(input(pin_b2)){ };

on_buz(); goto awal; }

else if (! input(pin_b1)){ on_buz(

testRGB_h();

while(input(pin_b2)){ };

(7)

goto awal;

=9){ 0);

(d=0;d<3;d++){ ++){

3)]);

x0,int y0,int dx,int dy,int color){ (i=y0;i <= (y0+dy);i ++){

j <= (x0+dx); j ++ ) { ,i,color);

etLine(int x0, int y0, int x1, int y1, int color) { };

countcol+=3; if (countcol= countcol=0;} delay_ms(30 }

}

void testRGB_v(){ int c,d;

for (d=0;d<3;d++){ for (c=0;c<3;c++){

lcdfill(0,c*44,131,43,testcol[c+(d*3)]); }

} }

void on_buz(){ output_low(buzz); delay_ms(1000); output_high(buzz); }

void testRGB_h(){ int c,d;

for

for (c=0;c<3;c

lcdfill(c*44,0,43,131,testcol[c+(d* }

} }

void lcdfill(int int i,j,k; for

for (j = x0; lcdsetpixel(j }

} }

(8)

int16 dy;

n;

x1 - x0;

r (stepy=0;stepy<132;stepy++){ 32;stepx++){ ixel(x0+stepx,y0+stepy,color);

id LCDPutStr(char *pString, int x, int y, int fColor, int bColor) { -terminator is seen

x00) {

DPutChar(*pString++, x, y, fColor, bColor); = y + 8;

if y exceeds 131

PutChar(char c,int x, int y, int fColor, int bColor) {

signed int nBytes; signed char PixelRow; signed char Mask; nsigned char indexc; nsigned int Word0; nsigned int Word1; int16 dx,fractio int16 stepx, stepy; dy = y1 - y0; dx =

fo

for (stepx=0;stepx<1 lcdsetp

} } } vo

// loop until null while (*pString != 0 // draw the character LC

y

// bail out

if (y > 131) break; }

}

void LCD int i,j;

unsigned int nCols; unsigned int nRows; un

un un u u u

(9)

// get the nColumns, nRows and nBytes

Bytes =8;

&(c<0x30)){ x20)+1)*8; tabel=1;}

e if ((c>=0x40)&&(c<0x50)){ ndexc=((c-0x40)+1)*8; tabel=3;}

e if ((c>=0x50)&&(c<0x60)){ indexc=((c-0x50)+1)*8;

lse if ((c>=0x60)&&(c<0x70)){

lse{

)*8;

command 0x2B) i_Command(PASET);

i_Data(x);

pi_Data(x + nRows - 1);

Column address set (command 0x2A) pi_Command(CASET);

pi_Data(y);

pi_Data(y + nCols - 1); E MEMORY

WR);

orking backwards from the bottom to the top

font table and then decrement row 1[indexc-i];

nCols = 8; nRows = 8; n

if ((c>=0x20)& indexc=((c-0

else if ((c>=0x30)&&(c<0x40)){ indexc=((c-0x30)+1)*8;

tabel=2;} els

i els

tabel=4;} e

indexc=((c-0x60)+1)*8; tabel=5;}

e

indexc=((c-0x70)+1 tabel=6;}

indexc=indexc-1; // Row address set ( Sp

Sp S // S S S // WRIT

Spi_Command(RAM // loop on each row, w for (i = 0; i < 8; i++) {

// copy pixel row from if (tabel==1)

(10)

else if (tabel==2) l==3)

TABEL3[indexc-i]; ==4)

i]; TABEL5[indexc-i]; c-i];

row (left to right) o two pixels each loop

lor; else use the background color r two successive pixels

& Mask) == 0) = bColor;

lor; ask = Mask >> 1;

((PixelRow & Mask) == 0)

>> 1;

tput three data bytes pi_Data((Word0 >> 4) & 0xFF);

1 >> 8) & 0xF)); ;

terminate the Write Memory command

Row address set (command 0x2B) pi_Command(PASET);

PixelRow = TABEL2[indexc-i]; else if (tabe

PixelRow = else if (tabel

PixelRow = TABEL4[indexc-else if (tabel==5)

PixelRow = else

PixelRow = TABEL6[index

// loop on each pixel in the // Note: we d

Mask = 0x80;

for (j = 0; j < 8; j += 2) {

// if pixel bit set, use foreground co // now get the pixel color fo

if ((PixelRow Word0 else

Word0 = fCo M

if

Word1 = bColor; else

Word1 = fColor; Mask = Mask

// use this information to ou S

Spi_Data(((Word0 & 0xF) << 4) | ((Word Spi_Data(Word1 & 0xFF)

} } //

Spi_Command(NOP); }

void LCDSetPixel(int x, int y, int color) { //

S

(11)

// Column address set (command 0x2A)

ixel will be ignored) MWR);

ata(((color & 0xF) << 4) | ((color >> 8) & 0xF));

ounter

Row address set (command 0x2B)

lumn address set (command 0x2A) SET);

the display memory to BLACK MWR);

131) / 2); i++) {

olour>> 8) & 0xF));

i_Command(NOP);

oid pset(unsigned char color, unsigned char x, unsigned char y){ x & y) coordinates in ram, then writes the colour to display memory. The ending x & y are left

ding colour data bytes to the 'open' fill further memory. issuing any other command MWR.

x += 2; // for some reason starts at 2 Spi_Command(CASET);

Spi_Data(y); Spi_Data(y);

// Now illuminate the pixel (2nd p Spi_Command(RA

Spi_Data((color >> 4) & 0xFF); Spi_D

Spi_Data(color & 0xFF); }

void LCDClearScreen(int colour) { long i; // loop c

//

Spi_Command(PASET); Spi_Data(0);

Spi_Data(131); // Co

Spi_Command(CA Spi_Data(0); Spi_Data(131); // set

Spi_Command(RA for(i = 0; i < ((131 *

Spi_Data((colour>> 4) & 0xFF); Spi_Data(((colour& 0xF) << 4) | ((c Spi_Data(colour & 0xFF);

} Sp } v

// sets the starting page(row) and column ( //

// maxed out so one can continue sen // RAMWR command to

(12)

spi_command(PASET); // page start/end ram PAGE);

; // write pi_data(color);

utput_high(lcd_led); K); output_low (SPI_DO);

0);

IN_A3);

ntrol

= 1100 - CL dividing ratio [don't divide] switching fault)

); // 32 = (128/4)-1 (round up) number of display lines for canning

umber of lines to be inversely highlighted

on // 0 0 0 = 1 -> 80 81 -> 160

// 0 0 1 = 1 -> 80 81 <- 160 1 -> 160 // 0 1 1 = 1 <- 80 81 <- 160

spi_command(OSCON); // internal oscialltor ON

htness nternal resistor ratio - coarse adjustment

spi_data(x); spi_data(END

spi_command(CASET); // column start/end ram spi_data(y);

spi_data(ENDCOL); spi_command(RAMWR) s

}

void init_lcd(void){ o

output_low (SPI_CL

output_high (LCD_CS); output_low (PIN_A3); delay_ms(50

output_high (P

spi_command(DISCTL); // display co spi_data(0x0C); // 12

period 8H (de spi_data(0x20 s

spi_data(0x0C); // 12 = 1100 - n // spi_data(0x00);

spi_command(COMSCN); // common scanning directi spi_data(0x01);

// 0 1 0 = 1 <- 80 8

spi_command(SLPOUT); // sleep out

spi_command(VOLCTR); // electronic volume, this is the contrast/brig spi_data(0x0); // volume (contrast) setting - fine tuning

spi_data(0x30); // i

(13)

spi_data(0x0f); //everything on, no external reference resistors

); // invert display mode

01); // P1: 0x01 = page address inverted, column address normal, direction

Spi_Data(0x00); // P2: 0x00 = RGB sequence (default value)

scale -> 16 (selects 12-bit color, type A) ISON); // display on

delay_ms(100);}

dat){

// enable chip

ut off hardware SPI allowing direct access to SPI DO); // output low on data out (9th bit low = command) lay_cycles(1); // send clock pulse

// make PIC do the work for the command byte

id spi_data(int dat){

// turn off hardware SPI allowing us direct access to SPI ut high on data out (9th bit high = data) ck pulse

output_low (SPI_CLK);

spi_write(dat); // make PIC do the work for the data byte delay_ms(100);

spi_command(DISINV

spi_command(DATCTL); // data control Spi_Data(0x

address scan in column

Spi_Data(0x02); // P3: 0x02 = Gray spi_command(D

void spi_command(int output_low(LCD_CS); SSPEN = 0; // sh in/out pins

output_low (SPI_

output_high (SPI_CLK); de

output_low (SPI_CLK);

SSPEN=1; // turn hardware SPI back on spi_write(dat);

output_high(LCD_CS); // disable }

vo

output_low(LCD_CS); // enable chip SSPEN = 0;

in/out pins

output_high (SPI_DO); // outp output_high (SPI_CLK); delay_cycles(1); // send clo

SSPEN=1; // turn hardware SPI back on

Referensi

Dokumen terkait

Per syar atan dan jadw al dapat dilihat pada w ebsi te LPSE Univer sitas Neger i Makassar. ( UNM) http:/ / lpse.unm.ac.id mulai tanggal 06

Allah SWT atas berkat, rahmat dan karunia-Nya sehingga penulis dapat menyelesaikan skripsi ini dengan judul “Faktor -Faktor Yang Mempengaruhi Pembiayaan Musyarakah

Permasalahan pada penelitian ini adalah tingginya frekuensi pengiriman produk serta ketidakseimbangan antara jumlah produk yang dipasok dengan jumlah permintaan produk

Jurusan Biologi FMIPA Universitas Riau, Jl. Mordant Black 17 adalah salah satu pewarna azo yang sukardidegradasi dan bersifat karsinogenik. BTA1 telah diketahui mempunyai

Premis 2 : Jika siswa mendapat nilai baik maka siswa tidak mengikuti kegiatan remedial Premis 3 : Siswa rajin belajar.. Kesimpulan dari ketiga premis tersebut adalah …

Psikologi Pendidikan Teori dan Aplikasi dalam Proses Pembelajaran.. Yogjakarta:

[r]

Berdasarkan jenis kapal terbesar yang masuk ke pelabuhan, kedalaman alur yang diperlukan yaitu 13,43 mLWS, lebar alur untuk satu jalur adalah 57,6 m, sedangkan untuk dua jalur