mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 14:25:20 +03:00
Merge branch 'PA_update1' of git://github.com/Pierre-A/cleanflight into Pierre-A-PA_update1
Conflicts: src/main/config/config.c src/main/io/serial_cli.c src/main/telemetry/hott.c src/main/telemetry/telemetry.h
This commit is contained in:
commit
7d9fc2699a
5 changed files with 38 additions and 1 deletions
|
@ -138,7 +138,7 @@ profile_t *currentProfile;
|
||||||
static uint8_t currentControlRateProfileIndex = 0;
|
static uint8_t currentControlRateProfileIndex = 0;
|
||||||
controlRateConfig_t *currentControlRateProfile;
|
controlRateConfig_t *currentControlRateProfile;
|
||||||
|
|
||||||
static const uint8_t EEPROM_CONF_VERSION = 94;
|
static const uint8_t EEPROM_CONF_VERSION = 95;
|
||||||
|
|
||||||
static void resetAccelerometerTrims(flightDynamicsTrims_t *accelerometerTrims)
|
static void resetAccelerometerTrims(flightDynamicsTrims_t *accelerometerTrims)
|
||||||
{
|
{
|
||||||
|
@ -247,6 +247,7 @@ void resetTelemetryConfig(telemetryConfig_t *telemetryConfig)
|
||||||
telemetryConfig->frsky_coordinate_format = FRSKY_FORMAT_DMS;
|
telemetryConfig->frsky_coordinate_format = FRSKY_FORMAT_DMS;
|
||||||
telemetryConfig->frsky_unit = FRSKY_UNIT_METRICS;
|
telemetryConfig->frsky_unit = FRSKY_UNIT_METRICS;
|
||||||
telemetryConfig->frsky_vfas_precision = 0;
|
telemetryConfig->frsky_vfas_precision = 0;
|
||||||
|
telemetryConfig->hottAlarmSoundInterval = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetBatteryConfig(batteryConfig_t *batteryConfig)
|
void resetBatteryConfig(batteryConfig_t *batteryConfig)
|
||||||
|
|
|
@ -348,6 +348,7 @@ const clivalue_t valueTable[] = {
|
||||||
{ "frsky_coordinates_format", VAR_UINT8 | MASTER_VALUE, &masterConfig.telemetryConfig.frsky_coordinate_format, 0, FRSKY_FORMAT_NMEA },
|
{ "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 },
|
{ "frsky_unit", VAR_UINT8 | MASTER_VALUE, &masterConfig.telemetryConfig.frsky_unit, 0, FRSKY_UNIT_IMPERIALS },
|
||||||
{ "frsky_vfas_precision", VAR_UINT8 | MASTER_VALUE, &masterConfig.telemetryConfig.frsky_vfas_precision, FRSKY_VFAS_PRECISION_LOW, FRSKY_VFAS_PRECISION_HIGH },
|
{ "frsky_vfas_precision", VAR_UINT8 | MASTER_VALUE, &masterConfig.telemetryConfig.frsky_vfas_precision, FRSKY_VFAS_PRECISION_LOW, FRSKY_VFAS_PRECISION_HIGH },
|
||||||
|
{ "hott_alarm_sound_interval", VAR_UINT8 | MASTER_VALUE, &masterConfig.telemetryConfig.hottAlarmSoundInterval, 0, 120 },
|
||||||
|
|
||||||
{ "battery_capacity", VAR_UINT16 | MASTER_VALUE, &masterConfig.batteryConfig.batteryCapacity, 0, 20000 },
|
{ "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 },
|
{ "vbat_scale", VAR_UINT8 | MASTER_VALUE, &masterConfig.batteryConfig.vbatscale, VBAT_SCALE_MIN, VBAT_SCALE_MAX },
|
||||||
|
|
|
@ -88,9 +88,11 @@ extern int16_t debug[4];
|
||||||
#define HOTT_MESSAGE_PREPARATION_FREQUENCY_5_HZ ((1000 * 1000) / 5)
|
#define HOTT_MESSAGE_PREPARATION_FREQUENCY_5_HZ ((1000 * 1000) / 5)
|
||||||
#define HOTT_RX_SCHEDULE 4000
|
#define HOTT_RX_SCHEDULE 4000
|
||||||
#define HOTT_TX_DELAY_US 3000
|
#define HOTT_TX_DELAY_US 3000
|
||||||
|
#define MILLISECONDS_IN_A_SECOND 1000
|
||||||
|
|
||||||
static uint32_t lastHoTTRequestCheckAt = 0;
|
static uint32_t lastHoTTRequestCheckAt = 0;
|
||||||
static uint32_t lastMessagesPreparedAt = 0;
|
static uint32_t lastMessagesPreparedAt = 0;
|
||||||
|
static uint32_t lastHottAlarmSoundTime = 0;
|
||||||
|
|
||||||
static bool hottIsSending = false;
|
static bool hottIsSending = false;
|
||||||
|
|
||||||
|
@ -210,12 +212,34 @@ void hottPrepareGPSResponse(HOTT_GPS_MSG_t *hottGPSMessage)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static bool shouldTriggerBatteryAlarmNow(void)
|
||||||
|
{
|
||||||
|
return ((millis() - lastHottAlarmSoundTime) >= (telemetryConfig->hottAlarmSoundInterval * MILLISECONDS_IN_A_SECOND));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void updateAlarmBatteryStatus(HOTT_EAM_MSG_t *hottEAMMessage)
|
||||||
|
{
|
||||||
|
if (shouldTriggerBatteryAlarmNow()){
|
||||||
|
lastHottAlarmSoundTime = millis();
|
||||||
|
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)
|
static inline void hottEAMUpdateBattery(HOTT_EAM_MSG_t *hottEAMMessage)
|
||||||
{
|
{
|
||||||
hottEAMMessage->main_voltage_L = vbat & 0xFF;
|
hottEAMMessage->main_voltage_L = vbat & 0xFF;
|
||||||
hottEAMMessage->main_voltage_H = vbat >> 8;
|
hottEAMMessage->main_voltage_H = vbat >> 8;
|
||||||
hottEAMMessage->batt1_voltage_L = vbat & 0xFF;
|
hottEAMMessage->batt1_voltage_L = vbat & 0xFF;
|
||||||
hottEAMMessage->batt1_voltage_H = vbat >> 8;
|
hottEAMMessage->batt1_voltage_H = vbat >> 8;
|
||||||
|
|
||||||
|
updateAlarmBatteryStatus(hottEAMMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void hottEAMUpdateCurrentMeter(HOTT_EAM_MSG_t *hottEAMMessage)
|
static inline void hottEAMUpdateCurrentMeter(HOTT_EAM_MSG_t *hottEAMMessage)
|
||||||
|
@ -387,6 +411,13 @@ static void hottCheckSerialData(uint32_t currentMicros)
|
||||||
uint8_t address = serialRead(hottPort);
|
uint8_t address = serialRead(hottPort);
|
||||||
|
|
||||||
if ((requestId == 0) || (requestId == HOTT_BINARY_MODE_REQUEST_ID) || (address == HOTT_TELEMETRY_NO_SENSOR_ID)) {
|
if ((requestId == 0) || (requestId == HOTT_BINARY_MODE_REQUEST_ID) || (address == HOTT_TELEMETRY_NO_SENSOR_ID)) {
|
||||||
|
/*
|
||||||
|
* FIXME the first byte of the HoTT request frame is ONLY either 0x80 (binary mode) or 0x7F (text mode).
|
||||||
|
* The binary mode is read as 0x00 (error reading the upper bit) while the text mode is correctly decoded.
|
||||||
|
* The (requestId == 0) test is a workaround for detecting the binary mode with no ambiguity as there is only
|
||||||
|
* one other valid value (0x7F) for text mode.
|
||||||
|
* The error reading for the upper bit should nevertheless be fixed
|
||||||
|
*/
|
||||||
processBinaryModeRequest(address);
|
processBinaryModeRequest(address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ typedef struct telemetryConfig_s {
|
||||||
frskyGpsCoordFormat_e frsky_coordinate_format;
|
frskyGpsCoordFormat_e frsky_coordinate_format;
|
||||||
frskyUnit_e frsky_unit;
|
frskyUnit_e frsky_unit;
|
||||||
uint8_t frsky_vfas_precision;
|
uint8_t frsky_vfas_precision;
|
||||||
|
uint8_t hottAlarmSoundInterval;
|
||||||
} telemetryConfig_t;
|
} telemetryConfig_t;
|
||||||
|
|
||||||
void checkTelemetryState(void);
|
void checkTelemetryState(void);
|
||||||
|
|
|
@ -152,6 +152,9 @@ int16_t debug[4];
|
||||||
|
|
||||||
uint8_t stateFlags;
|
uint8_t stateFlags;
|
||||||
|
|
||||||
|
uint16_t batteryWarningVoltage;
|
||||||
|
uint8_t useHottAlarmSoundPeriod (void) { return 0; }
|
||||||
|
|
||||||
|
|
||||||
uint8_t GPS_numSat;
|
uint8_t GPS_numSat;
|
||||||
int32_t GPS_coord[2];
|
int32_t GPS_coord[2];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue