-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8d37a11
commit fd5030b
Showing
4 changed files
with
120 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#ifndef __QUADROTOR_H__ | ||
#define __QUADROTOR_H__ | ||
|
||
#include <stdbool.h> | ||
|
||
bool is_flight_ctrl_running(void); | ||
void trigger_esc_calibration(void); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
#include "quadrotor.h" | ||
#include "shell.h" | ||
|
||
int esc_calib(int argc, char *argv[]) | ||
{ | ||
if (is_flight_ctrl_running()) { | ||
shell_puts("command rejected, flight control is running.\n\r"); | ||
return 0; | ||
} | ||
|
||
/* Confirmation */ | ||
struct shell shell; | ||
shell_init_minimal(&shell); | ||
shell_set_prompt(&shell, "confirm esc calibration command [y/n]: "); | ||
shell_listen(&shell); | ||
|
||
if (strcmp(shell.buf, "y") == 0 || strcmp(shell.buf, "Y") == 0) { | ||
shell_puts( | ||
"start esc calibration.\n\r" | ||
"restart the system after finishing the calibration.\n\r"); | ||
trigger_esc_calibration(); | ||
} else { | ||
shell_puts("abort.\n\r"); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
HOOK_SHELL_CMD("esc_calib", esc_calib); |