Skip to content

Commit

Permalink
Convert all services to extern pattern. Reduce warnings from boost sml
Browse files Browse the repository at this point in the history
  • Loading branch information
AJ-Koenig committed Nov 16, 2024
1 parent ed48a3c commit f6fa14f
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Software/src/services/encoder.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "encoder.h"

// Define the global encoder instance
AiEsp32RotaryEncoder encoder(
Pins::Remote::encoderA,
Pins::Remote::encoderB,
Pins::Remote::encoderSwitch,
Pins::Remote::encoderPower,
Pins::Remote::encoderStepsPerNotch
);

void IRAM_ATTR readEncoderISR() {
encoder.readEncoder_ISR();
}

void initEncoder() {
encoder.begin();
encoder.setup(readEncoderISR);
encoder.setBoundaries(0, 99, false);
encoder.setAcceleration(0);
encoder.disableAcceleration();
}
21 changes: 21 additions & 0 deletions Software/src/services/stepper.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "stepper.h"

FastAccelStepperEngine stepperEngine = FastAccelStepperEngine();
FastAccelStepper *stepper = nullptr;
class StrokeEngine Stroker;

void initStepper() {
stepperEngine.init();
stepper = stepperEngine.stepperConnectToPin(Pins::Driver::motorStepPin);
if (stepper) {
stepper->setDirectionPin(Pins::Driver::motorDirectionPin, false);
stepper->setEnablePin(Pins::Driver::motorEnablePin, true);
stepper->setAutoEnable(false);
}

// disable motor briefly in case we are against a hard stop.
digitalWrite(Pins::Driver::motorEnablePin, HIGH);
delay(600);
digitalWrite(Pins::Driver::motorEnablePin, LOW);
delay(100);
}
14 changes: 14 additions & 0 deletions Software/src/services/tasks.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "tasks.h"

namespace Tasks {
TaskHandle_t drawHelloTaskH = nullptr;
TaskHandle_t drawMenuTaskH = nullptr;
TaskHandle_t drawPlayControlsTaskH = nullptr;
TaskHandle_t drawPatternControlsTaskH = nullptr;
TaskHandle_t wmTaskH = nullptr;
TaskHandle_t drawPreflightTaskH = nullptr;

TaskHandle_t runHomingTaskH = nullptr;
TaskHandle_t runSimplePenetrationTaskH = nullptr;
TaskHandle_t runStrokeEngineTaskH = nullptr;
}

0 comments on commit f6fa14f

Please sign in to comment.