Use permanentId for config, convert to boxId_e at init
This commit is contained in:
parent
6557b161aa
commit
45c5d37693
|
@ -70,6 +70,7 @@
|
|||
#include "pg/pg.h"
|
||||
#include "pg/pg_ids.h"
|
||||
#include "pg/pinio.h"
|
||||
#include "pg/piniobox.h"
|
||||
#include "pg/rx_pwm.h"
|
||||
#include "pg/sdcard.h"
|
||||
#include "pg/vcd.h"
|
||||
|
@ -869,7 +870,9 @@ const clivalue_t valueTable[] = {
|
|||
// PG_PINIO_CONFIG
|
||||
#ifdef USE_PINIO
|
||||
{ "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) },
|
||||
#ifdef USE_PINIOBOX
|
||||
{ "pinio_box", VAR_INT8 | MASTER_VALUE | MODE_ARRAY, .config.array.length = PINIO_COUNT, PG_PINIOBOX_CONFIG, offsetof(pinioBoxConfig_t, boxId) },
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -33,11 +33,22 @@
|
|||
|
||||
#include "piniobox.h"
|
||||
|
||||
static const pinioBoxConfig_t *config;
|
||||
static pinioBoxConfig_t pinioBoxRuntimeConfig;
|
||||
|
||||
void pinioBoxInit(const pinioBoxConfig_t *pinioBoxConfig)
|
||||
{
|
||||
config = pinioBoxConfig;
|
||||
// Convert permanentId to boxId_e
|
||||
|
||||
pinioBoxRuntimeConfig = *pinioBoxConfig;
|
||||
|
||||
for (int i = 0; i < PINIO_COUNT; i++) {
|
||||
if (pinioBoxRuntimeConfig.boxId[i] >= 0) {
|
||||
const box_t *box = findBoxByPermanentId(pinioBoxRuntimeConfig.boxId[i]);
|
||||
if (box) {
|
||||
pinioBoxRuntimeConfig.boxId[i] = box->boxId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void pinioBoxUpdate(timeUs_t currentTimeUs)
|
||||
|
@ -45,7 +56,9 @@ void pinioBoxUpdate(timeUs_t currentTimeUs)
|
|||
UNUSED(currentTimeUs);
|
||||
|
||||
for (int i = 0; i < PINIO_COUNT; i++) {
|
||||
pinioSet(i, getBoxIdState(config->boxId[i]));
|
||||
if (pinioBoxRuntimeConfig.boxId[i] >= 0) {
|
||||
pinioSet(i, getBoxIdState(pinioBoxRuntimeConfig.boxId[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue