chrono+tactile
Dependencies: mbed TFT_fonts SeeedStudioTFTv2
Revision 5:df0112dc1ed6, committed 2020-12-15
- Comitter:
- valentinbruchet
- Date:
- Tue Dec 15 17:35:31 2020 +0000
- Parent:
- 4:e98910e480b4
- Commit message:
- chrono+tactile;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r e98910e480b4 -r df0112dc1ed6 main.cpp --- a/main.cpp Fri Feb 13 09:39:48 2015 +0000 +++ b/main.cpp Tue Dec 15 17:35:31 2020 +0000 @@ -1,25 +1,3 @@ -/* - main.cpp - 2014 Copyright (c) Seeed Technology Inc. All right reserved. - - Author:lawliet zou(lawliet.zou@gmail.com) - 2014-02-17 - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - #include "mbed.h" #include "SeeedStudioTFTv2.h" #include "Arial12x12.h" @@ -39,62 +17,108 @@ #define PIN_BL_TFT D7 #define PIN_CS_SD D4 +Timer timer1; +Timer timer2; +int milli1 = 0; +int milli2 = 0; +int secondes1 = 0; +int secondes2 = 0; +int minutes1 = 0; +int minutes2 = 0; + +/*InterruptIn start1 (PC_6); +InterruptIn start2 (PC_5); +InterruptIn stop1 (PC_8); +InterruptIn stop2 (PA_12); +*/ + 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); +/*void fonction_demarrer1() +{ + timer1.start(); +} +void fonction_arreter1() +{ + timer1.stop(); +} +void fonction_demarrer2() +{ + timer2.start(); +} +void fonction_arreter2() +{ + timer2.stop(); +} +*/ + int main() { - //Configure the display driver + /*start1.fall(&fonction_demarrer1); + stop1.fall(&fonction_arreter1); + start2.fall(&fonction_demarrer2); + stop2.fall(&fonction_arreter2); TFT.background(Black); TFT.foreground(White); - TFT.cls(); - - //Print a welcome message - TFT.set_font((unsigned char*) Arial12x12); - TFT.locate(0,0); - TFT.printf("Hello Mbed"); - - //Wait for 5 seconds - wait(5.0); - - //Draw some graphics - TFT.cls(); + */ + while (1) { + timer1.start(); + timer2.start(); TFT.set_font((unsigned char*) Arial24x23); - TFT.locate(100,100); - TFT.printf("Graphic"); - - TFT.line(0,0,100,0,Green); - TFT.line(0,0,0,200,Green); - TFT.line(0,0,100,200,Green); - - TFT.rect(100,50,150,100,Red); - TFT.fillrect(180,25,220,70,Blue); - - TFT.circle(80,150,33,White); - TFT.fillcircle(160,190,20,Yellow); - - double s; - for (int i = 0; i < 320; i++) { - s = 20 * sin((long double)i / 10); - TFT.pixel(i, 100 + (int)s, Red); + + TFT.locate(20,0); + TFT.printf(":"); + TFT.locate(80,0); + TFT.printf(":"); + TFT.locate(100,0); + TFT.printf("%d", timer1.read_ms()); + + TFT.locate(20,30); + TFT.printf(":"); + TFT.locate(80,30); + TFT.printf(":"); + TFT.locate(100,30); + TFT.printf("%d", timer2.read_ms()); + + milli1 = timer1; + milli2 = timer2; + + if (milli1 == 1) { + timer1.reset(); + milli1 = 0; + secondes1 = secondes1+1; + TFT.locate(40,0); + TFT.printf("%d", secondes1); + } + if (milli2 == 1) { + timer2.reset(); + milli2 = 0; + secondes2 = secondes2+1; + TFT.locate(40,30); + TFT.printf("%d", secondes2); + } + if (secondes1 == 60) { + secondes1 = 0; + minutes1 = minutes1+1; + TFT.locate(0,0); + TFT.printf("%d", minutes1); + } + if (secondes2 == 60) { + secondes2 = 0; + minutes2 = minutes2+1; + TFT.locate(0,30); + TFT.printf("%d", minutes2); + } + /*if (start1 == 1) + { + TFT.locate(40,0); + TFT.printf("%d", timer1.read_ms()); } - - //Wait for 5 seconds - wait(5.0); - - //Multiple fonts - TFT.foreground(White); - TFT.background(Blue); - TFT.cls(); - TFT.set_font((unsigned char*) Arial24x23); - TFT.locate(0,0); - TFT.printf("Different Fonts:"); - TFT.set_font((unsigned char*) Neu42x35); - TFT.locate(0,30); - TFT.printf("Hello Mbed 1"); - TFT.set_font((unsigned char*) Arial24x23); - TFT.locate(20,80); - TFT.printf("Hello Mbed 2"); - TFT.set_font((unsigned char*) Arial12x12); - TFT.locate(35,120); - TFT.printf("Hello Mbed 3"); + if (start2 == 1) + { + TFT.locate(40,1); + TFT.printf("%d", timer2.read_ms()); + } + */ } +} \ No newline at end of file
diff -r e98910e480b4 -r df0112dc1ed6 mbed.bld --- a/mbed.bld Fri Feb 13 09:39:48 2015 +0000 +++ b/mbed.bld Tue Dec 15 17:35:31 2020 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/e188a91d3eaa \ No newline at end of file +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file