Tipkalo Linija

Dependents:   Lilnija_29012017

Committer:
mario_meh
Date:
Wed Feb 08 08:36:23 2017 +0000
Revision:
2:9085093855f0
Parent:
1:fa666d2759a4
zadnje izmjene pred predaju seminarskog zadatka

Who changed what in which revision?

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