Skip to content

PWMOut class for ESP32SPI #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 7, 2019

Conversation

brentru
Copy link
Member

@brentru brentru commented Jun 7, 2019

This pull request adds PWMOut-like support for esp objects via the set_analog_write method in adafruit_esp32spi.py.

Note: The WiFiNINA firmware implements an analogWrite. Setting the frequency property of a PWMOut object with this class is currently not supported.

Implementation Example

# Create the ESP32 Object
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)

# Import PWMOut class
import adafruit_esp32spi.PWMOut

# Create an ESP32SPI PWMOut Object
led = adafruit_esp32spi.PWMOut.PWMOut(esp, 25)

while True:
    for i in range(100):
        # PWM LED up and down
        if i < 50:
            led.duty_cycle = int(i * 2 * 65535 / 100)  # Up
        else:
            led.duty_cycle = 65535 - int((i - 50) * 2 * 65535 / 100)  # Down
        time.sleep(0.01)

Tested on a Feather M4 w/AirLift FeatherWing

@brentru brentru requested a review from a team June 7, 2019 15:10
@brentru brentru merged commit 46b4dea into adafruit:master Jun 7, 2019
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Jun 8, 2019
Updating https://github.com/adafruit/Adafruit_CircuitPython_CircuitPlayground to 2.1.0 from 2.0.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_CircuitPlayground#59 from kattni/add-examples-content

Updating https://github.com/adafruit/Adafruit_CircuitPython_DS3502 to 1.0.1 from 1.0.0:
  > fixing lint (again)
  > fixed default example
  > lint fix
  > added updated examples

Updating https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI to 1.4.1 from 1.4.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_ESP32SPI#52 from brentru/add-pwmout-implementation

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA:
  > Added the following libraries: Adafruit_CircuitPython_DS3502
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.

2 participants