Oxford CWM Team / Mbed 2 deprecated TFT_CJS_ssd01399_portver_prettyfont

Dependencies:   LCDTFT TFT_fonts mbed

Files at this revision

API Documentation at this revision

Comitter:
cstevens
Date:
Fri Jun 12 09:05:58 2015 +0000
Parent:
0:92feefa9d5ba
Child:
2:1bc1605bffae
Commit message:
pretty font putc versoin;

Changed in this revision

LCDTFT.lib Show annotated file Show diff for this revision Revisions of this file
TFT_fonts.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/LCDTFT.lib	Tue Sep 02 09:02:37 2014 +0000
+++ b/LCDTFT.lib	Fri Jun 12 09:05:58 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/Suky/code/LCDTFT/#ebedda77b33b
+http://developer.mbed.org/users/cstevens/code/LCDTFT_ssd01399/#290d9f5dd5e8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TFT_fonts.lib	Fri Jun 12 09:05:58 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/dreschpe/code/TFT_fonts/#76774250fcec
--- a/main.cpp	Tue Sep 02 09:02:37 2014 +0000
+++ b/main.cpp	Fri Jun 12 09:05:58 2015 +0000
@@ -1,113 +1,93 @@
 #include "mbed.h"
-  #include "LCDTFT.h"
-  
- //BusOut     MyBus(p13,p14,p15,p16,p17,p18,p19,p20,p30,p29,p28,p27,p26,p25,p24,p23);
- BusOut MyBus(PTA13,PTD5,PTD4,PTA12,PTA4,PTA5,PTC8,PTC9);
- LCDTFT     MyLCD(PTB0,PTB1,PTB2,PTB3,PTC2,&MyBus);//LCDTFT(PinName PIN_RD,PinName PIN_WR,PinName PIN_RS,PinName PIN_CS,PinName PIN_RESET, BusOut *BUSLCD);
- 
- int main(){
-  while(1){
-  //landscape ?
-         MyLCD.vLCDTFTInit(1);
-         
-     
-     
-      
-      MyLCD.vLCDTFTFillScreen(ColorBlack);
-      MyLCD.vLCDTFTRectangle(3,3,319,157,0,ColorWhite);
-    
-      wait(1);
-      MyLCD.vLCDTFTSetParametersPrintf(8,8,8,155,3,ColorLime,ColorBlack);
-      MyLCD.printf("PPO2:\n 1.21\n 1.18\n 1.20");
-      MyLCD.vLCDTFTSetParametersPrintf(110,8,110,233,3,ColorCian,ColorBlack);
-      MyLCD.printf("fO2 %%:\n 27.3\n 26.5\n 27.1"); 
-wait(5);
+#include "LCDTFT.h"
+#include "Arial12x12.h"
+#include "Arial24x23.h"
+#include "Arial28x28.h"
+#include "font_big.h"
 
-//portrait
-            MyLCD.vLCDTFTInit(0);
-     wait(1);
-     MyLCD.vLCDTFTFillScreen(ColorWhite);
-     wait(2);
-        short int x,y;
-        y=250;
-         for(x=0;x<240;x++){
-               MyLCD.vLCDTFTPoint(x,y,ColorGreen);
-               wait_ms(1);
-         } //endfor
+//BusOut MyBus(PTA13,PTD5,PTD4,PTA12,PTA4,PTA5,PTC8,PTC9); // 8 bit bus on these dvices
+
+
+PortOut MyPort(PortD ,0xFF); // define a port with only the lower 8 bits included - that'llbe PTD0-PTD7 making a single 8 bit port.
+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);
+
+
 
-  // red square
-     for(x=100;x<140;x++){
-         for(y=100;y<140;y++){
-               MyLCD.vLCDTFTPoint(x,y,ColorRed);
-            
-             }//endfor
-         
-         
-         } // endfor
-         x=40;
-         for(y=0;y<320;y++){
-               MyLCD.vLCDTFTPoint(x,y,ColorBlue);
-               wait_ms(1);
-         } //endfor
-         y=40;
-         for(x=0;x<240;x++){
-               MyLCD.vLCDTFTPoint(x,y,ColorBlue);
-               wait_ms(1);
-         } //endfor
-         
-      MyLCD.vLCDTFTLine(0,0,239,319,ColorPurple);
-      
-      wait(1);
-      MyLCD.vLCDTFTRectangle(50,200,150,300,0,ColorNaranja);
-      
-      MyLCD.vLCDTFTRectangle(55,205,145,295,1,ColorYellow);
-      
-      MyLCD.vLCDTFTSetParametersPrintf(5,155,5,239,2,ColorBlue,ColorWhite);
-      MyLCD.printf("Hello mbed!!!");
-      
-      wait(3);
-      MyLCD.vLCDTFTFillScreen(ColorBlack);
-      MyLCD.vLCDTFTRectangle(3,3,236,157,0,ColorWhite);
-      MyLCD.vLCDTFTRectangle(4,4,235,156,0,ColorWhite);
-      wait(1);
-      MyLCD.vLCDTFTSetParametersPrintf(8,8,8,155,3,ColorLime,ColorBlack);
-      MyLCD.printf("PPO2:\n 1.21\n 1.18\n 1.20");
-      MyLCD.vLCDTFTSetParametersPrintf(110,8,110,233,3,ColorCian,ColorBlack);
-      MyLCD.printf("fO2 %%:\n 27.3\n 26.5\n 27.1");    
-      
-         MyLCD.vLCDTFTSetParametersPrintf(30,200,30,233,2,ColorRed,ColorBlack);
-         MyLCD.printf("Countdown\n"); 
-    int a=0;
-    for(a=10;a>0;a--){
-          MyLCD.vLCDTFTSetParametersPrintf(30,260,30,233,2,ColorRed,ColorBlack);
-      MyLCD.printf("%d ",a); 
-      wait(1);
-      
-      } // endfor
-      
-      
-     
-   
-   
-    //landscape ?
-         MyLCD.vLCDTFTInit(1);
-         
-        MyLCD.vLCDTFTFillScreen(ColorWhite);
-     
-      
-      MyLCD.vLCDTFTFillScreen(ColorWhite);
-      MyLCD.vLCDTFTRectangle(3,3,315,157,0,ColorNavy);
-    
-      wait(1);
-      MyLCD.vLCDTFTSetParametersPrintf(8,8,8,155,3,ColorGreen,ColorWhite);
-      MyLCD.printf("PPO2:\n 1.21\n 1.18\n 1.20");
-      MyLCD.vLCDTFTSetParametersPrintf(110,8,110,233,3,ColorBlue,ColorWhite);
-      MyLCD.printf("fO2 %%:\n 27.3\n 26.5\n 27.1"); 
-wait(5);
+// ok - a simple sub to put in a character from the fonts defined in TFT_fonts
+// c= charactetr to put
+// font = pointer to font to use
+// x,y locatoin of bottom lh of character, bcol = background color, fcol = foreground color
+void prettyputc(char c, const unsigned char *font,short xpos,short ypos,short bcol, short fcol)
+{
+    // Length,horz,vert,byte/vert
+    int length,hor,vert,bpver; // number of bytes per character, horizontal pixels, vertical pixels and bytes per column
+    //
+    int x,y,i,j,k,ptr;
+    short coltowrite;
+    char byte,point;
+    length=font[0];
+    hor=font[1];
+    vert=font[2];
+    bpver=font[3];
+    for(i=0; i<hor; i++) { // loop over columns
+        for(j=0; j<vert; j++) {
+            x=xpos+i;
+            y=ypos+j; // NB assumes colums stored from bottom to top.... ?
+            ptr=((c -32) * length+1) + 4+i*bpver+(j/8);  // pointer in font array to start of the character we want
+            byte=(char)font[ptr];
+            k=j%8; // number of the pixel in this byte
+            point=byte & (1<<k); // get the next bit
+            if(point>0) {
+                coltowrite=fcol;
+            } else {
+                coltowrite=bcol;
+            }
 
-for(a=0;a<320;a++){
-    MyLCD.vLCDTFTPoint(a,180,ColorBlue);
+            MyLCD.vLCDTFTPoint(x,y,coltowrite);
+
+        }
     }
 
- }// endwhile
- } //endmain
\ No newline at end of file
+}
+
+
+
+
+int main()
+{
+    int i,j;
+    char message[10];
+    sprintf(message,"Hello!!");
+    while(1) {
+
+        MyLCD.vLCDTFTInit(1);
+
+        MyLCD.vLCDTFTFillScreen(ColorWhite);
+
+        for(i=0; i<200; i++) {
+            MyLCD.vLCDTFTPoint(50+i,100,ColorRed);
+        }
+        for(j=0; j<10; j++) {
+            for(i=0; i<10; i++) {
+                prettyputc(32+(i+j*10)%90,Arial24x23,24*i,23*j ,ColorWhite, ColorGreen);
+                wait(0.03);
+            }
+        }
+        wait(5);
+        for(j=0; j<10; j++) {
+            for(i=0; i<10; i++) {
+                prettyputc(32+(i+j*10)%90,Arial12x12,12*i,12*j ,ColorWhite, ColorBlue);
+                wait(0.03);
+            }
+        }
+        wait(5);
+        for(j=0; j<10; j++) {
+            for(i=0; i<10; i++) {
+                prettyputc(32+(i+j*10)%90,Arial28x28,28*i,28*j ,ColorWhite, ColorRed);
+                wait(0.03);
+            }
+        }
+        wait(5);
+
+    }// endwhile
+} //endmain
\ No newline at end of file
--- a/mbed.bld	Tue Sep 02 09:02:37 2014 +0000
+++ b/mbed.bld	Fri Jun 12 09:05:58 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/0b3ab51c8877
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/7cff1c4259d7
\ No newline at end of file