-
Notifications
You must be signed in to change notification settings - Fork 46
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
Migrate to C++ class? #19
Comments
How about providing actual source code? The error messages without context are useless ... |
You're right. Give me one moment to check things again before asking for your time ... |
The header file of the FadeLed looks like this:
And the cpp like that:
|
or do you prefer the files? |
Hello again :) I created a separate class that can control GPIO2 and GPIO10 but the other pins won't work. I'm not sure if it is possible to control pin 5 (GPIO16) that way but digitalWrite() is working. Pin 2-4 are not working as well but I can't find the reason why. this is the header: #define PWM_CHANNELS 6
#include "Arduino.h"
class AachenerPwm
{
public:
AachenerPwm(uint32_t period);
static void setPwm(int _onTime, byte _pin, bool _start);
private:
uint32_t io_info[PWM_CHANNELS][3];
uint32_t pwm_duty_init[PWM_CHANNELS];
uint32_t period;
}; the cpp files is: #include "/Users/jt/Documents/Arduino/libraries/AachenerPwm/AachenerPwm.h"
extern "C" {
#include </Users/jt/Documents/Arduino/libraries/AachenerPwm/pwm.h>
}
AachenerPwm::AachenerPwm(uint32_t _period)
{
period = _period;
pwm_duty_init[0] = period;
for(int i=1; i<PWM_CHANNELS; i++){
pwm_duty_init[i] = 0;
}
io_info[0][0] = PERIPHS_IO_MUX_GPIO2_U;
io_info[0][1] = FUNC_GPIO2;
io_info[0][2] = 2;
io_info[1][0] = PERIPHS_IO_MUX_SD_DATA3_U;
io_info[1][1] = FUNC_GPIO10;
io_info[1][2] = 10;
io_info[2][0] = PERIPHS_IO_MUX_MTCK_U;
io_info[2][1] = FUNC_GPIO13;
io_info[2][2] = 13;
io_info[3][0] = PERIPHS_IO_MUX_MTDI_U;
io_info[3][1] = FUNC_GPIO12;
io_info[3][2] = 12;
io_info[4][0] = PERIPHS_IO_MUX_MTMS_U;
io_info[4][1] = FUNC_GPIO14;
io_info[4][2] = 14;
io_info[5][0] = PERIPHS_IO_MUX + 0x44;
io_info[5][1] = 1;
io_info[5][2] = 16;
pwm_init(period, pwm_duty_init, PWM_CHANNELS, io_info);
pwm_start();
}
void AachenerPwm::setPwm(int _onTime, byte _pin, bool _start){
pwm_set_duty(_onTime, _pin);
if(_start){
pwm_start();
}
} |
GPIO16 is in a different register location, so it will not work. Have you tried calling the functions directly? |
Hello :)
I am working on a board that can easily control up to 5 pwm outputs or 1 RGB light an 2 pwm outputs using one ESP12f. It is all up and running using the FadeLed class (https://github.com/septillion-git/FadeLed) which is based on the analogWrite(). In order to drive led (former halogen) bulbs, I need a low active option for my board. Besides that, I can hear some harmonics of the 1 kHz PWM. I tried to use your class including it using
but it wouldn't work. The error I get is
I guess the reason for this is that the compiler expects a "FadeLed::" in front of every function, right?
I tried to understand your code in order to implement it in to the FadeLed class but failed. Do you have any idea or could change your code to an independent class?
I study electronics at THM in Gießen, GER, so I try my best in programming but I'm not into it very deeply. If communicating with me is easier in German, feel free to contact me :-)
Best
The text was updated successfully, but these errors were encountered: