RobotDynOfficial / RBDDimmer

The following library is used for work with dimmer, it gives ability to control large ammoun of dimmer. This lib uses with Leonardo, Mega, UNO, ESP8266, ESP32, Arduino M0, Arduino Zero, Arduino Due, STM32.
241 stars 112 forks source link

Update RBDmcuESP32.cpp #66

Open jon-riches opened 1 year ago

jon-riches commented 1 year ago

only init timer once, regardless of how many dimmers, by adding if (current_num < 1)

TadeuszKarpinski commented 1 year ago

@jon-riches I tested it and it works great on esp32. Well done!

jon-riches commented 5 months ago

Can't see an obvious reason why it doesn't work.

Are you sure your code is correct?

E.g Try it on just 1

On Sun, 2 Jun 2024, 14:08 hotswapster, @.***> wrote:

@jon-riches https://github.com/jon-riches Thanks for providing this fix for ESP32. I've tried making the same change for the ESP8266 part but I still get exceptions when the code is run on the ESP8266. Could you please provide any advice as to which part needs changing to fix the ESP8266?

When I run the original code I get this exception:

Decoding stack results 0x402027a2: dimmerLamp::timer_init() at /home/user/Arduino/libraries/RBDdimmer/src/esp8266/RBDmcuESP8266.cpp:55 0x40206295: is in __attachInterruptFunctionalArg(uint8_t, voidFuncPtrArg, void*, int, bool) (/home/user/.arduino15/packages/esp8266/hardware/esp8266/3.1.2/cores/esp8266/core_esp8266_wiring_digital.cpp:204). 0x4020282e: is in dimmerLamp::begin(DIMMER_MODE_typedef, ON_OFF_typedef) (/home/user/Arduino/libraries/RBDdimmer/src/esp8266/RBDmcuESP8266.cpp:72). 0x40201b19: setup() at /home/user/Documents/projects/harleyfan/nodecode/nodecode.ino:78 0x402056c0: loop_wrapper() at /home/user/.arduino15/packages/esp8266/hardware/esp8266/3.1.2/cores/esp8266/core_esp8266_main.cpp:255

I then changed RBDmcuESP8266.cpp from:

void dimmerLamp::timer_init(void) { // only init timer once, regardless of how many dimmers

    timer1_attachInterrupt(onTimerISR);
    timer1_enable(TIM_DIV16, TIM_EDGE, TIM_SINGLE);
    timer1_write(timeoutPin); //100 us

}

to

void dimmerLamp::timer_init(void) { // only init timer once, regardless of how many dimmers if (current_num < 1) { timer1_attachInterrupt(onTimerISR); timer1_enable(TIM_DIV16, TIM_EDGE, TIM_SINGLE); timer1_write(timeoutPin); //100 us } }

and then got the following exception:

Decoding stack results 0x402027a8: dimmerLamp::timer_init() at /home/user/Arduino/libraries/RBDdimmer/src/esp8266/RBDmcuESP8266.cpp:55 0x402062a1: is in __attachInterruptFunctionalArg(uint8_t, voidFuncPtrArg, void*, int, bool) (/home/user/.arduino15/packages/esp8266/hardware/esp8266/3.1.2/cores/esp8266/core_esp8266_wiring_digital.cpp:204). 0x4020283a: is in dimmerLamp::begin(DIMMER_MODE_typedef, ON_OFF_typedef) (/home/user/Arduino/libraries/RBDdimmer/src/esp8266/RBDmcuESP8266.cpp:72). 0x40201b19: setup() at /home/user/Documents/projects/harleyfan/nodecode/nodecode.ino:78 0x402056cc: loop_wrapper() at /home/user/.arduino15/packages/esp8266/hardware/esp8266/3.1.2/cores/esp8266/core_esp8266_main.cpp:255

which looks the same as the original. So I'm guessing my interpertation if you fix doesn't work for ESP8266?

— Reply to this email directly, view it on GitHub https://github.com/RobotDynOfficial/RBDDimmer/pull/66#issuecomment-2143847206, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA3T3ZNPC47RCCG6MW2PUETZFMKNLAVCNFSM6AAAAAAWQGBFFCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBTHA2DOMRQGY . You are receiving this because you were mentioned.Message ID: @.***>

hotswapster commented 5 months ago

Thanks for finding the time to respond. I ended up finding the fix here: https://github.com/RobotDynOfficial/RBDDimmer/pull/57