Dependents: BULME-TIMER_V1 BULME-TIMER_V2 Diplomarbeit_V1
Revision 2:33f7ace525c1, committed 2016-06-23
- Comitter:
- 04M04
- Date:
- Thu Jun 23 18:59:00 2016 +0000
- Parent:
- 0:e627eaaa3dc2
- Commit message:
- dPrell
Changed in this revision
button.h | Show diff for this revision Revisions of this file |
dPrell.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/button.h Fri Apr 22 21:10:28 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -#include "mbed.h" - -class dPrell -{ - public: - dPrell(PinName pin):data(pin),interrupt(pin) - { - time = 500; - Run(); - interrupt.rise(this,&dPrell::druck); - interrupt.fall(this,&dPrell::druck); - } - void rise(void (*fptr)(void)) - { - press.attach(fptr); - } - void fall(void (*fptr)(void)) - { - release.attach(fptr); - } - void setTime(timestamp_t in) - { - time = in; - } - void mode(PinMode mode) - { - interrupt.mode(mode); - } - void trig() - { - Run(); - } - protected: - void druck() - { - if (last == data) - return; - else - { - if (data&En) - { - press.call(); - En=0; - res.attach_us(this,&dPrell::Run,time); - } - if((data==0)&En) - { - release.call(); - En=0; - res.attach_us(this,&dPrell::Run,time); - } - } - last = data; - } - void Run() - { - last = data; - En = 1; - } - timestamp_t time; - DigitalIn data; - Timeout res; - InterruptIn interrupt; - char last; - char En; - FunctionPointer press; - FunctionPointer release; -}; \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dPrell.h Thu Jun 23 18:59:00 2016 +0000 @@ -0,0 +1,68 @@ +#include "mbed.h" + +class dPrell +{ + public: + dPrell(PinName pin):data(pin),interrupt(pin) + { + time = 500; + Run(); + interrupt.rise(this,&dPrell::druck); + interrupt.fall(this,&dPrell::druck); + } + void rise(void (*fptr)(void)) + { + press.attach(fptr); + } + void fall(void (*fptr)(void)) + { + release.attach(fptr); + } + void setTime(timestamp_t in) + { + time = in; + } + void mode(PinMode mode) + { + interrupt.mode(mode); + } + void trig() + { + Run(); + } + protected: + void druck() + { + if (last == data) + return; + else + { + if (data&En) + { + press.call(); + En=0; + res.attach_us(this,&dPrell::Run,time); + } + if((data==0)&En) + { + release.call(); + En=0; + res.attach_us(this,&dPrell::Run,time); + } + } + last = data; + } + void Run() + { + last = data; + En = 1; + } + timestamp_t time; + DigitalIn data; + Timeout res; + InterruptIn interrupt; + char last; + char En; + FunctionPointer press; + FunctionPointer release; +}; \ No newline at end of file