Contains the main execution of the clock uses headers to import functions

Dependencies:   RTC-DS1307 SPI_TFT_ILI9341 TFT_fonts mbed tsi_sensor

Fork of TFT_Mikroelectronika_IL9341_sketchpad by Oxford CWM Team

render.h

Committer:
Owenmatthewmcgowan
Date:
2017-05-26
Revision:
49:243b5e826228
Parent:
41:3f2e75e7fbeb

File content as of revision 49:243b5e826228:


#include "string"
#include "Arial12x12.h"
#include "Arial24x23.h"
#include "Arial28x28.h"
#include "font_big.h"

//the functions to draw buttons , the analog clock and whiteboard

void drawbuttons()  //draw buttons
{
    TFT.fillrect(0, 0, 50, 50, Red);
    TFT.fillrect(0, 50, 50, 100, Green);
    TFT.fillrect(0, 100, 50, 150, Blue);
    TFT.fillrect(0, 150, 50, 200, White);
    TFT.fillrect(0, 200, 50, 250, Black);

    TFT.rect(0, 0, 50, 50, White);
    TFT.rect(0, 50, 50, 100, White);
    TFT.rect(0, 100, 50, 150, White);
    TFT.rect(0, 150, 50, 200, White);
    TFT.rect(0, 200, 50, 250, White);
}
void draw_clockface(int x0, int y0, int r, int markerlength, int color) // final version for analog clock
{ 
    TFT.circle(x0, y0, r, White);
    for ( int n = 0; n < 13; n++) {
      int x1, y1, x2, y2= 0;
      double angle = n * 2 * M_PI / 12;
      x2 = r * cos(angle) + x0;
      y2 = r * sin(angle) + y0;
      x1 = (r - markerlength) * cos(angle) + x0;
      y1 = (r - markerlength) * sin(angle) + y0;
      TFT.line(x1, y1, x2, y2, color);
    }
}
void whiteboard() //white board fuction
{   
    TFT.cls();
    int color = 0;
    int xp = 0,yp = 0,sw = 0;;
    drawbuttons();
    bool running = true;
    while(running) {

        xp = readX();
        yp = readY();
        // top chunk of the screen is the button area //
        // 0<y<50 is palette area //

        //pc.printf("xpos=%d\t,\typo=%d",xpos,ypos);
        // xp=(240*(xpos-5800))/51200;
        // yp=320-(320*(ypos-3000))/58300;
        if(touching == 1) pc.printf("\txp=%d\t,\typo=%d\n\r", xp, yp);
        if(xp > 5 && yp > 50 && touching == 1) TFT.fillcircle(xp,yp, 2, color);
        if(xp < 50) { // color buttons
            sw = (int)yp / 50;
            switch(sw) { // changing colors
                case 0:
                    color = 0xf800;
                    break;
                case 1:
                    color = 0x07e0;
                    break;
                case 2:
                    color = 0x001f;
                    break;
                case 3:
                    color = 0xffff;
                    break;
                case 4:
                    running = false;
                    color = 0x0000;
                    TFT.cls();
                    break;
            }
            //  if(xp<50) color=0xF800;
            //   if(50<xp && xp<100) color=0x07e0;
            // if(xp>100 && xp<150) color=0x001f;
        }

        wait(0.01);

    }
}