Demo code and library for teh SSD0139 screen on an arduino header For Oxford University Engineering Coursework Module

Dependencies:   LCDTFT_ssd0139 mbed

Committer:
cstevens
Date:
Mon Jun 06 13:40:16 2016 +0000
Revision:
1:e783e326d127
Parent:
0:92feefa9d5ba
library and demo code for tft ssd0139 controller on a 240x320 screen

Who changed what in which revision?

UserRevisionLine numberNew contents of line
cstevens 0:92feefa9d5ba 1 #include "mbed.h"
cstevens 0:92feefa9d5ba 2 #include "LCDTFT.h"
cstevens 0:92feefa9d5ba 3
cstevens 1:e783e326d127 4
cstevens 1:e783e326d127 5 BusOut MyBus(PTA13,PTD5,PTD4,PTA12,PTA4,PTA5,PTC8,PTC9); // 8 bit bus on these dvices
cstevens 0:92feefa9d5ba 6 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);
cstevens 0:92feefa9d5ba 7
cstevens 0:92feefa9d5ba 8 int main(){
cstevens 0:92feefa9d5ba 9 while(1){
cstevens 0:92feefa9d5ba 10 //landscape ?
cstevens 0:92feefa9d5ba 11 MyLCD.vLCDTFTInit(1);
cstevens 0:92feefa9d5ba 12
cstevens 1:e783e326d127 13 MyLCD.vLCDTFTFillScreen(ColorWhite);
cstevens 1:e783e326d127 14 MyLCD.vLCDTFTSetParametersPrintf(3,3,3,300,2,ColorBlue,ColorWhite);
cstevens 1:e783e326d127 15 MyLCD.printf("Dive Profile");
cstevens 1:e783e326d127 16 MyLCD.vLCDTFTRectangle(30,40,315,200,0,ColorBlack);
cstevens 1:e783e326d127 17 int a=0;
cstevens 1:e783e326d127 18 int depth=0;
cstevens 1:e783e326d127 19 short int x,y;
cstevens 1:e783e326d127 20 //dummy profile
cstevens 1:e783e326d127 21 for(a=1;a<279;a++){
cstevens 1:e783e326d127 22 depth=40+5.5*16*sin(a*a*3.14/280/280);
cstevens 1:e783e326d127 23 MyLCD.vLCDTFTLine(a+30,depth,a+30,41,ColorCian);
cstevens 1:e783e326d127 24 MyLCD.vLCDTFTPoint(a+30,depth,ColorBlue);
cstevens 1:e783e326d127 25 }
cstevens 1:e783e326d127 26 //tics
cstevens 1:e783e326d127 27 for(a=0;a<10;a++)
cstevens 1:e783e326d127 28 { if(a>0)
cstevens 1:e783e326d127 29 {
cstevens 1:e783e326d127 30 MyLCD.vLCDTFTLine(40,40+a*16,315,40+a*16,ColorNavy);
cstevens 1:e783e326d127 31 MyLCD.vLCDTFTLine(30+a*28,50,30+a*28,200,ColorNavy);
cstevens 1:e783e326d127 32 }
cstevens 1:e783e326d127 33 MyLCD.vLCDTFTLine(30,40+a*16,40,40+a*16,ColorBlack);
cstevens 1:e783e326d127 34 MyLCD.vLCDTFTLine(30+a*28,40,30+a*28,50,ColorBlack);
cstevens 1:e783e326d127 35
cstevens 1:e783e326d127 36 MyLCD.vLCDTFTSetParametersPrintf(3,40+a*16-3,3,28,1,ColorRed,ColorWhite);
cstevens 1:e783e326d127 37 MyLCD.printf("%d",a*5);
cstevens 1:e783e326d127 38 MyLCD.vLCDTFTSetParametersPrintf(30+a*28-3,30,30+a*28-3,319,1,ColorRed,ColorWhite);
cstevens 1:e783e326d127 39 MyLCD.printf("%d",a*5);
cstevens 1:e783e326d127 40 }
cstevens 1:e783e326d127 41 a=200;
cstevens 1:e783e326d127 42 x=a+30;
cstevens 1:e783e326d127 43 y=40+5.5*16*sin(a*a*3.14/280/280);
cstevens 1:e783e326d127 44 MyLCD.vLCDTFTCircle(200,y-6,6,1,ColorNaranja);
cstevens 1:e783e326d127 45
cstevens 1:e783e326d127 46 wait(10);
cstevens 0:92feefa9d5ba 47
cstevens 0:92feefa9d5ba 48
cstevens 0:92feefa9d5ba 49
cstevens 0:92feefa9d5ba 50 MyLCD.vLCDTFTFillScreen(ColorBlack);
cstevens 0:92feefa9d5ba 51 MyLCD.vLCDTFTRectangle(3,3,319,157,0,ColorWhite);
cstevens 0:92feefa9d5ba 52
cstevens 0:92feefa9d5ba 53 wait(1);
cstevens 0:92feefa9d5ba 54 MyLCD.vLCDTFTSetParametersPrintf(8,8,8,155,3,ColorLime,ColorBlack);
cstevens 0:92feefa9d5ba 55 MyLCD.printf("PPO2:\n 1.21\n 1.18\n 1.20");
cstevens 0:92feefa9d5ba 56 MyLCD.vLCDTFTSetParametersPrintf(110,8,110,233,3,ColorCian,ColorBlack);
cstevens 0:92feefa9d5ba 57 MyLCD.printf("fO2 %%:\n 27.3\n 26.5\n 27.1");
cstevens 0:92feefa9d5ba 58 wait(5);
cstevens 0:92feefa9d5ba 59
cstevens 0:92feefa9d5ba 60 //portrait
cstevens 0:92feefa9d5ba 61 MyLCD.vLCDTFTInit(0);
cstevens 0:92feefa9d5ba 62 wait(1);
cstevens 0:92feefa9d5ba 63 MyLCD.vLCDTFTFillScreen(ColorWhite);
cstevens 0:92feefa9d5ba 64 wait(2);
cstevens 1:e783e326d127 65
cstevens 0:92feefa9d5ba 66 y=250;
cstevens 0:92feefa9d5ba 67 for(x=0;x<240;x++){
cstevens 0:92feefa9d5ba 68 MyLCD.vLCDTFTPoint(x,y,ColorGreen);
cstevens 0:92feefa9d5ba 69 wait_ms(1);
cstevens 1:e783e326d127 70 MyLCD.vLCDTFTLine(x,160,x,250,x*80);
cstevens 0:92feefa9d5ba 71 } //endfor
cstevens 0:92feefa9d5ba 72
cstevens 0:92feefa9d5ba 73 // red square
cstevens 0:92feefa9d5ba 74 for(x=100;x<140;x++){
cstevens 0:92feefa9d5ba 75 for(y=100;y<140;y++){
cstevens 0:92feefa9d5ba 76 MyLCD.vLCDTFTPoint(x,y,ColorRed);
cstevens 0:92feefa9d5ba 77
cstevens 0:92feefa9d5ba 78 }//endfor
cstevens 0:92feefa9d5ba 79
cstevens 0:92feefa9d5ba 80
cstevens 0:92feefa9d5ba 81 } // endfor
cstevens 0:92feefa9d5ba 82 x=40;
cstevens 0:92feefa9d5ba 83 for(y=0;y<320;y++){
cstevens 0:92feefa9d5ba 84 MyLCD.vLCDTFTPoint(x,y,ColorBlue);
cstevens 0:92feefa9d5ba 85 wait_ms(1);
cstevens 0:92feefa9d5ba 86 } //endfor
cstevens 0:92feefa9d5ba 87 y=40;
cstevens 0:92feefa9d5ba 88 for(x=0;x<240;x++){
cstevens 0:92feefa9d5ba 89 MyLCD.vLCDTFTPoint(x,y,ColorBlue);
cstevens 0:92feefa9d5ba 90 wait_ms(1);
cstevens 0:92feefa9d5ba 91 } //endfor
cstevens 0:92feefa9d5ba 92
cstevens 0:92feefa9d5ba 93 MyLCD.vLCDTFTLine(0,0,239,319,ColorPurple);
cstevens 0:92feefa9d5ba 94
cstevens 0:92feefa9d5ba 95 wait(1);
cstevens 0:92feefa9d5ba 96 MyLCD.vLCDTFTRectangle(50,200,150,300,0,ColorNaranja);
cstevens 0:92feefa9d5ba 97
cstevens 0:92feefa9d5ba 98 MyLCD.vLCDTFTRectangle(55,205,145,295,1,ColorYellow);
cstevens 0:92feefa9d5ba 99
cstevens 0:92feefa9d5ba 100 MyLCD.vLCDTFTSetParametersPrintf(5,155,5,239,2,ColorBlue,ColorWhite);
cstevens 0:92feefa9d5ba 101 MyLCD.printf("Hello mbed!!!");
cstevens 0:92feefa9d5ba 102
cstevens 0:92feefa9d5ba 103 wait(3);
cstevens 0:92feefa9d5ba 104 MyLCD.vLCDTFTFillScreen(ColorBlack);
cstevens 0:92feefa9d5ba 105 MyLCD.vLCDTFTRectangle(3,3,236,157,0,ColorWhite);
cstevens 0:92feefa9d5ba 106 MyLCD.vLCDTFTRectangle(4,4,235,156,0,ColorWhite);
cstevens 0:92feefa9d5ba 107 wait(1);
cstevens 0:92feefa9d5ba 108 MyLCD.vLCDTFTSetParametersPrintf(8,8,8,155,3,ColorLime,ColorBlack);
cstevens 0:92feefa9d5ba 109 MyLCD.printf("PPO2:\n 1.21\n 1.18\n 1.20");
cstevens 0:92feefa9d5ba 110 MyLCD.vLCDTFTSetParametersPrintf(110,8,110,233,3,ColorCian,ColorBlack);
cstevens 0:92feefa9d5ba 111 MyLCD.printf("fO2 %%:\n 27.3\n 26.5\n 27.1");
cstevens 0:92feefa9d5ba 112
cstevens 0:92feefa9d5ba 113 MyLCD.vLCDTFTSetParametersPrintf(30,200,30,233,2,ColorRed,ColorBlack);
cstevens 0:92feefa9d5ba 114 MyLCD.printf("Countdown\n");
cstevens 1:e783e326d127 115
cstevens 0:92feefa9d5ba 116 for(a=10;a>0;a--){
cstevens 0:92feefa9d5ba 117 MyLCD.vLCDTFTSetParametersPrintf(30,260,30,233,2,ColorRed,ColorBlack);
cstevens 0:92feefa9d5ba 118 MyLCD.printf("%d ",a);
cstevens 0:92feefa9d5ba 119 wait(1);
cstevens 0:92feefa9d5ba 120
cstevens 0:92feefa9d5ba 121 } // endfor
cstevens 0:92feefa9d5ba 122
cstevens 0:92feefa9d5ba 123
cstevens 0:92feefa9d5ba 124
cstevens 0:92feefa9d5ba 125
cstevens 0:92feefa9d5ba 126
cstevens 0:92feefa9d5ba 127 //landscape ?
cstevens 0:92feefa9d5ba 128 MyLCD.vLCDTFTInit(1);
cstevens 0:92feefa9d5ba 129
cstevens 0:92feefa9d5ba 130 MyLCD.vLCDTFTFillScreen(ColorWhite);
cstevens 0:92feefa9d5ba 131
cstevens 0:92feefa9d5ba 132
cstevens 0:92feefa9d5ba 133 MyLCD.vLCDTFTFillScreen(ColorWhite);
cstevens 0:92feefa9d5ba 134 MyLCD.vLCDTFTRectangle(3,3,315,157,0,ColorNavy);
cstevens 0:92feefa9d5ba 135
cstevens 0:92feefa9d5ba 136 wait(1);
cstevens 0:92feefa9d5ba 137 MyLCD.vLCDTFTSetParametersPrintf(8,8,8,155,3,ColorGreen,ColorWhite);
cstevens 0:92feefa9d5ba 138 MyLCD.printf("PPO2:\n 1.21\n 1.18\n 1.20");
cstevens 0:92feefa9d5ba 139 MyLCD.vLCDTFTSetParametersPrintf(110,8,110,233,3,ColorBlue,ColorWhite);
cstevens 0:92feefa9d5ba 140 MyLCD.printf("fO2 %%:\n 27.3\n 26.5\n 27.1");
cstevens 0:92feefa9d5ba 141 wait(5);
cstevens 0:92feefa9d5ba 142
cstevens 0:92feefa9d5ba 143 }// endwhile
cstevens 0:92feefa9d5ba 144 } //endmain