Download the PHP package dept-of-scrapyard-robotics/pwm-rgb-fan without Composer
On this page you can find all versions of the php package dept-of-scrapyard-robotics/pwm-rgb-fan. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dept-of-scrapyard-robotics/pwm-rgb-fan
More information about dept-of-scrapyard-robotics/pwm-rgb-fan
Files in dept-of-scrapyard-robotics/pwm-rgb-fan
Package pwm-rgb-fan
Short Description A PHP package for controlling RGB LEDs and Fan Speed on a PWM-controlled fan.
License MIT
Informations about the package pwm-rgb-fan
PWM RGB Fan
A modern PHP 8.3+ library for controlling PWM-driven fans with integrated RGB LEDs on embedded Linux devices. This package extends pwm-fan-control by adding synchronized RGB LED control, combining fan motor and lighting into one elegant API.
Features
- Combined Control: Synchronize fan speed and RGB colors with single method calls
- Temperature Visualization: Automatic color gradients based on temperature (blue → cyan → green → yellow → red)
- Advanced Effects: Breathing, rainbow, spinning rainbow, and party mode
- Speed Indicator: RGB colors automatically reflect fan speed
- Full Inheritance: All PWMFan methods available (ramping, pulsing, temperature control)
- Flexible RGB: Direct access to underlying RGB channel for custom effects
- Type-Safe: Full PHP 8.3+ type hints and return type declarations
- Chainable Methods: Fluent API for readable, expressive code
Requirements
- PHP 8.3 or higher
- php-pwm extension installed
- phpixel extension installed
- phpdafruit/neopixel-php package
- dept-of-scrapyard-robotics/pwm-fan-control package
- Embedded Linux device with PWM and SPI support (Jetson Orin Nano, Raspberry Pi, etc.)
- PWM device nodes exported (e.g.,
/sys/class/pwm/pwmchip3/pwm0) - SPI device nodes accessible (e.g.,
/dev/spidev1.0)
Installation
Install via Composer
This will automatically install the required dependencies:
dept-of-scrapyard-robotics/pwm-fan-controlphpdafruit/neopixel-php
Install Required Extensions
Before using this library, ensure both extensions are installed:
Core Concepts
RGBPWMFan
An RGBPWMFan extends PWMFan and adds synchronized RGB LED control. It automatically selects the appropriate RGB controller (DoubleDots for 2-LED fans, PixelChannel for others) and provides methods that control both fan and LEDs together.
Basic Usage
API Reference
Construction
Creates a new RGBPWMFan instance.
- Parameters:
$pwm_path- Path to PWM device (e.g.,/sys/class/pwm/pwmchip3/pwm0)$spi_device_path- Path to SPI device (e.g.,/dev/spidev1.0)$pixel_type- LED color order (default:NeoPixelType::RGB)$no_lights- Number of RGB LEDs (default: 2)$frequency- PWM frequency in Hz (default: 1000)
Example:
Combined Control Methods
setSpeedWithColor()
Set fan speed and RGB color simultaneously.
speedIndicator()
Automatically set RGB color based on current fan speed. Blue (0%) → Red (100%).
temperatureVisual()
Adjust both fan speed AND RGB color based on temperature. Creates gradient: Blue (cool) → Cyan → Green → Yellow → Red (hot).
RGB Effects
breathe()
Synchronized breathing effect - fan speed and RGB brightness fade together.
rainbow()
Rainbow color cycle at specified fan speed.
spinningRainbow()
Spinning rainbow effect (best for 2-LED fans). Creates illusion of rotating colors.
party()
Random colors and fan speeds for party effect.
shutdown()
Gracefully fade out both fan and RGB simultaneously.
Direct RGB Access
getRGBChannel()
Get the underlying RGB channel for direct manipulation using neopixel-php methods.
Inherited Methods
All methods from PWMFan are available:
Basic Control:
on()- Turn on at last speedoff()- Turn off fansetSpeed(float $percent)- Set speed 0-100%getSpeed()- Get current speedisRunning()- Check if runninggetStatus()- Detailed status
Effects:
rampUp(float $target, int $duration_ms, int $steps)- Smooth ramp uprampDown(float $target, int $duration_ms, int $steps)- Smooth ramp downpulse(float $low, float $high, int $cycles, int $duration_ms)- Pulsing effect
Temperature:
autoControl(float $temp, float $min, float $max, float $minSpeed)- Auto fan controlgetCPUTemp(int $zone)- Read CPU temperature
Presets:
setPreset(string $preset)- Use preset: 'off', 'low', 'medium', 'high', 'full'
Usage Examples
Example 1: Basic Combined Control
Example 2: Temperature-Based Control
Example 3: RGB Effects
Example 4: Direct RGB Control
Testing
The library includes a comprehensive Pest v4 test suite.
Running Tests
Included Examples
The package includes three comprehensive examples:
Troubleshooting
Extensions Not Found
Solution: Install both php-pwm and phpixel extensions.
PWM or SPI Device Not Found
Solution:
- Export PWM:
echo 0 | sudo tee /sys/class/pwm/pwmchip3/export - Check SPI:
ls /dev/spidev* - Verify permissions (add user to
gpioandspigroups)
Wrong RGB Colors
Solution: Try different NeoPixelType values:
License
MIT License. See LICENSE file for details.
Credits
This library combines:
- dept-of-scrapyard-robotics/pwm-fan-control - Base fan control
- phpdafruit/neopixel-php - RGB LED control
Contributing
Contributions are welcome! When contributing:
- Follow PSR-12 coding standards
- Add tests for new features
- Update documentation as needed
- Ensure all tests pass before submitting pull requests
Support
For issues related to:
- This library: Open an issue in this repository
- pwm-fan-control: See the pwm-fan-control repository
- neopixel-php: See the neopixel-php repository
- Hardware setup: Consult your device's documentation
All versions of pwm-rgb-fan with dependencies
ext-pwm Version *
ext-phpixel Version *
ext-sockets Version *
phpdafruit/neopixel-php Version ^0.2.0
dept-of-scrapyard-robotics/pwm-fan-control Version ^0.2.0