File tree Expand file tree Collapse file tree 3 files changed +10
-7
lines changed
Expand file tree Collapse file tree 3 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ HandServos handServos(15);
1818SavePattern savePattern;
1919String savedPattern;
2020String rxValueString;
21+ bool freezeThumb = false ;
2122
2223bool deviceConnected = false ;
2324BLECharacteristic *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" );
Original file line number Diff line number Diff 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 ();
Original file line number Diff line number Diff 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;
You can’t perform that action at this time.
0 commit comments