PIR grove sensor that sends the sensed data to Thingspeak.com through the wifi module ESP 8266
esp_attemp3/mbed/drivers/Timeout.h@0:3954a906acc2, 2016-12-05 (annotated)
- Committer:
- skrawool
- Date:
- Mon Dec 05 16:39:27 2016 +0000
- Revision:
- 0:3954a906acc2
PIR grove sensor that sends the sensed data to thingspeak through the wifi module ESP 8266
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
skrawool | 0:3954a906acc2 | 1 | /* mbed Microcontroller Library |
skrawool | 0:3954a906acc2 | 2 | * Copyright (c) 2006-2013 ARM Limited |
skrawool | 0:3954a906acc2 | 3 | * |
skrawool | 0:3954a906acc2 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
skrawool | 0:3954a906acc2 | 5 | * you may not use this file except in compliance with the License. |
skrawool | 0:3954a906acc2 | 6 | * You may obtain a copy of the License at |
skrawool | 0:3954a906acc2 | 7 | * |
skrawool | 0:3954a906acc2 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
skrawool | 0:3954a906acc2 | 9 | * |
skrawool | 0:3954a906acc2 | 10 | * Unless required by applicable law or agreed to in writing, software |
skrawool | 0:3954a906acc2 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
skrawool | 0:3954a906acc2 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
skrawool | 0:3954a906acc2 | 13 | * See the License for the specific language governing permissions and |
skrawool | 0:3954a906acc2 | 14 | * limitations under the License. |
skrawool | 0:3954a906acc2 | 15 | */ |
skrawool | 0:3954a906acc2 | 16 | #ifndef MBED_TIMEOUT_H |
skrawool | 0:3954a906acc2 | 17 | #define MBED_TIMEOUT_H |
skrawool | 0:3954a906acc2 | 18 | |
skrawool | 0:3954a906acc2 | 19 | #include "drivers/Ticker.h" |
skrawool | 0:3954a906acc2 | 20 | |
skrawool | 0:3954a906acc2 | 21 | namespace mbed { |
skrawool | 0:3954a906acc2 | 22 | /** \addtogroup drivers */ |
skrawool | 0:3954a906acc2 | 23 | /** @{*/ |
skrawool | 0:3954a906acc2 | 24 | |
skrawool | 0:3954a906acc2 | 25 | /** A Timeout is used to call a function at a point in the future |
skrawool | 0:3954a906acc2 | 26 | * |
skrawool | 0:3954a906acc2 | 27 | * You can use as many seperate Timeout objects as you require. |
skrawool | 0:3954a906acc2 | 28 | * |
skrawool | 0:3954a906acc2 | 29 | * @Note Synchronization level: Interrupt safe |
skrawool | 0:3954a906acc2 | 30 | * |
skrawool | 0:3954a906acc2 | 31 | * Example: |
skrawool | 0:3954a906acc2 | 32 | * @code |
skrawool | 0:3954a906acc2 | 33 | * // Blink until timeout. |
skrawool | 0:3954a906acc2 | 34 | * |
skrawool | 0:3954a906acc2 | 35 | * #include "mbed.h" |
skrawool | 0:3954a906acc2 | 36 | * |
skrawool | 0:3954a906acc2 | 37 | * Timeout timeout; |
skrawool | 0:3954a906acc2 | 38 | * DigitalOut led(LED1); |
skrawool | 0:3954a906acc2 | 39 | * |
skrawool | 0:3954a906acc2 | 40 | * int on = 1; |
skrawool | 0:3954a906acc2 | 41 | * |
skrawool | 0:3954a906acc2 | 42 | * void attimeout() { |
skrawool | 0:3954a906acc2 | 43 | * on = 0; |
skrawool | 0:3954a906acc2 | 44 | * } |
skrawool | 0:3954a906acc2 | 45 | * |
skrawool | 0:3954a906acc2 | 46 | * int main() { |
skrawool | 0:3954a906acc2 | 47 | * timeout.attach(&attimeout, 5); |
skrawool | 0:3954a906acc2 | 48 | * while(on) { |
skrawool | 0:3954a906acc2 | 49 | * led = !led; |
skrawool | 0:3954a906acc2 | 50 | * wait(0.2); |
skrawool | 0:3954a906acc2 | 51 | * } |
skrawool | 0:3954a906acc2 | 52 | * } |
skrawool | 0:3954a906acc2 | 53 | * @endcode |
skrawool | 0:3954a906acc2 | 54 | */ |
skrawool | 0:3954a906acc2 | 55 | class Timeout : public Ticker { |
skrawool | 0:3954a906acc2 | 56 | |
skrawool | 0:3954a906acc2 | 57 | protected: |
skrawool | 0:3954a906acc2 | 58 | virtual void handler(); |
skrawool | 0:3954a906acc2 | 59 | }; |
skrawool | 0:3954a906acc2 | 60 | |
skrawool | 0:3954a906acc2 | 61 | } // namespace mbed |
skrawool | 0:3954a906acc2 | 62 | |
skrawool | 0:3954a906acc2 | 63 | #endif |
skrawool | 0:3954a906acc2 | 64 | |
skrawool | 0:3954a906acc2 | 65 | /** @}*/ |