2 * This file is part of Cleanflight.
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 Cleanflight. If not, see <http://www.gnu.org/licenses/>.
26 #include "build/debug.h"
28 #include "pg/pg_ids.h"
31 #include "flight/mixer.h"
33 //PG_DECLARE(motorConfig_t, motorConfig);
35 PG_REGISTER_WITH_RESET_TEMPLATE(motorConfig_t
, motorConfig
, PG_MOTOR_CONFIG
, 1);
37 PG_RESET_TEMPLATE(motorConfig_t
, motorConfig
,
38 .dev
= {.motorPwmRate
= 400},
45 #include "unittest_macros.h"
46 #include "gtest/gtest.h"
48 TEST(ParameterGroupsfTest
, Test_pgResetAll
)
50 memset(motorConfigMutable(), 0, sizeof(motorConfig_t
));
52 EXPECT_EQ(1850, motorConfig()->maxthrottle
);
53 EXPECT_EQ(1000, motorConfig()->mincommand
);
54 EXPECT_EQ(400, motorConfig()->dev
.motorPwmRate
);
57 TEST(ParameterGroupsfTest
, Test_pgFind
)
59 memset(motorConfigMutable(), 0, sizeof(motorConfig_t
));
60 const pgRegistry_t
*pgRegistry
= pgFind(PG_MOTOR_CONFIG
);
62 EXPECT_EQ(1850, motorConfig()->maxthrottle
);
63 EXPECT_EQ(1000, motorConfig()->mincommand
);
64 EXPECT_EQ(400, motorConfig()->dev
.motorPwmRate
);
66 motorConfig_t motorConfig2
;
67 memset(&motorConfig2
, 0, sizeof(motorConfig_t
));
68 motorConfigMutable()->dev
.motorPwmRate
= 500;
69 pgStore(pgRegistry
, &motorConfig2
, sizeof(motorConfig_t
));
70 EXPECT_EQ(1850, motorConfig2
.maxthrottle
);
71 EXPECT_EQ(1000, motorConfig2
.mincommand
);
72 EXPECT_EQ(500, motorConfig2
.dev
.motorPwmRate
);
74 motorConfig_t motorConfig3
;
75 memset(&motorConfig3
, 0, sizeof(motorConfig_t
));
76 pgResetCopy(&motorConfig3
, PG_MOTOR_CONFIG
);
77 EXPECT_EQ(1850, motorConfig3
.maxthrottle
);
78 EXPECT_EQ(1000, motorConfig3
.mincommand
);
79 EXPECT_EQ(400, motorConfig3
.dev
.motorPwmRate
);