Servita-Community / ServitaFirmware

The main firmware for the Servita and ServitaDuo base devices.
3 stars 1 forks source link

Implement True Limit Switch Interrupting #6

Closed TeaBear5 closed 5 months ago

TeaBear5 commented 5 months ago

Move the limit switch on the elevator/gantry system to become a true interrupt instead of serviced depending on state in the loop():

void loop() {
  sCmd.readSerial();               // We don't do much, just process serial commands
  dnsServer.processNextRequest();  // wifi related

  // Response to limit switch hardware interrupt
  if (endStopHighTrigger && gantry.state == MOTOR_UP) {
    set_motor_state(&gantry, MOTOR_OFF);
    endStopHighTrigger = false;
    Serial.println("endStopHigh");
  }
  if (endStopLowTrigger && gantry.state == MOTOR_DOWN) {
    set_motor_state(&gantry, MOTOR_OFF);
    endStopLowTrigger = false;
    Serial.println("endStopLow");
  }

  if (dispenseInProgress) dispenseDrink();  // Dispense routine gets called repeatedly when dispenseInProgress flag is high

  readButtons();  // Read inputs on every loop

  // Clean up socket connections
  ws.cleanupClients();
}
TeaBear5 commented 5 months ago

appears to already be implemented and was missed. May have some logic error somewhere with recovering from these, but will be handled by the refactor.