2 * This file is part of INAV.
4 * Cleanflight is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with INAV. If not, see <http://www.gnu.org/licenses/>.
23 #include "gtest/gtest.h"
24 #include "unittest_macros.h"
26 #include "io/gimbal_serial.h"
27 #include "drivers/headtracker_common.h"
29 void dumpMemory(uint8_t *mem
, int size
)
31 for(int i
=0; i
< size
; ++i
) {
32 printf("%02x ", mem
[i
]);
37 TEST(GimbalSerialTest
, TestGimbalSerialScale
)
39 int16_t res16
= gimbal_scale12(1000, 2000, 2000);
40 EXPECT_TRUE(res16
== 2047);
41 res16
= gimbal_scale12(1000, 2000, 1000);
42 printf("res16: %i\n", res16
);
43 EXPECT_TRUE(res16
== -2048);
44 res16
= gimbal_scale12(1000, 2000, 1500);
45 printf("res16: %i\n", res16
);
46 EXPECT_TRUE(res16
== -1);
47 res16
= gimbal_scale12(1000, 2000, 1501);
48 printf("res16: %i\n", res16
);
49 EXPECT_TRUE(res16
== 3);