mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
OP-1302 use pios_notify api to alert user of ongoing CF gyro calibration
This commit is contained in:
parent
299f388245
commit
20508314f2
@ -116,13 +116,11 @@ void NotificationOnboardLedsRun()
|
||||
STATUS_LENGHT
|
||||
} status;
|
||||
|
||||
|
||||
if (!started || (xTaskGetTickCount() - lastRunTimestamp) < (LED_BLINK_PERIOD_MS * portTICK_RATE_MS / 2)) {
|
||||
return;
|
||||
}
|
||||
|
||||
lastRunTimestamp = xTaskGetTickCount();
|
||||
|
||||
// the led will show various status information, subdivided in three phases
|
||||
// - Notification
|
||||
// - Alarm
|
||||
@ -131,25 +129,24 @@ void NotificationOnboardLedsRun()
|
||||
// a phase last exactly 8 cycles (so bit 1<<4 is used to determine if a phase end
|
||||
|
||||
cycleCount++;
|
||||
|
||||
// Notifications are "modal" to other statuses so they takes precedence
|
||||
if (status != STATUS_NOTIFY && nextNotification != NOTIFY_NONE) {
|
||||
// Force a notification status
|
||||
// read next notification to show
|
||||
runningNotification = nextNotification;
|
||||
nextNotification = NOTIFY_NONE;
|
||||
|
||||
// Force a notification status
|
||||
status = STATUS_NOTIFY;
|
||||
cycleCount = 0; // instantly start a notify cycle
|
||||
}
|
||||
|
||||
// check if a phase has just finished
|
||||
if (cycleCount & 0x08) {
|
||||
// add a short pause between each phase
|
||||
// add a pause between each phase
|
||||
if (cycleCount > 0x8 + LED_PAUSE_BETWEEN_PHASES) {
|
||||
// ready to start a new phase
|
||||
cycleCount = 0x0;
|
||||
|
||||
// Notification has been already shown, so clear the running one
|
||||
// Notification has been just shown, cleanup
|
||||
if (status == STATUS_NOTIFY) {
|
||||
runningNotification = NOTIFY_NONE;
|
||||
}
|
||||
@ -161,11 +158,12 @@ void NotificationOnboardLedsRun()
|
||||
}
|
||||
}
|
||||
|
||||
// a blink last 2 cycles.
|
||||
// a blink last 2 cycles(on and off cycle).
|
||||
blinkCount = (cycleCount & 0xF) >> 1;
|
||||
|
||||
if (status == STATUS_NOTIFY) {
|
||||
if (!handleNotifications(cycleCount, runningNotification)) {
|
||||
// no notifications, advance
|
||||
status++;
|
||||
}
|
||||
}
|
||||
@ -174,12 +172,15 @@ void NotificationOnboardLedsRun()
|
||||
if (status == STATUS_ALARM) {
|
||||
#ifdef PIOS_LED_ALARM
|
||||
if (!handleAlarms(cycleCount, blinkCount)) {
|
||||
// no alarms, advance
|
||||
status++;
|
||||
}
|
||||
#else
|
||||
// no alarms leds, advance
|
||||
status++;
|
||||
#endif // PIOS_LED_ALARM
|
||||
}
|
||||
|
||||
// **** Handles flightmode display
|
||||
if (status == STATUS_FLIGHTMODE) {
|
||||
handleStatus(cycleCount, blinkCount);
|
||||
@ -189,27 +190,27 @@ void NotificationOnboardLedsRun()
|
||||
#if defined(PIOS_LED_ALARM)
|
||||
static bool handleAlarms(uint8_t cycleCount, uint8_t blinkCount)
|
||||
{
|
||||
if (currentAlarmLevel > SYSTEMALARMS_ALARM_OK) {
|
||||
if (currentAlarmLevel == SYSTEMALARMS_ALARM_CRITICAL) {
|
||||
// Slow blink
|
||||
ALARM_LED_OFF();
|
||||
if (cycleCount & 0x4) {
|
||||
ALARM_LED_OFF();
|
||||
} else {
|
||||
ALARM_LED_ON();
|
||||
}
|
||||
} else {
|
||||
if ((blinkCount < (ALARM_BLINK_COUNT(currentAlarmLevel))) &&
|
||||
(cycleCount & 0x1)) {
|
||||
ALARM_LED_ON();
|
||||
} else {
|
||||
ALARM_LED_OFF();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
if (currentAlarmLevel == SYSTEMALARMS_ALARM_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (currentAlarmLevel == SYSTEMALARMS_ALARM_CRITICAL) {
|
||||
// Slow blink
|
||||
ALARM_LED_OFF();
|
||||
if (cycleCount & 0x4) {
|
||||
ALARM_LED_OFF();
|
||||
} else {
|
||||
ALARM_LED_ON();
|
||||
}
|
||||
} else {
|
||||
if ((blinkCount < (ALARM_BLINK_COUNT(currentAlarmLevel))) &&
|
||||
(cycleCount & 0x1)) {
|
||||
ALARM_LED_ON();
|
||||
} else {
|
||||
ALARM_LED_OFF();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif /* PIOS_LED_ALARM */
|
||||
|
||||
@ -244,7 +245,7 @@ static void handleStatus(uint8_t cycleCount, uint8_t blinkCount)
|
||||
} else {
|
||||
if ((blinkCount < BLINK_COUNT(flightmode)) &&
|
||||
(cycleCount & 0x1)) {
|
||||
// red led will be active active in last or last two (4 blinks case) blinks
|
||||
// red led will be active active on last (1-3 blinks) or last two (4 blinks case) blinks
|
||||
if (BLINK_RED(flightmode) &&
|
||||
((blinkCount == BLINK_COUNT(flightmode) - 1) ||
|
||||
blinkCount > 1)) {
|
||||
|
@ -63,7 +63,7 @@
|
||||
#include "taskinfo.h"
|
||||
|
||||
#include "CoordinateConversions.h"
|
||||
|
||||
#include <pios_notify.h>
|
||||
|
||||
// Private constants
|
||||
#define STACK_SIZE_BYTES 540
|
||||
@ -252,6 +252,7 @@ static void AttitudeTask(__attribute__((unused)) void *parameters)
|
||||
rollPitchBiasRate = 0.01f;
|
||||
accel_filter_enabled = false;
|
||||
init = 0;
|
||||
PIOS_NOTIFY_StartNotification(NOTIFY_DRAW_ATTENTION, NOTIFY_PRIORITY_REGULAR);
|
||||
} else if (zero_during_arming && (flightStatus.Armed == FLIGHTSTATUS_ARMED_ARMING)) {
|
||||
accelKp = 1.0f;
|
||||
accelKi = 0.0f;
|
||||
@ -259,6 +260,7 @@ static void AttitudeTask(__attribute__((unused)) void *parameters)
|
||||
rollPitchBiasRate = 0.01f;
|
||||
accel_filter_enabled = false;
|
||||
init = 0;
|
||||
PIOS_NOTIFY_StartNotification(NOTIFY_DRAW_ATTENTION, NOTIFY_PRIORITY_REGULAR);
|
||||
} else if (init == 0) {
|
||||
// Reload settings (all the rates)
|
||||
AttitudeSettingsAccelKiGet(&accelKi);
|
||||
|
@ -42,7 +42,7 @@
|
||||
#include <revocalibration.h>
|
||||
|
||||
#include <CoordinateConversions.h>
|
||||
|
||||
#include <pios_notify.h>
|
||||
// Private constants
|
||||
|
||||
#define STACK_REQUIRED 512
|
||||
@ -295,6 +295,7 @@ static int32_t complementaryFilter(struct data *this, float gyro[3], float accel
|
||||
this->accel_filter_enabled = false;
|
||||
this->rollPitchBiasRate = 0.01f;
|
||||
this->attitudeSettings.MagKp = this->magCalibrated ? 1.0f : 0.0f;
|
||||
PIOS_NOTIFY_StartNotification(NOTIFY_DRAW_ATTENTION, NOTIFY_PRIORITY_REGULAR);
|
||||
} else if ((this->attitudeSettings.ZeroDuringArming == ATTITUDESETTINGS_ZERODURINGARMING_TRUE) && (flightStatus.Armed == FLIGHTSTATUS_ARMED_ARMING)) {
|
||||
this->attitudeSettings.AccelKp = 1.0f;
|
||||
this->attitudeSettings.AccelKi = 0.0f;
|
||||
@ -303,6 +304,7 @@ static int32_t complementaryFilter(struct data *this, float gyro[3], float accel
|
||||
this->rollPitchBiasRate = 0.01f;
|
||||
this->attitudeSettings.MagKp = this->magCalibrated ? 1.0f : 0.0f;
|
||||
this->init = 0;
|
||||
PIOS_NOTIFY_StartNotification(NOTIFY_DRAW_ATTENTION, NOTIFY_PRIORITY_REGULAR);
|
||||
} else if (this->init == 0) {
|
||||
// Reload settings (all the rates)
|
||||
AttitudeSettingsGet(&this->attitudeSettings);
|
||||
|
Loading…
x
Reference in New Issue
Block a user