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