Wled: Touch buttons integration on ESP32

Created on 3 Mar 2020  路  12Comments  路  Source: Aircoookie/WLED

Sorry for the naive approach but I do not have much time to dig into this for now :)

Can someone please point me to the direction where I could integrate functionality (on ESP32) of a touchRead() on three buttons where first toggles on/off segment 0, second toggles segment 1 and last toggles both of them. Is there better place a than wled09_button.ino?

enhancement fixed in source

Most helpful comment

Sure, especially given that the ESP32 supports touch without additional hardware!

All 12 comments

Hi, no worries :)
The best place for custom code is the wled06_usermod.ino. It allows you to more easily integrate your code and even share it with others if you like.

Since you want to toggle segments, keep in mind there is no official mechanism for that in place yet.
This should work though:

uint16_t lastStop[2];

void toggleSegment(byte segm, bool on)
{
  WS2812FX::Segment& seg = strip.getSegment(segm);
  if (on) {
    strip.setSegment(segm, seg.start, lastStop[segm], seg.grouping, seg.spacing);
  } else {
    lastStop[segm] = seg.stop;
    strip.setSegment(segm, seg.start, 0, seg.grouping, seg.spacing);
  }
}

Nice, thanks for such a detailed explanation!
Will try it as soon as I get all the ordered parts :)

Hey! This issue has been open for quite some time without any new comments now. It will be closed automatically in a week if no further activity occurs.
Thank you for using WLED!

Could this be added as a feature of WLED @Aircoookie ?

Sure, especially given that the ESP32 supports touch without additional hardware!

Hope you can integrate the touch function (esp32).

For first integration touch on or off.

Next maybe with long hold dimm function.

That would be realy nice. I've build a "cloud-looking-hexagon"-thing with lots of screws.
And i realy would like to use the screws as touch-buttons:
photo_2020-09-09_18-58-51 (1)

On/Off, Next Favourite, Dimm, Speed, Start Night-Timer ... and so on. There are 10 buttons to use :)

My Project (german):
https://www.maker-forum.net/forum/index.php?thread/161-mein-erstes-wled-projekt/&postID=704#post704

Thanks to @Jakeler 's PR #1190 this is now included! (you need to compile with the TOUCHPIN T0 flag)

@donabi that looks amazing!

Thanks to @Jakeler 's PR #1190 this is now included! (you need to compile with the TOUCHPIN T0 flag)

@donabi that looks amazing!

Can you please help explaining how can I now use touch sensors as button alternative on ESP32? What exactly needs to be done?

I use WLED_0.11.0_ESP32.bin with esp32-wroom module

@Monacoslo
You have to compile it from source, follow these instructions: https://github.com/Aircoookie/WLED/wiki/Compiling-WLED
Set default_envs = custom32_TOUCHPIN_T0.

You can also scroll down and edit the [env:custom32_TOUCHPIN_T0] or any other definition, notice that build_flags includes the TOUCHPIN flag. Default is T0 (= GPIO4), but T1, T2... up to T9 is possible.

Thanks for answer! But unfortunally I can not compile in VSC (latest).
After hitting checkmark, I get
`

Executing task: k:ArduinoWLEDWLED-0.11.0pio.exe run <
The terminal process failed to launch: Path to shell executable "k:ArduinoWLEDWLED-0.11.0pio.exe" does not exist.
Terminal will be reused by tasks, press any key to close it.
`

edit: after a few reboots it worked, but then I got stuck on:

Compiling .pio\build\custom32_TOUCHPIN_T0\src\wled.cpp.o Compiling .pio\build\custom32_TOUCHPIN_T0\src\wled00.ino.cpp.o xtensa-esp32-elf-g++: error: wled00\wled00.ino.cpp: No such file or directory xtensa-esp32-elf-g++: fatal error: no input files compilation terminated. *** [.pio\build\custom32_TOUCHPIN_T0\src\wled00.ino.cpp.o] Error 1

Since I have also seen already a few questions on facebook regarding this option, maybe it would be great if you also add the compiled option to downloads list :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PKCubed picture PKCubed  路  4Comments

cemasss picture cemasss  路  3Comments

Dann-io picture Dann-io  路  3Comments

Aircoookie picture Aircoookie  路  4Comments

rfordhamjr picture rfordhamjr  路  4Comments