mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 04:15:44 +03:00
Merge pull request #5891 from mikeller/add_disable_rx_loss_dshot_beacon_option
Implemented 'beacon' command in CLI.
This commit is contained in:
commit
f37a8184d5
12 changed files with 129 additions and 137 deletions
|
@ -350,6 +350,21 @@ static void validateAndFixConfig(void)
|
||||||
if (beeperDevConfig()->frequency && !timerGetByTag(beeperDevConfig()->ioTag)) {
|
if (beeperDevConfig()->frequency && !timerGetByTag(beeperDevConfig()->ioTag)) {
|
||||||
beeperDevConfigMutable()->frequency = 0;
|
beeperDevConfigMutable()->frequency = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (beeperConfig()->beeper_off_flags & ~BEEPER_ALLOWED_MODES) {
|
||||||
|
beeperConfigMutable()->beeper_off_flags = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef USE_DSHOT
|
||||||
|
if (beeperConfig()->dshotBeaconOffFlags & ~DSHOT_BEACON_ALLOWED_MODES) {
|
||||||
|
beeperConfigMutable()->dshotBeaconOffFlags = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (beeperConfig()->dshotBeaconTone < DSHOT_CMD_BEACON1
|
||||||
|
|| beeperConfig()->dshotBeaconTone > DSHOT_CMD_BEACON5) {
|
||||||
|
beeperConfigMutable()->dshotBeaconTone = DSHOT_CMD_BEACON1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(TARGET_VALIDATECONFIG)
|
#if defined(TARGET_VALIDATECONFIG)
|
||||||
|
@ -522,73 +537,3 @@ void changePidProfile(uint8_t pidProfileIndex)
|
||||||
beeperConfirmationBeeps(pidProfileIndex + 1);
|
beeperConfirmationBeeps(pidProfileIndex + 1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void beeperOffSet(uint32_t mask)
|
|
||||||
{
|
|
||||||
#ifdef USE_BEEPER
|
|
||||||
beeperConfigMutable()->beeper_off_flags |= mask;
|
|
||||||
#else
|
|
||||||
UNUSED(mask);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void beeperOffSetAll(uint8_t beeperCount)
|
|
||||||
{
|
|
||||||
#ifdef USE_BEEPER
|
|
||||||
beeperConfigMutable()->beeper_off_flags = (1 << beeperCount) -1;
|
|
||||||
#else
|
|
||||||
UNUSED(beeperCount);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void beeperOffClear(uint32_t mask)
|
|
||||||
{
|
|
||||||
#ifdef USE_BEEPER
|
|
||||||
beeperConfigMutable()->beeper_off_flags &= ~(mask);
|
|
||||||
#else
|
|
||||||
UNUSED(mask);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void beeperOffClearAll(void)
|
|
||||||
{
|
|
||||||
#ifdef USE_BEEPER
|
|
||||||
beeperConfigMutable()->beeper_off_flags = 0;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t getBeeperOffMask(void)
|
|
||||||
{
|
|
||||||
#ifdef USE_BEEPER
|
|
||||||
return beeperConfig()->beeper_off_flags;
|
|
||||||
#else
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void setBeeperOffMask(uint32_t mask)
|
|
||||||
{
|
|
||||||
#ifdef USE_BEEPER
|
|
||||||
beeperConfigMutable()->beeper_off_flags = mask;
|
|
||||||
#else
|
|
||||||
UNUSED(mask);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t getPreferredBeeperOffMask(void)
|
|
||||||
{
|
|
||||||
#ifdef USE_BEEPER
|
|
||||||
return beeperConfig()->preferred_beeper_off_flags;
|
|
||||||
#else
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void setPreferredBeeperOffMask(uint32_t mask)
|
|
||||||
{
|
|
||||||
#ifdef USE_BEEPER
|
|
||||||
beeperConfigMutable()->preferred_beeper_off_flags = mask;
|
|
||||||
#else
|
|
||||||
UNUSED(mask);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
|
@ -49,15 +49,6 @@ PG_DECLARE(systemConfig_t, systemConfig);
|
||||||
struct pidProfile_s;
|
struct pidProfile_s;
|
||||||
extern struct pidProfile_s *currentPidProfile;
|
extern struct pidProfile_s *currentPidProfile;
|
||||||
|
|
||||||
void beeperOffSet(uint32_t mask);
|
|
||||||
void beeperOffSetAll(uint8_t beeperCount);
|
|
||||||
void beeperOffClear(uint32_t mask);
|
|
||||||
void beeperOffClearAll(void);
|
|
||||||
uint32_t getBeeperOffMask(void);
|
|
||||||
void setBeeperOffMask(uint32_t mask);
|
|
||||||
uint32_t getPreferredBeeperOffMask(void);
|
|
||||||
void setPreferredBeeperOffMask(uint32_t mask);
|
|
||||||
|
|
||||||
void initEEPROM(void);
|
void initEEPROM(void);
|
||||||
void resetEEPROM(void);
|
void resetEEPROM(void);
|
||||||
bool readEEPROM(void);
|
bool readEEPROM(void);
|
||||||
|
|
|
@ -91,6 +91,7 @@
|
||||||
#include "msp/msp_serial.h"
|
#include "msp/msp_serial.h"
|
||||||
|
|
||||||
#include "pg/adc.h"
|
#include "pg/adc.h"
|
||||||
|
#include "pg/beeper.h"
|
||||||
#include "pg/beeper_dev.h"
|
#include "pg/beeper_dev.h"
|
||||||
#include "pg/bus_i2c.h"
|
#include "pg/bus_i2c.h"
|
||||||
#include "pg/bus_spi.h"
|
#include "pg/bus_spi.h"
|
||||||
|
@ -525,10 +526,16 @@ void init(void)
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
LED1_TOGGLE;
|
LED1_TOGGLE;
|
||||||
LED0_TOGGLE;
|
LED0_TOGGLE;
|
||||||
|
#if defined(USE_BEEPER)
|
||||||
delay(25);
|
delay(25);
|
||||||
if (!(getBeeperOffMask() & (1 << (BEEPER_SYSTEM_INIT - 1)))) BEEP_ON;
|
if (!(beeperConfig()->beeper_off_flags & BEEPER_GET_FLAG(BEEPER_SYSTEM_INIT))) {
|
||||||
|
BEEP_ON;
|
||||||
|
}
|
||||||
delay(25);
|
delay(25);
|
||||||
BEEP_OFF;
|
BEEP_OFF;
|
||||||
|
#else
|
||||||
|
delay(50);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
LED0_OFF;
|
LED0_OFF;
|
||||||
LED1_OFF;
|
LED1_OFF;
|
||||||
|
|
|
@ -2432,46 +2432,45 @@ static void cliFeature(char *cmdline)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_BEEPER
|
#if defined(USE_BEEPER)
|
||||||
static void printBeeper(uint8_t dumpMask, const beeperConfig_t *beeperConfig, const beeperConfig_t *beeperConfigDefault)
|
static void printBeeper(uint8_t dumpMask, const uint32_t offFlags, const uint32_t offFlagsDefault, const char *name)
|
||||||
{
|
{
|
||||||
const uint8_t beeperCount = beeperTableEntryCount();
|
const uint8_t beeperCount = beeperTableEntryCount();
|
||||||
const uint32_t mask = beeperConfig->beeper_off_flags;
|
|
||||||
const uint32_t defaultMask = beeperConfigDefault->beeper_off_flags;
|
|
||||||
for (int32_t i = 0; i < beeperCount - 2; i++) {
|
for (int32_t i = 0; i < beeperCount - 2; i++) {
|
||||||
const char *formatOff = "beeper -%s";
|
const char *formatOff = "%s -%s";
|
||||||
const char *formatOn = "beeper %s";
|
const char *formatOn = "%s %s";
|
||||||
const uint32_t beeperModeMask = beeperModeMaskForTableIndex(i);
|
const uint32_t beeperModeMask = beeperModeMaskForTableIndex(i);
|
||||||
cliDefaultPrintLinef(dumpMask, ~(mask ^ defaultMask) & beeperModeMask, mask & beeperModeMask ? formatOn : formatOff, beeperNameForTableIndex(i));
|
cliDefaultPrintLinef(dumpMask, ~(offFlags ^ offFlagsDefault) & beeperModeMask, offFlags & beeperModeMask ? formatOn : formatOff, name, beeperNameForTableIndex(i));
|
||||||
cliDumpPrintLinef(dumpMask, ~(mask ^ defaultMask) & beeperModeMask, mask & beeperModeMask ? formatOff : formatOn, beeperNameForTableIndex(i));
|
cliDumpPrintLinef(dumpMask, ~(offFlags ^ offFlagsDefault) & beeperModeMask, offFlags & beeperModeMask ? formatOff : formatOn, name, beeperNameForTableIndex(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cliBeeper(char *cmdline)
|
static void processBeeperCommand(char *cmdline, uint32_t *offFlags, const uint32_t allowedFlags)
|
||||||
{
|
{
|
||||||
uint32_t len = strlen(cmdline);
|
uint32_t len = strlen(cmdline);
|
||||||
uint8_t beeperCount = beeperTableEntryCount();
|
uint8_t beeperCount = beeperTableEntryCount();
|
||||||
uint32_t mask = getBeeperOffMask();
|
|
||||||
|
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
cliPrintf("Disabled:");
|
cliPrintf("Disabled:");
|
||||||
for (int32_t i = 0; ; i++) {
|
for (int32_t i = 0; ; i++) {
|
||||||
if (i == beeperCount - 2) {
|
if (i == beeperCount - 1) {
|
||||||
if (mask == 0)
|
if (*offFlags == 0)
|
||||||
cliPrint(" none");
|
cliPrint(" none");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask & beeperModeMaskForTableIndex(i))
|
if (beeperModeMaskForTableIndex(i) & *offFlags)
|
||||||
cliPrintf(" %s", beeperNameForTableIndex(i));
|
cliPrintf(" %s", beeperNameForTableIndex(i));
|
||||||
}
|
}
|
||||||
cliPrintLinefeed();
|
cliPrintLinefeed();
|
||||||
} else if (strncasecmp(cmdline, "list", len) == 0) {
|
} else if (strncasecmp(cmdline, "list", len) == 0) {
|
||||||
cliPrint("Available:");
|
cliPrint("Available:");
|
||||||
for (uint32_t i = 0; i < beeperCount; i++)
|
for (uint32_t i = 0; i < beeperCount; i++) {
|
||||||
cliPrintf(" %s", beeperNameForTableIndex(i));
|
if (beeperModeMaskForTableIndex(i) & allowedFlags) {
|
||||||
|
cliPrintf(" %s", beeperNameForTableIndex(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
cliPrintLinefeed();
|
cliPrintLinefeed();
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
bool remove = false;
|
bool remove = false;
|
||||||
if (cmdline[0] == '-') {
|
if (cmdline[0] == '-') {
|
||||||
|
@ -2485,27 +2484,21 @@ static void cliBeeper(char *cmdline)
|
||||||
cliPrintErrorLinef("Invalid name");
|
cliPrintErrorLinef("Invalid name");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (strncasecmp(cmdline, beeperNameForTableIndex(i), len) == 0) {
|
if (strncasecmp(cmdline, beeperNameForTableIndex(i), len) == 0 && beeperModeMaskForTableIndex(i) & (allowedFlags | BEEPER_GET_FLAG(BEEPER_ALL))) {
|
||||||
if (remove) { // beeper off
|
if (remove) { // beeper off
|
||||||
if (i == BEEPER_ALL-1)
|
if (i == BEEPER_ALL - 1) {
|
||||||
beeperOffSetAll(beeperCount-2);
|
*offFlags = allowedFlags;
|
||||||
else
|
} else {
|
||||||
if (i == BEEPER_PREFERENCE-1)
|
*offFlags |= beeperModeMaskForTableIndex(i);
|
||||||
setBeeperOffMask(getPreferredBeeperOffMask());
|
}
|
||||||
else {
|
|
||||||
beeperOffSet(beeperModeMaskForTableIndex(i));
|
|
||||||
}
|
|
||||||
cliPrint("Disabled");
|
cliPrint("Disabled");
|
||||||
}
|
}
|
||||||
else { // beeper on
|
else { // beeper on
|
||||||
if (i == BEEPER_ALL-1)
|
if (i == BEEPER_ALL - 1) {
|
||||||
beeperOffClearAll();
|
*offFlags = 0;
|
||||||
else
|
} else {
|
||||||
if (i == BEEPER_PREFERENCE-1)
|
*offFlags &= ~beeperModeMaskForTableIndex(i);
|
||||||
setPreferredBeeperOffMask(getBeeperOffMask());
|
}
|
||||||
else {
|
|
||||||
beeperOffClear(beeperModeMaskForTableIndex(i));
|
|
||||||
}
|
|
||||||
cliPrint("Enabled");
|
cliPrint("Enabled");
|
||||||
}
|
}
|
||||||
cliPrintLinef(" %s", beeperNameForTableIndex(i));
|
cliPrintLinef(" %s", beeperNameForTableIndex(i));
|
||||||
|
@ -2514,6 +2507,18 @@ static void cliBeeper(char *cmdline)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(USE_DSHOT)
|
||||||
|
static void cliBeacon(char *cmdline)
|
||||||
|
{
|
||||||
|
processBeeperCommand(cmdline, &(beeperConfigMutable()->dshotBeaconOffFlags), DSHOT_BEACON_ALLOWED_MODES);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void cliBeeper(char *cmdline)
|
||||||
|
{
|
||||||
|
processBeeperCommand(cmdline, &(beeperConfigMutable()->beeper_off_flags), BEEPER_ALLOWED_MODES);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_RX_FRSKY_SPI
|
#ifdef USE_RX_FRSKY_SPI
|
||||||
|
@ -4149,10 +4154,15 @@ static void printConfig(char *cmdline, bool doDiff)
|
||||||
cliPrintHashLine("feature");
|
cliPrintHashLine("feature");
|
||||||
printFeature(dumpMask, &featureConfig_Copy, featureConfig());
|
printFeature(dumpMask, &featureConfig_Copy, featureConfig());
|
||||||
|
|
||||||
#ifdef USE_BEEPER
|
#if defined(USE_BEEPER)
|
||||||
cliPrintHashLine("beeper");
|
cliPrintHashLine("beeper");
|
||||||
printBeeper(dumpMask, &beeperConfig_Copy, beeperConfig());
|
printBeeper(dumpMask, beeperConfig_Copy.beeper_off_flags, beeperConfig()->beeper_off_flags, "beeper");
|
||||||
|
|
||||||
|
#if defined(USE_DSHOT)
|
||||||
|
cliPrintHashLine("beacon");
|
||||||
|
printBeeper(dumpMask, beeperConfig_Copy.dshotBeaconOffFlags, beeperConfig()->dshotBeaconOffFlags, "beacon");
|
||||||
#endif
|
#endif
|
||||||
|
#endif // USE_BEEPER
|
||||||
|
|
||||||
cliPrintHashLine("map");
|
cliPrintHashLine("map");
|
||||||
printMap(dumpMask, &rxConfig_Copy, rxConfig());
|
printMap(dumpMask, &rxConfig_Copy, rxConfig());
|
||||||
|
@ -4307,10 +4317,14 @@ static void cliHelp(char *cmdline);
|
||||||
const clicmd_t cmdTable[] = {
|
const clicmd_t cmdTable[] = {
|
||||||
CLI_COMMAND_DEF("adjrange", "configure adjustment ranges", NULL, cliAdjustmentRange),
|
CLI_COMMAND_DEF("adjrange", "configure adjustment ranges", NULL, cliAdjustmentRange),
|
||||||
CLI_COMMAND_DEF("aux", "configure modes", "<index> <mode> <aux> <start> <end> <logic>", cliAux),
|
CLI_COMMAND_DEF("aux", "configure modes", "<index> <mode> <aux> <start> <end> <logic>", cliAux),
|
||||||
#ifdef USE_BEEPER
|
#if defined(USE_BEEPER)
|
||||||
|
#if defined(USE_DSHOT)
|
||||||
|
CLI_COMMAND_DEF("beacon", "turn on/off beeper", "list\r\n"
|
||||||
|
"\t<+|->[name]", cliBeacon),
|
||||||
|
#endif
|
||||||
CLI_COMMAND_DEF("beeper", "turn on/off beeper", "list\r\n"
|
CLI_COMMAND_DEF("beeper", "turn on/off beeper", "list\r\n"
|
||||||
"\t<+|->[name]", cliBeeper),
|
"\t<+|->[name]", cliBeeper),
|
||||||
#endif
|
#endif // USE_BEEPER
|
||||||
CLI_COMMAND_DEF("bl", "reboot into bootloader", NULL, cliBootloader),
|
CLI_COMMAND_DEF("bl", "reboot into bootloader", NULL, cliBootloader),
|
||||||
#if defined(USE_BOARD_INFO)
|
#if defined(USE_BOARD_INFO)
|
||||||
CLI_COMMAND_DEF("board_name", "get / set the name of the board model", "[board name]", cliBoardName),
|
CLI_COMMAND_DEF("board_name", "get / set the name of the board model", "[board name]", cliBoardName),
|
||||||
|
|
|
@ -524,7 +524,7 @@ static bool mspCommonProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProce
|
||||||
|
|
||||||
#ifdef USE_BEEPER
|
#ifdef USE_BEEPER
|
||||||
case MSP_BEEPER_CONFIG:
|
case MSP_BEEPER_CONFIG:
|
||||||
sbufWriteU32(dst, getBeeperOffMask());
|
sbufWriteU32(dst, beeperConfig()->beeper_off_flags);
|
||||||
sbufWriteU8(dst, beeperConfig()->dshotBeaconTone);
|
sbufWriteU8(dst, beeperConfig()->dshotBeaconTone);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1880,8 +1880,7 @@ static mspResult_e mspProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
|
||||||
|
|
||||||
#ifdef USE_BEEPER
|
#ifdef USE_BEEPER
|
||||||
case MSP_SET_BEEPER_CONFIG:
|
case MSP_SET_BEEPER_CONFIG:
|
||||||
beeperOffClearAll();
|
beeperConfigMutable()->beeper_off_flags = sbufReadU32(src);
|
||||||
setBeeperOffMask(sbufReadU32(src));
|
|
||||||
if (sbufBytesRemaining(src) >= 1) {
|
if (sbufBytesRemaining(src) >= 1) {
|
||||||
beeperConfigMutable()->dshotBeaconTone = sbufReadU8(src);
|
beeperConfigMutable()->dshotBeaconTone = sbufReadU8(src);
|
||||||
}
|
}
|
||||||
|
|
|
@ -632,9 +632,9 @@ const clivalue_t valueTable[] = {
|
||||||
|
|
||||||
// PG_BEEPER_CONFIG
|
// PG_BEEPER_CONFIG
|
||||||
#ifdef USE_DSHOT
|
#ifdef USE_DSHOT
|
||||||
{ "beeper_dshot_beacon_tone", VAR_UINT8 | MASTER_VALUE, .config.minmax = {0, DSHOT_CMD_BEACON5 }, PG_BEEPER_CONFIG, offsetof(beeperConfig_t, dshotBeaconTone) },
|
{ "beeper_dshot_beacon_tone", VAR_UINT8 | MASTER_VALUE, .config.minmax = {1, DSHOT_CMD_BEACON5 }, PG_BEEPER_CONFIG, offsetof(beeperConfig_t, dshotBeaconTone) },
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
#endif // USE_BEEPER
|
||||||
|
|
||||||
// PG_MIXER_CONFIG
|
// PG_MIXER_CONFIG
|
||||||
{ "yaw_motors_reversed", VAR_INT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_MIXER_CONFIG, offsetof(mixerConfig_t, yaw_motors_reversed) },
|
{ "yaw_motors_reversed", VAR_INT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_MIXER_CONFIG, offsetof(mixerConfig_t, yaw_motors_reversed) },
|
||||||
|
|
|
@ -194,7 +194,7 @@ typedef struct beeperTableEntry_s {
|
||||||
#define BEEPER_ENTRY(a,b,c,d) a,b,c
|
#define BEEPER_ENTRY(a,b,c,d) a,b,c
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*static*/ const beeperTableEntry_t beeperTable[] = {
|
static const beeperTableEntry_t beeperTable[] = {
|
||||||
{ BEEPER_ENTRY(BEEPER_GYRO_CALIBRATED, 0, beep_gyroCalibrated, "GYRO_CALIBRATED") },
|
{ BEEPER_ENTRY(BEEPER_GYRO_CALIBRATED, 0, beep_gyroCalibrated, "GYRO_CALIBRATED") },
|
||||||
{ BEEPER_ENTRY(BEEPER_RX_LOST, 1, beep_txLostBeep, "RX_LOST") },
|
{ BEEPER_ENTRY(BEEPER_RX_LOST, 1, beep_txLostBeep, "RX_LOST") },
|
||||||
{ BEEPER_ENTRY(BEEPER_RX_LOST_LANDING, 2, beep_sos, "RX_LOST_LANDING") },
|
{ BEEPER_ENTRY(BEEPER_RX_LOST_LANDING, 2, beep_sos, "RX_LOST_LANDING") },
|
||||||
|
@ -218,7 +218,6 @@ typedef struct beeperTableEntry_s {
|
||||||
{ BEEPER_ENTRY(BEEPER_CAM_CONNECTION_OPEN, 20, beep_camOpenBeep, "CAM_CONNECTION_OPEN") },
|
{ BEEPER_ENTRY(BEEPER_CAM_CONNECTION_OPEN, 20, beep_camOpenBeep, "CAM_CONNECTION_OPEN") },
|
||||||
{ BEEPER_ENTRY(BEEPER_CAM_CONNECTION_CLOSE, 21, beep_camCloseBeep, "CAM_CONNECTION_CLOSED") },
|
{ BEEPER_ENTRY(BEEPER_CAM_CONNECTION_CLOSE, 21, beep_camCloseBeep, "CAM_CONNECTION_CLOSED") },
|
||||||
{ BEEPER_ENTRY(BEEPER_ALL, 22, NULL, "ALL") },
|
{ BEEPER_ENTRY(BEEPER_ALL, 22, NULL, "ALL") },
|
||||||
{ BEEPER_ENTRY(BEEPER_PREFERENCE, 23, NULL, "PREFERRED") },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const beeperTableEntry_t *currentBeeperEntry = NULL;
|
static const beeperTableEntry_t *currentBeeperEntry = NULL;
|
||||||
|
@ -233,7 +232,7 @@ void beeper(beeperMode_e mode)
|
||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
mode == BEEPER_SILENCE || (
|
mode == BEEPER_SILENCE || (
|
||||||
(getBeeperOffMask() & (1 << (BEEPER_USB - 1)))
|
(beeperConfigMutable()->beeper_off_flags & BEEPER_GET_FLAG(BEEPER_USB - 1))
|
||||||
&& getBatteryState() == BATTERY_NOT_PRESENT
|
&& getBatteryState() == BATTERY_NOT_PRESENT
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
|
@ -346,7 +345,7 @@ void beeperWarningBeeps(uint8_t beepCount)
|
||||||
#ifdef USE_GPS
|
#ifdef USE_GPS
|
||||||
static void beeperGpsStatus(void)
|
static void beeperGpsStatus(void)
|
||||||
{
|
{
|
||||||
if (!(getBeeperOffMask() & (1 << (BEEPER_GPS_STATUS - 1)))) {
|
if (!(beeperConfigMutable()->beeper_off_flags & BEEPER_GET_FLAG(BEEPER_GPS_STATUS))) {
|
||||||
// if GPS fix then beep out number of satellites
|
// if GPS fix then beep out number of satellites
|
||||||
if (STATE(GPS_FIX) && gpsSol.numSat >= 5) {
|
if (STATE(GPS_FIX) && gpsSol.numSat >= 5) {
|
||||||
uint8_t i = 0;
|
uint8_t i = 0;
|
||||||
|
@ -392,7 +391,9 @@ void beeperUpdate(timeUs_t currentTimeUs)
|
||||||
beeperIsOn = 1;
|
beeperIsOn = 1;
|
||||||
|
|
||||||
#ifdef USE_DSHOT
|
#ifdef USE_DSHOT
|
||||||
if (!areMotorsRunning() && beeperConfig()->dshotBeaconTone && (beeperConfig()->dshotBeaconTone <= DSHOT_CMD_BEACON5) && (currentBeeperEntry->mode == BEEPER_RX_SET || currentBeeperEntry->mode == BEEPER_RX_LOST)) {
|
if (!areMotorsRunning()
|
||||||
|
&& ((currentBeeperEntry->mode == BEEPER_RX_SET && beeperConfig()->dshotBeaconOffFlags & BEEPER_GET_FLAG(BEEPER_RX_SET))
|
||||||
|
|| (currentBeeperEntry->mode == BEEPER_RX_LOST && beeperConfig()->dshotBeaconOffFlags & BEEPER_GET_FLAG(BEEPER_RX_LOST)))) {
|
||||||
pwmDisableMotors();
|
pwmDisableMotors();
|
||||||
delay(1);
|
delay(1);
|
||||||
|
|
||||||
|
@ -403,7 +404,7 @@ void beeperUpdate(timeUs_t currentTimeUs)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (currentBeeperEntry->sequence[beeperPos] != 0) {
|
if (currentBeeperEntry->sequence[beeperPos] != 0) {
|
||||||
if (!(getBeeperOffMask() & (1 << (currentBeeperEntry->mode - 1))))
|
if (!(beeperConfigMutable()->beeper_off_flags & BEEPER_GET_FLAG(currentBeeperEntry->mode)))
|
||||||
BEEP_ON;
|
BEEP_ON;
|
||||||
warningLedEnable();
|
warningLedEnable();
|
||||||
warningLedRefresh();
|
warningLedRefresh();
|
||||||
|
@ -470,7 +471,7 @@ uint32_t beeperModeMaskForTableIndex(int idx)
|
||||||
beeperMode_e beeperMode = beeperModeForTableIndex(idx);
|
beeperMode_e beeperMode = beeperModeForTableIndex(idx);
|
||||||
if (beeperMode == BEEPER_SILENCE)
|
if (beeperMode == BEEPER_SILENCE)
|
||||||
return 0;
|
return 0;
|
||||||
return 1 << (beeperMode - 1);
|
return BEEPER_GET_FLAG(beeperMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -21,7 +21,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/time.h"
|
#include "common/time.h"
|
||||||
#include "pg/pg.h"
|
|
||||||
|
#define BEEPER_GET_FLAG(mode) (1 << (mode - 1))
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
// IMPORTANT: these are in priority order, 0 = Highest
|
// IMPORTANT: these are in priority order, 0 = Highest
|
||||||
|
@ -50,10 +51,38 @@ typedef enum {
|
||||||
BEEPER_CAM_CONNECTION_OPEN, // When the 5 key simulation stated
|
BEEPER_CAM_CONNECTION_OPEN, // When the 5 key simulation stated
|
||||||
BEEPER_CAM_CONNECTION_CLOSE, // When the 5 key simulation stop
|
BEEPER_CAM_CONNECTION_CLOSE, // When the 5 key simulation stop
|
||||||
BEEPER_ALL, // Turn ON or OFF all beeper conditions
|
BEEPER_ALL, // Turn ON or OFF all beeper conditions
|
||||||
BEEPER_PREFERENCE, // Save preferred beeper configuration
|
// BEEPER_ALL must remain at the bottom of this enum
|
||||||
// BEEPER_ALL and BEEPER_PREFERENCE must remain at the bottom of this enum
|
|
||||||
} beeperMode_e;
|
} beeperMode_e;
|
||||||
|
|
||||||
|
|
||||||
|
#define BEEPER_ALLOWED_MODES ( \
|
||||||
|
BEEPER_GET_FLAG(BEEPER_GYRO_CALIBRATED) \
|
||||||
|
| BEEPER_GET_FLAG(BEEPER_RX_LOST) \
|
||||||
|
| BEEPER_GET_FLAG(BEEPER_RX_LOST_LANDING) \
|
||||||
|
| BEEPER_GET_FLAG(BEEPER_DISARMING) \
|
||||||
|
| BEEPER_GET_FLAG(BEEPER_ARMING) \
|
||||||
|
| BEEPER_GET_FLAG(BEEPER_ARMING_GPS_FIX) \
|
||||||
|
| BEEPER_GET_FLAG(BEEPER_BAT_CRIT_LOW) \
|
||||||
|
| BEEPER_GET_FLAG(BEEPER_BAT_LOW) \
|
||||||
|
| BEEPER_GET_FLAG(BEEPER_GPS_STATUS) \
|
||||||
|
| BEEPER_GET_FLAG(BEEPER_RX_SET) \
|
||||||
|
| BEEPER_GET_FLAG(BEEPER_ACC_CALIBRATION) \
|
||||||
|
| BEEPER_GET_FLAG(BEEPER_ACC_CALIBRATION_FAIL) \
|
||||||
|
| BEEPER_GET_FLAG(BEEPER_READY_BEEP) \
|
||||||
|
| BEEPER_GET_FLAG(BEEPER_MULTI_BEEPS) \
|
||||||
|
| BEEPER_GET_FLAG(BEEPER_DISARM_REPEAT) \
|
||||||
|
| BEEPER_GET_FLAG(BEEPER_ARMED) \
|
||||||
|
| BEEPER_GET_FLAG(BEEPER_SYSTEM_INIT) \
|
||||||
|
| BEEPER_GET_FLAG(BEEPER_USB) \
|
||||||
|
| BEEPER_GET_FLAG(BEEPER_BLACKBOX_ERASE) \
|
||||||
|
| BEEPER_GET_FLAG(BEEPER_CRASH_FLIP_MODE) \
|
||||||
|
| BEEPER_GET_FLAG(BEEPER_CAM_CONNECTION_OPEN) \
|
||||||
|
| BEEPER_GET_FLAG(BEEPER_CAM_CONNECTION_CLOSE) )
|
||||||
|
|
||||||
|
#define DSHOT_BEACON_ALLOWED_MODES ( \
|
||||||
|
BEEPER_GET_FLAG(BEEPER_RX_LOST) \
|
||||||
|
| BEEPER_GET_FLAG(BEEPER_RX_SET) )
|
||||||
|
|
||||||
void beeper(beeperMode_e mode);
|
void beeper(beeperMode_e mode);
|
||||||
void beeperSilence(void);
|
void beeperSilence(void);
|
||||||
void beeperUpdate(timeUs_t currentTimeUs);
|
void beeperUpdate(timeUs_t currentTimeUs);
|
||||||
|
|
|
@ -247,10 +247,14 @@ void init(void)
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
LED1_TOGGLE;
|
LED1_TOGGLE;
|
||||||
LED0_TOGGLE;
|
LED0_TOGGLE;
|
||||||
|
#if defined(USE_BEEPER)
|
||||||
delay(25);
|
delay(25);
|
||||||
if (!(getBeeperOffMask() & (1 << (BEEPER_SYSTEM_INIT - 1)))) BEEP_ON;
|
if (!(beeperConfig()->beeper_off_flags & BEEPER_GET_FLAG(BEEPER_SYSTEM_INIT))) BEEP_ON;
|
||||||
delay(25);
|
delay(25);
|
||||||
BEEP_OFF;
|
BEEP_OFF;
|
||||||
|
#else
|
||||||
|
delay(50);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
LED0_OFF;
|
LED0_OFF;
|
||||||
LED1_OFF;
|
LED1_OFF;
|
||||||
|
|
|
@ -27,8 +27,9 @@
|
||||||
|
|
||||||
#include "beeper.h"
|
#include "beeper.h"
|
||||||
|
|
||||||
PG_REGISTER_WITH_RESET_TEMPLATE(beeperConfig_t, beeperConfig, PG_BEEPER_CONFIG, 1);
|
PG_REGISTER_WITH_RESET_TEMPLATE(beeperConfig_t, beeperConfig, PG_BEEPER_CONFIG, 2);
|
||||||
|
|
||||||
PG_RESET_TEMPLATE(beeperConfig_t, beeperConfig,
|
PG_RESET_TEMPLATE(beeperConfig_t, beeperConfig,
|
||||||
.dshotBeaconTone = 0
|
.dshotBeaconTone = 1,
|
||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -25,8 +25,8 @@
|
||||||
|
|
||||||
typedef struct beeperConfig_s {
|
typedef struct beeperConfig_s {
|
||||||
uint32_t beeper_off_flags;
|
uint32_t beeper_off_flags;
|
||||||
uint32_t preferred_beeper_off_flags;
|
|
||||||
uint8_t dshotBeaconTone;
|
uint8_t dshotBeaconTone;
|
||||||
|
uint32_t dshotBeaconOffFlags;
|
||||||
} beeperConfig_t;
|
} beeperConfig_t;
|
||||||
|
|
||||||
PG_DECLARE(beeperConfig_t, beeperConfig);
|
PG_DECLARE(beeperConfig_t, beeperConfig);
|
||||||
|
|
|
@ -83,7 +83,8 @@ void targetConfiguration(void)
|
||||||
rxConfigMutable()->serialrx_inverted = true;
|
rxConfigMutable()->serialrx_inverted = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
beeperOffSet((BEEPER_BAT_CRIT_LOW | BEEPER_BAT_LOW | BEEPER_RX_SET) ^ BEEPER_GYRO_CALIBRATED);
|
// Don't know what this is meant to do, but it's broken because enum values can't be directly set
|
||||||
|
// beeperOffSet((BEEPER_BAT_CRIT_LOW | BEEPER_BAT_LOW | BEEPER_RX_SET) ^ BEEPER_GYRO_CALIBRATED);
|
||||||
|
|
||||||
/* Breadboard-specific settings for development purposes only
|
/* Breadboard-specific settings for development purposes only
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue