Skip to content

Commit b295f9c

Browse files
committed
feat(rmt): legacy driver example
1 parent 4ddeb3b commit b295f9c

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#ifndef NO_NEW_RMT_DRV
2+
// add the file "build_opt.h" to your Arduino project folder with "-DNO_NEW_RMT_DRV" to use the RMT Legacy driver
3+
#warning "NO_NEW_RMT_DRV is not defined, using new RMT driver"
4+
5+
#define RMT_PIN 4 // Valid GPIO for ESP32, S2, S3, C3, C6 and H2
6+
bool installed = false;
7+
8+
void setup() {
9+
Serial.begin(115200);
10+
Serial.println("This sketch uses the new RMT driver.");
11+
installed = rmtInit(RMT_PIN, RMT_TX_MODE, RMT_MEM_NUM_BLOCKS_1, 10000000);
12+
}
13+
14+
void loop() {
15+
Serial.println("RMT New driver is installed: " + installed ? String("Yes.") : String("No."));
16+
delay(5000);
17+
}
18+
19+
#else
20+
21+
// add the file "build_opt.h" to your Arduino project folder with "-DNO_NEW_RMT_DRV" to use the RMT Legacy driver
22+
// neoPixelWrite() is a function that writes to the RGB LED and it won't be available here
23+
#include "driver/rmt.h"
24+
25+
bool installed = false;
26+
27+
void setup() {
28+
Serial.begin(115200);
29+
Serial.println("This sketch is using the RMT Legacy driver.");
30+
installed = rmt_driver_install(RMT_CHANNEL_0, 0, 0) == ESP_OK;
31+
}
32+
33+
void loop() {
34+
Serial.println("RMT Legacy driver is installed: " + installed ? String("Yes.") : String("No."));
35+
delay(5000);
36+
}
37+
38+
39+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-DNO_NEW_RMT_DRV

0 commit comments

Comments
 (0)