Skip to content

Commit dc51f6a

Browse files
committed
freeze thumb
1 parent f5d1558 commit dc51f6a

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

Bluetooth-Arduino-Prosthetic-Control.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ HandServos handServos(15);
1818
SavePattern savePattern;
1919
String savedPattern;
2020
String rxValueString;
21+
bool freezeThumb = false;
2122

2223
bool deviceConnected = false;
2324
BLECharacteristic *pCharacteristic;
@@ -49,7 +50,7 @@ class ReceivedDataCallback: public BLECharacteristicCallbacks {
4950
void onWrite(BLECharacteristic *pCharacteristic) {
5051
std::string rxValue = pCharacteristic->getValue();
5152
rxValueString = pCharacteristic->getValue().c_str();
52-
handServos.moveServos(rxValueString);
53+
handServos.moveServos(rxValueString, freezeThumb);
5354

5455
int str_len = rxValueString.length() + 1;
5556
char * char_array[str_len];
@@ -101,8 +102,7 @@ void handler(Button2& btn) {
101102
Serial.println(btn.isPressed());
102103
switch (btn.getClickType()) {
103104
case SINGLE_CLICK:
104-
Serial.println("single ");
105-
//handServos.movee();
105+
freezeThumb = !freezeThumb;
106106
break;
107107
case DOUBLE_CLICK:
108108
Serial.println("double load");

HandServos.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ void HandServos::calibrate() {
130130
lastPosR = servoR.read();
131131
}
132132

133-
void HandServos::moveServos(String input) {
133+
void HandServos::moveServos(String input, boolean freezeThumb) {
134134
//parse String
135135
//https://gist.github.com/mattfelsen/9467420
136136

@@ -164,11 +164,14 @@ void HandServos::moveServos(String input) {
164164
Serial.println(pieces[2]);
165165
Serial.println(pieces[3]);
166166

167-
servoT.write(pieces[0].toInt());
167+
if (!freezeThumb) {
168+
servoT.write(pieces[0].toInt());
169+
}
170+
168171
servoI.write(pieces[1].toInt());
169172
servoM.write(pieces[2].toInt());
170173
servoR.write(pieces[3].toInt());
171-
174+
172175
lastPosT = servoT.read();
173176
lastPosI = servoI.read();
174177
lastPosM = servoM.read();

HandServos.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class HandServos
1919
void openFingers();
2020
void openThumb();
2121
void closeFingers();
22-
void moveServos(String input);
22+
void moveServos(String input, boolean freezeThumb);
2323
void moveServos2(String input);
2424
int var;
2525
int interval;

0 commit comments

Comments
 (0)