Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add LED Fade Example#105

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
wnienhaus merged 3 commits intomicropython:masterfrommjaspers2mtu:master
Jul 8, 2025
Merged

Conversation

@mjaspers2mtu
Copy link
Contributor

An example that uses ULP self-modifying code to create a PWM-like LED dimming effect on GPIO 15.

An example that uses ULP self-modifying code to create a PWM-like LED dimming effect on GPIO 15.
@wnienhaus
Copy link
Collaborator

Very cool contribution! I like the self-modification to work around WAIT's fixed operand limitation.

Did you run this on an S2 or S3 (given that we're using theesp32s2 cpu option for both)? I want to test it too. Then we can merge this example.

@mjaspers2mtu
Copy link
ContributorAuthor

Thanks, I have only tested this on an S2 (seehere for the board I used) , as this is all I have access to right now.

Example code for reading the temperature of the chip using the ULP of the ESP32-S2
@wnienhaus
Copy link
Collaborator

Just tested this on my S2 and it worked a charm.

Except for one small niggly... related to my board: the LED was already on with a faint glow, before I started the program. The reason turns out, that on my board (Waveshare ESP32-S2 Pico), GPIO15 is used for I2C and pin 15 is pulled high with an external resistor. So current leaks via that resistor and my LED.

Looking at the schematic of your board, GPIO15 is not connected to anything else, so in your case GPIO15 will work fine.

Was there a reason you picked GPIO15? I have generally used GPIO4 for my projects, which does not usually seem to be used for anything else. I googled for a few dev boards, and none used GPIO4 for anything. And theESP32-S2 Technical Reference Manual also shows that GPIO4 has no other functions mapped to it. I have also often used GPIO2, but on one of my boards it was connected to the onboard LED (but in active-low mode).

Perhaps it's useful to change the example to use GPIO4? That way is should not (as far as I can see) interfere with other things. Also the code might read more easily, because the current constants refer to XTAL32 (because of what Espressif named it) and it might not be obvious to readers that this refers to GPIO15. GPIO4 instead is named TOUCH_PAD4, which is still somewhat confusing, but a bit more obvious in that it refers to GPIO4.

I don't mind that much keeping the example at GPIO15, but if you had no specific reason (or wish) to have it on GPIO15, then I'd suggest changing it.

i.e.
replaceRTC_IO_XTAL_32P_PAD_REG withRTC_IO_TOUCH_PAD4_REG
replaceRTC_IO_X32P_MUX_SEL_M withRTC_IO_TOUCH_PAD4_MUX_SEL_M
replaceRTCIO_GPIO15_CHANNEL withRTCIO_GPIO4_CHANNEL
...of course with their correct values as perhttps://github.com/espressif/esp-idf/blob/v5.0.2/components/soc/esp32s2/include/soc/rtc_io_reg.h#L922

@wnienhaus
Copy link
Collaborator

Btw, the temperature sensing example also works as advertised. Very nice. We can merge it as is.

mjaspers2mtu reacted with thumbs up emoji

made the default LED pin 4, with the option for the user to change led_pin.
@mjaspers2mtu
Copy link
ContributorAuthor

@wnienhaus
I have updated the led fade example to have an easy way to change the pin where the LED is attachedhere. XTAL32 is indeed not a very clear name for pin 15, and can confuse the user. The reason I chose this anyway was because this is where the build-in LED is on my s2 board, see bottom right corner:
https://www.wemos.cc/en/latest/_static/boards/s2_mini_v1.0.0_1_16x16.jpg

The example now makes no reference to any particular dev board, and is set to pin 4 by default. The user only has to change led_pin (is this obvious, or should this be made more clear?).

@wnienhaus
Copy link
Collaborator

Very nice! I like the generic constants, so the code doesn't need to change, when one changes the led_pin. Thank you for those examples.

@wnienhauswnienhaus merged commitd11afd1 intomicropython:masterJul 8, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@mjaspers2mtu@wnienhaus

[8]ページ先頭

©2009-2025 Movatter.jp