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
clocklogic.h
- Committer:
- mlin
- Date:
- 2017-05-25
- Revision:
- 31:3255668e6b08
- Parent:
- 29:684e2a3e17b5
- Child:
- 32:56f59b79720c
File content as of revision 31:3255668e6b08:
int digital_clock_press(){ int x = readX(); int y = readY(); if (touching == 1) { if (x > 0 && x < 50 && y > 0 & y < 50) // side button 1 (clock state) { //set desired state to 1 return 1; } else if (x > 0 && x < 50 && y > 50 & y < 100) //side button 2 (change time) { //set desired state to 2 return 2; } else if (x > 0 && x < 50 && y > 100 && y < 150) // side button 3 { //set desired state to 3 return 3; } else if (x > 0 && x < 50 && y > 150 && y < 200) // side button 4 { //set desired state to 4 return 4; }else if (x > 0 && x < 50 && y > 200 && y < 240) // button home { //set desired state to 0 return 0; } else if (x > 140 && x < 320 && y > 100 && y < 200) // alarm button on or off { //set desired state to 5 f_alarm = !(f_alarm); return -1; } } return -1; } void runclock() { draw_state(1); while (f_state == 1){ read_time(); TFT.set_font((unsigned char*) Arial24x23); //set alarm hour if (tm_c.sec == 0){ TFT.locate(250,40); TFT.printf(" "); if (tm_c.min == 0){ TFT.locate(160,40); printf("%d",tm_c.min); if (tm_c.hour == 0) { TFT.locate(70,40); printf("%d",tm_c.hour); } } } TFT.locate(70,40); TFT.printf("%d",tm_c.hour); TFT.locate(160,40); TFT.printf("%d",tm_c.min); TFT.locate(250,40); TFT.printf("%d",tm_c.sec); TFT.locate(60,140); TFT.set_font((unsigned char*) Arial12x12); TFT.printf("%s",tm_c.wday); TFT.set_font((unsigned char*) Arial24x23); if (f_alarm) { TFT.locate(160,140); TFT.printf("%d",tm_a_hr); TFT.locate(250,140); TFT.printf("%d",tm_a_min); } else { TFT.locate(160,140); TFT.printf(" "); TFT.locate(250,140); TFT.printf(" "); } TFT.locate(70,210); TFT.printf("%d / %d / %d", tm_c.date, tm_c.mon, tm_c.year); wait(0.2); /* TFT.locate(160,210); TFT.printf("%d",tm_c.mon); TFT.locate(220,210); TFT.printf("%d",tm_c.year); */ switch (digital_clock_press()){ case (-1): break; case (0): f_state = 0; break; case (1): f_state = 2; break; case (2): f_state = 3; break; case (3): f_state = 4; break; } } }