Skip to content

Dev#141

Merged
pjbRPF merged 65 commits into
mainfrom
dev
Nov 28, 2025
Merged

Dev#141
pjbRPF merged 65 commits into
mainfrom
dev

Conversation

@pjbRPF
Copy link
Copy Markdown
Contributor

@pjbRPF pjbRPF commented Nov 28, 2025

No description provided.

pjbRPF and others added 30 commits October 17, 2025 16:14
Core Implementation:
• Complete Stepper class supporting 4-pin stepper motors (28BYJ-48 + ULN2003)
• Three step sequences: wave, full, half-step for different torque/smoothness needs
• Position tracking with step counting and angle calculation
• Configurable steps-per-revolution and step delays for different motors

API Design Philosophy - Four Complementary Approaches:

1. DEFAULT DIRECTION (Simplest)
   • step(10) - Uses default clockwise direction
   • Minimizes cognitive load for basic use cases

2. CONVENIENCE METHODS (Explicit Intent)
   • step_clockwise(10), step_counterclockwise(10)
   • rotate_clockwise(90), rotate_counterclockwise(90)
   • revolve_clockwise(2), revolve_counterclockwise(2)
   • Short aliases: step_cw(), rotate_ccw(), revolve_cw()
   • Clear, readable, self-documenting code

3. PARAMETERIZED METHODS (Flexible Control)
   • step(10, direction='cw'|'ccw'|1|-1)
   • rotate(90, direction='clockwise'|'counter-clockwise')
   • revolution(2, direction=1|-1)
   • Supports both string and numeric direction parameters
   • Flexible _normalize_direction() handles multiple formats

4. ALIAS SUPPORT (Compatibility)
   • revolve() as alias for revolution()
   • StepperMotor as backward-compatible class alias
   • Maintains consistency with existing picozero patterns

Technical Features:
• Polymorphic direction parameters (string/numeric) with validation
• Real-time speed control via step_delay property
• Position reset capability for homing/calibration
• Proper resource management with off() and close() methods
• Comprehensive error handling with descriptive messages

Testing Strategy:
• Validates all API approaches for consistency
• Covers edge cases and error conditions

Documentation:
• Added Stepper class to API documentation
• Exported in __init__.py for public access
• Comprehensive docstrings with parameter details
• Usage examples showing all API patterns
- Add MotionSensor section to recipes.rst (missing from previous merge)
- Add Stepper section to recipes.rst with comprehensive examples
- Update changelog.rst with v0.5.0 entries for both classes
- Organize motor sections together for better flow
Core Implementation:
• Complete Stepper class supporting 4-pin stepper motors (28BYJ-48 + ULN2003)
• Three step sequences: wave, full, half-step for different torque/smoothness needs
• Position tracking with step counting and angle calculation
• Configurable steps-per-revolution and step delays for different motors

API Design Philosophy - Four Complementary Approaches:

1. DEFAULT DIRECTION (Simplest)
   • step(10) - Uses default clockwise direction
   • Minimizes cognitive load for basic use cases

2. CONVENIENCE METHODS (Explicit Intent)
   • step_clockwise(10), step_counterclockwise(10)
   • rotate_clockwise(90), rotate_counterclockwise(90)
   • revolve_clockwise(2), revolve_counterclockwise(2)
   • Short aliases: step_cw(), rotate_ccw(), revolve_cw()
   • Clear, readable, self-documenting code

3. PARAMETERIZED METHODS (Flexible Control)
   • step(10, direction='cw'|'ccw'|1|-1)
   • rotate(90, direction='clockwise'|'counter-clockwise')
   • revolution(2, direction=1|-1)
   • Supports both string and numeric direction parameters
   • Flexible _normalize_direction() handles multiple formats

4. ALIAS SUPPORT (Compatibility)
   • revolve() as alias for revolution()
   • StepperMotor as backward-compatible class alias
   • Maintains consistency with existing picozero patterns

Technical Features:
• Polymorphic direction parameters (string/numeric) with validation
• Real-time speed control via step_delay property
• Position reset capability for homing/calibration
• Proper resource management with off() and close() methods
• Comprehensive error handling with descriptive messages

Testing Strategy:
• Validates all API approaches for consistency
• Covers edge cases and error conditions

Documentation:
• Added Stepper class to API documentation
• Exported in __init__.py for public access
• Comprehensive docstrings with parameter details
• Usage examples showing all API patterns
- Add MotionSensor section to recipes.rst (missing from previous merge)
- Add Stepper section to recipes.rst with comprehensive examples
- Update changelog.rst with v0.5.0 entries for both classes
- Organize motor sections together for better flow
After rebase onto dev branch that includes MotionSensor docs from PR #131,
remove the duplicate MotionSensor section that was incorrectly positioned
after temperature sensor. MotionSensor documentation now correctly appears
only once after Buttons section, maintaining proper input device grouping.
…--manual-install

118 documentation   manual install
Use debounced last_state instead of re-reading pin after bounce_time wait.
The bounce_time loop stabilizes the value in last_state, but the code was
re-reading the pin which could return a transient/unstable value, causing
valid state changes to be missed.

This fixes sound sensors and other fast-pulsing inputs with bounce_time enabled.

Fixes issue: Sound Sensor with bounce_time=1 not detecting signals
Co-authored-by: pjbRPF <104009652+pjbRPF@users.noreply.github.com>
Co-authored-by: pjbRPF <104009652+pjbRPF@users.noreply.github.com>
Co-authored-by: pjbRPF <104009652+pjbRPF@users.noreply.github.com>
Co-authored-by: pjbRPF <104009652+pjbRPF@users.noreply.github.com>
…st_picozero.py

- Changed pin assignments across multiple PWM tests to avoid channel conflicts
  (test_pwm_output_device_default_values: 1→14, test_pwm_output_device_alt_values: 1→5,
   test_pwm_output_device_blink: 1→6, test_pwm_output_device_pulse: 1→7,
   test_motor_default_values: 1,2→8,9, test_robot: 1,2,3,4→10,11,12,13,
   test_LED_factory: 1→20,21)
- Updated test_pwm_output_device_alt_values to accept both duty values (9999 or 10000)
  for compatibility with MicroPython versions before and after v1.20
- Ensures PWM hardware channels are not reused between sequential tests
pjbRPF and others added 27 commits November 27, 2025 13:39
…and_distance_sensor_tests

Add comprehensive tests for Speaker and DistanceSensor classes
…-time-sound-sensor

Fix bounce_time debouncing for brief signals in DigitalInputDevice
@pjbRPF pjbRPF requested a review from MarcScott as a code owner November 28, 2025 15:41
@pjbRPF pjbRPF merged commit a8a7206 into main Nov 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants