mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-27 02:05:26 +03:00
Merge pull request #1130 from martinbudden/inav_pg34_beeperConfig
Added beeperConfig parameter group
This commit is contained in:
commit
c896ad4480
9 changed files with 47 additions and 32 deletions
|
@ -40,7 +40,6 @@
|
||||||
#include "drivers/pwm_rx.h"
|
#include "drivers/pwm_rx.h"
|
||||||
#include "drivers/accgyro.h"
|
#include "drivers/accgyro.h"
|
||||||
#include "drivers/light_led.h"
|
#include "drivers/light_led.h"
|
||||||
#include "drivers/sound_beeper.h"
|
|
||||||
#include "drivers/gyro_sync.h"
|
#include "drivers/gyro_sync.h"
|
||||||
|
|
||||||
#include "sensors/sensors.h"
|
#include "sensors/sensors.h"
|
||||||
|
|
|
@ -52,9 +52,6 @@ typedef struct master_s {
|
||||||
|
|
||||||
profile_t profile[MAX_PROFILE_COUNT];
|
profile_t profile[MAX_PROFILE_COUNT];
|
||||||
|
|
||||||
uint32_t beeper_off_flags;
|
|
||||||
uint32_t preferred_beeper_off_flags;
|
|
||||||
|
|
||||||
uint8_t magic_ef; // magic number, should be 0xEF
|
uint8_t magic_ef; // magic number, should be 0xEF
|
||||||
uint8_t chk; // XOR checksum
|
uint8_t chk; // XOR checksum
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -84,6 +84,7 @@
|
||||||
#define PG_NAV_CONFIG 1002
|
#define PG_NAV_CONFIG 1002
|
||||||
#define PG_MODE_ACTIVATION_OPERATOR_CONFIG 1003
|
#define PG_MODE_ACTIVATION_OPERATOR_CONFIG 1003
|
||||||
#define PG_OSD_CONFIG 1004
|
#define PG_OSD_CONFIG 1004
|
||||||
|
#define PG_BEEPER_CONFIG 1005
|
||||||
|
|
||||||
// OSD configuration (subject to change)
|
// OSD configuration (subject to change)
|
||||||
//#define PG_OSD_FONT_CONFIG 2047
|
//#define PG_OSD_FONT_CONFIG 2047
|
||||||
|
|
|
@ -49,7 +49,7 @@ void systemBeepToggle(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void beeperInit(const beeperConfig_t *config)
|
void beeperInit(const beeperDevConfig_t *config)
|
||||||
{
|
{
|
||||||
#ifndef BEEPER
|
#ifndef BEEPER
|
||||||
UNUSED(config);
|
UNUSED(config);
|
||||||
|
|
|
@ -29,13 +29,13 @@
|
||||||
#define BEEP_ON do {} while(0)
|
#define BEEP_ON do {} while(0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct beeperConfig_s {
|
typedef struct beeperDevConfig_s {
|
||||||
ioTag_t ioTag;
|
ioTag_t ioTag;
|
||||||
unsigned isInverted : 1;
|
unsigned isInverted : 1;
|
||||||
unsigned isOD : 1;
|
unsigned isOD : 1;
|
||||||
} beeperConfig_t;
|
} beeperDevConfig_t;
|
||||||
|
|
||||||
void systemBeep(bool on);
|
void systemBeep(bool on);
|
||||||
void systemBeepToggle(void);
|
void systemBeepToggle(void);
|
||||||
void beeperInit(const beeperConfig_t *beeperConfig);
|
void beeperInit(const beeperDevConfig_t *beeperConfig);
|
||||||
|
|
||||||
|
|
|
@ -100,6 +100,8 @@ PG_RESET_TEMPLATE(systemConfig_t, systemConfig,
|
||||||
.throttle_tilt_compensation_strength = 0 // 0-100, 0 - disabled
|
.throttle_tilt_compensation_strength = 0 // 0-100, 0 - disabled
|
||||||
);
|
);
|
||||||
|
|
||||||
|
PG_REGISTER(beeperConfig_t, beeperConfig, PG_BEEPER_CONFIG, 0);
|
||||||
|
|
||||||
#ifdef NAV
|
#ifdef NAV
|
||||||
void validateNavConfig(void)
|
void validateNavConfig(void)
|
||||||
{
|
{
|
||||||
|
@ -608,40 +610,40 @@ void changeProfile(uint8_t profileIndex)
|
||||||
|
|
||||||
void beeperOffSet(uint32_t mask)
|
void beeperOffSet(uint32_t mask)
|
||||||
{
|
{
|
||||||
masterConfig.beeper_off_flags |= mask;
|
beeperConfigMutable()->beeper_off_flags |= mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
void beeperOffSetAll(uint8_t beeperCount)
|
void beeperOffSetAll(uint8_t beeperCount)
|
||||||
{
|
{
|
||||||
masterConfig.beeper_off_flags = (1 << beeperCount) -1;
|
beeperConfigMutable()->beeper_off_flags = (1 << beeperCount) -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void beeperOffClear(uint32_t mask)
|
void beeperOffClear(uint32_t mask)
|
||||||
{
|
{
|
||||||
masterConfig.beeper_off_flags &= ~(mask);
|
beeperConfigMutable()->beeper_off_flags &= ~(mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void beeperOffClearAll(void)
|
void beeperOffClearAll(void)
|
||||||
{
|
{
|
||||||
masterConfig.beeper_off_flags = 0;
|
beeperConfigMutable()->beeper_off_flags = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t getBeeperOffMask(void)
|
uint32_t getBeeperOffMask(void)
|
||||||
{
|
{
|
||||||
return masterConfig.beeper_off_flags;
|
return beeperConfig()->beeper_off_flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setBeeperOffMask(uint32_t mask)
|
void setBeeperOffMask(uint32_t mask)
|
||||||
{
|
{
|
||||||
masterConfig.beeper_off_flags = mask;
|
beeperConfigMutable()->beeper_off_flags = mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t getPreferredBeeperOffMask(void)
|
uint32_t getPreferredBeeperOffMask(void)
|
||||||
{
|
{
|
||||||
return masterConfig.preferred_beeper_off_flags;
|
return beeperConfig()->preferred_beeper_off_flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPreferredBeeperOffMask(uint32_t mask)
|
void setPreferredBeeperOffMask(uint32_t mask)
|
||||||
{
|
{
|
||||||
masterConfig.preferred_beeper_off_flags = mask;
|
beeperConfigMutable()->preferred_beeper_off_flags = mask;
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,6 +91,13 @@ typedef struct systemConfig_s {
|
||||||
|
|
||||||
PG_DECLARE(systemConfig_t, systemConfig);
|
PG_DECLARE(systemConfig_t, systemConfig);
|
||||||
|
|
||||||
|
typedef struct beeperConfig_s {
|
||||||
|
uint32_t beeper_off_flags;
|
||||||
|
uint32_t preferred_beeper_off_flags;
|
||||||
|
} beeperConfig_t;
|
||||||
|
|
||||||
|
PG_DECLARE(beeperConfig_t, beeperConfig);
|
||||||
|
|
||||||
void beeperOffSet(uint32_t mask);
|
void beeperOffSet(uint32_t mask);
|
||||||
void beeperOffSetAll(uint8_t beeperCount);
|
void beeperOffSetAll(uint8_t beeperCount);
|
||||||
void beeperOffClear(uint32_t mask);
|
void beeperOffClear(uint32_t mask);
|
||||||
|
|
|
@ -339,7 +339,7 @@ void init(void)
|
||||||
systemState |= SYSTEM_STATE_MOTORS_READY;
|
systemState |= SYSTEM_STATE_MOTORS_READY;
|
||||||
|
|
||||||
#ifdef BEEPER
|
#ifdef BEEPER
|
||||||
beeperConfig_t beeperConfig = {
|
beeperDevConfig_t beeperDevConfig = {
|
||||||
.ioTag = IO_TAG(BEEPER),
|
.ioTag = IO_TAG(BEEPER),
|
||||||
#ifdef BEEPER_INVERTED
|
#ifdef BEEPER_INVERTED
|
||||||
.isOD = false,
|
.isOD = false,
|
||||||
|
@ -353,12 +353,12 @@ void init(void)
|
||||||
#if defined(NAZE) && defined(USE_HARDWARE_REVISION_DETECTION)
|
#if defined(NAZE) && defined(USE_HARDWARE_REVISION_DETECTION)
|
||||||
if (hardwareRevision >= NAZE32_REV5) {
|
if (hardwareRevision >= NAZE32_REV5) {
|
||||||
// naze rev4 and below used opendrain to PNP for buzzer. Rev5 and above use PP to NPN.
|
// naze rev4 and below used opendrain to PNP for buzzer. Rev5 and above use PP to NPN.
|
||||||
beeperConfig.isOD = false;
|
beeperDevConfig.isOD = false;
|
||||||
beeperConfig.isInverted = true;
|
beeperDevConfig.isInverted = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
beeperInit(&beeperConfig);
|
beeperInit(&beeperDevConfig);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef INVERTER
|
#ifdef INVERTER
|
||||||
|
|
|
@ -1151,6 +1151,9 @@ static ledStripConfig_t ledStripConfigCopy;
|
||||||
static osdConfig_t osdConfigCopy;
|
static osdConfig_t osdConfigCopy;
|
||||||
#endif
|
#endif
|
||||||
static systemConfig_t systemConfigCopy;
|
static systemConfig_t systemConfigCopy;
|
||||||
|
#ifdef BEEPER
|
||||||
|
static beeperConfig_t beeperConfigCopy;
|
||||||
|
#endif
|
||||||
|
|
||||||
static void backupConfigs(void)
|
static void backupConfigs(void)
|
||||||
{
|
{
|
||||||
|
@ -1223,6 +1226,9 @@ static void backupConfigs(void)
|
||||||
osdConfigCopy = *osdConfig();
|
osdConfigCopy = *osdConfig();
|
||||||
#endif
|
#endif
|
||||||
systemConfigCopy = *systemConfig();
|
systemConfigCopy = *systemConfig();
|
||||||
|
#ifdef BEEPER
|
||||||
|
beeperConfigCopy = *beeperConfig();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void restoreConfigs(void)
|
static void restoreConfigs(void)
|
||||||
|
@ -1295,6 +1301,9 @@ static void restoreConfigs(void)
|
||||||
*osdConfigMutable() = osdConfigCopy;
|
*osdConfigMutable() = osdConfigCopy;
|
||||||
#endif
|
#endif
|
||||||
*systemConfigMutable() = systemConfigCopy;
|
*systemConfigMutable() = systemConfigCopy;
|
||||||
|
#ifdef BEEPER
|
||||||
|
*beeperConfigMutable() = beeperConfigCopy;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *getDefaultPointer(const void *valuePointer, const master_t *defaultConfig)
|
static void *getDefaultPointer(const void *valuePointer, const master_t *defaultConfig)
|
||||||
|
@ -2808,12 +2817,12 @@ static void cliFeature(char *cmdline)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BEEPER
|
#ifdef BEEPER
|
||||||
static void printBeeper(uint8_t dumpMask, const master_t *defaultConfig)
|
static void printBeeper(uint8_t dumpMask, const beeperConfig_t *beeperConfig, const beeperConfig_t *beeperConfigDefault)
|
||||||
{
|
{
|
||||||
uint8_t beeperCount = beeperTableEntryCount();
|
const uint8_t beeperCount = beeperTableEntryCount();
|
||||||
uint32_t mask = getBeeperOffMask();
|
const uint32_t mask = beeperConfig->beeper_off_flags;
|
||||||
uint32_t defaultMask = defaultConfig->beeper_off_flags;
|
const uint32_t defaultMask = beeperConfigDefault->beeper_off_flags;
|
||||||
for (int32_t i = 0; i < beeperCount - 2; i++) {
|
for (int i = 0; i < beeperCount - 2; i++) {
|
||||||
const char *formatOff = "beeper -%s\r\n";
|
const char *formatOff = "beeper -%s\r\n";
|
||||||
const char *formatOn = "beeper %s\r\n";
|
const char *formatOn = "beeper %s\r\n";
|
||||||
cliDefaultPrintf(dumpMask, ~(mask ^ defaultMask) & (1 << i), mask & (1 << i) ? formatOn : formatOff, beeperNameForTableIndex(i));
|
cliDefaultPrintf(dumpMask, ~(mask ^ defaultMask) & (1 << i), mask & (1 << i) ? formatOn : formatOff, beeperNameForTableIndex(i));
|
||||||
|
@ -3521,7 +3530,7 @@ static void printConfig(char *cmdline, bool doDiff)
|
||||||
|
|
||||||
#ifdef BEEPER
|
#ifdef BEEPER
|
||||||
cliPrintHashLine("beeper");
|
cliPrintHashLine("beeper");
|
||||||
printBeeper(dumpMask, &defaultConfig);
|
printBeeper(dumpMask, &beeperConfigCopy, beeperConfig());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cliPrintHashLine("map");
|
cliPrintHashLine("map");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue