Hello! I was just made aware of the Arduino101 section of the forum. I have posted a question regarding the use of the CurieTimerOne library from within another library. I am having issues with my ISR not working properly once I have moved my code from a sketch to the library format (.cpp, .h and example .ino). Can anyone point me in the right direction?
I have a very simplified version of what I want to do in hopes of pinpointing what the error is. Instead of the LED being toggled every time the ISR is called, it turns on and remains on. It seems like there is an issue with calling CurieTimerOne.start() from the library, but not from the IDE. The toggleLed() function is in there just as a sanity check to make sure the library was working, but is not being called.
#include "testLib_Timer1.h"
const int oneSecInUsec = 1000000; // A second in mirco second unit.
volatile bool toggle = 0;
void timedBlinkISR()
{
digitalWrite(13,toggle);
toggle = !toggle;
}
void testLib_Timer1::Initialize()
{
pinMode(13, OUTPUT);
CurieTimerOne.start(2000, timedBlinkISR);
}
void testLib_Timer1::toggleLed()
{
if(toggle == 0)
{
digitalWrite(13,HIGH);
toggle = 1;
}
else
{
digitalWrite(13, LOW);
toggle = 0;
}
}
.ino
#include <testLib_Timer1.h>
testLib_Timer1 myTest;
void setup() {
// put your setup code here, to run once:
myTest.Initialize();
}
void loop() {
// put your main code here, to run repeatedly:
//myTest.toggleLed();
//delay(2000);
//myTest.toggleLed();
//delay(2000);
}