
chrono+tactile
Dependencies: mbed TFT_fonts SeeedStudioTFTv2
main.cpp
00001 #include "mbed.h" 00002 #include "SeeedStudioTFTv2.h" 00003 #include "Arial12x12.h" 00004 #include "Arial24x23.h" 00005 #include "Arial28x28.h" 00006 #include "font_big.h" 00007 00008 #define PIN_XP A3 00009 #define PIN_XM A1 00010 #define PIN_YP A2 00011 #define PIN_YM A0 00012 #define PIN_MOSI D11 00013 #define PIN_MISO D12 00014 #define PIN_SCLK D13 00015 #define PIN_CS_TFT D5 00016 #define PIN_DC_TFT D6 00017 #define PIN_BL_TFT D7 00018 #define PIN_CS_SD D4 00019 00020 Timer timer1; 00021 Timer timer2; 00022 int milli1 = 0; 00023 int milli2 = 0; 00024 int secondes1 = 0; 00025 int secondes2 = 0; 00026 int minutes1 = 0; 00027 int minutes2 = 0; 00028 00029 /*InterruptIn start1 (PC_6); 00030 InterruptIn start2 (PC_5); 00031 InterruptIn stop1 (PC_8); 00032 InterruptIn stop2 (PA_12); 00033 */ 00034 00035 SeeedStudioTFTv2 TFT(PIN_XP, PIN_XM, PIN_YP, PIN_YM, PIN_MOSI, PIN_MISO, PIN_SCLK, PIN_CS_TFT, PIN_DC_TFT, PIN_BL_TFT, PIN_CS_SD); 00036 00037 /*void fonction_demarrer1() 00038 { 00039 timer1.start(); 00040 } 00041 void fonction_arreter1() 00042 { 00043 timer1.stop(); 00044 } 00045 void fonction_demarrer2() 00046 { 00047 timer2.start(); 00048 } 00049 void fonction_arreter2() 00050 { 00051 timer2.stop(); 00052 } 00053 */ 00054 00055 int main() 00056 { 00057 /*start1.fall(&fonction_demarrer1); 00058 stop1.fall(&fonction_arreter1); 00059 start2.fall(&fonction_demarrer2); 00060 stop2.fall(&fonction_arreter2); 00061 TFT.background(Black); 00062 TFT.foreground(White); 00063 */ 00064 while (1) { 00065 timer1.start(); 00066 timer2.start(); 00067 TFT.set_font((unsigned char*) Arial24x23); 00068 00069 TFT.locate(20,0); 00070 TFT.printf(":"); 00071 TFT.locate(80,0); 00072 TFT.printf(":"); 00073 TFT.locate(100,0); 00074 TFT.printf("%d", timer1.read_ms()); 00075 00076 TFT.locate(20,30); 00077 TFT.printf(":"); 00078 TFT.locate(80,30); 00079 TFT.printf(":"); 00080 TFT.locate(100,30); 00081 TFT.printf("%d", timer2.read_ms()); 00082 00083 milli1 = timer1; 00084 milli2 = timer2; 00085 00086 if (milli1 == 1) { 00087 timer1.reset(); 00088 milli1 = 0; 00089 secondes1 = secondes1+1; 00090 TFT.locate(40,0); 00091 TFT.printf("%d", secondes1); 00092 } 00093 if (milli2 == 1) { 00094 timer2.reset(); 00095 milli2 = 0; 00096 secondes2 = secondes2+1; 00097 TFT.locate(40,30); 00098 TFT.printf("%d", secondes2); 00099 } 00100 if (secondes1 == 60) { 00101 secondes1 = 0; 00102 minutes1 = minutes1+1; 00103 TFT.locate(0,0); 00104 TFT.printf("%d", minutes1); 00105 } 00106 if (secondes2 == 60) { 00107 secondes2 = 0; 00108 minutes2 = minutes2+1; 00109 TFT.locate(0,30); 00110 TFT.printf("%d", minutes2); 00111 } 00112 /*if (start1 == 1) 00113 { 00114 TFT.locate(40,0); 00115 TFT.printf("%d", timer1.read_ms()); 00116 } 00117 if (start2 == 1) 00118 { 00119 TFT.locate(40,1); 00120 TFT.printf("%d", timer2.read_ms()); 00121 } 00122 */ 00123 } 00124 }
Generated on Fri Jul 15 2022 13:06:42 by
