SChuleEE 1
/
linienverfolgung
z
BtnEventM0.h@0:688028485205, 2016-06-14 (annotated)
- Committer:
- manuelschnider
- Date:
- Tue Jun 14 10:51:28 2016 +0000
- Revision:
- 0:688028485205
zz
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
manuelschnider | 0:688028485205 | 1 | |
manuelschnider | 0:688028485205 | 2 | |
manuelschnider | 0:688028485205 | 3 | class BtnEventM0 |
manuelschnider | 0:688028485205 | 4 | { |
manuelschnider | 0:688028485205 | 5 | public: |
manuelschnider | 0:688028485205 | 6 | int16_t pressed; |
manuelschnider | 0:688028485205 | 7 | |
manuelschnider | 0:688028485205 | 8 | BtnEventM0(PinName pin) : _isr(pin) { |
manuelschnider | 0:688028485205 | 9 | pressed=0; |
manuelschnider | 0:688028485205 | 10 | } |
manuelschnider | 0:688028485205 | 11 | |
manuelschnider | 0:688028485205 | 12 | // Ist eine steigende Flanke aufgetreten ? |
manuelschnider | 0:688028485205 | 13 | int CheckFlag() { |
manuelschnider | 0:688028485205 | 14 | if( pressed ) { |
manuelschnider | 0:688028485205 | 15 | pressed=0; |
manuelschnider | 0:688028485205 | 16 | return 1; |
manuelschnider | 0:688028485205 | 17 | } |
manuelschnider | 0:688028485205 | 18 | return 0; |
manuelschnider | 0:688028485205 | 19 | } |
manuelschnider | 0:688028485205 | 20 | |
manuelschnider | 0:688028485205 | 21 | // 1..Button is pressed else 0 |
manuelschnider | 0:688028485205 | 22 | int CheckButton() { |
manuelschnider | 0:688028485205 | 23 | return _isr.read(); |
manuelschnider | 0:688028485205 | 24 | } |
manuelschnider | 0:688028485205 | 25 | |
manuelschnider | 0:688028485205 | 26 | void Init() { |
manuelschnider | 0:688028485205 | 27 | _isr.rise(this, &BtnEventM0::RisingISR); |
manuelschnider | 0:688028485205 | 28 | } |
manuelschnider | 0:688028485205 | 29 | |
manuelschnider | 0:688028485205 | 30 | void RisingISR() { |
manuelschnider | 0:688028485205 | 31 | if( _isr.read() ) |
manuelschnider | 0:688028485205 | 32 | pressed = 1; |
manuelschnider | 0:688028485205 | 33 | } |
manuelschnider | 0:688028485205 | 34 | protected: |
manuelschnider | 0:688028485205 | 35 | InterruptIn _isr; |
manuelschnider | 0:688028485205 | 36 | }; |
manuelschnider | 0:688028485205 | 37 | |
manuelschnider | 0:688028485205 | 38 | /* |
manuelschnider | 0:688028485205 | 39 | class BtnEventM02 : public BtnEventM0 |
manuelschnider | 0:688028485205 | 40 | { |
manuelschnider | 0:688028485205 | 41 | public: |
manuelschnider | 0:688028485205 | 42 | BtnEventM02(PinName pin) : BtnEventM0(pin) { |
manuelschnider | 0:688028485205 | 43 | _tm.stop(); |
manuelschnider | 0:688028485205 | 44 | _tm.reset(); |
manuelschnider | 0:688028485205 | 45 | _state=1; |
manuelschnider | 0:688028485205 | 46 | } |
manuelschnider | 0:688028485205 | 47 | |
manuelschnider | 0:688028485205 | 48 | void Init() { |
manuelschnider | 0:688028485205 | 49 | _isr.rise(this, &BtnEventM02::RisingISR); |
manuelschnider | 0:688028485205 | 50 | } |
manuelschnider | 0:688028485205 | 51 | |
manuelschnider | 0:688028485205 | 52 | void RisingISR() { |
manuelschnider | 0:688028485205 | 53 | if( !_isr.read() ) |
manuelschnider | 0:688028485205 | 54 | return; |
manuelschnider | 0:688028485205 | 55 | pressed = 1; |
manuelschnider | 0:688028485205 | 56 | _tm.start(); |
manuelschnider | 0:688028485205 | 57 | _state = 2; |
manuelschnider | 0:688028485205 | 58 | } |
manuelschnider | 0:688028485205 | 59 | |
manuelschnider | 0:688028485205 | 60 | void CheckButton() { |
manuelschnider | 0:688028485205 | 61 | if( _state==1 ) |
manuelschnider | 0:688028485205 | 62 | return; |
manuelschnider | 0:688028485205 | 63 | if( _state==2 ) { |
manuelschnider | 0:688028485205 | 64 | if( !_isr.read() ) { |
manuelschnider | 0:688028485205 | 65 | _state = 1; |
manuelschnider | 0:688028485205 | 66 | return; |
manuelschnider | 0:688028485205 | 67 | } |
manuelschnider | 0:688028485205 | 68 | if( _tm.read_ms()>500 ) { |
manuelschnider | 0:688028485205 | 69 | _tm.reset(); |
manuelschnider | 0:688028485205 | 70 | _state = 3; |
manuelschnider | 0:688028485205 | 71 | pressed = 1; |
manuelschnider | 0:688028485205 | 72 | } |
manuelschnider | 0:688028485205 | 73 | } else if( _state==3 ) { |
manuelschnider | 0:688028485205 | 74 | if( !_isr.read() ) { |
manuelschnider | 0:688028485205 | 75 | _state = 1; |
manuelschnider | 0:688028485205 | 76 | return; |
manuelschnider | 0:688028485205 | 77 | } |
manuelschnider | 0:688028485205 | 78 | if( _tm.read_ms()>100 ) { |
manuelschnider | 0:688028485205 | 79 | _tm.reset(); |
manuelschnider | 0:688028485205 | 80 | _state = 3; |
manuelschnider | 0:688028485205 | 81 | pressed = 1; |
manuelschnider | 0:688028485205 | 82 | } |
manuelschnider | 0:688028485205 | 83 | } |
manuelschnider | 0:688028485205 | 84 | } |
manuelschnider | 0:688028485205 | 85 | private: |
manuelschnider | 0:688028485205 | 86 | int16_t _state; |
manuelschnider | 0:688028485205 | 87 | Timer _tm; |
manuelschnider | 0:688028485205 | 88 | }; |
manuelschnider | 0:688028485205 | 89 | */ |
manuelschnider | 0:688028485205 | 90 | |
manuelschnider | 0:688028485205 | 91 | class AnalogInHL : public AnalogIn |
manuelschnider | 0:688028485205 | 92 | { |
manuelschnider | 0:688028485205 | 93 | public: |
manuelschnider | 0:688028485205 | 94 | AnalogInHL(PinName pin) : AnalogIn(pin) { } |
manuelschnider | 0:688028485205 | 95 | int Read() { |
manuelschnider | 0:688028485205 | 96 | return read_u16()>>6; |
manuelschnider | 0:688028485205 | 97 | } |
manuelschnider | 0:688028485205 | 98 | }; |
manuelschnider | 0:688028485205 | 99 | |
manuelschnider | 0:688028485205 | 100 | |
manuelschnider | 0:688028485205 | 101 | |
manuelschnider | 0:688028485205 | 102 | |
manuelschnider | 0:688028485205 | 103 | |
manuelschnider | 0:688028485205 | 104 | |
manuelschnider | 0:688028485205 | 105 | |
manuelschnider | 0:688028485205 | 106 | |
manuelschnider | 0:688028485205 | 107 | |
manuelschnider | 0:688028485205 | 108 | |
manuelschnider | 0:688028485205 | 109 | |
manuelschnider | 0:688028485205 | 110 | |
manuelschnider | 0:688028485205 | 111 | |
manuelschnider | 0:688028485205 | 112 | |
manuelschnider | 0:688028485205 | 113 | |
manuelschnider | 0:688028485205 | 114 | |
manuelschnider | 0:688028485205 | 115 | |
manuelschnider | 0:688028485205 | 116 | |
manuelschnider | 0:688028485205 | 117 | |
manuelschnider | 0:688028485205 | 118 | |
manuelschnider | 0:688028485205 | 119 | |
manuelschnider | 0:688028485205 | 120 | |
manuelschnider | 0:688028485205 | 121 | |
manuelschnider | 0:688028485205 | 122 | |
manuelschnider | 0:688028485205 | 123 | |
manuelschnider | 0:688028485205 | 124 | |
manuelschnider | 0:688028485205 | 125 | |
manuelschnider | 0:688028485205 | 126 | |
manuelschnider | 0:688028485205 | 127 | |
manuelschnider | 0:688028485205 | 128 | |
manuelschnider | 0:688028485205 | 129 | |
manuelschnider | 0:688028485205 | 130 | |
manuelschnider | 0:688028485205 | 131 | |
manuelschnider | 0:688028485205 | 132 | |
manuelschnider | 0:688028485205 | 133 | |
manuelschnider | 0:688028485205 | 134 | |
manuelschnider | 0:688028485205 | 135 | |
manuelschnider | 0:688028485205 | 136 | |
manuelschnider | 0:688028485205 | 137 | |
manuelschnider | 0:688028485205 | 138 | |
manuelschnider | 0:688028485205 | 139 | |
manuelschnider | 0:688028485205 | 140 | |
manuelschnider | 0:688028485205 | 141 | |
manuelschnider | 0:688028485205 | 142 | |
manuelschnider | 0:688028485205 | 143 | |
manuelschnider | 0:688028485205 | 144 | |
manuelschnider | 0:688028485205 | 145 | |
manuelschnider | 0:688028485205 | 146 |