From 820e89ead9577c7aa4b7ef10f363daf8a28247ac Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Tue, 8 Jun 2021 00:56:19 +0200 Subject: :sparkles: Do lots of small tweaks --- source/HoverBitController.cpp | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'source/HoverBitController.cpp') diff --git a/source/HoverBitController.cpp b/source/HoverBitController.cpp index 1ecc21b..301fdeb 100644 --- a/source/HoverBitController.cpp +++ b/source/HoverBitController.cpp @@ -27,8 +27,6 @@ DEALINGS IN THE SOFTWARE. /** * Init method for HoverBitController, this sets everything to the default values. * It also initializes the airbit-pcb with some protocol magic. - * - * @param _uBit the MicroBit instance */ void HoverBitController::init() { mainController = false; @@ -44,9 +42,8 @@ void HoverBitController::init() { throttle = 0; lastReceiveTime = uBit.systemTime(); - /* I am not completly sure what this does, but it seems to me like this is - putting the air:bit board in some kind of "bind-mode", on the spec-sheet - there isn't any documentation for what 20 pulses means tho... */ + /* I am not completly sure what this does, according to the hover:bit guys + this is some magic to disable gyro-control of the lift fan. */ uBit.sleep(100); int o; for (o = 0; o < 20; o++) { @@ -60,14 +57,14 @@ void HoverBitController::init() { */ bool HoverBitController::failSafe(void) { unsigned long deltaReceiveTime = uBit.systemTime() - lastReceiveTime; - if (deltaReceiveTime > FSAFE_TLIM_THROTTLE) { - Throttle(0); - Rudder(0); - AirBit(0, arm, 0, throttle, roll, roll + 45, servo_1); - } if (deltaReceiveTime > FSAFE_TLIM_ARM) { - Arm(0); - AirBit(0, arm, 0, throttle, roll, roll + 45, servo_1); + arm = 0; + AirBit(0, 0, 0, 0, 0, 0 + 45, servo_1); + } + if (deltaReceiveTime > FSAFE_TLIM_THROTTLE) { + throttle = 0; + roll = 0; + AirBit(0, arm, 0, 0, 0, 0 + 45, servo_1); } return (deltaReceiveTime > FSAFE_TLIM_THROTTLE) || (deltaReceiveTime > FSAFE_TLIM_ARM); } @@ -87,9 +84,9 @@ unsigned int HoverBitController::GetBatteryVoltage() { void HoverBitController::checkBattery() { if (GetBatteryVoltage() < BATTERY_LOW_LIMIT - 60) { bBatteryEmpty = true; - Throttle(0); - Arm(0); - Rudder(0); + throttle = 0; + arm = 0; + roll = 0; } } @@ -162,7 +159,7 @@ void HoverBitController::AirBit(int Pitch,int Arm,int Roll,int Throttle,int Yaw, void HoverBitController::HoverControl() { checkBattery(); if (BatteryEmpty()) { - Arm(0); + arm = 0; } if (!failSafe()) { AirBit(0, arm, 0, throttle, roll, roll + 45, servo_1); -- cgit v1.2.3