Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: RTC-DS1307 SPI_TFT_ILI9341 TFT_fonts mbed tsi_sensor
Fork of TFT_Mikroelectronika_IL9341_sketchpad 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 //the functions to draw buttons , the analog clock and whiteboard 00009 00010 void drawbuttons() //draw buttons 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) // final version for analog clock 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 y1 = (r - markerlength) * sin(angle) + y0; 00034 TFT.line(x1, y1, x2, y2, color); 00035 } 00036 } 00037 void whiteboard() //white board fuction 00038 { 00039 TFT.cls(); 00040 int color = 0; 00041 int xp = 0,yp = 0,sw = 0;; 00042 drawbuttons(); 00043 bool running = true; 00044 while(running) { 00045 00046 xp = readX(); 00047 yp = readY(); 00048 // top chunk of the screen is the button area // 00049 // 0<y<50 is palette area // 00050 00051 //pc.printf("xpos=%d\t,\typo=%d",xpos,ypos); 00052 // xp=(240*(xpos-5800))/51200; 00053 // yp=320-(320*(ypos-3000))/58300; 00054 if(touching == 1) pc.printf("\txp=%d\t,\typo=%d\n\r", xp, yp); 00055 if(xp > 5 && yp > 50 && touching == 1) TFT.fillcircle(xp,yp, 2, color); 00056 if(xp < 50) { // color buttons 00057 sw = (int)yp / 50; 00058 switch(sw) { // changing colors 00059 case 0: 00060 color = 0xf800; 00061 break; 00062 case 1: 00063 color = 0x07e0; 00064 break; 00065 case 2: 00066 color = 0x001f; 00067 break; 00068 case 3: 00069 color = 0xffff; 00070 break; 00071 case 4: 00072 running = false; 00073 color = 0x0000; 00074 TFT.cls(); 00075 break; 00076 } 00077 // if(xp<50) color=0xF800; 00078 // if(50<xp && xp<100) color=0x07e0; 00079 // if(xp>100 && xp<150) color=0x001f; 00080 } 00081 00082 wait(0.01); 00083 00084 } 00085 }
Generated on Thu Jul 14 2022 09:34:11 by
1.7.2
