Implemented servo main switch

This commit is contained in:
2025-12-31 17:08:29 -06:00
parent 90e967c6f8
commit d3e4b9a59e
2 changed files with 7 additions and 29 deletions

View File

@@ -35,32 +35,6 @@
#define servoPin GPIO_NUM_20 #define servoPin GPIO_NUM_20
#define servoLEDCChannel LEDC_CHANNEL_0 #define servoLEDCChannel LEDC_CHANNEL_0
#define servoSwitch GPIO_NUM_17
#define getMovingCW(port) ((movingCW & (1 << port)) >> port)
#define setMovingCW(port) (movingCW |= (1 << port))
#define clearMovingCW(port) (movingCW &= ~(1 << port))
#define getMovingCCW(port) ((movingCCW & (1 << port)) >> port)
#define setMovingCCW(port) (movingCCW |= (1 << port))
#define clearMovingCCW(port) (movingCCW &= ~(1 << port))
#define getCalibCW(port) ((calibCW & (1 << port)) >> port)
#define setCalibCW(port) (calibCW |= (1 << port))
#define clearCalibCW(port) (calibCW &= ~(1 << port))
#define getCalibCCW(port) ((calibCCW & (1 << port)) >> port)
#define setCalibCCW(port) (calibCCW |= (1 << port))
#define clearCalibCCW(port) (calibCCW &= ~(1 << port))
#define getCalibDone(port) ((calibDone & (1 << port)) >> port)
#define setCalibDone(port) (calibDone |= (1 << port))
#define clearCalibDone(port) (calibDone &= ~(1 << port))
#define getBlocked(port) ((blocked & (1 << port)) >> port)
#define setBlocked(port) (blocked |= (1 << port))
#define clearBlocked(port) (blocked &= ~(1 << port))
#define getPos10(port) ((movingCCW & (1 << (port + 4))) >> (port + 4))
#define setPos10(port) (movingCCW |= (1 << (port + 4)))
#define clearPos10(port) (movingCCW &= ~(1 << (port + 4)))
#define getPos0(port) ((movingCW & (1 << (port + 4))) >> (port + 4))
#define setPos0(port) (movingCW |= (1 << (port + 4)))
#define clearPos0(port) (movingCW &= ~(1 << (port + 4)))
#define prefNameCalibs "periph_info_"
#endif #endif

View File

@@ -43,6 +43,10 @@ void servoInit(Encoder& bottom, Encoder& top) {
topEnc = &top; topEnc = &top;
bottomEnc = &bottom; bottomEnc = &bottom;
// Configure servo power switch pin as output
gpio_set_direction(servoSwitch, GPIO_MODE_OUTPUT);
gpio_set_level(servoSwitch, 0); // Start with servo power off
topEnc->count = servoReadPos(); topEnc->count = servoReadPos();
if (calib.getCalibrated()) initMainLoop(); if (calib.getCalibrated()) initMainLoop();
} }
@@ -58,13 +62,13 @@ void servoOn(uint8_t dir, uint8_t manOrServer) {
void servoOff() { void servoOff() {
ledc_set_duty(LEDC_LOW_SPEED_MODE, servoLEDCChannel, offSpeed); ledc_set_duty(LEDC_LOW_SPEED_MODE, servoLEDCChannel, offSpeed);
ledc_update_duty(LEDC_LOW_SPEED_MODE, servoLEDCChannel); ledc_update_duty(LEDC_LOW_SPEED_MODE, servoLEDCChannel);
servoMainSwitch(0);
runningManual = false; runningManual = false;
runningServer = false; runningServer = false;
servoMainSwitch(0);
} }
void servoMainSwitch(uint8_t onOff) { void servoMainSwitch(uint8_t onOff) {
// To Be Implemented gpio_set_level(servoSwitch, onOff ? 1 : 0);
} }
bool servoInitCalib() { bool servoInitCalib() {