-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Initial version of rmt driver #1525
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
Conversation
|
The header file needs a define at the beginning to prevent reloading. |
cores/esp32/esp32-hal-rmt.h
Outdated
| struct rmt_obj_s; | ||
|
|
||
| typedef enum { | ||
| e_reserve_64_items = 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets have the enum names in capital letters and name them like RMT_MEM_64 and so on
cores/esp32/esp32-hal-rmt.h
Outdated
| * (more data being send while updating buffers in interrupts) | ||
| * | ||
| */ | ||
| bool rmtSend(rmt_obj_t* rmt, uint32_t* data, size_t size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets not use uint32_t and instead expose a proper item structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also name of te function should be rmtWrite to follow Arduino's code style
cores/esp32/esp32-hal-rmt.h
Outdated
| * Initiates async receive, event flag indicates data received | ||
| * | ||
| */ | ||
| bool rmtReceive(rmt_obj_t* rmt, uint32_t* data, size_t size, void* eventFlag, bool waitForData, uint32_t timeout); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets rename this to rmtReadAsync and add rmtRead method that will default event flag (RX+ERROR?), true for waitForData and some sane timeout that can be adjusted by rmtSetRxTimeout(time_ms)
cores/esp32/esp32-hal-rmt.h
Outdated
| * Reads the data for particular channel | ||
| * | ||
| */ | ||
| bool rmtGetData(rmt_obj_t* rmt, uint32_t* data, size_t size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rmtGetData -> rmtReadData
|
|
||
|
|
||
| void setup() | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use Serial.begin(115200); to init serial here.
| { | ||
| if ((rmt_send = rmtInit(18, true, 2, 1000)) == NULL) | ||
| { | ||
| printf("init sender failed\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace such messages with Serial.println("init sender failed");. Note! Serial.printf(...) also exists.
|
|
||
|
|
||
| float realTick = rmtSetTick(rmt_send, 400); | ||
| printf("real tick set to: %f\n", realTick); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Serial.print("real tick set to: ");
Serial.println(realTick, 2);| data[255] = 0; | ||
|
|
||
| // Start receiving | ||
| rmtReceiveAsync(rmt_recv, 0x4F, my_data, 60, events); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
those do not exist anymore :)
|
|
||
| #include "esp32-hal.h" | ||
|
|
||
| #define LED_MATRIX_SIZE 8*4*24 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make 8*4 to be NUMBER_PIXELS.
| #include "esp32-hal.h" | ||
|
|
||
| #define NR_OF_LEDS 8*4 | ||
| #define NR_OF_PIXELS 24*NR_OF_LEDS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be number of bits. each led is a pixel
| for (col=0; col<3; col++ ) { | ||
| for (bit=0; bit<8; bit++){ | ||
| if ( (color[col] & (1<<(8-bit))) && (led == led_index) ) { | ||
| led_data[i].val = 0x80070006; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this value? please use the struct fields
| led_data[i].duration0 = 8; | ||
| led_data[i].level1 = 0; | ||
| led_data[i].duration1 = 1; | ||
| } else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These values are different,. a direct conversion between the .val and fields would be
led_data[i].level0 = 1;
led_data[i].duration0 = 7;
led_data[i].level1 = 0;
led_data[i].duration1 = 6;Did you want to change the values?
Chuck
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you chuck, good catch!
Indeed I meant to update the values (to be in line with the diagrams), but not that much. wanted to use pulses 8/4 instead of 7/6 (the led's are quite tolerant so it's accepted)
This is an initial version of RMT driver which supports
Please look mainly at the interface if this is viable and convenient for users; Please comment.
Still missing feature for using carrier frequency and a lot of testing needed...