Programme d'utilisation des AX12 et de l'MX12 V3. 0C = action de l'MX12. (data0) 0 | 1 | 2 = position & sens de rotation
Dependencies: MX12
Fork of Utilisatio_MX12_V3 by
Timeout.h
00001 /* mbed Microcontroller Library - Timeout 00002 * Copyright (c) 2007-2009 ARM Limited. All rights reserved. 00003 */ 00004 00005 #ifndef MBED_TIMEOUT_H 00006 #define MBED_TIMEOUT_H 00007 00008 #include "Ticker.h" 00009 00010 namespace mbed { 00011 00012 /* Class: Timeout 00013 * A Timeout is used to call a function at a point in the future 00014 * 00015 * You can use as many seperate Timeout objects as you require. 00016 * 00017 * Example: 00018 * > // Blink until timeout. 00019 * > 00020 * > #include "mbed.h" 00021 * > 00022 * > Timeout timeout; 00023 * > DigitalOut led(LED1); 00024 * > 00025 * > int on = 1; 00026 * > 00027 * > void attimeout() { 00028 * > on = 0; 00029 * > } 00030 * > 00031 * > int main() { 00032 * > timeout.attach(&attimeout, 5); 00033 * > while(on) { 00034 * > led = !led; 00035 * > wait(0.2); 00036 * > } 00037 * > } 00038 */ 00039 class Timeout : public Ticker { 00040 00041 #if 0 // For documentation 00042 00043 /* Function: attach 00044 * Attach a function to be called by the Timeout, specifiying the delay in seconds 00045 * 00046 * Variables: 00047 * fptr - pointer to the function to be called 00048 * t - the time before the call in seconds 00049 */ 00050 void attach(void (*fptr)(void), float t) { 00051 attach_us(fptr, t * 1000000.0f); 00052 } 00053 00054 /* Function: attach 00055 * Attach a member function to be called by the Timeout, specifiying the delay in seconds 00056 * 00057 * Variables: 00058 * tptr - pointer to the object to call the member function on 00059 * mptr - pointer to the member function to be called 00060 * t - the time before the calls in seconds 00061 */ 00062 template<typename T> 00063 void attach(T* tptr, void (T::*mptr)(void), float t) { 00064 attach_us(tptr, mptr, t * 1000000.0f); 00065 } 00066 00067 /* Function: attach_us 00068 * Attach a function to be called by the Timeout, specifiying the delay in micro-seconds 00069 * 00070 * Variables: 00071 * fptr - pointer to the function to be called 00072 * t - the time before the call in micro-seconds 00073 */ 00074 void attach_us(void (*fptr)(void), unsigned int t) { 00075 _function.attach(fptr); 00076 setup(t); 00077 } 00078 00079 /* Function: attach_us 00080 * Attach a member function to be called by the Timeout, specifiying the delay in micro-seconds 00081 * 00082 * Variables: 00083 * tptr - pointer to the object to call the member function on 00084 * mptr - pointer to the member function to be called 00085 * t - the time before the call in micro-seconds 00086 */ 00087 template<typename T> 00088 void attach_us(T* tptr, void (T::*mptr)(void), unsigned int t) { 00089 _function.attach(tptr, mptr); 00090 setup(t); 00091 } 00092 00093 /* Function: detach 00094 * Detach the function 00095 */ 00096 void detach(); 00097 00098 #endif 00099 00100 protected: 00101 00102 virtual void handler(); 00103 00104 }; 00105 00106 } // namespace mbed 00107 00108 #endif
Generated on Tue Jul 12 2022 15:52:00 by 1.7.2