chrono+tactile
Dependencies: mbed TFT_fonts SeeedStudioTFTv2
main.cpp@5:df0112dc1ed6, 2020-12-15 (annotated)
- Committer:
- valentinbruchet
- Date:
- Tue Dec 15 17:35:31 2020 +0000
- Revision:
- 5:df0112dc1ed6
- Parent:
- 2:5c2f6ff36ff1
chrono+tactile;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
neilt6 | 0:407dafce805d | 1 | #include "mbed.h" |
neilt6 | 0:407dafce805d | 2 | #include "SeeedStudioTFTv2.h" |
neilt6 | 0:407dafce805d | 3 | #include "Arial12x12.h" |
neilt6 | 0:407dafce805d | 4 | #include "Arial24x23.h" |
neilt6 | 0:407dafce805d | 5 | #include "Arial28x28.h" |
neilt6 | 0:407dafce805d | 6 | #include "font_big.h" |
neilt6 | 0:407dafce805d | 7 | |
screamer | 2:5c2f6ff36ff1 | 8 | #define PIN_XP A3 |
screamer | 2:5c2f6ff36ff1 | 9 | #define PIN_XM A1 |
screamer | 2:5c2f6ff36ff1 | 10 | #define PIN_YP A2 |
screamer | 2:5c2f6ff36ff1 | 11 | #define PIN_YM A0 |
screamer | 2:5c2f6ff36ff1 | 12 | #define PIN_MOSI D11 |
screamer | 2:5c2f6ff36ff1 | 13 | #define PIN_MISO D12 |
screamer | 2:5c2f6ff36ff1 | 14 | #define PIN_SCLK D13 |
screamer | 2:5c2f6ff36ff1 | 15 | #define PIN_CS_TFT D5 |
screamer | 2:5c2f6ff36ff1 | 16 | #define PIN_DC_TFT D6 |
screamer | 2:5c2f6ff36ff1 | 17 | #define PIN_BL_TFT D7 |
screamer | 2:5c2f6ff36ff1 | 18 | #define PIN_CS_SD D4 |
lawliet | 1:b2794eb7c940 | 19 | |
valentinbruchet | 5:df0112dc1ed6 | 20 | Timer timer1; |
valentinbruchet | 5:df0112dc1ed6 | 21 | Timer timer2; |
valentinbruchet | 5:df0112dc1ed6 | 22 | int milli1 = 0; |
valentinbruchet | 5:df0112dc1ed6 | 23 | int milli2 = 0; |
valentinbruchet | 5:df0112dc1ed6 | 24 | int secondes1 = 0; |
valentinbruchet | 5:df0112dc1ed6 | 25 | int secondes2 = 0; |
valentinbruchet | 5:df0112dc1ed6 | 26 | int minutes1 = 0; |
valentinbruchet | 5:df0112dc1ed6 | 27 | int minutes2 = 0; |
valentinbruchet | 5:df0112dc1ed6 | 28 | |
valentinbruchet | 5:df0112dc1ed6 | 29 | /*InterruptIn start1 (PC_6); |
valentinbruchet | 5:df0112dc1ed6 | 30 | InterruptIn start2 (PC_5); |
valentinbruchet | 5:df0112dc1ed6 | 31 | InterruptIn stop1 (PC_8); |
valentinbruchet | 5:df0112dc1ed6 | 32 | InterruptIn stop2 (PA_12); |
valentinbruchet | 5:df0112dc1ed6 | 33 | */ |
valentinbruchet | 5:df0112dc1ed6 | 34 | |
screamer | 2:5c2f6ff36ff1 | 35 | 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); |
neilt6 | 0:407dafce805d | 36 | |
valentinbruchet | 5:df0112dc1ed6 | 37 | /*void fonction_demarrer1() |
valentinbruchet | 5:df0112dc1ed6 | 38 | { |
valentinbruchet | 5:df0112dc1ed6 | 39 | timer1.start(); |
valentinbruchet | 5:df0112dc1ed6 | 40 | } |
valentinbruchet | 5:df0112dc1ed6 | 41 | void fonction_arreter1() |
valentinbruchet | 5:df0112dc1ed6 | 42 | { |
valentinbruchet | 5:df0112dc1ed6 | 43 | timer1.stop(); |
valentinbruchet | 5:df0112dc1ed6 | 44 | } |
valentinbruchet | 5:df0112dc1ed6 | 45 | void fonction_demarrer2() |
valentinbruchet | 5:df0112dc1ed6 | 46 | { |
valentinbruchet | 5:df0112dc1ed6 | 47 | timer2.start(); |
valentinbruchet | 5:df0112dc1ed6 | 48 | } |
valentinbruchet | 5:df0112dc1ed6 | 49 | void fonction_arreter2() |
valentinbruchet | 5:df0112dc1ed6 | 50 | { |
valentinbruchet | 5:df0112dc1ed6 | 51 | timer2.stop(); |
valentinbruchet | 5:df0112dc1ed6 | 52 | } |
valentinbruchet | 5:df0112dc1ed6 | 53 | */ |
valentinbruchet | 5:df0112dc1ed6 | 54 | |
neilt6 | 0:407dafce805d | 55 | int main() |
neilt6 | 0:407dafce805d | 56 | { |
valentinbruchet | 5:df0112dc1ed6 | 57 | /*start1.fall(&fonction_demarrer1); |
valentinbruchet | 5:df0112dc1ed6 | 58 | stop1.fall(&fonction_arreter1); |
valentinbruchet | 5:df0112dc1ed6 | 59 | start2.fall(&fonction_demarrer2); |
valentinbruchet | 5:df0112dc1ed6 | 60 | stop2.fall(&fonction_arreter2); |
neilt6 | 0:407dafce805d | 61 | TFT.background(Black); |
neilt6 | 0:407dafce805d | 62 | TFT.foreground(White); |
valentinbruchet | 5:df0112dc1ed6 | 63 | */ |
valentinbruchet | 5:df0112dc1ed6 | 64 | while (1) { |
valentinbruchet | 5:df0112dc1ed6 | 65 | timer1.start(); |
valentinbruchet | 5:df0112dc1ed6 | 66 | timer2.start(); |
neilt6 | 0:407dafce805d | 67 | TFT.set_font((unsigned char*) Arial24x23); |
valentinbruchet | 5:df0112dc1ed6 | 68 | |
valentinbruchet | 5:df0112dc1ed6 | 69 | TFT.locate(20,0); |
valentinbruchet | 5:df0112dc1ed6 | 70 | TFT.printf(":"); |
valentinbruchet | 5:df0112dc1ed6 | 71 | TFT.locate(80,0); |
valentinbruchet | 5:df0112dc1ed6 | 72 | TFT.printf(":"); |
valentinbruchet | 5:df0112dc1ed6 | 73 | TFT.locate(100,0); |
valentinbruchet | 5:df0112dc1ed6 | 74 | TFT.printf("%d", timer1.read_ms()); |
valentinbruchet | 5:df0112dc1ed6 | 75 | |
valentinbruchet | 5:df0112dc1ed6 | 76 | TFT.locate(20,30); |
valentinbruchet | 5:df0112dc1ed6 | 77 | TFT.printf(":"); |
valentinbruchet | 5:df0112dc1ed6 | 78 | TFT.locate(80,30); |
valentinbruchet | 5:df0112dc1ed6 | 79 | TFT.printf(":"); |
valentinbruchet | 5:df0112dc1ed6 | 80 | TFT.locate(100,30); |
valentinbruchet | 5:df0112dc1ed6 | 81 | TFT.printf("%d", timer2.read_ms()); |
valentinbruchet | 5:df0112dc1ed6 | 82 | |
valentinbruchet | 5:df0112dc1ed6 | 83 | milli1 = timer1; |
valentinbruchet | 5:df0112dc1ed6 | 84 | milli2 = timer2; |
valentinbruchet | 5:df0112dc1ed6 | 85 | |
valentinbruchet | 5:df0112dc1ed6 | 86 | if (milli1 == 1) { |
valentinbruchet | 5:df0112dc1ed6 | 87 | timer1.reset(); |
valentinbruchet | 5:df0112dc1ed6 | 88 | milli1 = 0; |
valentinbruchet | 5:df0112dc1ed6 | 89 | secondes1 = secondes1+1; |
valentinbruchet | 5:df0112dc1ed6 | 90 | TFT.locate(40,0); |
valentinbruchet | 5:df0112dc1ed6 | 91 | TFT.printf("%d", secondes1); |
valentinbruchet | 5:df0112dc1ed6 | 92 | } |
valentinbruchet | 5:df0112dc1ed6 | 93 | if (milli2 == 1) { |
valentinbruchet | 5:df0112dc1ed6 | 94 | timer2.reset(); |
valentinbruchet | 5:df0112dc1ed6 | 95 | milli2 = 0; |
valentinbruchet | 5:df0112dc1ed6 | 96 | secondes2 = secondes2+1; |
valentinbruchet | 5:df0112dc1ed6 | 97 | TFT.locate(40,30); |
valentinbruchet | 5:df0112dc1ed6 | 98 | TFT.printf("%d", secondes2); |
valentinbruchet | 5:df0112dc1ed6 | 99 | } |
valentinbruchet | 5:df0112dc1ed6 | 100 | if (secondes1 == 60) { |
valentinbruchet | 5:df0112dc1ed6 | 101 | secondes1 = 0; |
valentinbruchet | 5:df0112dc1ed6 | 102 | minutes1 = minutes1+1; |
valentinbruchet | 5:df0112dc1ed6 | 103 | TFT.locate(0,0); |
valentinbruchet | 5:df0112dc1ed6 | 104 | TFT.printf("%d", minutes1); |
valentinbruchet | 5:df0112dc1ed6 | 105 | } |
valentinbruchet | 5:df0112dc1ed6 | 106 | if (secondes2 == 60) { |
valentinbruchet | 5:df0112dc1ed6 | 107 | secondes2 = 0; |
valentinbruchet | 5:df0112dc1ed6 | 108 | minutes2 = minutes2+1; |
valentinbruchet | 5:df0112dc1ed6 | 109 | TFT.locate(0,30); |
valentinbruchet | 5:df0112dc1ed6 | 110 | TFT.printf("%d", minutes2); |
valentinbruchet | 5:df0112dc1ed6 | 111 | } |
valentinbruchet | 5:df0112dc1ed6 | 112 | /*if (start1 == 1) |
valentinbruchet | 5:df0112dc1ed6 | 113 | { |
valentinbruchet | 5:df0112dc1ed6 | 114 | TFT.locate(40,0); |
valentinbruchet | 5:df0112dc1ed6 | 115 | TFT.printf("%d", timer1.read_ms()); |
neilt6 | 0:407dafce805d | 116 | } |
valentinbruchet | 5:df0112dc1ed6 | 117 | if (start2 == 1) |
valentinbruchet | 5:df0112dc1ed6 | 118 | { |
valentinbruchet | 5:df0112dc1ed6 | 119 | TFT.locate(40,1); |
valentinbruchet | 5:df0112dc1ed6 | 120 | TFT.printf("%d", timer2.read_ms()); |
valentinbruchet | 5:df0112dc1ed6 | 121 | } |
valentinbruchet | 5:df0112dc1ed6 | 122 | */ |
neilt6 | 0:407dafce805d | 123 | } |
valentinbruchet | 5:df0112dc1ed6 | 124 | } |