-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprobe.c
64 lines (46 loc) · 1.33 KB
/
probe.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <avr/io.h>
#include <math.h>
#include "nuts_bolts.h"
#include "settings.h"
#include "eeprom.h"
#include "print.h"
#include "planner.h"
#include <avr/pgmspace.h>
#include "protocol.h"
#include "config.h"
#include "stepper.h"
#include "planner.h"
#include "serial.h"
#include "motion_control.h"
uint8_t probe_get_status(){
return (PROBE_PIN & PROBE_MASK)?0:1;
}
void probe_init(){
// set as input
//PROBE_DDR &= ~(PROBE_MASK);
cbi(PROBE_DDR, PROBE_PORT_PIN);
// enable pullup
//PROBE_PORT &= (PROBE_MASK);
sbi(PROBE_PORT, PROBE_PORT_PIN);
}
uint8_t probe_step_callback(block_t* pBlock){
if((PROBE_PIN & PROBE_MASK) != 0){
return STEPPER_INHIBIT_NONE;
}
printPgmString(PSTR("probe tripped \n"));
plan_set_current_position_n(pBlock->position[X_AXIS], pBlock->position[Y_AXIS], pBlock->position[Z_AXIS]);
return STEPPER_INHIBIT_ALL;
}
uint8_t probe_seek(double x, double y, double z, double feed_rate){
// ensure no other block is pending
st_synchronize();
st_set_step_callback(&probe_step_callback);
mc_line(x, y, z, feed_rate, false);
// wait for our block to complete
st_synchronize();
st_set_step_callback(NULL);
// check here to see if the current position is less then target or probe is tripped
// back to where we came from a bit
// move again at quarter feed rate
return(STATUS_OK);
}