Tuan Nguyen před 1 rokem
rodič
revize
8f0c2db450
4 změnil soubory, kde provedl 39 přidání a 89 odebrání
  1. 23 1
      CHANGELOG.md
  2. 14 13
      app.py
  3. 1 30
      arduino_code/arduino_code.ino
  4. 1 45
      arduino_code_TMC2209/arduino_code_TMC2209.ino

+ 23 - 1
CHANGELOG.md

@@ -5,8 +5,30 @@ All notable changes to this project will be documented in this file.
 ## [1.2.0] - Spirograph functionality
 
 ### Added
+
+#### Playlist mode
+
+- Added UI selection mode for single pattern run, create a playlist, and run a playlist. The UI is work in progress and will be changed in the near future.
+- Created playlist will be saved as a JSON file on disk. There are options to:
+  - Run the playlist once or on an indefinite loop
+  - Shuffle the playlist
+  - Add a clear pattern between files that will run immmidiately before each pattern. If you would like to customize the clear pattern, select None here and add clear patterns manually.
+  - Add a pause time (in second) between each pattern.
+
+#### Spirograph mode
+
 - Added support for Spirograph mode for the arduino with DRV8825 or TMC2209 motor drivers
-  - can be used if optional hardware (two potentiometers and a button) is connected.
+- Can be used if optional hardware (two potentiometers and a button) is connected.
+
+### Changed
+
+- Fixed a bug that created conflicting threads, leading to serial errors
+- Fixed a bug that caused the speed setting functionality to not work
+- Fixed a bug that caused the ball to move in slightly when a pattern starts at the perimeter and theta != 0
+
+### Known issues
+
+- Patterns with theta does not start with 0 will behave abnormally. To get around this, be sure to select start from center or perimeter when creating your pattern in sandify.org.
 
 ## [1.1.0] - Auto connect functionality
 

+ 14 - 13
app.py

@@ -213,19 +213,6 @@ def run_theta_rho_files(
                 print("Execution stopped before starting next pattern.")
                 return
 
-            # Run the main pattern
-            print(f"Running pattern {idx + 1} of {len(file_paths)}: {path}")
-            run_theta_rho_file(path)
-            
-            if idx < len(file_paths) -1:
-                if stop_requested:
-                    print("Execution stopped before running the next clear pattern.")
-                    return
-                # Pause after each pattern if requested
-                if pause_time > 0:
-                    print(f"Pausing for {pause_time} seconds...")
-                    time.sleep(pause_time)
-
             if clear_pattern:
                 if stop_requested:
                     print("Execution stopped before running the next clear pattern.")
@@ -235,6 +222,20 @@ def run_theta_rho_files(
                 clear_file_path = get_clear_pattern_file(clear_pattern)
                 print(f"Running clear pattern: {clear_file_path}")
                 run_theta_rho_file(clear_file_path)
+            
+            if not stop_requested:
+                # Run the main pattern
+                print(f"Running pattern {idx + 1} of {len(file_paths)}: {path}")
+                run_theta_rho_file(path)
+            
+            if idx < len(file_paths) -1:
+                if stop_requested:
+                    print("Execution stopped before running the next clear pattern.")
+                    return
+                # Pause after each pattern if requested
+                if pause_time > 0:
+                    print(f"Pausing for {pause_time} seconds...")
+                    time.sleep(pause_time)
 
         # After completing the playlist
         if run_mode == "indefinite":

+ 1 - 30
arduino_code/arduino_code.ino

@@ -202,6 +202,7 @@ void appMode()
                 {
                     // Convert percentage to actual speed
                     long newSpeed = (speedPercentage / 100.0) * maxSpeed;
+                    userDefinedSpeed = newSpeed;
 
                     // Set the stepper speeds
                     rotStepper.setMaxSpeed(newSpeed);
@@ -222,36 +223,6 @@ void appMode()
             return;
         }
 
-
-        if (input.startsWith("SET_SPEED"))
-        {
-            // Parse and set the speed
-            int spaceIndex = input.indexOf(' ');
-            if (spaceIndex != -1)
-            {
-                String speedStr = input.substring(spaceIndex + 1);
-                float speed = speedStr.toFloat();
-
-                if (speed > 0) // Ensure valid speed
-                {
-                    userDefinedSpeed = speed;
-                    rotStepper.setMaxSpeed(speed);
-                    inOutStepper.setMaxSpeed(speed);
-                    Serial.println("SPEED_SET");
-                    Serial.println("R");
-                }
-                else
-                {
-                    Serial.println("INVALID_SPEED");
-                }
-            }
-            else
-            {
-                Serial.println("INVALID_COMMAND");
-            }
-            return;
-        }
-
         if (input == "HOME")
         {
             homing();

+ 1 - 45
arduino_code_TMC2209/arduino_code_TMC2209.ino

@@ -189,50 +189,6 @@ void appMode()
         }
 
 
-        if (input.startsWith("SET_SPEED"))
-        {
-            // Parse and set the speed
-            int spaceIndex = input.indexOf(' ');
-            if (spaceIndex != -1)
-            {
-                String speedStr = input.substring(spaceIndex + 1);
-                float speed = speedStr.toFloat();
-
-                if (speed > 0) // Ensure valid speed
-                {
-                    userDefinedSpeed = speed;
-                    rotStepper.setMaxSpeed(speed);
-                    inOutStepper.setMaxSpeed(speed);
-                    Serial.println("SPEED_SET");
-                    Serial.println("R");
-                }
-                else
-                {
-                    Serial.println("INVALID_SPEED");
-                }
-            }
-            else
-            {
-                Serial.println("INVALID_COMMAND");
-            }
-            return;
-        }
-
-        if (input == "HOME")
-        {
-            homing();
-            return;
-        }
-
-        if (input == "RESET_THETA")
-        {
-            resetTheta(); // Reset currentTheta
-            Serial.println("THETA_RESET"); // Notify Python
-            Serial.println("R");
-            return;
-        }
-
-        // Example: The user calls "SET_SPEED 60" => 60% of maxSpeed
         if (input.startsWith("SET_SPEED"))
         {
             // Parse out the speed value from the command string
@@ -247,6 +203,7 @@ void appMode()
                 {
                     // Convert percentage to actual speed
                     long newSpeed = (speedPercentage / 100.0) * maxSpeed;
+                    userDefinedSpeed = newSpeed;
 
                     // Set the stepper speeds
                     rotStepper.setMaxSpeed(newSpeed);
@@ -267,7 +224,6 @@ void appMode()
             return;
         }
 
-
         // If not a command, assume it's a batch of theta-rho pairs
         if (!batchComplete)
         {