Skip to content
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

How to use with Platform.IO / Arduino Framework #2

Closed
ellogwen opened this issue Aug 31, 2021 · 7 comments
Closed

How to use with Platform.IO / Arduino Framework #2

ellogwen opened this issue Aug 31, 2021 · 7 comments
Assignees
Labels
enhancement New feature or request question Further information is requested

Comments

@ellogwen
Copy link

ellogwen commented Aug 31, 2021

Hi, I am trying for hours to get this to work with Platform.IO and the Arduino Framework.
Do you know how I could mix this esp-idf component withing my existing Arduino project or do you know if there is a platform.io lib for this repo?

@ellogwen ellogwen changed the title How to use with Platofrmio / Arduino Frameform How to use with Platform.IO / Arduino Framework Aug 31, 2021
@someweisguy someweisguy self-assigned this Sep 1, 2021
@someweisguy
Copy link
Owner

Thanks for the question! I am working on implementing this repo on Arduino. I haven't done much work in a while because life has gotten in the way a bit, but the Arduino implementation is close. I will hopefully have some free time coming up soon and I'll see where I get with it.

I can add a Platform.IO implementation as well, but I will have to do some research to figure out what that entails. I not very up to date on how PIO works. I'll keep you updated!

@ellogwen
Copy link
Author

ellogwen commented Sep 2, 2021

Hi, thanks for your answer. No need to rush or stress yourself :) I am currently using a modified LXESP32DMX to work with uart1, but this library needs to patch a core file for receiving to work, which is nothing I can do easily, so I am using it only for transmitting. For now. I will switch definetly in the near future.

I would offer you my help, but I have no clue about esp-idf though.

@someweisguy
Copy link
Owner

I've pushed some code to the dev branch that builds on Arduino! Woohoo! You can clone that branch and copy the folder into your libraries folder in your Arduino directory, and that should allow you to #include "esp_dmx.h".

I am doubtful that the keyword highlighting will work, but I am making progress. I am not thrilled with the fixes I made in the last commit; I'm still trying to figure out how the ESP32 Arduino core works in the grand scheme of things so I am sure that there are better ways to do what I did. For now, this code will work on ESP32, but it can likely break on ESP32-S2 or ESP32-C3. If you use the latter, let me know and I can push a hotfix so that you will be able to play with this library.

No word on Platform.IO yet. That will probably be much, much later.

@someweisguy
Copy link
Owner

Highlighting works now! Turns out I had to use a single tab instead of spaces in my keywords.txt file. Whoops!

@someweisguy someweisguy added enhancement New feature or request question Further information is requested labels Sep 10, 2021
@someweisguy
Copy link
Owner

The latest commit did some reorganizing. In /examples I've renamed all the example files. The example files for ESP-IDF code are now prefixed with idf_. I'm not sure if I love that formatting so it may change in the future.

I've also added some Arduino DMX read example code!

Finally, I found an interesting bug in the previous code. Whenever you called dmx_driver_delete() the ESP32 would attempt to free the heap-allocated double-buffer. It would then detect a corrupted heap and would crash. I couldn't find any other solutions online, but what I found is that when the size of the DMX double-buffer is divisible by 4, the problem goes away. I suspect what is happening is that the Arduino implementation of ESP32's malloc() function only allows you to allocate 32-bit aligned memory as if calling heap_caps_malloc(size, MALLOC_CAP_32BIT) in ESP-IDF. Long story short, only allocate memory by factors of 4 on ESP32 Arduino!

@someweisguy
Copy link
Owner

Another update: I've finished adding example code for Arduino! I'm going to style those examples so that they better fit the Arduino example sketch style guide, but they work now as is.

I found that Arduino-ESP32 v1.0.6 and earlier don't support the newest ESP32 chipsets. Arduino-ESP32 v2.0.0 was JUST released less than two weeks ago, and it does support the S2 and the C3. For the sake of inclusion, I'm going to support Arduino-ESP32 v2.0.0 and up only. If you want to use Arduino v1.0.6, I've created a branch called arduino-v1.0.6 but I'm not planning on updating it in the future.

@someweisguy
Copy link
Owner

I've officially ported this library to Arduino. It's available in the Arduino IDE library manager and the example code is working. So I am going to close this issue.

I'm still looking into Platform.IO. It looks simple enough, but that will be another release! Let me know if you have any other questions. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants