-
Notifications
You must be signed in to change notification settings - Fork 103
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
Modify OnTick_t typedef for ESP8266 platform #16
base: master
Are you sure you want to change the base?
Conversation
Having this change does not modify library interface but enables the possibility to use class member methods as callback with the help of `std::bind()`. Unfortunately I've not found a way to do the same with Arduino platform, so I've filtered it using preprocessor..
Add TimeAlarm example for ESP8266 using class methods
*/ | ||
|
||
#define YOUR_WIFI_SSID "Your_SSID" | ||
#define YOUR_WIFI_SSID "Your_Pw" |
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.
Hi gmag11,
thank you very much for your job.
The line 21 should be corrected as follows:
-#define YOUR_WIFI_SSID "Your_Pw"
+#define YOUR_WIFI_PASSWD "Your_Pw"
Since Arduino esp8266 release 2.4.0 makes the TimeLib not needed it would be interesting to build a newlib time.h version of TimeAlarms. |
@@ -242,7 +242,7 @@ void TimeAlarmsClass::serviceAlarms() | |||
Alarm[servicedAlarmId].updateNextTrigger(); | |||
} | |||
if (TickHandler != NULL) { | |||
(*TickHandler)(); // call the handler | |||
TickHandler(); // call the handler |
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 pull request was not merged because of this change.
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.
Hi, even though I'm not the author of the pull request, I'm still wondering why line 245 is preventing the PR from being merged. Would you mind elaborating? To me the proposed extension seem to be implemented exactly as it is in other libraries (e.g. the ubiquitous "PubSubClient" MQTT client). The syntax change of line 245 simply ensures that the calling syntax is compatible with both cases: plain old function pointer and std::function.
I'd quite like to see this extension implemented in TimeAlarms. It allows for more elegant OOP design.
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.
If you like you can have a try of my fork of the TimeAlarm. I rewrote it using the latest ESP 2.4 that is using Newlib C time functions.
https://github.com/jhagberg/ESP8266TimeAlarms
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.
Thanks for pointing that out! Personally I try as much as possible to use the libraries available through platform.io's package manager and treat those as the "canonical" versions. That's why I'm interested in contributing some minor ESP8266-relatex fixes. A second consideration is to use platform-agnostic libraries (AVR vs ESP) whenever possible.
But then again, having a rebased library specifically for the ESP8266's C library is quite nice, too. Thanks!
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.
Yes this code is not reviewed by anyone yet. But it will handle Timezones and Daylight savings very nicely without any extra library. And works for me for the moment at least!
Edit: I'm trying to do this on Arduino not ESP8266 @gmag11 finally did you use your branch? I'd like to use auto activation = std::bind(activateEvenDay, sector.id);
Alarm.alarmRepeat(hour, minutes, 0, activation); I tried with lambda functions too but cannot convert unsigned char id = sector.id;
auto activation = [id]() { activateEvenDay(id); };
Alarm.alarmRepeat(hour, minutes, 0, activation); |
Having this change does not modify library interface but enables the possibility to use class member methods as callback with the help of
std::bind()
.Unfortunately I've not found a way to do the same with Arduino platform, so I've filtered it using preprocessor.
I've added an example on how to use this feature.