1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 00:05:33 +03:00

new version including corrections

This commit is contained in:
Pierre-A 2015-03-04 15:53:09 +01:00
parent 39160a785a
commit af2cd4087a
5 changed files with 20 additions and 15 deletions

View file

@ -220,7 +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;
telemetryConfig->hottAlarmSoundInterval = 5;
}
void resetBatteryConfig(batteryConfig_t *batteryConfig)

View file

@ -317,7 +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 },
{ "hott_alarm_sound_interval", VAR_UINT8 | MASTER_VALUE, &masterConfig.telemetryConfig.hottAlarmSoundInterval, 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

@ -88,11 +88,11 @@ extern int16_t debug[4];
#define HOTT_MESSAGE_PREPARATION_FREQUENCY_5_HZ ((1000 * 1000) / 5)
#define HOTT_RX_SCHEDULE 4000
#define HOTT_TX_DELAY_US 3000
#define MILLISECONDS_IN_A_SECOND 1000
static uint32_t lastHoTTRequestCheckAt = 0;
static uint32_t lastMessagesPreparedAt = 0;
static uint32_t alarmSound_currentTime, previous_alarmSound_time;
static uint32_t lastHottAlarmSoundTime = 0;
static bool hottIsSending = false;
@ -211,15 +211,15 @@ void hottPrepareGPSResponse(HOTT_GPS_MSG_t *hottGPSMessage)
}
#endif
static bool time_for_Voice_Alarm(void)
static bool shouldTriggerVoiceAlarmNow(void)
{
return ((alarmSound_currentTime - previous_alarmSound_time) >= (useHottAlarmSoundPeriod() * 1000000));
return ((millis() - lastHottAlarmSoundTime) >= (useHottAlarmSoundInterval() * MILLISECONDS_IN_A_SECOND));
}
static inline void checkAlarmBattery(HOTT_EAM_MSG_t *hottEAMMessage)
static inline void updateAlarmBatteryStatus(HOTT_EAM_MSG_t *hottEAMMessage)
{
if (time_for_Voice_Alarm()){
previous_alarmSound_time = alarmSound_currentTime;
if (shouldTriggerVoiceAlarmNow()){
lastHottAlarmSoundTime = millis();
if (vbat <= batteryWarningVoltage){
hottEAMMessage->warning_beeps = 0x10;
hottEAMMessage->alarm_invers1 = HOTT_EAM_ALARM1_FLAG_BATTERY_1;
@ -238,7 +238,7 @@ static inline void hottEAMUpdateBattery(HOTT_EAM_MSG_t *hottEAMMessage)
hottEAMMessage->batt1_voltage_L = vbat & 0xFF;
hottEAMMessage->batt1_voltage_H = vbat >> 8;
checkAlarmBattery(hottEAMMessage);
updateAlarmBatteryStatus(hottEAMMessage);
}
static inline void hottEAMUpdateCurrentMeter(HOTT_EAM_MSG_t *hottEAMMessage)
@ -440,6 +440,12 @@ static void hottCheckSerialData(uint32_t currentMicros)
uint8_t requestId = serialRead(hottPort);
uint8_t address = serialRead(hottPort);
/*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 */
if (requestId == HOTT_BINARY_MODE_REQUEST_ID) {
processBinaryModeRequest(address);
}
@ -489,7 +495,6 @@ void handleHoTTTelemetry(void)
{
static uint32_t serialTimer;
uint32_t now = micros();
alarmSound_currentTime = now;
if (shouldPrepareHoTTMessages(now)) {

View file

@ -49,9 +49,9 @@ static bool telemetryPortIsShared;
static telemetryConfig_t *telemetryConfig;
uint8_t useHottAlarmSoundPeriod (void)
uint8_t useHottAlarmSoundInterval(void)
{
return telemetryConfig->HottAlarmSoundPeriod;
return telemetryConfig->hottAlarmSoundInterval;
}
void useTelemetryConfig(telemetryConfig_t *telemetryConfigToUse)
{

View file

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