PIR grove sensor that sends the sensed data to Thingspeak.com through the wifi module ESP 8266

Dependencies:   mbed

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?

UserRevisionLine numberNew contents of line
skrawool 0:3954a906acc2 1 /* mbed Microcontroller Library
skrawool 0:3954a906acc2 2 * Copyright (c) 2006-2015 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_FUNCTIONPOINTER_H
skrawool 0:3954a906acc2 17 #define MBED_FUNCTIONPOINTER_H
skrawool 0:3954a906acc2 18
skrawool 0:3954a906acc2 19 #include "platform/Callback.h"
skrawool 0:3954a906acc2 20 #include "platform/toolchain.h"
skrawool 0:3954a906acc2 21 #include <string.h>
skrawool 0:3954a906acc2 22 #include <stdint.h>
skrawool 0:3954a906acc2 23
skrawool 0:3954a906acc2 24 namespace mbed {
skrawool 0:3954a906acc2 25 /** \addtogroup platform */
skrawool 0:3954a906acc2 26 /** @{*/
skrawool 0:3954a906acc2 27
skrawool 0:3954a906acc2 28
skrawool 0:3954a906acc2 29 // Declarations for backwards compatibility
skrawool 0:3954a906acc2 30 // To be foward compatible, code should adopt the Callback class
skrawool 0:3954a906acc2 31 template <typename R, typename A1>
skrawool 0:3954a906acc2 32 class FunctionPointerArg1 : public Callback<R(A1)> {
skrawool 0:3954a906acc2 33 public:
skrawool 0:3954a906acc2 34 MBED_DEPRECATED_SINCE("mbed-os-5.1",
skrawool 0:3954a906acc2 35 "FunctionPointerArg1<R, A> has been replaced by Callback<R(A)>")
skrawool 0:3954a906acc2 36 FunctionPointerArg1(R (*function)(A1) = 0)
skrawool 0:3954a906acc2 37 : Callback<R(A1)>(function) {}
skrawool 0:3954a906acc2 38
skrawool 0:3954a906acc2 39 template<typename T>
skrawool 0:3954a906acc2 40 MBED_DEPRECATED_SINCE("mbed-os-5.1",
skrawool 0:3954a906acc2 41 "FunctionPointerArg1<R, A> has been replaced by Callback<R(A)>")
skrawool 0:3954a906acc2 42 FunctionPointerArg1(T *object, R (T::*member)(A1))
skrawool 0:3954a906acc2 43 : Callback<R(A1)>(object, member) {}
skrawool 0:3954a906acc2 44
skrawool 0:3954a906acc2 45 R (*get_function())(A1) {
skrawool 0:3954a906acc2 46 return *reinterpret_cast<R (**)(A1)>(this);
skrawool 0:3954a906acc2 47 }
skrawool 0:3954a906acc2 48
skrawool 0:3954a906acc2 49 R call(A1 a1) const {
skrawool 0:3954a906acc2 50 if (!Callback<R(A1)>::operator bool()) {
skrawool 0:3954a906acc2 51 return (R)0;
skrawool 0:3954a906acc2 52 }
skrawool 0:3954a906acc2 53
skrawool 0:3954a906acc2 54 return Callback<R(A1)>::call(a1);
skrawool 0:3954a906acc2 55 }
skrawool 0:3954a906acc2 56
skrawool 0:3954a906acc2 57 R operator()(A1 a1) const {
skrawool 0:3954a906acc2 58 return Callback<R(A1)>::call(a1);
skrawool 0:3954a906acc2 59 }
skrawool 0:3954a906acc2 60 };
skrawool 0:3954a906acc2 61
skrawool 0:3954a906acc2 62 template <typename R>
skrawool 0:3954a906acc2 63 class FunctionPointerArg1<R, void> : public Callback<R()> {
skrawool 0:3954a906acc2 64 public:
skrawool 0:3954a906acc2 65 MBED_DEPRECATED_SINCE("mbed-os-5.1",
skrawool 0:3954a906acc2 66 "FunctionPointer has been replaced by Callback<void()>")
skrawool 0:3954a906acc2 67 FunctionPointerArg1(R (*function)() = 0)
skrawool 0:3954a906acc2 68 : Callback<R()>(function) {}
skrawool 0:3954a906acc2 69
skrawool 0:3954a906acc2 70 template<typename T>
skrawool 0:3954a906acc2 71 MBED_DEPRECATED_SINCE("mbed-os-5.1",
skrawool 0:3954a906acc2 72 "FunctionPointer has been replaced by Callback<void()>")
skrawool 0:3954a906acc2 73 FunctionPointerArg1(T *object, R (T::*member)())
skrawool 0:3954a906acc2 74 : Callback<R()>(object, member) {}
skrawool 0:3954a906acc2 75
skrawool 0:3954a906acc2 76 R (*get_function())() {
skrawool 0:3954a906acc2 77 return *reinterpret_cast<R (**)()>(this);
skrawool 0:3954a906acc2 78 }
skrawool 0:3954a906acc2 79
skrawool 0:3954a906acc2 80 R call() const {
skrawool 0:3954a906acc2 81 if (!Callback<R()>::operator bool()) {
skrawool 0:3954a906acc2 82 return (R)0;
skrawool 0:3954a906acc2 83 }
skrawool 0:3954a906acc2 84
skrawool 0:3954a906acc2 85 return Callback<R()>::call();
skrawool 0:3954a906acc2 86 }
skrawool 0:3954a906acc2 87
skrawool 0:3954a906acc2 88 R operator()() const {
skrawool 0:3954a906acc2 89 return Callback<R()>::call();
skrawool 0:3954a906acc2 90 }
skrawool 0:3954a906acc2 91 };
skrawool 0:3954a906acc2 92
skrawool 0:3954a906acc2 93 typedef FunctionPointerArg1<void, void> FunctionPointer;
skrawool 0:3954a906acc2 94
skrawool 0:3954a906acc2 95
skrawool 0:3954a906acc2 96 } // namespace mbed
skrawool 0:3954a906acc2 97
skrawool 0:3954a906acc2 98 #endif
skrawool 0:3954a906acc2 99
skrawool 0:3954a906acc2 100 /** @}*/