pong game added to the main sketch
Dependencies: RTC-DS1307 SPI_TFT_ILI9341 TFT_fonts mbed tsi_sensor
Fork of MainSketch by
render.h
00001 00002 #include "string" 00003 #include "Arial12x12.h" 00004 #include "Arial24x23.h" 00005 #include "Arial28x28.h" 00006 #include "font_big.h" 00007 00008 00009 00010 void drawbuttons() 00011 { 00012 TFT.fillrect(0, 0, 50, 50, Red); 00013 TFT.fillrect(0, 50, 50, 100, Green); 00014 TFT.fillrect(0, 100, 50, 150, Blue); 00015 TFT.fillrect(0, 150, 50, 200, White); 00016 TFT.fillrect(0, 200, 50, 250, Black); 00017 00018 TFT.rect(0, 0, 50, 50, White); 00019 TFT.rect(0, 50, 50, 100, White); 00020 TFT.rect(0, 100, 50, 150, White); 00021 TFT.rect(0, 150, 50, 200, White); 00022 TFT.rect(0, 200, 50, 250, White); 00023 } 00024 void draw_clockface(int x0, int y0, int r, int markerlength, int color) 00025 { 00026 TFT.circle(x0, y0, r, White); 00027 //for ( int n = 0; n < 13; n++) { 00028 // int x1, y1, x2, y2= 0; 00029 // double angle = n * 2 * M_PI / 12; 00030 // x2 = r * cos(angle) + x0; 00031 // y2 = r * sin(angle) + y0; 00032 // x1 = (r - markerlength) * cos(angle) + x0; 00033 // y2 = (r - markerlength) * sin(angle) + y0; 00034 // TFT.line(x1, y1, x2, y2, color); 00035 //} 00036 } 00037 void whiteboard() 00038 { 00039 int color = 0; 00040 int xpos = 0,ypos = 0,xp = 0,yp = 0,sw = 0;; 00041 drawbuttons(); 00042 bool running = true; 00043 while(running) { 00044 00045 xp = readX(); 00046 yp = readY(); 00047 // top chunk of the screen is the button area // 00048 // 0<y<50 is palette area // 00049 00050 //pc.printf("xpos=%d\t,\typo=%d",xpos,ypos); 00051 // xp=(240*(xpos-5800))/51200; 00052 // yp=320-(320*(ypos-3000))/58300; 00053 if(touching == 1) pc.printf("\txp=%d\t,\typo=%d\n\r", xp, yp); 00054 if(xp > 5 && yp > 50 && touching == 1) TFT.fillcircle(yp, xp, 2, color); 00055 if(yp < 50) { // color buttons 00056 sw = (int)xp / 50; 00057 switch(sw) { 00058 case 0: 00059 color = 0xf800; 00060 break; 00061 case 1: 00062 color = 0x07e0; 00063 break; 00064 case 2: 00065 color = 0x001f; 00066 break; 00067 case 3: 00068 color = 0xffff; 00069 break; 00070 case 4: 00071 running = false; 00072 color = 0x0000; 00073 TFT.cls(); 00074 break; 00075 } 00076 // if(xp<50) color=0xF800; 00077 // if(50<xp && xp<100) color=0x07e0; 00078 // if(xp>100 && xp<150) color=0x001f; 00079 } 00080 00081 wait(0.01); 00082 00083 } 00084 }
Generated on Fri Jul 15 2022 04:09:45 by 1.7.2