Mercurial > public > hwos_code
annotate src/Tests/compass_trigo_test.cpp @ 501:69a98f3f3b84
minor
author | heinrichsweikamp |
---|---|
date | Mon, 22 May 2017 23:03:21 +0200 |
parents | 7d9edd3b8c86 |
children |
rev | line source |
---|---|
282
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
1 ////////////////////////////////////////////////////////////////////////////// |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
2 /// compass_trigo_test.cpp |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
3 /// Unit test for compass various operations. |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
4 /// Copyright (c) 2012-2015, JD Gascuel, HeinrichsWeikamp, all right reserved. |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
5 ////////////////////////////////////////////////////////////////////////////// |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
6 // HISTORY |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
7 // 2015-05-23 jDG: Rewrite compass testing, to allow reducing code size. |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
8 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
9 extern "C" { |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
10 # include "compass.h" |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
11 } |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
12 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
13 #include <gtest/gtest.h> |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
14 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
15 ////////////////////////////////////////////////////////////////////////////// |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
16 // Fake assembleur fixed point multiplies. |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
17 extern "C" Int16 compass_umul(void); |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
18 extern "C" Int16 compass_imul(void); |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
19 extern "C" Int16 compass_a, compass_b; |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
20 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
21 // The (filtered) components of the magnetometer sensor: |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
22 Int16 compass_DX_f; |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
23 Int16 compass_DY_f; |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
24 Int16 compass_DZ_f; |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
25 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
26 // Found soft-iron calibration values, deduced from already filtered values. |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
27 Int16 compass_CX_f; |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
28 Int16 compass_CY_f; |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
29 Int16 compass_CZ_f; |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
30 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
31 // The (filtered) components of the accelerometer sensor: |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
32 Int16 accel_DX_f; |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
33 Int16 accel_DY_f; |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
34 Int16 accel_DZ_f; |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
35 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
36 // The compass result value. |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
37 Int16 compass_heading; |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
38 Int16 compass_roll; |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
39 Int16 compass_pitch; |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
40 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
41 Int16 compass_a, compass_b; |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
42 Int16 compass_umul() |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
43 { |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
44 unsigned int a = compass_a; |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
45 unsigned int b = compass_b; |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
46 a *= b; |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
47 a >>= 15; |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
48 return (Int16)a; |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
49 } |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
50 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
51 Int16 compass_imul() |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
52 { |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
53 int a = compass_a; |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
54 int b = compass_b; |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
55 a *= b; |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
56 a >>= 15; |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
57 return (Int16)a; |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
58 } |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
59 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
60 ////////////////////////////////////////////////////////////////////////////// |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
61 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
62 TEST(ops, multiply) { |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
63 // Check basic sign handling: |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
64 EXPECT_EQ(umul( 8000, 4000), (Int16)0x03D0); // 8000/2**15 * 4000/2**15 = 0x3D0 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
65 EXPECT_EQ(imul(-8000, 4000), (Int16)0xFC2F); // -976 = 0xFC2F |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
66 EXPECT_EQ(imul( 8000, -4000), (Int16)0xFC2F); // -976 = 0xFC2F |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
67 EXPECT_EQ(imul(-8000, -4000), (Int16)0x03D0); // +976 = 0x3D0 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
68 } |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
69 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
70 TEST(ops, divide) { |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
71 // Check basic divides: |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
72 EXPECT_EQ(udiv(32000, 32001), (Int16)32766); // 0.99997 ~ 32766 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
73 EXPECT_EQ(udiv( 4000, 8000), (Int16)16384); |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
74 EXPECT_EQ(udiv( 2000, 8000), (Int16) 8192); |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
75 EXPECT_EQ(udiv( 1000, 8000), (Int16) 4096); |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
76 EXPECT_EQ(udiv( 500, 8000), (Int16) 2048); |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
77 } |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
78 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
79 TEST(trigo, atan) { |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
80 // Check angles returned by the SINGLE QUADRANT atan() function: |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
81 EXPECT_EQ(utan(100, 100), (Int16)4501); // +1 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
82 EXPECT_EQ(utan( 90, 100), (Int16)4195); // -4 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
83 EXPECT_EQ(utan( 80, 100), (Int16)3864); // -2 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
84 EXPECT_EQ(utan( 70, 100), (Int16)3500); // +1 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
85 EXPECT_EQ(utan( 60, 100), (Int16)3099); // +3 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
86 EXPECT_EQ(utan( 50, 100), (Int16)2658); // +1 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
87 EXPECT_EQ(utan( 40, 100), (Int16)2179); // -1 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
88 EXPECT_EQ(utan( 30, 100), (Int16)1667); // -3 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
89 EXPECT_EQ(utan( 20, 100), (Int16)1127); // -4 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
90 EXPECT_EQ(utan( 10, 100), (Int16) 569); // -2 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
91 EXPECT_EQ(utan( 0, 100), (Int16) 0); |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
92 } |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
93 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
94 TEST(trigo, cosx2h2) { |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
95 // Check ONE-OCTANT pseudo-cosinus function |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
96 // Note: cosxh(x**2, x**2+y**2) is computing cos(atan(y/x)) |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
97 EXPECT_EQ(cosxh(12769, 13169), (Int16)32268); // 113, 20 --> 10.0369° --> 32267 +1 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
98 EXPECT_EQ(cosxh(10000, 12500), (Int16)29310); // 100, 50 --> 26.5650° --> 29309 +1 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
99 EXPECT_EQ(cosxh(10000, 20000), (Int16)23171); // 100, 100 --> 45.0000° --> 23170 +1 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
100 EXPECT_EQ(cosxh( 2500, 12500), (Int16)14658); // 50, 100 --> 63.4349° --> 14654 +4 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
101 EXPECT_EQ(cosxh( 400, 13169), (Int16) 5718); // 20, 113 --> 79.9631° --> 5711 +7 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
102 } |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
103 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
104 TEST(trigo, sinCos) { |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
105 Int16 sin, cos; |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
106 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
107 //---- Check sincos() FIRST QUADRANT --------------------------------- |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
108 sincos( 20, 113, &sin, &cos); // 80° |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
109 EXPECT_EQ(sin, (Int16)32269); // +2 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
110 EXPECT_EQ(cos, (Int16) 5727); // +16 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
111 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
112 sincos( 50, 100, &sin, &cos); // 63° |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
113 EXPECT_EQ(sin, (Int16)29311); // +2 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
114 EXPECT_EQ(cos, (Int16)14660); // +6 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
115 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
116 sincos(100, 100, &sin, &cos); // 45° |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
117 EXPECT_EQ(sin, (Int16)23173); // +3 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
118 EXPECT_EQ(cos, (Int16)23173); // +3 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
119 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
120 sincos(100, 50, &sin, &cos); // 27° |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
121 EXPECT_EQ(sin, (Int16)14660); // +6 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
122 EXPECT_EQ(cos, (Int16)29311); // +2 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
123 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
124 sincos(113, 20, &sin, &cos); // 10° |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
125 EXPECT_EQ(sin, (Int16) 5727); // +16 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
126 EXPECT_EQ(cos, (Int16)32269); // +2 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
127 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
128 //---- Check sincos() OTHER QUADRANTS -------------------------------- |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
129 sincos(-20, 113, &sin, &cos); // 90+80° |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
130 EXPECT_EQ(sin, (Int16) 32269); // +2 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
131 EXPECT_EQ(cos, (Int16) -5727); // +16 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
132 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
133 sincos(-20,-113, &sin, &cos); // 180+80° |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
134 EXPECT_EQ(sin, (Int16)-32269); // +2 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
135 EXPECT_EQ(cos, (Int16) -5727); // +16 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
136 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
137 sincos( 20,-113, &sin, &cos); // 270+80° |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
138 EXPECT_EQ(sin, (Int16)-32269); // +2 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
139 EXPECT_EQ(cos, (Int16) 5727); // +16 |
7d9edd3b8c86
Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents:
diff
changeset
|
140 } |