chrono+tactile

Dependencies:   mbed TFT_fonts SeeedStudioTFTv2

main.cpp

Committer:
valentinbruchet
Date:
24 months ago
Revision:
5:df0112dc1ed6
Parent:
2:5c2f6ff36ff1

File content as of revision 5:df0112dc1ed6:

#include "mbed.h"
#include "SeeedStudioTFTv2.h"
#include "Arial12x12.h"
#include "Arial24x23.h"
#include "Arial28x28.h"
#include "font_big.h"

#define PIN_XP          A3
#define PIN_XM          A1
#define PIN_YP          A2
#define PIN_YM          A0
#define PIN_MOSI        D11
#define PIN_MISO        D12
#define PIN_SCLK        D13
#define PIN_CS_TFT      D5
#define PIN_DC_TFT      D6
#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()
{
    /*start1.fall(&fonction_demarrer1);
    stop1.fall(&fonction_arreter1);
    start2.fall(&fonction_demarrer2);
    stop2.fall(&fonction_arreter2);
    TFT.background(Black);
    TFT.foreground(White);
    */
    while (1) {
    timer1.start();
    timer2.start();
    TFT.set_font((unsigned char*) Arial24x23);
    
    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());
    }
    if (start2 == 1)
    {
        TFT.locate(40,1);
        TFT.printf("%d", timer2.read_ms());
    }
    */
}
}