mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-27 01:53:35 +08:00
Merge branch 'lights'
This commit is contained in:
@@ -85,6 +85,9 @@ static volatile uint8_t msg_next_out, msg_next_in;
|
|||||||
#define NUM_MSG 2
|
#define NUM_MSG 2
|
||||||
static char msg[NUM_MSG][40];
|
static char msg[NUM_MSG][40];
|
||||||
|
|
||||||
|
static void heartbeat_blink(void);
|
||||||
|
static void ring_blink(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* add a debug message to be printed on the console
|
* add a debug message to be printed on the console
|
||||||
*/
|
*/
|
||||||
@@ -124,8 +127,54 @@ heartbeat_blink(void)
|
|||||||
{
|
{
|
||||||
static bool heartbeat = false;
|
static bool heartbeat = false;
|
||||||
LED_BLUE(heartbeat = !heartbeat);
|
LED_BLUE(heartbeat = !heartbeat);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
ring_blink(void)
|
||||||
|
{
|
||||||
#ifdef GPIO_LED4
|
#ifdef GPIO_LED4
|
||||||
LED_RING(heartbeat);
|
|
||||||
|
// XXX this led code does have
|
||||||
|
// intentionally a few magic numbers.
|
||||||
|
const unsigned max_brightness = 118;
|
||||||
|
|
||||||
|
static unsigned counter = 0;
|
||||||
|
static unsigned brightness = max_brightness;
|
||||||
|
static unsigned brightness_counter = 0;
|
||||||
|
static unsigned on_counter = 0;
|
||||||
|
|
||||||
|
if (brightness_counter < max_brightness) {
|
||||||
|
|
||||||
|
bool on = ((on_counter * 100) / brightness_counter+1) <= ((brightness * 100) / max_brightness+1);
|
||||||
|
|
||||||
|
LED_RING(on);
|
||||||
|
brightness_counter++;
|
||||||
|
|
||||||
|
if (on) {
|
||||||
|
on_counter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (counter >= 62) {
|
||||||
|
counter = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int n;
|
||||||
|
|
||||||
|
if (counter < 32) {
|
||||||
|
n = counter;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
n = 62 - counter;
|
||||||
|
}
|
||||||
|
|
||||||
|
brightness = (n * n) / 9;
|
||||||
|
brightness_counter = 0;
|
||||||
|
on_counter = 0;
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,6 +349,8 @@ user_start(int argc, char *argv[])
|
|||||||
heartbeat_blink();
|
heartbeat_blink();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ring_blink();
|
||||||
|
|
||||||
check_reboot();
|
check_reboot();
|
||||||
|
|
||||||
/* check for debug activity (default: none) */
|
/* check for debug activity (default: none) */
|
||||||
|
|||||||
Reference in New Issue
Block a user