1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-18 13:55:18 +03:00

battery alarm sound for Hott telemetry binary mode

This commit is contained in:
Pierre-A 2015-02-22 09:47:22 +01:00
parent c6d71f148d
commit 83aa49a812
5 changed files with 34 additions and 0 deletions

View file

@ -220,6 +220,7 @@ void resetTelemetryConfig(telemetryConfig_t *telemetryConfig)
telemetryConfig->gpsNoFixLongitude = 0;
telemetryConfig->frsky_coordinate_format = FRSKY_FORMAT_DMS;
telemetryConfig->frsky_unit = FRSKY_UNIT_METRICS;
telemetryConfig->HottAlarmSoundPeriod = 5;
}
void resetBatteryConfig(batteryConfig_t *batteryConfig)

View file

@ -317,6 +317,7 @@ const clivalue_t valueTable[] = {
{ "frsky_default_longitude", VAR_FLOAT | MASTER_VALUE, &masterConfig.telemetryConfig.gpsNoFixLongitude, -180.0, 180.0 },
{ "frsky_coordinates_format", VAR_UINT8 | MASTER_VALUE, &masterConfig.telemetryConfig.frsky_coordinate_format, 0, FRSKY_FORMAT_NMEA },
{ "frsky_unit", VAR_UINT8 | MASTER_VALUE, &masterConfig.telemetryConfig.frsky_unit, 0, FRSKY_UNIT_IMPERIALS },
{ "Hott_alarm_sound_period", VAR_UINT8 | MASTER_VALUE, &masterConfig.telemetryConfig.HottAlarmSoundPeriod, 0, 120 },
{ "battery_capacity", VAR_UINT16 | MASTER_VALUE, &masterConfig.batteryConfig.batteryCapacity, 0, 20000 },
{ "vbat_scale", VAR_UINT8 | MASTER_VALUE, &masterConfig.batteryConfig.vbatscale, VBAT_SCALE_MIN, VBAT_SCALE_MAX },

View file

@ -92,6 +92,8 @@ extern int16_t debug[4];
static uint32_t lastHoTTRequestCheckAt = 0;
static uint32_t lastMessagesPreparedAt = 0;
static uint32_t alarmSound_currentTime, previous_alarmSound_time;
static bool hottIsSending = false;
static uint8_t *hottMsg = NULL;
@ -209,12 +211,34 @@ void hottPrepareGPSResponse(HOTT_GPS_MSG_t *hottGPSMessage)
}
#endif
static bool time_for_Voice_Alarm(void)
{
return ((alarmSound_currentTime - previous_alarmSound_time) >= (useHottAlarmSoundPeriod() * 1000000));
}
static inline void checkAlarmBattery(HOTT_EAM_MSG_t *hottEAMMessage)
{
if (time_for_Voice_Alarm()){
previous_alarmSound_time = alarmSound_currentTime;
if (vbat <= batteryWarningVoltage){
hottEAMMessage->warning_beeps = 0x10;
hottEAMMessage->alarm_invers1 = HOTT_EAM_ALARM1_FLAG_BATTERY_1;
}
else {
hottEAMMessage->warning_beeps = HOTT_EAM_ALARM1_FLAG_NONE;
hottEAMMessage->alarm_invers1 = HOTT_EAM_ALARM1_FLAG_NONE;
}
}
}
static inline void hottEAMUpdateBattery(HOTT_EAM_MSG_t *hottEAMMessage)
{
hottEAMMessage->main_voltage_L = vbat & 0xFF;
hottEAMMessage->main_voltage_H = vbat >> 8;
hottEAMMessage->batt1_voltage_L = vbat & 0xFF;
hottEAMMessage->batt1_voltage_H = vbat >> 8;
checkAlarmBattery(hottEAMMessage);
}
static inline void hottEAMUpdateCurrentMeter(HOTT_EAM_MSG_t *hottEAMMessage)
@ -465,6 +489,7 @@ void handleHoTTTelemetry(void)
{
static uint32_t serialTimer;
uint32_t now = micros();
alarmSound_currentTime = now;
if (shouldPrepareHoTTMessages(now)) {

View file

@ -48,6 +48,11 @@ static bool telemetryPortIsShared;
static telemetryConfig_t *telemetryConfig;
uint8_t useHottAlarmSoundPeriod (void)
{
return telemetryConfig->HottAlarmSoundPeriod;
}
void useTelemetryConfig(telemetryConfig_t *telemetryConfigToUse)
{
telemetryConfig = telemetryConfigToUse;

View file

@ -50,6 +50,7 @@ typedef struct telemetryConfig_s {
float gpsNoFixLongitude;
frskyGpsCoordFormat_e frsky_coordinate_format;
frskyUnit_e frsky_unit;
uint8_t HottAlarmSoundPeriod;
} telemetryConfig_t;
void checkTelemetryState(void);
@ -59,5 +60,6 @@ uint32_t getTelemetryProviderBaudRate(void);
void useTelemetryConfig(telemetryConfig_t *telemetryConfig);
bool telemetryAllowsOtherSerial(int serialPortFunction);
bool isTelemetryPortShared(void);
uint8_t useHottAlarmSoundPeriod (void);
#endif /* TELEMETRY_COMMON_H_ */