LCD
Dependencies: LCDTFT TFT_fonts mbed
Fork of TFT_CJS_ssd01399_portver_prettyfont by
main.cpp@1:b4ae6047d590, 2015-06-12 (annotated)
- Committer:
- cstevens
- Date:
- Fri Jun 12 09:05:58 2015 +0000
- Revision:
- 1:b4ae6047d590
- Parent:
- 0:92feefa9d5ba
- Child:
- 2:1bc1605bffae
pretty font putc versoin;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cstevens | 0:92feefa9d5ba | 1 | #include "mbed.h" |
cstevens | 1:b4ae6047d590 | 2 | #include "LCDTFT.h" |
cstevens | 1:b4ae6047d590 | 3 | #include "Arial12x12.h" |
cstevens | 1:b4ae6047d590 | 4 | #include "Arial24x23.h" |
cstevens | 1:b4ae6047d590 | 5 | #include "Arial28x28.h" |
cstevens | 1:b4ae6047d590 | 6 | #include "font_big.h" |
cstevens | 0:92feefa9d5ba | 7 | |
cstevens | 1:b4ae6047d590 | 8 | //BusOut MyBus(PTA13,PTD5,PTD4,PTA12,PTA4,PTA5,PTC8,PTC9); // 8 bit bus on these dvices |
cstevens | 1:b4ae6047d590 | 9 | |
cstevens | 1:b4ae6047d590 | 10 | |
cstevens | 1:b4ae6047d590 | 11 | PortOut MyPort(PortD ,0xFF); // define a port with only the lower 8 bits included - that'llbe PTD0-PTD7 making a single 8 bit port. |
cstevens | 1:b4ae6047d590 | 12 | LCDTFT MyLCD(PTB0,PTB1,PTB2,PTB3,PTC2,&MyPort);//LCDTFT(PinName PIN_RD,PinName PIN_WR,PinName PIN_RS,PinName PIN_CS,PinName PIN_RESET, PortOut *PORTLCD); |
cstevens | 1:b4ae6047d590 | 13 | |
cstevens | 1:b4ae6047d590 | 14 | |
cstevens | 0:92feefa9d5ba | 15 | |
cstevens | 1:b4ae6047d590 | 16 | // ok - a simple sub to put in a character from the fonts defined in TFT_fonts |
cstevens | 1:b4ae6047d590 | 17 | // c= charactetr to put |
cstevens | 1:b4ae6047d590 | 18 | // font = pointer to font to use |
cstevens | 1:b4ae6047d590 | 19 | // x,y locatoin of bottom lh of character, bcol = background color, fcol = foreground color |
cstevens | 1:b4ae6047d590 | 20 | void prettyputc(char c, const unsigned char *font,short xpos,short ypos,short bcol, short fcol) |
cstevens | 1:b4ae6047d590 | 21 | { |
cstevens | 1:b4ae6047d590 | 22 | // Length,horz,vert,byte/vert |
cstevens | 1:b4ae6047d590 | 23 | int length,hor,vert,bpver; // number of bytes per character, horizontal pixels, vertical pixels and bytes per column |
cstevens | 1:b4ae6047d590 | 24 | // |
cstevens | 1:b4ae6047d590 | 25 | int x,y,i,j,k,ptr; |
cstevens | 1:b4ae6047d590 | 26 | short coltowrite; |
cstevens | 1:b4ae6047d590 | 27 | char byte,point; |
cstevens | 1:b4ae6047d590 | 28 | length=font[0]; |
cstevens | 1:b4ae6047d590 | 29 | hor=font[1]; |
cstevens | 1:b4ae6047d590 | 30 | vert=font[2]; |
cstevens | 1:b4ae6047d590 | 31 | bpver=font[3]; |
cstevens | 1:b4ae6047d590 | 32 | for(i=0; i<hor; i++) { // loop over columns |
cstevens | 1:b4ae6047d590 | 33 | for(j=0; j<vert; j++) { |
cstevens | 1:b4ae6047d590 | 34 | x=xpos+i; |
cstevens | 1:b4ae6047d590 | 35 | y=ypos+j; // NB assumes colums stored from bottom to top.... ? |
cstevens | 1:b4ae6047d590 | 36 | ptr=((c -32) * length+1) + 4+i*bpver+(j/8); // pointer in font array to start of the character we want |
cstevens | 1:b4ae6047d590 | 37 | byte=(char)font[ptr]; |
cstevens | 1:b4ae6047d590 | 38 | k=j%8; // number of the pixel in this byte |
cstevens | 1:b4ae6047d590 | 39 | point=byte & (1<<k); // get the next bit |
cstevens | 1:b4ae6047d590 | 40 | if(point>0) { |
cstevens | 1:b4ae6047d590 | 41 | coltowrite=fcol; |
cstevens | 1:b4ae6047d590 | 42 | } else { |
cstevens | 1:b4ae6047d590 | 43 | coltowrite=bcol; |
cstevens | 1:b4ae6047d590 | 44 | } |
cstevens | 0:92feefa9d5ba | 45 | |
cstevens | 1:b4ae6047d590 | 46 | MyLCD.vLCDTFTPoint(x,y,coltowrite); |
cstevens | 1:b4ae6047d590 | 47 | |
cstevens | 1:b4ae6047d590 | 48 | } |
cstevens | 0:92feefa9d5ba | 49 | } |
cstevens | 0:92feefa9d5ba | 50 | |
cstevens | 1:b4ae6047d590 | 51 | } |
cstevens | 1:b4ae6047d590 | 52 | |
cstevens | 1:b4ae6047d590 | 53 | |
cstevens | 1:b4ae6047d590 | 54 | |
cstevens | 1:b4ae6047d590 | 55 | |
cstevens | 1:b4ae6047d590 | 56 | int main() |
cstevens | 1:b4ae6047d590 | 57 | { |
cstevens | 1:b4ae6047d590 | 58 | int i,j; |
cstevens | 1:b4ae6047d590 | 59 | char message[10]; |
cstevens | 1:b4ae6047d590 | 60 | sprintf(message,"Hello!!"); |
cstevens | 1:b4ae6047d590 | 61 | while(1) { |
cstevens | 1:b4ae6047d590 | 62 | |
cstevens | 1:b4ae6047d590 | 63 | MyLCD.vLCDTFTInit(1); |
cstevens | 1:b4ae6047d590 | 64 | |
cstevens | 1:b4ae6047d590 | 65 | MyLCD.vLCDTFTFillScreen(ColorWhite); |
cstevens | 1:b4ae6047d590 | 66 | |
cstevens | 1:b4ae6047d590 | 67 | for(i=0; i<200; i++) { |
cstevens | 1:b4ae6047d590 | 68 | MyLCD.vLCDTFTPoint(50+i,100,ColorRed); |
cstevens | 1:b4ae6047d590 | 69 | } |
cstevens | 1:b4ae6047d590 | 70 | for(j=0; j<10; j++) { |
cstevens | 1:b4ae6047d590 | 71 | for(i=0; i<10; i++) { |
cstevens | 1:b4ae6047d590 | 72 | prettyputc(32+(i+j*10)%90,Arial24x23,24*i,23*j ,ColorWhite, ColorGreen); |
cstevens | 1:b4ae6047d590 | 73 | wait(0.03); |
cstevens | 1:b4ae6047d590 | 74 | } |
cstevens | 1:b4ae6047d590 | 75 | } |
cstevens | 1:b4ae6047d590 | 76 | wait(5); |
cstevens | 1:b4ae6047d590 | 77 | for(j=0; j<10; j++) { |
cstevens | 1:b4ae6047d590 | 78 | for(i=0; i<10; i++) { |
cstevens | 1:b4ae6047d590 | 79 | prettyputc(32+(i+j*10)%90,Arial12x12,12*i,12*j ,ColorWhite, ColorBlue); |
cstevens | 1:b4ae6047d590 | 80 | wait(0.03); |
cstevens | 1:b4ae6047d590 | 81 | } |
cstevens | 1:b4ae6047d590 | 82 | } |
cstevens | 1:b4ae6047d590 | 83 | wait(5); |
cstevens | 1:b4ae6047d590 | 84 | for(j=0; j<10; j++) { |
cstevens | 1:b4ae6047d590 | 85 | for(i=0; i<10; i++) { |
cstevens | 1:b4ae6047d590 | 86 | prettyputc(32+(i+j*10)%90,Arial28x28,28*i,28*j ,ColorWhite, ColorRed); |
cstevens | 1:b4ae6047d590 | 87 | wait(0.03); |
cstevens | 1:b4ae6047d590 | 88 | } |
cstevens | 1:b4ae6047d590 | 89 | } |
cstevens | 1:b4ae6047d590 | 90 | wait(5); |
cstevens | 1:b4ae6047d590 | 91 | |
cstevens | 1:b4ae6047d590 | 92 | }// endwhile |
cstevens | 1:b4ae6047d590 | 93 | } //endmain |