Skip to content
Snippets Groups Projects
Commit f9cf7843 authored by Jake Read's avatar Jake Read
Browse files

add limit-halt-output

parent a76660c3
No related branches found
No related tags found
No related merge requests found
......@@ -18,8 +18,11 @@
//OSAP osap("axl-stepper_z-front-right");
//OSAP osap("axl-stepper_y-left");
//OSAP osap("axl-stepper_y-right");
OSAP osap("axl-stepper_x");
//OSAP osap("axl-stepper_x");
//OSAP osap("axl-stepper_e");
OSAP osap("axl-stepper_z");
//OSAP osap("axl-stepper_rl");
//OSAP osap("axl-stepper_rr");
VPort_ArduinoSerial vpUSBSerial(&osap, "arduinoUSBSerial", &Serial);
......@@ -232,6 +235,10 @@ EP_ONDATA_RESPONSES onPrecalculatedMoveData(uint8_t* data, uint16_t len){
Endpoint precalculatedMoveEP(&osap, "precalculatedMoves", onPrecalculatedMoveData);
// -------------------------------------------------------- 9: Limit Halt-Output:
Endpoint limitHaltEP(&osap, "limitOutput");
// -------------------------------------------------------- Arduino Setup
void setup() {
......@@ -257,6 +264,12 @@ uint32_t lastBlink = 0;
uint32_t blinkInterval = 50; // ms
uint8_t dummy[128];
uint32_t lastLimitCheck = 0;
uint32_t limitCheckInterval = 1; // ms, helps debounce
uint8_t limitStates = 0;
uint32_t errLightOnTime = 0;
boolean errLightOn = false;
void loop() {
osap.loop();
stepper_hw->dacRefresh();
......@@ -267,9 +280,25 @@ void loop() {
updateStatesEP();
//axl_printHomeState();
}
// if(haltLightOnTime + 250 < millis()){
// ERRLIGHT_OFF;
// }
// this, i.e, could be on the endpoint's loop code, non?
if(lastLimitCheck + limitCheckInterval < millis()){
lastLimitCheck = millis();
// shift left one & tack bit on the end,
limitStates = limitStates << 1;
limitStates |= axl_checkLimit() ? 1 : 0;
// this is the positive-edge mask,
if(limitStates == 0b00001111){
ERRLIGHT_ON;
errLightOnTime = millis();
errLightOn = true;
dummy[0] = 1;
limitHaltEP.write(dummy, 1);
}
}
if(errLightOn && errLightOnTime + 250 < millis()){
ERRLIGHT_OFF;
errLightOn = false;
}
}
// -------------------------------------------------------- Small-Time Ops
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment