Browse Source

Updated side panel length

Toby Chui 9 months ago
parent
commit
8b209f820f

+ 1 - 1
firmware/cute_useless_robot/cute_useless_robot.ino

@@ -51,7 +51,7 @@ AsyncWebServer server(80);
 DNSServer dnsServer;
 
 /* Calibrated offset for switch pusher servo, in degrees */
-#define SERVO_ALIGNMENT_OFFSET 1
+#define SERVO_ALIGNMENT_OFFSET 4
 
 /* Hardware Type Definations */
 Servo servoSwitchPusher;

+ 4 - 3
firmware/cute_useless_robot/logics.ino

@@ -130,15 +130,16 @@ void executePushAnimationSequence(int seqID) {
       setAnimationCode('a');
       delay(3000);
       pushSwitchDelayed(1000, 1000);
-      delay(3000);
+      delay(500);
     } else if (expression == 1) {
       setAnimationCode('b');
       delay(500);
       pushSwitchNow();
+      delay(500);
     } else if (expression == 2) {
       setAnimationCode('g');
       pushWithHesitation();
-      delay(5000);
+      delay(500);
     } else {
       setAnimationCode('e');
       pushSwitchNow();
@@ -146,7 +147,7 @@ void executePushAnimationSequence(int seqID) {
     }
   }
   clearFrame();
-  delay(1000);
+  delay(500);
 }
 
 //Debug sequence to test all movement functions

+ 50 - 2
firmware/cute_useless_robot/servo.ino

@@ -17,24 +17,72 @@ void pushSwitchDelayed(int coverDelay, int pusherDelay) {
   delay(coverDelay);
   servoSwitchPusher.write(130 + SERVO_ALIGNMENT_OFFSET);
   delay(pusherDelay);
+  handlePushBackException(); //Check if switch is properly pushed back
   servoCoverPusher.write(0);
   servoSwitchPusher.write(0);
 }
 
 //Push with a pause before the switch is pushed
-void pushWithHesitation(){
+void pushWithHesitation() {
   servoCoverPusher.write(90);
   delay(1000);
   servoSwitchPusher.write(90 + SERVO_ALIGNMENT_OFFSET);
   delay(2000);
   servoSwitchPusher.write(130 + SERVO_ALIGNMENT_OFFSET);
   delay(1000);
+  handlePushBackException(); //Check if switch is properly pushed back
   servoCoverPusher.write(0);
   servoSwitchPusher.write(0);
 }
 
+//Handle case where user hold the switch
+void handlePushBackException() {
+  bool switchPushed = getSwitchState();
+  int triedResetCount = 0;
+  if (switchPushed) {
+    //Switch position still not reset. Wait and try again
+    while (triedResetCount < 5) {
+      switchPushed = getSwitchState();
+      if (!switchPushed) {
+        //Switch reset
+        return;
+      }
+      if (triedResetCount < 1) {
+        //Light push retry
+        servoSwitchPusher.write(90 + SERVO_ALIGNMENT_OFFSET);
+        delay(300);
+        servoSwitchPusher.write(130 + SERVO_ALIGNMENT_OFFSET);
+        delay(1000);
+      }else if (triedResetCount < 3) {
+        //Light push retry
+        servoSwitchPusher.write(90 + SERVO_ALIGNMENT_OFFSET);
+        delay(500);
+        servoSwitchPusher.write(130 + SERVO_ALIGNMENT_OFFSET);
+        delay(2000);
+      } else {
+        //Hard push retry
+        servoSwitchPusher.write(0);
+        delay(500);
+        servoSwitchPusher.write(130 + SERVO_ALIGNMENT_OFFSET);
+        delay(2000);
+      }
+      triedResetCount++;
+    }
+
+    //Max retry reached
+    switchPushed = getSwitchState();
+    if (switchPushed){
+      char originalAnicode = animation;
+      setAnimationCode('v');
+      delay(5000);
+      setAnimationCode(originalAnicode); //Restore the animation charcode
+    }
+   
+    return;
+  }
+}
 
 //Set the pusher servo to arm installation position
-void setSwitchToInstallPosition(){
+void setSwitchToInstallPosition() {
   servoSwitchPusher.write(125 + SERVO_ALIGNMENT_OFFSET);
 }

BIN
lasercut/OldVersions/all-parts_A4-fill.0006.dwg


BIN
lasercut/OldVersions/all-parts_v1.0004.dwg


+ 0 - 0
lasercut/OldVersions/all-parts_A4-fill.0005.dwg → lasercut/OldVersions/all-parts_v1.0005.dwg


BIN
lasercut/OldVersions/side-panels.0011.ipt


BIN
lasercut/OldVersions/side-panels.0012.ipt


BIN
lasercut/all-parts_A4-fill.dwg


BIN
lasercut/all-parts_v1.dwg


BIN
lasercut/lockfile.lck


BIN
lasercut/side-panels.ipt


BIN
model/mockups/OldVersions/test-fit.0067.iam


BIN
model/mockups/OldVersions/test-fit.0068.iam


BIN
model/mockups/test-fit.iam


BIN
sd_card/anime/v.bin