Arduino driver library for Decawave DW1000

- Main Page
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Macros
DW1000Time.h
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2015 by Thomas Trojer <thomas@trojer.net>
3 * Decawave DW1000 library for arduino.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * @file DW1000Time.h
18 * Arduino driver library timestamp wrapper (header file) for the Decawave
19 * DW1000 UWB transceiver IC.
20 */
21
22 #ifndef _DW1000Time_H_INCLUDED
23 #define _DW1000Time_H_INCLUDED
24
25 // Time resolution in micro-seconds of time based registers/values.
26 // Each bit in a timestamp counts for a period of approx. 15.65ps
27 #define TIME_RES 0.000015650040064103f
28 #define TIME_RES_INV 63897.6f
29
30 // Speed of radio waves [m/s] * timestamp resolution [~15.65ps] of DW1000
31 #define DISTANCE_OF_RADIO 0.0046917639786159f
32
33 // time stamp byte length
34 #define LEN_STAMP 5
35
36 #include <Arduino.h>
37
38 class DW1000Time {
39 public:
40 DW1000Time();
41 DW1000Time(long long int time);
42 DW1000Time(float timeUs);
43 DW1000Time(byte data[]);
44 DW1000Time(long value, float factorUs);
45 DW1000Time(const DW1000Time& copy);
46 ~DW1000Time();
47
48 void setTime(float timeUs);
49 void setTime(long value, float factorUs);
50
51 float getAsFloat() const;
52 void getAsBytes(byte data[]) const;
53 float getAsMeters() const;
54
55 void getTimestamp(byte data[]) const;
56 long long int getTimestamp() const;
57 void setTimestamp(byte data[]);
58 void setTimestamp(const DW1000Time& copy);
59
60 DW1000Time& operator=(const DW1000Time &assign);
61 DW1000Time& operator+=(const DW1000Time &add);
62 const DW1000Time operator+(const DW1000Time &add) const;
63 DW1000Time& operator-=(const DW1000Time &sub);
64 const DW1000Time operator-(const DW1000Time &sub) const;
65 DW1000Time& operator*=(float factor);
66 const DW1000Time operator*(float factor) const;
67 DW1000Time& operator/=(float factor);
68 const DW1000Time operator/(float factor) const;
69 boolean operator==(const DW1000Time &cmp) const;
70 boolean operator!=(const DW1000Time &cmp) const;
71
72 // time factors (relative to [us]) for setting delayed transceive
73 static const float SECONDS = 1e6;
74 static const float MILLISECONDS = 1e3;
75 static const float MICROSECONDS = 1;
76 static const float NANOSECONDS = 1e-3;
77
78 // timer/counter overflow (40 bits)
79 static const long long unsigned int TIME_OVERFLOW = 1099511627776;
80
81 private:
82 long long int _timestamp;
83 };
84
85 #endif
86
DW1000Time::setTime
void setTime(float timeUs)
Definition: DW1000Time.cpp:46
DW1000Time::getAsBytes
void getAsBytes(byte data[]) const
DW1000Time::getAsMeters
float getAsMeters() const
Definition: DW1000Time.cpp:82
DW1000Time::operator!=
boolean operator!=(const DW1000Time &cmp) const
Definition: DW1000Time.cpp:134
DW1000Time::NANOSECONDS
static const float NANOSECONDS
Definition: DW1000Time.h:76
DW1000Time::operator/=
DW1000Time & operator/=(float factor)
Definition: DW1000Time.cpp:122
DW1000Time::operator/
const DW1000Time operator/(float factor) const
Definition: DW1000Time.cpp:126
DW1000Time::getAsFloat
float getAsFloat() const
Definition: DW1000Time.cpp:78
DW1000Time::MILLISECONDS
static const float MILLISECONDS
Definition: DW1000Time.h:74
DW1000Time::operator+=
DW1000Time & operator+=(const DW1000Time &add)
Definition: DW1000Time.cpp:94
DW1000Time::operator-
const DW1000Time operator-(const DW1000Time &sub) const
Definition: DW1000Time.cpp:108
DW1000Time::operator==
boolean operator==(const DW1000Time &cmp) const
Definition: DW1000Time.cpp:130
DW1000Time::TIME_OVERFLOW
static const long long unsigned int TIME_OVERFLOW
Definition: DW1000Time.h:79
DW1000Time::DW1000Time
DW1000Time()
Definition: DW1000Time.cpp:24
DW1000Time::SECONDS
static const float SECONDS
Definition: DW1000Time.h:73
DW1000Time::operator*
const DW1000Time operator*(float factor) const
Definition: DW1000Time.cpp:118
DW1000Time::MICROSECONDS
static const float MICROSECONDS
Definition: DW1000Time.h:75
DW1000Time::~DW1000Time
~DW1000Time()
Definition: DW1000Time.cpp:44
DW1000Time
Definition: DW1000Time.h:38
DW1000Time::setTimestamp
void setTimestamp(byte data[])
Definition: DW1000Time.cpp:56
DW1000Time::getTimestamp
long long int getTimestamp() const
Definition: DW1000Time.cpp:67
DW1000Time::operator*=
DW1000Time & operator*=(float factor)
Definition: DW1000Time.cpp:112
DW1000Time::operator=
DW1000Time & operator=(const DW1000Time &assign)
Definition: DW1000Time.cpp:86
DW1000Time::operator+
const DW1000Time operator+(const DW1000Time &add) const
Definition: DW1000Time.cpp:99
DW1000Time::operator-=
DW1000Time & operator-=(const DW1000Time &sub)
Definition: DW1000Time.cpp:103