2 * This file is part of Cleanflight, Betaflight and INAV
4 * Cleanflight, Betaflight and INAV are free software. You can
5 * redistribute this software and/or modify this software under
6 * the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License,
8 * or (at your option) any later version.
10 * Cleanflight, Betaflight and INAV are distributed in the hope that
11 * they will be useful, but WITHOUT ANY WARRANTY; without even the
12 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13 * PURPOSE. See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
28 #include "build/debug.h"
29 #include "common/utils.h"
31 #include "config/parameter_group.h"
32 #include "config/parameter_group_ids.h"
34 #include "fc/fc_msp.h"
35 #include "fc/fc_msp_box.h"
36 #include "fc/settings.h"
38 #include "io/piniobox.h"
41 PG_REGISTER_WITH_RESET_TEMPLATE(pinioBoxConfig_t
, pinioBoxConfig
, PG_PINIOBOX_CONFIG
, 1);
43 PG_RESET_TEMPLATE(pinioBoxConfig_t
, pinioBoxConfig
,
44 { SETTING_PINIO_BOX1_DEFAULT
, SETTING_PINIO_BOX2_DEFAULT
, SETTING_PINIO_BOX3_DEFAULT
, SETTING_PINIO_BOX4_DEFAULT
}
47 typedef struct pinioBoxRuntimeConfig_s
{
48 uint8_t boxId
[PINIO_COUNT
];
49 } pinioBoxRuntimeConfig_t
;
51 static pinioBoxRuntimeConfig_t pinioBoxRuntimeConfig
;
53 void pinioBoxInit(void)
55 // Convert permanentId to boxId_e
56 for (int i
= 0; i
< PINIO_COUNT
; i
++) {
57 const box_t
*box
= findBoxByPermanentId(pinioBoxConfig()->permanentId
[i
]);
59 pinioBoxRuntimeConfig
.boxId
[i
] = box
? box
->boxId
: BOXID_NONE
;
63 void pinioBoxUpdate(void)
65 for (int i
= 0; i
< PINIO_COUNT
; i
++) {
66 if (pinioBoxRuntimeConfig
.boxId
[i
] != BOXID_NONE
) {
67 pinioSet(i
, IS_RC_MODE_ACTIVE(pinioBoxRuntimeConfig
.boxId
[i
]));