Tipkalo Linija

Dependents:   Lilnija_29012017

Committer:
mario_meh
Date:
Wed Nov 22 08:51:34 2017 +0000
Revision:
3:b9ab9a191011
Parent:
1:fa666d2759a4
reserved

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mario_meh 3:b9ab9a191011 1 /** Projektiranje ugradbenih računalnih sustava
mario_meh 3:b9ab9a191011 2 * Default metoda za dodavanje tipkala
mario_meh 3:b9ab9a191011 3 * @author: mario_meh
mario_meh 3:b9ab9a191011 4 * @code
mario_meh 3:b9ab9a191011 5 * #include "mbed.h"
mario_meh 3:b9ab9a191011 6 * #include "tipkalo.h"
mario_meh 3:b9ab9a191011 7 *
mario_meh 3:b9ab9a191011 8 * @endcode
mario_meh 1:fa666d2759a4 9 */
mario_meh 0:9624782a02b3 10 #include "mbed.h"
mario_meh 0:9624782a02b3 11 #include "tipkalo.h"
mario_meh 0:9624782a02b3 12
mario_meh 3:b9ab9a191011 13 int timeAtPress;
mario_meh 3:b9ab9a191011 14 bool pressed = false;
mario_meh 3:b9ab9a191011 15
mario_meh 3:b9ab9a191011 16 Tipkalo::Tipkalo() : pbutton(PTA5), ledSec(PTE30)
mario_meh 3:b9ab9a191011 17
mario_meh 3:b9ab9a191011 18 {
mario_meh 3:b9ab9a191011 19 t.start();
mario_meh 3:b9ab9a191011 20 pbutton.fall(this, &Tipkalo::blinkFall);
mario_meh 3:b9ab9a191011 21 pbutton.rise(this, &Tipkalo::blinkRise);
mario_meh 3:b9ab9a191011 22 }
mario_meh 3:b9ab9a191011 23
mario_meh 3:b9ab9a191011 24 void Tipkalo::blinkFall() {
mario_meh 3:b9ab9a191011 25 if(t.read_ms() > t_milisec_pritisnut) {
mario_meh 3:b9ab9a191011 26 pressed = false;
mario_meh 3:b9ab9a191011 27 ledSec = 0;
mario_meh 3:b9ab9a191011 28 //ledSec != ledSec;
mario_meh 3:b9ab9a191011 29 } t.reset();
mario_meh 3:b9ab9a191011 30 toggler.attach(this, &Tipkalo::togglerOff, 0.3);
mario_meh 0:9624782a02b3 31 }
mario_meh 0:9624782a02b3 32
mario_meh 3:b9ab9a191011 33 void Tipkalo::togglerOff() {
mario_meh 3:b9ab9a191011 34 if(pressed == false) {
mario_meh 3:b9ab9a191011 35 ledSec = 0;
mario_meh 3:b9ab9a191011 36 //fallL = 0;
mario_meh 3:b9ab9a191011 37 pressed = true;
mario_meh 3:b9ab9a191011 38 t.reset();
mario_meh 3:b9ab9a191011 39 }
mario_meh 0:9624782a02b3 40 }
mario_meh 0:9624782a02b3 41
mario_meh 3:b9ab9a191011 42 void Tipkalo::blinkRise() {
mario_meh 3:b9ab9a191011 43 if(t.read_ms() > t_milisec_pritisnut) {
mario_meh 3:b9ab9a191011 44 pressed = true;
mario_meh 3:b9ab9a191011 45 ledSec = 1;
mario_meh 3:b9ab9a191011 46 //ledSec != ledSec;
mario_meh 3:b9ab9a191011 47 } t.reset();
mario_meh 3:b9ab9a191011 48 }
mario_meh 0:9624782a02b3 49
mario_meh 3:b9ab9a191011 50 void Tipkalo::bStop() {
mario_meh 3:b9ab9a191011 51 toggler.detach();
mario_meh 3:b9ab9a191011 52 }
mario_meh 3:b9ab9a191011 53