Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into Controls
Browse files Browse the repository at this point in the history
  • Loading branch information
cameron-goddard committed Dec 2, 2024
2 parents 7b30c73 + f817f66 commit d7671b6
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
11 changes: 11 additions & 0 deletions src/Control Tasks/MotorControlTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ void MotorControlTask::begin() {
}

void MotorControlTask::execute() {
if (sfr::flight::initial_hold && (millis() > constants::flight::initial_hold_time)) {
sfr::flight::initial_hold = false;
sfr::flight::initial_spin = true;
esc.write(map(1180, 1000, 2000, 0, 180));
}

if (sfr::flight::initial_spin && (millis() > constants::flight::initial_spin_time)) {
sfr::flight::initial_spin = false;
set_white();
}

if (sfr::motor::spinning_up) {
vlogln("asking it to spin up: ");
spinup();
Expand Down
4 changes: 4 additions & 0 deletions src/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ inline void set_purple() {
}

namespace constants {
namespace flight {
constexpr unsigned long initial_hold_time = 5000;
constexpr unsigned long initial_spin_time = 10000; // TODO: This is kinda hacky but I'm lazy rn
} // namespace flight
namespace ir {
constexpr unsigned long arm_timeout = 2000;
constexpr unsigned long deploy_led_timeout = 3000;
Expand Down
8 changes: 5 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ MotorControlTask motor_control_task;
SDControlTask sd_control_task;

void set_automated() {
sfr::test::automated = true;
sfr::flight::automated = true;
set_purple();
}

Expand All @@ -28,7 +28,7 @@ void setup() {
pinMode(BUTTON_PIN, INPUT);
attachInterrupt(BUTTON_PIN, set_automated, FALLING);

set_white();
set_blue();

imu_monitor.begin();
ir_control_task.begin();
Expand All @@ -40,7 +40,9 @@ void loop() {
vlogln(F("-------------------- START LOOP --------------------"));

imu_monitor.execute();
ir_control_task.execute();
if (!sfr::flight::automated) {
ir_control_task.execute();
}
motor_control_task.execute();
sd_control_task.execute();

Expand Down
6 changes: 4 additions & 2 deletions src/sfr.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#include "sfr.hpp"

namespace sfr {
namespace test {
namespace flight {
bool initial_hold = true;
bool initial_spin = false;
volatile bool automated = false;
} // namespace test
} // namespace flight
namespace ir {
bool is_armed = false;
unsigned long armed_start = 0;
Expand Down
6 changes: 4 additions & 2 deletions src/sfr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
#define SFR_HPP

namespace sfr {
namespace test {
namespace flight {
extern bool initial_hold;
extern bool initial_spin;
extern volatile bool automated;
} // namespace test
} // namespace flight
namespace ir {
extern bool is_armed;
extern unsigned long armed_start;
Expand Down

0 comments on commit d7671b6

Please sign in to comment.