1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-30 15:52:12 +01:00

OP-1302 use pios_notify api to alert user of ongoing CF gyro calibration

This commit is contained in:
Alessio Morale 2014-04-13 17:56:20 +02:00
parent 299f388245
commit 20508314f2
3 changed files with 35 additions and 30 deletions

View File

@ -116,13 +116,11 @@ void NotificationOnboardLedsRun()
STATUS_LENGHT STATUS_LENGHT
} status; } status;
if (!started || (xTaskGetTickCount() - lastRunTimestamp) < (LED_BLINK_PERIOD_MS * portTICK_RATE_MS / 2)) { if (!started || (xTaskGetTickCount() - lastRunTimestamp) < (LED_BLINK_PERIOD_MS * portTICK_RATE_MS / 2)) {
return; return;
} }
lastRunTimestamp = xTaskGetTickCount(); lastRunTimestamp = xTaskGetTickCount();
// the led will show various status information, subdivided in three phases // the led will show various status information, subdivided in three phases
// - Notification // - Notification
// - Alarm // - 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 // a phase last exactly 8 cycles (so bit 1<<4 is used to determine if a phase end
cycleCount++; cycleCount++;
// Notifications are "modal" to other statuses so they takes precedence // Notifications are "modal" to other statuses so they takes precedence
if (status != STATUS_NOTIFY && nextNotification != NOTIFY_NONE) { if (status != STATUS_NOTIFY && nextNotification != NOTIFY_NONE) {
// Force a notification status // read next notification to show
runningNotification = nextNotification; runningNotification = nextNotification;
nextNotification = NOTIFY_NONE; nextNotification = NOTIFY_NONE;
// Force a notification status
status = STATUS_NOTIFY; status = STATUS_NOTIFY;
cycleCount = 0; // instantly start a notify cycle cycleCount = 0; // instantly start a notify cycle
} }
// check if a phase has just finished // check if a phase has just finished
if (cycleCount & 0x08) { if (cycleCount & 0x08) {
// add a short pause between each phase // add a pause between each phase
if (cycleCount > 0x8 + LED_PAUSE_BETWEEN_PHASES) { if (cycleCount > 0x8 + LED_PAUSE_BETWEEN_PHASES) {
// ready to start a new phase // ready to start a new phase
cycleCount = 0x0; cycleCount = 0x0;
// Notification has been already shown, so clear the running one // Notification has been just shown, cleanup
if (status == STATUS_NOTIFY) { if (status == STATUS_NOTIFY) {
runningNotification = NOTIFY_NONE; 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; blinkCount = (cycleCount & 0xF) >> 1;
if (status == STATUS_NOTIFY) { if (status == STATUS_NOTIFY) {
if (!handleNotifications(cycleCount, runningNotification)) { if (!handleNotifications(cycleCount, runningNotification)) {
// no notifications, advance
status++; status++;
} }
} }
@ -174,12 +172,15 @@ void NotificationOnboardLedsRun()
if (status == STATUS_ALARM) { if (status == STATUS_ALARM) {
#ifdef PIOS_LED_ALARM #ifdef PIOS_LED_ALARM
if (!handleAlarms(cycleCount, blinkCount)) { if (!handleAlarms(cycleCount, blinkCount)) {
// no alarms, advance
status++; status++;
} }
#else #else
// no alarms leds, advance
status++; status++;
#endif // PIOS_LED_ALARM #endif // PIOS_LED_ALARM
} }
// **** Handles flightmode display // **** Handles flightmode display
if (status == STATUS_FLIGHTMODE) { if (status == STATUS_FLIGHTMODE) {
handleStatus(cycleCount, blinkCount); handleStatus(cycleCount, blinkCount);
@ -189,27 +190,27 @@ void NotificationOnboardLedsRun()
#if defined(PIOS_LED_ALARM) #if defined(PIOS_LED_ALARM)
static bool handleAlarms(uint8_t cycleCount, uint8_t blinkCount) static bool handleAlarms(uint8_t cycleCount, uint8_t blinkCount)
{ {
if (currentAlarmLevel > SYSTEMALARMS_ALARM_OK) { 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 {
return false; 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 */ #endif /* PIOS_LED_ALARM */
@ -244,7 +245,7 @@ static void handleStatus(uint8_t cycleCount, uint8_t blinkCount)
} else { } else {
if ((blinkCount < BLINK_COUNT(flightmode)) && if ((blinkCount < BLINK_COUNT(flightmode)) &&
(cycleCount & 0x1)) { (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) && if (BLINK_RED(flightmode) &&
((blinkCount == BLINK_COUNT(flightmode) - 1) || ((blinkCount == BLINK_COUNT(flightmode) - 1) ||
blinkCount > 1)) { blinkCount > 1)) {

View File

@ -63,7 +63,7 @@
#include "taskinfo.h" #include "taskinfo.h"
#include "CoordinateConversions.h" #include "CoordinateConversions.h"
#include <pios_notify.h>
// Private constants // Private constants
#define STACK_SIZE_BYTES 540 #define STACK_SIZE_BYTES 540
@ -252,6 +252,7 @@ static void AttitudeTask(__attribute__((unused)) void *parameters)
rollPitchBiasRate = 0.01f; rollPitchBiasRate = 0.01f;
accel_filter_enabled = false; accel_filter_enabled = false;
init = 0; init = 0;
PIOS_NOTIFY_StartNotification(NOTIFY_DRAW_ATTENTION, NOTIFY_PRIORITY_REGULAR);
} else if (zero_during_arming && (flightStatus.Armed == FLIGHTSTATUS_ARMED_ARMING)) { } else if (zero_during_arming && (flightStatus.Armed == FLIGHTSTATUS_ARMED_ARMING)) {
accelKp = 1.0f; accelKp = 1.0f;
accelKi = 0.0f; accelKi = 0.0f;
@ -259,6 +260,7 @@ static void AttitudeTask(__attribute__((unused)) void *parameters)
rollPitchBiasRate = 0.01f; rollPitchBiasRate = 0.01f;
accel_filter_enabled = false; accel_filter_enabled = false;
init = 0; init = 0;
PIOS_NOTIFY_StartNotification(NOTIFY_DRAW_ATTENTION, NOTIFY_PRIORITY_REGULAR);
} else if (init == 0) { } else if (init == 0) {
// Reload settings (all the rates) // Reload settings (all the rates)
AttitudeSettingsAccelKiGet(&accelKi); AttitudeSettingsAccelKiGet(&accelKi);

View File

@ -42,7 +42,7 @@
#include <revocalibration.h> #include <revocalibration.h>
#include <CoordinateConversions.h> #include <CoordinateConversions.h>
#include <pios_notify.h>
// Private constants // Private constants
#define STACK_REQUIRED 512 #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->accel_filter_enabled = false;
this->rollPitchBiasRate = 0.01f; this->rollPitchBiasRate = 0.01f;
this->attitudeSettings.MagKp = this->magCalibrated ? 1.0f : 0.0f; 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)) { } else if ((this->attitudeSettings.ZeroDuringArming == ATTITUDESETTINGS_ZERODURINGARMING_TRUE) && (flightStatus.Armed == FLIGHTSTATUS_ARMED_ARMING)) {
this->attitudeSettings.AccelKp = 1.0f; this->attitudeSettings.AccelKp = 1.0f;
this->attitudeSettings.AccelKi = 0.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->rollPitchBiasRate = 0.01f;
this->attitudeSettings.MagKp = this->magCalibrated ? 1.0f : 0.0f; this->attitudeSettings.MagKp = this->magCalibrated ? 1.0f : 0.0f;
this->init = 0; this->init = 0;
PIOS_NOTIFY_StartNotification(NOTIFY_DRAW_ATTENTION, NOTIFY_PRIORITY_REGULAR);
} else if (this->init == 0) { } else if (this->init == 0) {
// Reload settings (all the rates) // Reload settings (all the rates)
AttitudeSettingsGet(&this->attitudeSettings); AttitudeSettingsGet(&this->attitudeSettings);