Lib_Misc
Unwrapper.cpp@0:3312872854c4, 2019-03-04 (annotated)
- Committer:
- altb
- Date:
- Mon Mar 04 11:03:51 2019 +0000
- Revision:
- 0:3312872854c4
New Lib Folder
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
altb | 0:3312872854c4 | 1 | /* |
altb | 0:3312872854c4 | 2 | */ |
altb | 0:3312872854c4 | 3 | |
altb | 0:3312872854c4 | 4 | #include "Unwrapper.h" |
altb | 0:3312872854c4 | 5 | #define pi 3.141592653589793 |
altb | 0:3312872854c4 | 6 | using namespace std; |
altb | 0:3312872854c4 | 7 | |
altb | 0:3312872854c4 | 8 | Unwrapper::Unwrapper(double i2r) |
altb | 0:3312872854c4 | 9 | { |
altb | 0:3312872854c4 | 10 | inc2rad = i2r; |
altb | 0:3312872854c4 | 11 | last_value = 0; |
altb | 0:3312872854c4 | 12 | } |
altb | 0:3312872854c4 | 13 | |
altb | 0:3312872854c4 | 14 | Unwrapper::~Unwrapper() {} |
altb | 0:3312872854c4 | 15 | |
altb | 0:3312872854c4 | 16 | void Unwrapper::reset(void) |
altb | 0:3312872854c4 | 17 | { |
altb | 0:3312872854c4 | 18 | last_value = 0; |
altb | 0:3312872854c4 | 19 | } |
altb | 0:3312872854c4 | 20 | |
altb | 0:3312872854c4 | 21 | double Unwrapper::doStep(short inc) |
altb | 0:3312872854c4 | 22 | { |
altb | 0:3312872854c4 | 23 | long temp = inc; |
altb | 0:3312872854c4 | 24 | if((temp - last_value) > 32000) |
altb | 0:3312872854c4 | 25 | temp -= 0xFFFF; |
altb | 0:3312872854c4 | 26 | else if((temp - last_value) < -32000) |
altb | 0:3312872854c4 | 27 | temp += 0xFFFF; |
altb | 0:3312872854c4 | 28 | last_value = temp; |
altb | 0:3312872854c4 | 29 | return (temp*inc2rad); |
altb | 0:3312872854c4 | 30 | } |