bluerange-io / bluerange-mesh

BlueRange Mesh (formerly FruityMesh) - The first completely connection-based open source mesh on top of Bluetooth Low Energy (4.1/5.0 or higher)
https://bluerange.io/
Other
287 stars 109 forks source link

Timer event handler questions #111

Closed LeoEras closed 5 years ago

LeoEras commented 5 years ago

Good evening,

I was testing the project and I came across the description of the timer in types.h //Returns true if the timer should have trigered the interval in the passedTime #define SHOULD_IV_TRIGGER(timer, passedTime, interval) (interval != 0 && (((timer)-(passedTime)) % (interval) >= (timer) % (interval))) so I tried to put this function inside PingModule::TimerEventHandler(u16 passedTimeDs) to make a led blink every once in a while (like in IoModule). I think passedTimeDs is the second argument of SHOULD_IV_TRIGGER, but which are the first and the third one? I tried with many numbers but I see the same effect on a led: it either turns on immediately or it turns off immediately and stays that way until reset. I don't understand what is passedTimeDs either. Is it an accumulative amount? What are the arguments SHOULD_IV_TRIGGER takes, does it fire once? Thank you very much!

mariusheil commented 5 years ago

Hi,

have a look at the status reporter module for how the arguments are used. Timer is the variable that counts the total time while passedTimeDs is the time that has passed since the last time the TimerEventHandler was called. The third argument is the interval, e.g. 20 ds. All units are in deci seconds, so using 20 as an interval and calling the led toggle function should let the led blink every 2 seconds. You must however first set the led mode to custom in the Io module, otherwise it will immediately overwrite your led settings.

Hope that explanation works for you 🙂

Leonardo Eras notifications@github.com schrieb am Do., 1. Aug. 2019, 00:46:

Good evening,

I was testing the project and I came across the description of the timer in types.h //Returns true if the timer should have trigered the interval in the passedTime

define SHOULD_IV_TRIGGER(timer, passedTime, interval) (interval != 0 &&

(((timer)-(passedTime)) % (interval) >= (timer) % (interval))) so I tried to put this function inside PingModule::TimerEventHandler(u16 passedTimeDs) to make a led blink every once in a while (like in IoModule). I think passedTimeDs is the second argument of SHOULD_IV_TRIGGER, but which are the first and the third one? I tried with many numbers but I see the same effect on a led: it either turns on immediately or it turns off immediately and stays that way until reset. I don't understand what is passedTimeDs either. Is it an accumulative amount? What are the arguments SHOULD_IV_TRIGGER takes, does it fire once? Thank you very much!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mwaylabs/fruitymesh/issues/111?email_source=notifications&email_token=ABM62NFASKAKND35PYKSMF3QCII33A5CNFSM4IILE232YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HCV4CAA, or mute the thread https://github.com/notifications/unsubscribe-auth/ABM62NFASLSWJ7JDJDOACKTQCII33ANCNFSM4IILE23Q .

LeoEras commented 5 years ago

Yesm I set the led on custom mode. Thank you so much, it works perfectly now!