Dependencies:   mbed

main.cpp

Committer:
tim008
Date:
2014-04-10
Revision:
1:cb175cbb79e2
Parent:
0:4d3312955f0c

File content as of revision 1:cb175cbb79e2:

#include "mbed.h"
 
BusOut cifra(dp23,dp24,dp25);
BusOut broj(dp18,dp4,dp28,dp6,dp5,dp27,dp26);
DigitalOut tacka(dp17);
int segmenti[10] = {0x01, 0x4f, 0x12, 0x06, 0x4c,0x24, 0x20, 0x0f, 0x00, 0x04};
InterruptIn taster1(dp1);
InterruptIn taster2(dp2);
 
bool stop(true);
Timer t,t1,t2,t3;
Ticker ticker,ticker1;
int i=0;

void pomocna(int b)
{
    if(b>=0 && b<=9)
    broj=segmenti[b];
    else 
    broj=0x7f;
 }   



 
 
void display()
{
    
    float  vrijeme=t.read();
 
  int cifre[3]={ (int)(vrijeme / 10.) % 10,(int)(vrijeme) % 10,(int)(vrijeme* 10.) % 10};

  for( i=1;i<=4;i=i*2)
  {
        cifra=~i;
      pomocna(cifre[i/2]);
      if(i==2)
      tacka=0;
      else tacka=1;
       t3.start();
       while(t3.read_ms()<1);
       t3.reset();
       t3.stop();
     
       cifra=7;
      }
  
 
}
 
 
void start_stop()
{
 
  if(t1.read_ms()>200){
        if(stop){
         t.start();
         stop = false;
         }
        else if (!stop){
            t.stop();
            stop = true;
        }
 
        t1.reset();     
    }
    
    }
 
void reset()
{
 
  if(t2.read_ms() > 200) {
        t.reset();
        t.stop();
        stop = true;
      
        t2.reset();
    }
 
}
 
 
 
 
 
int main() 
{
    t1.start();
    t2.start();
    ticker.attach_us(&display,5000);
    taster1.rise(&start_stop);
    taster2.rise(&reset);
    while(1) 
    {
    
    }
}