Skip to content

Commit

Permalink
Merge branch 'main' into smooth_thrusters
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminwp18 committed Jun 21, 2024
2 parents 618c071 + 8e5d684 commit b6a01b1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
- name: Build and push Docker image
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
context: .
push: true
Expand Down
23 changes: 16 additions & 7 deletions src/float/float_transceiver/float_transceiver.ino
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ const uint32_t PRESSURE_READ_INTERVAL = 5000;
const uint32_t PROFILE_SEGMENT = 60000;
#endif

const uint32_t ONE_MINUTE = 60000;

// Schedule (all delays in ms)
const uint32_t RELEASE_MAX = 8 * 60000;
const uint32_t RELEASE_MAX = 8 * ONE_MINUTE;
const uint32_t SUCK_MAX = PROFILE_SEGMENT;
const uint32_t DESCEND_TIME = PROFILE_SEGMENT;
const uint32_t PUMP_MAX = PROFILE_SEGMENT;
const uint32_t ASCEND_TIME = 0; // Disable ascend times now that we're properly ballasted
const uint32_t TX_MAX = 2 * 60000;
const uint32_t CODA = 2 * 60000;
const uint32_t TX_MAX_TIME = 2 * ONE_MINUTE;

const size_t SCHEDULE_LENGTH = 12;

Expand All @@ -57,7 +58,7 @@ struct Stage {
OverrideState overrideState = OverrideState::NoOverride;
uint8_t currentStage = 0;

Stage SCHEDULE[SCHEDULE_LENGTH] = {
const Stage SCHEDULE[SCHEDULE_LENGTH] = {
// Pump immediately in case we just rebooted at the bottom of the pool
{StageType::Pump, PUMP_MAX },

Expand All @@ -70,15 +71,15 @@ Stage SCHEDULE[SCHEDULE_LENGTH] = {
{StageType::Pump, PUMP_MAX },
{StageType::WaitProfiling, ASCEND_TIME },

{StageType::WaitTransmitting, TX_MAX },
{StageType::WaitTransmitting, TX_MAX_TIME },

// Profile 2
{StageType::Suck, SUCK_MAX },
{StageType::WaitProfiling, DESCEND_TIME},
{StageType::Pump, PUMP_MAX },
{StageType::WaitProfiling, ASCEND_TIME },

{StageType::WaitTransmitting, CODA },
{StageType::WaitTransmitting, TX_MAX_TIME },
};

uint32_t stageStartTime;
Expand Down Expand Up @@ -139,7 +140,10 @@ void setup() {

void loop() {
bool submergeReceived = false;
if (!stageIs(StageType::Suck) && !stageIs(StageType::Pump)) {

// Disable command Rx when the motor is moving
// Otherwise the motor can overrun the limit switch
if (!isMotorMoving()) {
submergeReceived = receiveCommand();
}

Expand Down Expand Up @@ -394,6 +398,11 @@ MotorState getMotorState() {
}
}

bool isMotorMoving() {
const MotorState motorState = getMotorState();
return motorState == MotorState::Pump || motorState == MotorState::Suck;
}

bool stageIs(StageType type) { return SCHEDULE[currentStage].type == type; }

bool isSurfaced() {
Expand Down

0 comments on commit b6a01b1

Please sign in to comment.