mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-18 22:05:17 +03:00
Add box to pinio monitor/mapper
This commit is contained in:
parent
8294048ce5
commit
6557b161aa
15 changed files with 193 additions and 1 deletions
|
@ -57,6 +57,7 @@ COMMON_SRC = \
|
||||||
interface/msp.c \
|
interface/msp.c \
|
||||||
interface/msp_box.c \
|
interface/msp_box.c \
|
||||||
io/beeper.c \
|
io/beeper.c \
|
||||||
|
io/piniobox.c \
|
||||||
io/serial.c \
|
io/serial.c \
|
||||||
io/statusindicator.c \
|
io/statusindicator.c \
|
||||||
io/transponder_ir.c \
|
io/transponder_ir.c \
|
||||||
|
@ -69,6 +70,7 @@ COMMON_SRC = \
|
||||||
pg/dashboard.c \
|
pg/dashboard.c \
|
||||||
pg/max7456.c \
|
pg/max7456.c \
|
||||||
pg/pinio.c \
|
pg/pinio.c \
|
||||||
|
pg/piniobox.c \
|
||||||
pg/pg.c \
|
pg/pg.c \
|
||||||
pg/rx_pwm.c \
|
pg/rx_pwm.c \
|
||||||
pg/sdcard.c \
|
pg/sdcard.c \
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#ifndef PINIO_COUNT
|
#ifndef PINIO_COUNT
|
||||||
#define PINIO_COUNT 4
|
#define PINIO_COUNT 4
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -88,6 +88,7 @@
|
||||||
#include "pg/bus_spi.h"
|
#include "pg/bus_spi.h"
|
||||||
#include "pg/flash.h"
|
#include "pg/flash.h"
|
||||||
#include "pg/pinio.h"
|
#include "pg/pinio.h"
|
||||||
|
#include "pg/piniobox.h"
|
||||||
#include "pg/pg.h"
|
#include "pg/pg.h"
|
||||||
#include "pg/rx_pwm.h"
|
#include "pg/rx_pwm.h"
|
||||||
#include "pg/sdcard.h"
|
#include "pg/sdcard.h"
|
||||||
|
@ -113,6 +114,7 @@
|
||||||
#include "io/transponder_ir.h"
|
#include "io/transponder_ir.h"
|
||||||
#include "io/osd.h"
|
#include "io/osd.h"
|
||||||
#include "io/osd_slave.h"
|
#include "io/osd_slave.h"
|
||||||
|
#include "io/piniobox.h"
|
||||||
#include "io/displayport_msp.h"
|
#include "io/displayport_msp.h"
|
||||||
#include "io/vtx.h"
|
#include "io/vtx.h"
|
||||||
#include "io/vtx_rtc6705.h"
|
#include "io/vtx_rtc6705.h"
|
||||||
|
@ -538,6 +540,10 @@ void init(void)
|
||||||
pinioInit(pinioConfig());
|
pinioInit(pinioConfig());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_PINIOBOX
|
||||||
|
pinioBoxInit(pinioBoxConfig());
|
||||||
|
#endif
|
||||||
|
|
||||||
LED1_ON;
|
LED1_ON;
|
||||||
LED0_OFF;
|
LED0_OFF;
|
||||||
LED2_OFF;
|
LED2_OFF;
|
||||||
|
|
|
@ -60,6 +60,7 @@
|
||||||
#include "io/ledstrip.h"
|
#include "io/ledstrip.h"
|
||||||
#include "io/osd.h"
|
#include "io/osd.h"
|
||||||
#include "io/osd_slave.h"
|
#include "io/osd_slave.h"
|
||||||
|
#include "io/piniobox.h"
|
||||||
#include "io/serial.h"
|
#include "io/serial.h"
|
||||||
#include "io/transponder_ir.h"
|
#include "io/transponder_ir.h"
|
||||||
#include "io/vtx_tramp.h" // Will be gone
|
#include "io/vtx_tramp.h" // Will be gone
|
||||||
|
@ -305,6 +306,9 @@ void fcTasksInit(void)
|
||||||
#ifdef USE_ADC_INTERNAL
|
#ifdef USE_ADC_INTERNAL
|
||||||
setTaskEnabled(TASK_ADC_INTERNAL, true);
|
setTaskEnabled(TASK_ADC_INTERNAL, true);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef USE_PINIOBOX
|
||||||
|
setTaskEnabled(TASK_PINIOBOX, true);
|
||||||
|
#endif
|
||||||
#ifdef USE_CMS
|
#ifdef USE_CMS
|
||||||
#ifdef USE_MSP_DISPLAYPORT
|
#ifdef USE_MSP_DISPLAYPORT
|
||||||
setTaskEnabled(TASK_CMS, true);
|
setTaskEnabled(TASK_CMS, true);
|
||||||
|
@ -585,5 +589,14 @@ cfTask_t cfTasks[TASK_COUNT] = {
|
||||||
.staticPriority = TASK_PRIORITY_IDLE
|
.staticPriority = TASK_PRIORITY_IDLE
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_PINIOBOX
|
||||||
|
[TASK_PINIOBOX] = {
|
||||||
|
.taskName = "PINIOBOX",
|
||||||
|
.taskFunc = pinioBoxUpdate,
|
||||||
|
.desiredPeriod = TASK_PERIOD_HZ(20),
|
||||||
|
.staticPriority = TASK_PRIORITY_IDLE
|
||||||
|
},
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
|
@ -67,6 +67,10 @@ typedef enum {
|
||||||
BOXBEEPGPSCOUNT,
|
BOXBEEPGPSCOUNT,
|
||||||
BOX3DONASWITCH,
|
BOX3DONASWITCH,
|
||||||
BOXVTXPITMODE,
|
BOXVTXPITMODE,
|
||||||
|
BOXUSER1,
|
||||||
|
BOXUSER2,
|
||||||
|
BOXUSER3,
|
||||||
|
BOXUSER4,
|
||||||
CHECKBOX_ITEM_COUNT
|
CHECKBOX_ITEM_COUNT
|
||||||
} boxId_e;
|
} boxId_e;
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,8 @@
|
||||||
|
|
||||||
#include "telemetry/telemetry.h"
|
#include "telemetry/telemetry.h"
|
||||||
|
|
||||||
|
#include "pg/piniobox.h"
|
||||||
|
|
||||||
|
|
||||||
#ifndef USE_OSD_SLAVE
|
#ifndef USE_OSD_SLAVE
|
||||||
// permanent IDs must uniquely identify BOX meaning, DO NOT REUSE THEM!
|
// permanent IDs must uniquely identify BOX meaning, DO NOT REUSE THEM!
|
||||||
|
@ -82,6 +84,10 @@ static const box_t boxes[CHECKBOX_ITEM_COUNT] = {
|
||||||
{ BOXBEEPGPSCOUNT, "BEEP GPS SATELLITE COUNT", 37 },
|
{ BOXBEEPGPSCOUNT, "BEEP GPS SATELLITE COUNT", 37 },
|
||||||
{ BOX3DONASWITCH, "3D ON A SWITCH", 38 },
|
{ BOX3DONASWITCH, "3D ON A SWITCH", 38 },
|
||||||
{ BOXVTXPITMODE, "VTX PIT MODE", 39 },
|
{ BOXVTXPITMODE, "VTX PIT MODE", 39 },
|
||||||
|
{ BOXUSER1, "USER1", 40 },
|
||||||
|
{ BOXUSER2, "USER2", 41 },
|
||||||
|
{ BOXUSER3, "USER3", 42 },
|
||||||
|
{ BOXUSER4, "USER4", 43 },
|
||||||
};
|
};
|
||||||
|
|
||||||
// mask of enabled IDs, calculated on startup based on enabled features. boxId_e is used as bit index
|
// mask of enabled IDs, calculated on startup based on enabled features. boxId_e is used as bit index
|
||||||
|
@ -260,6 +266,23 @@ void initActiveBoxIds(void)
|
||||||
BME(BOXVTXPITMODE);
|
BME(BOXVTXPITMODE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_PINIOBOX
|
||||||
|
// Turn BOXUSERx only if pinioBox facility monitors them, as the facility is the only BOXUSERx observer.
|
||||||
|
// Note that pinioBoxConfig can be set to monitor any box.
|
||||||
|
for (int i = 0; i < PINIO_COUNT; i++) {
|
||||||
|
switch(pinioBoxConfig()->boxId[i]) {
|
||||||
|
case BOXUSER1:
|
||||||
|
case BOXUSER2:
|
||||||
|
case BOXUSER3:
|
||||||
|
case BOXUSER4:
|
||||||
|
BME(pinioBoxConfig()->boxId[i]);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#undef BME
|
#undef BME
|
||||||
// check that all enabled IDs are in boxes array (check may be skipped when using findBoxById() functions)
|
// check that all enabled IDs are in boxes array (check may be skipped when using findBoxById() functions)
|
||||||
for (boxId_e boxId = 0; boxId < CHECKBOX_ITEM_COUNT; boxId++)
|
for (boxId_e boxId = 0; boxId < CHECKBOX_ITEM_COUNT; boxId++)
|
||||||
|
|
|
@ -36,3 +36,4 @@ void serializeBoxPermanentIdFn(struct sbuf_s *dst, const box_t *box);
|
||||||
typedef void serializeBoxFn(struct sbuf_s *dst, const box_t *box);
|
typedef void serializeBoxFn(struct sbuf_s *dst, const box_t *box);
|
||||||
void serializeBoxReply(struct sbuf_s *dst, int page, serializeBoxFn *serializeBox);
|
void serializeBoxReply(struct sbuf_s *dst, int page, serializeBoxFn *serializeBox);
|
||||||
void initActiveBoxIds(void);
|
void initActiveBoxIds(void);
|
||||||
|
bool getBoxIdState(boxId_e boxid);
|
||||||
|
|
|
@ -869,6 +869,7 @@ const clivalue_t valueTable[] = {
|
||||||
// PG_PINIO_CONFIG
|
// PG_PINIO_CONFIG
|
||||||
#ifdef USE_PINIO
|
#ifdef USE_PINIO
|
||||||
{ "pinio_config", VAR_UINT8 | MASTER_VALUE | MODE_ARRAY, .config.array.length = PINIO_COUNT, PG_PINIO_CONFIG, offsetof(pinioConfig_t, config) },
|
{ "pinio_config", VAR_UINT8 | MASTER_VALUE | MODE_ARRAY, .config.array.length = PINIO_COUNT, PG_PINIO_CONFIG, offsetof(pinioConfig_t, config) },
|
||||||
|
{ "piniobox_config", VAR_INT8 | MASTER_VALUE | MODE_ARRAY, .config.array.length = PINIO_COUNT, PG_PINIOBOX_CONFIG, offsetof(pinioBoxConfig_t, boxId) },
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
52
src/main/io/piniobox.c
Normal file
52
src/main/io/piniobox.c
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Cleanflight.
|
||||||
|
*
|
||||||
|
* Cleanflight is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Cleanflight is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <platform.h>
|
||||||
|
|
||||||
|
#ifdef USE_PINIOBOX
|
||||||
|
|
||||||
|
#include "build/debug.h"
|
||||||
|
|
||||||
|
#include "common/utils.h"
|
||||||
|
#include "common/time.h"
|
||||||
|
|
||||||
|
#include "interface/msp_box.h"
|
||||||
|
|
||||||
|
#include "pg/pinio.h"
|
||||||
|
#include "pg/piniobox.h"
|
||||||
|
|
||||||
|
#include "piniobox.h"
|
||||||
|
|
||||||
|
static const pinioBoxConfig_t *config;
|
||||||
|
|
||||||
|
void pinioBoxInit(const pinioBoxConfig_t *pinioBoxConfig)
|
||||||
|
{
|
||||||
|
config = pinioBoxConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
void pinioBoxUpdate(timeUs_t currentTimeUs)
|
||||||
|
{
|
||||||
|
UNUSED(currentTimeUs);
|
||||||
|
|
||||||
|
for (int i = 0; i < PINIO_COUNT; i++) {
|
||||||
|
pinioSet(i, getBoxIdState(config->boxId[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
21
src/main/io/piniobox.h
Normal file
21
src/main/io/piniobox.h
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Cleanflight.
|
||||||
|
*
|
||||||
|
* Cleanflight is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Cleanflight is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "pg/piniobox.h"
|
||||||
|
|
||||||
|
void pinioBoxInit(const pinioBoxConfig_t *pinioBoxConfig);
|
||||||
|
void pinioBoxUpdate(timeUs_t currentTimeUs);
|
|
@ -120,7 +120,8 @@
|
||||||
#define PG_RANGEFINDER_CONFIG 527 // iNav
|
#define PG_RANGEFINDER_CONFIG 527 // iNav
|
||||||
#define PG_TRICOPTER_CONFIG 528
|
#define PG_TRICOPTER_CONFIG 528
|
||||||
#define PG_PINIO_CONFIG 529
|
#define PG_PINIO_CONFIG 529
|
||||||
#define PG_BETAFLIGHT_END 529
|
#define PG_PINIOBOX_CONFIG 530
|
||||||
|
#define PG_BETAFLIGHT_END 530
|
||||||
|
|
||||||
|
|
||||||
// OSD configuration (subject to change)
|
// OSD configuration (subject to change)
|
||||||
|
|
31
src/main/pg/piniobox.c
Normal file
31
src/main/pg/piniobox.c
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Cleanflight.
|
||||||
|
*
|
||||||
|
* Cleanflight is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Cleanflight is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "platform.h"
|
||||||
|
|
||||||
|
#ifdef USE_PINIOBOX
|
||||||
|
|
||||||
|
#include "pg/pg_ids.h"
|
||||||
|
#include "piniobox.h"
|
||||||
|
#include "drivers/io.h"
|
||||||
|
|
||||||
|
PG_REGISTER_WITH_RESET_TEMPLATE(pinioBoxConfig_t, pinioBoxConfig, PG_PINIOBOX_CONFIG, 0);
|
||||||
|
|
||||||
|
PG_RESET_TEMPLATE(pinioBoxConfig_t, pinioBoxConfig,
|
||||||
|
{ BOXNONE, BOXNONE, BOXNONE, BOXNONE }
|
||||||
|
);
|
||||||
|
#endif
|
30
src/main/pg/piniobox.h
Normal file
30
src/main/pg/piniobox.h
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Cleanflight.
|
||||||
|
*
|
||||||
|
* Cleanflight is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Cleanflight is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "drivers/pinio.h"
|
||||||
|
#include "fc/rc_modes.h"
|
||||||
|
#include "pg/pg.h"
|
||||||
|
|
||||||
|
typedef struct pinioBoxConfig_s {
|
||||||
|
int8_t boxId[PINIO_COUNT];
|
||||||
|
} pinioBoxConfig_t;
|
||||||
|
|
||||||
|
PG_DECLARE(pinioBoxConfig_t, pinioBoxConfig);
|
||||||
|
|
||||||
|
#define BOXNONE (-1)
|
|
@ -127,6 +127,10 @@ typedef enum {
|
||||||
TASK_ADC_INTERNAL,
|
TASK_ADC_INTERNAL,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_PINIOBOX
|
||||||
|
TASK_PINIOBOX,
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Count of real tasks */
|
/* Count of real tasks */
|
||||||
TASK_COUNT,
|
TASK_COUNT,
|
||||||
|
|
||||||
|
|
|
@ -138,6 +138,7 @@
|
||||||
#define USE_OSD
|
#define USE_OSD
|
||||||
#define USE_OSD_OVER_MSP_DISPLAYPORT
|
#define USE_OSD_OVER_MSP_DISPLAYPORT
|
||||||
#define USE_PINIO
|
#define USE_PINIO
|
||||||
|
#define USE_PINIOBOX
|
||||||
#define USE_RCDEVICE
|
#define USE_RCDEVICE
|
||||||
#define USE_RTC_TIME
|
#define USE_RTC_TIME
|
||||||
#define USE_RX_MSP
|
#define USE_RX_MSP
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue