mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-07 02:01:35 +08:00
px4io: moved blue heartbeat LED to main loop
this allows us to tell if the main loop is running by looking for a blinking blue LED
This commit is contained in:
@@ -117,6 +117,13 @@ show_debug_messages(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
heartbeat_blink(void)
|
||||||
|
{
|
||||||
|
static bool heartbeat = false;
|
||||||
|
LED_BLUE(heartbeat = !heartbeat);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
user_start(int argc, char *argv[])
|
user_start(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@@ -201,6 +208,7 @@ user_start(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
uint64_t last_debug_time = 0;
|
uint64_t last_debug_time = 0;
|
||||||
|
uint64_t last_heartbeat_time = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
||||||
/* track the rate at which the loop is running */
|
/* track the rate at which the loop is running */
|
||||||
@@ -216,6 +224,11 @@ user_start(int argc, char *argv[])
|
|||||||
controls_tick();
|
controls_tick();
|
||||||
perf_end(controls_perf);
|
perf_end(controls_perf);
|
||||||
|
|
||||||
|
if ((hrt_absolute_time() - last_heartbeat_time) > 250*1000) {
|
||||||
|
last_heartbeat_time = hrt_absolute_time();
|
||||||
|
heartbeat_blink();
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* check for debug activity */
|
/* check for debug activity */
|
||||||
show_debug_messages();
|
show_debug_messages();
|
||||||
|
|||||||
@@ -77,7 +77,6 @@ static unsigned blink_counter = 0;
|
|||||||
static bool safety_button_pressed;
|
static bool safety_button_pressed;
|
||||||
|
|
||||||
static void safety_check_button(void *arg);
|
static void safety_check_button(void *arg);
|
||||||
static void heartbeat_blink(void *arg);
|
|
||||||
static void failsafe_blink(void *arg);
|
static void failsafe_blink(void *arg);
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -86,9 +85,6 @@ safety_init(void)
|
|||||||
/* arrange for the button handler to be called at 10Hz */
|
/* arrange for the button handler to be called at 10Hz */
|
||||||
hrt_call_every(&arming_call, 1000, 100000, safety_check_button, NULL);
|
hrt_call_every(&arming_call, 1000, 100000, safety_check_button, NULL);
|
||||||
|
|
||||||
/* arrange for the heartbeat handler to be called at 4Hz */
|
|
||||||
hrt_call_every(&heartbeat_call, 1000, 250000, heartbeat_blink, NULL);
|
|
||||||
|
|
||||||
/* arrange for the failsafe blinker to be called at 8Hz */
|
/* arrange for the failsafe blinker to be called at 8Hz */
|
||||||
hrt_call_every(&failsafe_call, 1000, 125000, failsafe_blink, NULL);
|
hrt_call_every(&failsafe_call, 1000, 125000, failsafe_blink, NULL);
|
||||||
}
|
}
|
||||||
@@ -163,16 +159,6 @@ safety_check_button(void *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
heartbeat_blink(void *arg)
|
|
||||||
{
|
|
||||||
static bool heartbeat = false;
|
|
||||||
|
|
||||||
/* XXX add flags here that need to be frobbed by various loops */
|
|
||||||
|
|
||||||
LED_BLUE(heartbeat = !heartbeat);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
failsafe_blink(void *arg)
|
failsafe_blink(void *arg)
|
||||||
{
|
{
|
||||||
@@ -192,4 +178,4 @@ failsafe_blink(void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
LED_AMBER(failsafe);
|
LED_AMBER(failsafe);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user