TimeAlarms.h, problem accessing member function
Posted: Mon Nov 28, 2016 8:53 am
Hello,
#include <TimeAlarms.h>
I have this class:
Using TimerAlarms lib I want to set the "on" property of the device at a designated time.
I use this function:
but I get an error:
I'm so confused of this void (*)() thing, I am missing something for sure!
device[0].scheduleOn(); works great!
What's that "onTickHandler" variable that the "AlarmRepeat" function gets?
The end result I need is:
user logs in and attaches an alarm to a device and when it goes off the device is turned on/off.
I thought about adding turnOn and turnOff functions to be called when the alarm goes off.
I'll use an index to the device I want to attach the alarm to like that:
Alarm.alarmRepeat(13,55,50,device[i].scheduleOn);
Any recommended ways to implement this?
Thanks for the help
#include <TimeAlarms.h>
I have this class:
Code: Select all
class Device {
public:
int pin;//pin
int enable;//enabled?
int ON;//On or off?
String itsName;//name
boolean ScheduleForOn;//is it schedule to turn on?
boolean ScheduleForOff;//is it schedule to turn off?
void scheduleOn(){
Serial.println(pin);
Serial.println(" set to on by schedule");
}
void scheduleOff()
{Serial.println(pin);
Serial.println(" set to off by schedule");
}
};
Using TimerAlarms lib I want to set the "on" property of the device at a designated time.
I use this function:
Code: Select all
Device device[10];
Serial.println(Alarm.alarmRepeat(13,55,50,device[0].scheduleOn);
but I get an error:
Code: Select all
Arduino: 1.6.9 (Windows 7), Board: "NodeMCU 1.0 (ESP-12E Module), 160 MHz, 115200, 4M (1M SPIFFS)"
Arduino\ESP8266_withAlarms\ESP8266_withAlarms.ino: In function 'void setup()':
[u][b]ESP8266_withAlarms:127: error: no matching function for call to 'TimeAlarmsClass::alarmRepeat(int, int, int, <unresolved overloaded function type>)'
Serial.println(Alarm.alarmRepeat(13,55,50,device[0].scheduleOn);[/b][/u]
^
Arduino\ESP8266_withAlarms\ESP8266_withAlarms.ino:127:65: note: candidates are:
Arduino\ESP8266_withAlarms\ESP8266_withAlarms.ino:9:0:
Arduino\libraries\TimeAlarms/TimeAlarms.h:106:13: note: AlarmID_t TimeAlarmsClass::alarmRepeat(time_t, OnTick_t)
AlarmID_t alarmRepeat(time_t value, OnTick_t onTickHandler) {
^
Arduino\libraries\TimeAlarms/TimeAlarms.h:106:13: note: candidate expects 2 arguments, 4 provided
Arduino\libraries\TimeAlarms/TimeAlarms.h:110:13: note: AlarmID_t TimeAlarmsClass::alarmRepeat(int, int, int, OnTick_t)
AlarmID_t alarmRepeat(const int H, const int M, const int S, OnTick_t onTickHandler) {
^
Arduino\libraries\TimeAlarms/TimeAlarms.h:110:13: note: no known conversion for argument 4 from '<unresolved overloaded function type>' to 'OnTick_t {aka void (*)()}'
Arduino\libraries\TimeAlarms/TimeAlarms.h:115:13: note: AlarmID_t TimeAlarmsClass::alarmRepeat(timeDayOfWeek_t, int, int, int, OnTick_t)
AlarmID_t alarmRepeat(const timeDayOfWeek_t DOW, const int H, const int M, const int S, OnTick_t onTickHandler) {
^
Arduino\libraries\TimeAlarms/TimeAlarms.h:115:13: note: candidate expects 5 arguments, 4 provided
exit status 1
no matching function for call to 'TimeAlarmsClass::alarmRepeat(int, int, int, <unresolved overloaded function type>)'
I'm so confused of this void (*)() thing, I am missing something for sure!
device[0].scheduleOn(); works great!
What's that "onTickHandler" variable that the "AlarmRepeat" function gets?
The end result I need is:
user logs in and attaches an alarm to a device and when it goes off the device is turned on/off.
I thought about adding turnOn and turnOff functions to be called when the alarm goes off.
I'll use an index to the device I want to attach the alarm to like that:
Alarm.alarmRepeat(13,55,50,device[i].scheduleOn);
Any recommended ways to implement this?
Thanks for the help