UVic Assistive Technology Lab / Mbed 2 deprecated DSLR_Camera_Gimbal

Dependencies:   mbed ros_lib_kinetic

Committer:
group-UVic-Assistive-Technolog
Date:
Wed Jan 31 05:24:12 2018 +0000
Revision:
0:3a767f41cf04
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
group-UVic-Assistive-Technolog 0:3a767f41cf04 1 /* mbed Microcontroller Library
group-UVic-Assistive-Technolog 0:3a767f41cf04 2 * Copyright (c) 2006-2013 ARM Limited
group-UVic-Assistive-Technolog 0:3a767f41cf04 3 *
group-UVic-Assistive-Technolog 0:3a767f41cf04 4 * Licensed under the Apache License, Version 2.0 (the "License");
group-UVic-Assistive-Technolog 0:3a767f41cf04 5 * you may not use this file except in compliance with the License.
group-UVic-Assistive-Technolog 0:3a767f41cf04 6 * You may obtain a copy of the License at
group-UVic-Assistive-Technolog 0:3a767f41cf04 7 *
group-UVic-Assistive-Technolog 0:3a767f41cf04 8 * http://www.apache.org/licenses/LICENSE-2.0
group-UVic-Assistive-Technolog 0:3a767f41cf04 9 *
group-UVic-Assistive-Technolog 0:3a767f41cf04 10 * Unless required by applicable law or agreed to in writing, software
group-UVic-Assistive-Technolog 0:3a767f41cf04 11 * distributed under the License is distributed on an "AS IS" BASIS,
group-UVic-Assistive-Technolog 0:3a767f41cf04 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
group-UVic-Assistive-Technolog 0:3a767f41cf04 13 * See the License for the specific language governing permissions and
group-UVic-Assistive-Technolog 0:3a767f41cf04 14 * limitations under the License.
group-UVic-Assistive-Technolog 0:3a767f41cf04 15 */
group-UVic-Assistive-Technolog 0:3a767f41cf04 16 #ifndef MBED_TIMER_H
group-UVic-Assistive-Technolog 0:3a767f41cf04 17 #define MBED_TIMER_H
group-UVic-Assistive-Technolog 0:3a767f41cf04 18
group-UVic-Assistive-Technolog 0:3a767f41cf04 19 #include "platform.h"
group-UVic-Assistive-Technolog 0:3a767f41cf04 20 #include "ticker_api.h"
group-UVic-Assistive-Technolog 0:3a767f41cf04 21
group-UVic-Assistive-Technolog 0:3a767f41cf04 22 namespace mbed {
group-UVic-Assistive-Technolog 0:3a767f41cf04 23
group-UVic-Assistive-Technolog 0:3a767f41cf04 24 /** A general purpose timer
group-UVic-Assistive-Technolog 0:3a767f41cf04 25 *
group-UVic-Assistive-Technolog 0:3a767f41cf04 26 * Example:
group-UVic-Assistive-Technolog 0:3a767f41cf04 27 * @code
group-UVic-Assistive-Technolog 0:3a767f41cf04 28 * // Count the time to toggle a LED
group-UVic-Assistive-Technolog 0:3a767f41cf04 29 *
group-UVic-Assistive-Technolog 0:3a767f41cf04 30 * #include "mbed.h"
group-UVic-Assistive-Technolog 0:3a767f41cf04 31 *
group-UVic-Assistive-Technolog 0:3a767f41cf04 32 * Timer timer;
group-UVic-Assistive-Technolog 0:3a767f41cf04 33 * DigitalOut led(LED1);
group-UVic-Assistive-Technolog 0:3a767f41cf04 34 * int begin, end;
group-UVic-Assistive-Technolog 0:3a767f41cf04 35 *
group-UVic-Assistive-Technolog 0:3a767f41cf04 36 * int main() {
group-UVic-Assistive-Technolog 0:3a767f41cf04 37 * timer.start();
group-UVic-Assistive-Technolog 0:3a767f41cf04 38 * begin = timer.read_us();
group-UVic-Assistive-Technolog 0:3a767f41cf04 39 * led = !led;
group-UVic-Assistive-Technolog 0:3a767f41cf04 40 * end = timer.read_us();
group-UVic-Assistive-Technolog 0:3a767f41cf04 41 * printf("Toggle the led takes %d us", end - begin);
group-UVic-Assistive-Technolog 0:3a767f41cf04 42 * }
group-UVic-Assistive-Technolog 0:3a767f41cf04 43 * @endcode
group-UVic-Assistive-Technolog 0:3a767f41cf04 44 */
group-UVic-Assistive-Technolog 0:3a767f41cf04 45 class Timer {
group-UVic-Assistive-Technolog 0:3a767f41cf04 46
group-UVic-Assistive-Technolog 0:3a767f41cf04 47 public:
group-UVic-Assistive-Technolog 0:3a767f41cf04 48 Timer();
group-UVic-Assistive-Technolog 0:3a767f41cf04 49 Timer(const ticker_data_t *data);
group-UVic-Assistive-Technolog 0:3a767f41cf04 50
group-UVic-Assistive-Technolog 0:3a767f41cf04 51 /** Start the timer
group-UVic-Assistive-Technolog 0:3a767f41cf04 52 */
group-UVic-Assistive-Technolog 0:3a767f41cf04 53 void start();
group-UVic-Assistive-Technolog 0:3a767f41cf04 54
group-UVic-Assistive-Technolog 0:3a767f41cf04 55 /** Stop the timer
group-UVic-Assistive-Technolog 0:3a767f41cf04 56 */
group-UVic-Assistive-Technolog 0:3a767f41cf04 57 void stop();
group-UVic-Assistive-Technolog 0:3a767f41cf04 58
group-UVic-Assistive-Technolog 0:3a767f41cf04 59 /** Reset the timer to 0.
group-UVic-Assistive-Technolog 0:3a767f41cf04 60 *
group-UVic-Assistive-Technolog 0:3a767f41cf04 61 * If it was already counting, it will continue
group-UVic-Assistive-Technolog 0:3a767f41cf04 62 */
group-UVic-Assistive-Technolog 0:3a767f41cf04 63 void reset();
group-UVic-Assistive-Technolog 0:3a767f41cf04 64
group-UVic-Assistive-Technolog 0:3a767f41cf04 65 /** Get the time passed in seconds
group-UVic-Assistive-Technolog 0:3a767f41cf04 66 */
group-UVic-Assistive-Technolog 0:3a767f41cf04 67 float read();
group-UVic-Assistive-Technolog 0:3a767f41cf04 68
group-UVic-Assistive-Technolog 0:3a767f41cf04 69 /** Get the time passed in mili-seconds
group-UVic-Assistive-Technolog 0:3a767f41cf04 70 */
group-UVic-Assistive-Technolog 0:3a767f41cf04 71 int read_ms();
group-UVic-Assistive-Technolog 0:3a767f41cf04 72
group-UVic-Assistive-Technolog 0:3a767f41cf04 73 /** Get the time passed in micro-seconds
group-UVic-Assistive-Technolog 0:3a767f41cf04 74 */
group-UVic-Assistive-Technolog 0:3a767f41cf04 75 int read_us();
group-UVic-Assistive-Technolog 0:3a767f41cf04 76
group-UVic-Assistive-Technolog 0:3a767f41cf04 77 #ifdef MBED_OPERATORS
group-UVic-Assistive-Technolog 0:3a767f41cf04 78 operator float();
group-UVic-Assistive-Technolog 0:3a767f41cf04 79 #endif
group-UVic-Assistive-Technolog 0:3a767f41cf04 80
group-UVic-Assistive-Technolog 0:3a767f41cf04 81 protected:
group-UVic-Assistive-Technolog 0:3a767f41cf04 82 int slicetime();
group-UVic-Assistive-Technolog 0:3a767f41cf04 83 int _running; // whether the timer is running
group-UVic-Assistive-Technolog 0:3a767f41cf04 84 unsigned int _start; // the start time of the latest slice
group-UVic-Assistive-Technolog 0:3a767f41cf04 85 int _time; // any accumulated time from previous slices
group-UVic-Assistive-Technolog 0:3a767f41cf04 86 const ticker_data_t *_ticker_data;
group-UVic-Assistive-Technolog 0:3a767f41cf04 87 };
group-UVic-Assistive-Technolog 0:3a767f41cf04 88
group-UVic-Assistive-Technolog 0:3a767f41cf04 89 } // namespace mbed
group-UVic-Assistive-Technolog 0:3a767f41cf04 90
group-UVic-Assistive-Technolog 0:3a767f41cf04 91 #endif