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

Dependencies:   LCDTFT_ssd0139 mbed

main.cpp

Committer:
cstevens
Date:
2016-06-06
Revision:
1:e783e326d127
Parent:
0:92feefa9d5ba

File content as of revision 1:e783e326d127:

#include "mbed.h"
  #include "LCDTFT.h"
  

 BusOut MyBus(PTA13,PTD5,PTD4,PTA12,PTA4,PTA5,PTC8,PTC9); // 8 bit bus on these dvices
 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(ColorWhite);
        MyLCD.vLCDTFTSetParametersPrintf(3,3,3,300,2,ColorBlue,ColorWhite);
      MyLCD.printf("Dive Profile"); 
   MyLCD.vLCDTFTRectangle(30,40,315,200,0,ColorBlack);
int a=0;
       int depth=0;
              short int x,y;
    //dummy profile
    for(a=1;a<279;a++){
        depth=40+5.5*16*sin(a*a*3.14/280/280);
        MyLCD.vLCDTFTLine(a+30,depth,a+30,41,ColorCian);
        MyLCD.vLCDTFTPoint(a+30,depth,ColorBlue);
        }
  //tics
   for(a=0;a<10;a++)
   {    if(a>0)
   {
        MyLCD.vLCDTFTLine(40,40+a*16,315,40+a*16,ColorNavy);
          MyLCD.vLCDTFTLine(30+a*28,50,30+a*28,200,ColorNavy);
        }
        MyLCD.vLCDTFTLine(30,40+a*16,40,40+a*16,ColorBlack);
        MyLCD.vLCDTFTLine(30+a*28,40,30+a*28,50,ColorBlack);
      
        MyLCD.vLCDTFTSetParametersPrintf(3,40+a*16-3,3,28,1,ColorRed,ColorWhite);
      MyLCD.printf("%d",a*5); 
             MyLCD.vLCDTFTSetParametersPrintf(30+a*28-3,30,30+a*28-3,319,1,ColorRed,ColorWhite);
      MyLCD.printf("%d",a*5); 
       }
     a=200;
     x=a+30;
     y=40+5.5*16*sin(a*a*3.14/280/280);
       MyLCD.vLCDTFTCircle(200,y-6,6,1,ColorNaranja);
       
       wait(10);
     
     
      
      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);

//portrait
            MyLCD.vLCDTFTInit(0);
     wait(1);
     MyLCD.vLCDTFTFillScreen(ColorWhite);
     wait(2);
 
        y=250;
         for(x=0;x<240;x++){
               MyLCD.vLCDTFTPoint(x,y,ColorGreen);
               wait_ms(1);
               MyLCD.vLCDTFTLine(x,160,x,250,x*80);
         } //endfor

  // 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"); 
    
    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);

 }// endwhile
 } //endmain