IoT Ox / Mbed 2 deprecated MainSketch Featured

Dependencies:   RTC-DS1307 SPI_TFT_ILI9341 TFT_fonts mbed tsi_sensor

Fork of TFT_Mikroelectronika_IL9341_sketchpad by Oxford CWM Team

settings.h

Committer:
Owenmatthewmcgowan
Date:
2017-05-25
Revision:
24:93e1474d6d8b
Parent:
20:e4572fc1b10d
Child:
25:ff73360cd038

File content as of revision 24:93e1474d6d8b:

int setting_press(){
    int x = readX();
    int y = readY();
    if (touching == 1) {
        if (x > 0 && x < 50 && y > 0 & y < 100) // side button 1 (set)
        {
            //set desired state to 1 
            return 1;
        }
        else if (x > 0 && x < 50 && y > 100 & y < 200) //side button 2 (cancel)
        {
            //set desired state to 2 
            return 2;
        }
        else if (x > 0 && x < 50 && y > 200 && y < 240) // button home
        {
            //set desired state to 0
            return 0;
        }
        else if (x > 50 && x < 185 && y > 0 && y < 100) // Alarm Hour 
        {
            return 11;
        }
        else if (x > 185 && x < 320 && y >  0 && y < 100) // Alarm Min
        {
            return 12;
        }
        else if (x > 50 && x < 185 && y >  100 && y < 200) //Time Hour
        {
            return 13;
        }
        else if (x > 185 && x < 320 && y >  100 && y < 200)//Time Min
        {
            return 14;
        }
        else if (x > 50 && x < 140 && y >  200 && y < 300)//Time Date      
        {
            return 15;
        }
        else if (x > 140 && x < 230 && y >  200 && y < 300)//Time Month
        {
            return 16;
        }
        else if (x > 230 && x < 320 && y >  200 && y < 300) //Time Year
        {
            return 17;
        }       
    }
    return -1;
}

void drawsettingback() //Navigation Buttons
{
  TFT.fillrect(0,0,50,100,Blue);        //set alarm button
    TFT.fillrect(0,100,50,200,White);   //set time button

 
    TFT.rect(0,0,50,100,Blue);      //outlines
    TFT.rect(0,100,50,200,White);   //outlines
    TFT.rect(0,200,50,240,White);   //outlines
    
    //alarm/time colons
            int tx,ty = 0;
            ty = 50;
            tx = 185;
            TFT.fillcircle(tx, ty - 10, 2, White);
            TFT.fillcircle(tx, ty + 10, 2, White);
            ty = 150;
            TFT.fillcircle(tx, ty - 10, 2, White);
            TFT.fillcircle(tx, ty + 10, 2, White);
    

}

void drawsettinganimate() //draw alarm, time, date
{
    TFT.rect(50,0,320,100,Blue);  //set alarm box
    TFT.rect(50,100,320,200,White); //set time box
    TFT.rect(50,200,320,240,White); //set date box

    TFT.set_font((unsigned char*) Arial12x12); //set alarm title
    TFT.locate(157,8);
    TFT.printf("Set Alarm");


    TFT.set_font((unsigned char*) Arial28x28); //set alarm hour

    TFT.locate(90,40);

    TFT.printf("AH");//Alarm_Hour

     //set alarm mins
    TFT.locate(230,40);
    TFT.printf("AM");//Alarm_Min
    TFT.set_font((unsigned char*) Arial12x12); //set time title
    TFT.locate(157,108);
    TFT.printf("Set Time");

    TFT.set_font((unsigned char*) Arial28x28); //set time hour
    TFT.locate(90,140);
    TFT.printf("TH"); // Time_hour
    
    //set time mins
    TFT.locate(230,140);
    TFT.printf("TM");//Time Min

    //set date day
    TFT.set_font((unsigned char*) Arial12x12);
    TFT.locate(60,215);
    TFT.printf("day");

    //set date month
    TFT.locate(150,215);
    TFT.printf("month");

    //set date year
    TFT.locate(265,215);
    TFT.printf("year");

    //Cancel button 
    TFT.set_font((unsigned char*) Arial12x12); 
    TFT.locate(62,20);
    TFT.set_orientation(0);
    TFT.background(White);
    TFT.foreground(Black);
    TFT.printf("Cancel");
    TFT.background(Black);
    TFT.foreground(White);
    TFT.set_orientation(1);

    //Set New button (used to set new alarm/time/date)
    
    TFT.locate(161,20);
    TFT.set_orientation(0);
    TFT.background(Blue);
    TFT.printf("Set New");
    TFT.background(Black);
    TFT.set_orientation(1);
     //home button
    TFT.locate(5,217);
    TFT.foreground(Blue);
    TFT.printf("Home");
    TFT.foreground(White);

    
}
void settings() {
    
    }