Library to calculate movement and to draw the objects in the pong game

Dependencies:   RTC-DS1307 SPI_TFT_ILI9341 TFT_fonts mbed

Fork of MainSketch by IoT Ox

Committer:
cstevens
Date:
Thu Jun 09 16:19:10 2016 +0000
Revision:
5:424af4fa03ab
Parent:
4:14043cafbec7
Child:
6:18c7288b5e00
working demo;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
cstevens 4:14043cafbec7 1 // example to test the TFT Display from Mikroelectronika
dreschpe 0:7c3b9bfd6ead 2
dreschpe 0:7c3b9bfd6ead 3 #include "stdio.h"
dreschpe 0:7c3b9bfd6ead 4 #include "mbed.h"
dreschpe 0:7c3b9bfd6ead 5 #include "SPI_TFT_ILI9341.h"
dreschpe 0:7c3b9bfd6ead 6 #include "string"
dreschpe 0:7c3b9bfd6ead 7 #include "Arial12x12.h"
dreschpe 0:7c3b9bfd6ead 8 #include "Arial24x23.h"
dreschpe 0:7c3b9bfd6ead 9 #include "Arial28x28.h"
dreschpe 0:7c3b9bfd6ead 10 #include "font_big.h"
cstevens 4:14043cafbec7 11
dreschpe 0:7c3b9bfd6ead 12
cstevens 4:14043cafbec7 13
dreschpe 0:7c3b9bfd6ead 14
dreschpe 0:7c3b9bfd6ead 15
pegcjs 3:676adf84c914 16
dreschpe 0:7c3b9bfd6ead 17
dreschpe 0:7c3b9bfd6ead 18 // the display has a backlight switch on board
cstevens 5:424af4fa03ab 19 DigitalOut LCD_LED(PTA13); // may not be needed on mikroelectronika board
cstevens 5:424af4fa03ab 20 DigitalOut pwr(PTD7); // ditto
dreschpe 0:7c3b9bfd6ead 21
dreschpe 0:7c3b9bfd6ead 22 // the TFT is connected to SPI pin 5-7
pegcjs 1:e0479f60cd48 23 //SPI_TFT_ILI9341 TFT(p5, p6, p7, p8, p9, p10,"TFT"); // mosi, miso, sclk, cs, reset, dc for lpc1768
cstevens 5:424af4fa03ab 24 SPI_TFT_ILI9341 TFT(PTD2, PTD3, PTD1, PTD5, PTD0, PTA13,"TFT"); // mosi, miso, sclk, cs, reset, dc for frdmkl25z
pegcjs 3:676adf84c914 25 //NB better combination to use a coherent 2x4 block for lcd
pegcjs 3:676adf84c914 26 // SPI_TFT_ILI9341 TFT(PTD2, PTD3, PTD1, PTA16, PTA17, PTC16,"TFT"); // mosi, miso, sclk, cs, reset, dc for frdmkl25z
pegcjs 3:676adf84c914 27 // DigitalOut LCD_LED(PTC17);
cstevens 4:14043cafbec7 28
dreschpe 0:7c3b9bfd6ead 29 int main()
dreschpe 0:7c3b9bfd6ead 30 {
pegcjs 3:676adf84c914 31 pwr=1;
pegcjs 3:676adf84c914 32 wait(0.2);
pegcjs 1:e0479f60cd48 33 while(1){
dreschpe 0:7c3b9bfd6ead 34 int i;
pegcjs 2:25bfb21253a6 35 LCD_LED = 1; // backlight on
dreschpe 0:7c3b9bfd6ead 36
dreschpe 0:7c3b9bfd6ead 37 TFT.claim(stdout); // send stdout to the TFT display
dreschpe 0:7c3b9bfd6ead 38 TFT.set_orientation(1);
dreschpe 0:7c3b9bfd6ead 39 TFT.background(Black); // set background to black
dreschpe 0:7c3b9bfd6ead 40 TFT.foreground(White); // set chars to white
dreschpe 0:7c3b9bfd6ead 41 TFT.cls(); // clear the screen
dreschpe 0:7c3b9bfd6ead 42
dreschpe 0:7c3b9bfd6ead 43 //first show the 4 directions
dreschpe 0:7c3b9bfd6ead 44 TFT.set_orientation(0);
dreschpe 0:7c3b9bfd6ead 45 TFT.background(Black);
dreschpe 0:7c3b9bfd6ead 46 TFT.cls();
dreschpe 0:7c3b9bfd6ead 47
dreschpe 0:7c3b9bfd6ead 48 TFT.set_font((unsigned char*) Arial12x12);
dreschpe 0:7c3b9bfd6ead 49 TFT.locate(0,0);
dreschpe 0:7c3b9bfd6ead 50 printf(" Hello Mbed 0");
dreschpe 0:7c3b9bfd6ead 51 TFT.set_orientation(1);
dreschpe 0:7c3b9bfd6ead 52 TFT.locate(0,0);
dreschpe 0:7c3b9bfd6ead 53 printf(" Hello Mbed 1");
dreschpe 0:7c3b9bfd6ead 54 TFT.set_orientation(2);
dreschpe 0:7c3b9bfd6ead 55 TFT.locate(0,0);
dreschpe 0:7c3b9bfd6ead 56 printf(" Hello Mbed 2");
dreschpe 0:7c3b9bfd6ead 57 TFT.set_orientation(3);
dreschpe 0:7c3b9bfd6ead 58 TFT.locate(0,0);
dreschpe 0:7c3b9bfd6ead 59 printf(" Hello Mbed 3");
pegcjs 1:e0479f60cd48 60 TFT.set_orientation(3);
dreschpe 0:7c3b9bfd6ead 61 TFT.set_font((unsigned char*) Arial24x23);
dreschpe 0:7c3b9bfd6ead 62 TFT.locate(50,100);
dreschpe 0:7c3b9bfd6ead 63 TFT.printf("TFT orientation");
dreschpe 0:7c3b9bfd6ead 64
pegcjs 1:e0479f60cd48 65 wait(1); // wait two seconds
pegcjs 1:e0479f60cd48 66 TFT.cls();
pegcjs 1:e0479f60cd48 67 LCD_LED = 1;
pegcjs 1:e0479f60cd48 68 TFT.set_font((unsigned char*) Arial12x12);
pegcjs 1:e0479f60cd48 69 TFT.locate(1,10);
pegcjs 1:e0479f60cd48 70 TFT.foreground(Green);
pegcjs 1:e0479f60cd48 71 TFT.printf("Depth Max Depth Dive Time");
pegcjs 1:e0479f60cd48 72 TFT.locate(1,24);
pegcjs 1:e0479f60cd48 73 TFT.foreground(White);
pegcjs 1:e0479f60cd48 74 TFT.set_font((unsigned char*) Arial28x28);
pegcjs 1:e0479f60cd48 75 TFT.printf("32.4m");
pegcjs 1:e0479f60cd48 76
pegcjs 1:e0479f60cd48 77 TFT.locate(130,24);
pegcjs 1:e0479f60cd48 78 TFT.foreground(White);
pegcjs 1:e0479f60cd48 79 TFT.set_font((unsigned char*) Arial24x23);
pegcjs 1:e0479f60cd48 80 TFT.printf("45.6m");
pegcjs 1:e0479f60cd48 81 TFT.locate(240,24);
pegcjs 1:e0479f60cd48 82 TFT.printf("37'");
pegcjs 1:e0479f60cd48 83
pegcjs 1:e0479f60cd48 84 TFT.locate(1,70);
pegcjs 1:e0479f60cd48 85 TFT.set_font((unsigned char*) Arial12x12);
pegcjs 1:e0479f60cd48 86 TFT.foreground(Green);
pegcjs 1:e0479f60cd48 87 TFT.printf("ppO2:\nSensor 1 Sensor 2 Sensor 3");
pegcjs 1:e0479f60cd48 88
pegcjs 1:e0479f60cd48 89 TFT.locate(1,100);
pegcjs 1:e0479f60cd48 90 TFT.foreground(White);
pegcjs 1:e0479f60cd48 91 TFT.set_font((unsigned char*) Arial28x28);
pegcjs 1:e0479f60cd48 92 TFT.printf("1.21 1.21 1.21");
pegcjs 1:e0479f60cd48 93 wait(10);
pegcjs 1:e0479f60cd48 94
cstevens 4:14043cafbec7 95
pegcjs 1:e0479f60cd48 96 }
pegcjs 1:e0479f60cd48 97
dreschpe 0:7c3b9bfd6ead 98 }