I am trying to call sunrise using the Alarm.alarmRepeat. When i try i get an error
C:\Users\Tara Stanley\Documents\Arduino\AquariumControllerTest\AquariumControllerTest.ino: In function 'void loop()':
C:\Users\Tara Stanley\Documents\Arduino\AquariumControllerTest\AquariumControllerTest.ino:32:52: warning: invalid conversion from 'void ()(long unsigned int)' to 'OnTick_t {aka void ()()}' [-fpermissive]
alarms[0] = Alarm.alarmRepeat(8, 0, 35, sunrise);
^
In file included from C:\Users\Tara Stanley\Documents\Arduino\AquariumControllerTest\AquariumControllerTest.ino:1:0:
C:\Program Files (x86)\Arduino\libraries\TimeAlarms/TimeAlarms.h:110:13: note: initializing argument 4 of 'AlarmID_t TimeAlarmsClass::alarmRepeat(int, int, int, OnTick_t)'
AlarmID_t alarmRepeat(const int H, const int M, const int S, OnTick_t onTickHandler) {
^
The code will work like this but will continues to loop. If i comment out sunrise(currentMillis); in void loop and uncomment alarms[0] i get the above error.
#include <TimeAlarms.h>
#include <Time.h>
#include <Wire.h>
#include <ds3231.h>
#define UP 0 // define directions for LED fade
#define DOWN 1 // define directions for LED fade
const byte led = 11;
const int minPWM = 0; // constants for min and max PWM
const int maxPWM = 255; // constants for min and max PWM
int fadeValue = 0; // Global Fade Value, but be bigger than byte and signed, for rollover
int fadeInterval = 10; // How fast to increment?
byte fadeDirection = UP; // State Variable for Fade Direction
byte fadeIncrement = 1; // How smooth to fade?
unsigned long previousFadeMillis = 0; // millis() timing Variable, just for fading
AlarmID_t alarms[4];
void setup() {
analogWrite(led, fadeValue);
Serial.begin(9600);
setTime(8, 0, 30, 7, 12, 16);
}
void loop() {
unsigned long currentMillis = millis();
//sunrise(currentMillis);
showTime();
Alarm.delay(1000);
alarms[0] = Alarm.alarmRepeat(8, 0, 35, sunrise);
//alarms[1] = Alarm.alarmRepeat(8,0,40, turnOffLed);
//alarms[2] = Alarm.alarmRepeat(8,0,45, turnOnLed);
//alarms[3] = Alarm.alarmRepeat(8,0,50, turnOffLed);
}
/*void turnOnLed() {
digitalWrite(led, HIGH);
}
void turnOffLed() {
digitalWrite(led, LOW);
}
*/
void showTime() {
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.println();
}
void printDigits(int digits) {
Serial.print(":");
if (digits < 10);
Serial.print('0');
Serial.print(digits);
}
void sunrise(unsigned long thisMillis) {
// is it time to update yet?
// if not, nothing happens
if (thisMillis - previousFadeMillis >= fadeInterval) {
// yup, it's time!
if (fadeDirection == UP) {
fadeValue = fadeValue + fadeIncrement;
if (fadeValue >= maxPWM) {
// At max, limit and change direction
fadeValue = maxPWM;
fadeDirection = DOWN;
}
} else {
//if we aren't going up, we're going down
fadeValue = fadeValue - fadeIncrement;
if (fadeValue <= minPWM) {
// At min, limit and change direction
fadeValue = led;
fadeDirection = UP;
}
}
// Only need to update when it changes
analogWrite(led, fadeValue);
// reset millis for the next iteration (fade timer only)
previousFadeMillis = thisMillis;
}
}