-
Notifications
You must be signed in to change notification settings - Fork 0
/
calibration.cpp
65 lines (57 loc) · 1.97 KB
/
calibration.cpp
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
65
/*
Calibration Sequence
Designed by: Bibaswan Bhawal
Version: 1.0
Script to calibrate hand
*/
#include "includes/calibration.h"
/******************************************************************
* Function: calibration
*
* Description: Calibrates each finger one by one
*
* Return: returns calibration completion code
* 1 - success
* 0 - failure
*****************************************************************/
int calibration(){
calibrationFinger(thumb);
calibrationFinger(index);
calibrationFinger(middle);
calibrationFinger(ring);
calibrationFinger(pinky);
return 1;
}
/******************************************************************
* Function: calibrationThumb
*
* Description: calibrates the thumb by continuously
* retracting the thumb until endstop interupt
* is triggered. Then the thumb is expanded
* completely
*
*****************************************************************/
void calibrationFinger(Finger finger){
maxMovement = false; // reset endstop trigger
interrupts();
// Keep retracting finger until endstop interupt triggered
while(maxMovement == false){
movefinger(finger, calibrationMovementSpeed, antiClockwise);
}
// Extend finger to max extension
for(int i = 0; i < finger.maxSteps; i++){
movefinger(finger, movementSpeed, clockwise);
}
}
/******************************************************************
* Function: endstop_ISR
*
* Description: Function gets called when interrupt triggered
* and sets maxMovement to true to indicate
* finger is at max retraction.
*
*****************************************************************/
void endstop_ISR(){
maxMovement = true;
noInterrupts();
}