Hi all,
I want to use the TimerInterruptTest example (below) from the ESP8266TimerInterrupt library. In the desktop IDE v2 the code compiles and runs successfully, but in the cloud/web compiler there are errors.
I am using the same device selection (Node MCU ESP 12E), the same version of the library (1.60) and the same example code.
Does anyone have any suggestions how to overcome these errors? The location of this project will be really difficult to access and I need the cloud compiler and OTA updates to work, so I can't rely solely on the desktop IDE.
#if !defined(ESP8266)
#error This code is designed to run on ESP8266 and ESP8266-based boards! Please check your Tools->Board setting.
#endif
// These define's must be placed at the beginning before #include "ESP8266TimerInterrupt.h"
// _TIMERINTERRUPT_LOGLEVEL_ from 0 to 4
// Don't define _TIMERINTERRUPT_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
#define TIMER_INTERRUPT_DEBUG 1
#define _TIMERINTERRUPT_LOGLEVEL_ 1
// Select a Timer Clock
#define USING_TIM_DIV1 false // for shortest and most accurate timer
#define USING_TIM_DIV16 false // for medium time and medium accurate timer
#define USING_TIM_DIV256 true // for longest timer but least accurate. Default
#include "ESP8266TimerInterrupt.h"
#define BUILTIN_LED 2 // Pin D4 mapped to pin GPIO2/TXD1 of ESP8266, NodeMCU and WeMoS, control on-board LED
volatile bool statusLed = false;
volatile uint32_t lastMillis = 0;
#define TIMER_INTERVAL_MS 1000
// Init ESP8266 timer 1
ESP8266Timer ITimer;
//=======================================================================
void IRAM_ATTR TimerHandler()
{
static bool started = false;
if (!started)
{
started = true;
pinMode(BUILTIN_LED, OUTPUT);
}
digitalWrite(BUILTIN_LED, statusLed); //Toggle LED Pin
statusLed = !statusLed;
#if (TIMER_INTERRUPT_DEBUG > 0)
Serial.println("Delta ms = " + String(millis() - lastMillis));
lastMillis = millis();
#endif
}
//=======================================================================
// Setup
//=======================================================================
void setup()
{
Serial.begin(115200);
while (!Serial);
delay(300);
Serial.print(F("\nStarting TimerInterruptTest on ")); Serial.println(ARDUINO_BOARD);
Serial.println(ESP8266_TIMER_INTERRUPT_VERSION);
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));
// Interval in microsecs
if (ITimer.attachInterruptInterval(TIMER_INTERVAL_MS * 1000, TimerHandler))
{
lastMillis = millis();
Serial.print(F("Starting ITimer OK, millis() = ")); Serial.println(lastMillis);
}
else
Serial.println(F("Can't set ITimer correctly. Select another freq. or interval"));
}
//=======================================================================
// MAIN LOOP
//=======================================================================
void loop()
{
}
When I try and compile it in the cloud compiler, I open the example and add the library. Two includes that are not in the IDE version of the sketch get added, ESP8266_ISR_Timer.h and ESP8266_ISR_Timer.hpp. The compile then fails with the following error:
In file included from /home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.h:49:0,
from /tmp/1904111783/TimerInterruptTest/TimerInterruptTest.ino:2:
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:108:10: error: variable or field 'IRAM_ATTR' declared void
void IRAM_ATTR init();
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:108:10: error: expected ';' at end of member declaration
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:108:25: error: ISO C++ forbids declaration of 'init' with no type [-fpermissive]
void IRAM_ATTR init();
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:111:10: error: variable or field 'IRAM_ATTR' declared void
void IRAM_ATTR run();
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:111:10: error: expected ';' at end of member declaration
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:111:24: error: ISO C++ forbids declaration of 'run' with no type [-fpermissive]
void IRAM_ATTR run();
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:116:9: error: expected ';' at end of member declaration
int IRAM_ATTR setInterval(const unsigned long& d, const timer_callback& f);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:116:78: error: ISO C++ forbids declaration of 'setInterval' with no type [-fpermissive]
int IRAM_ATTR setInterval(const unsigned long& d, const timer_callback& f);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:121:9: error: expected ';' at end of member declaration
int IRAM_ATTR setInterval(const unsigned long& d, const timer_callback_p& f, void* p);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:121:9: error: redeclaration of 'int ISRTimer::IRAM_ATTR'
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:116:9: note: previous declaration 'int ISRTimer::IRAM_ATTR'
int IRAM_ATTR setInterval(const unsigned long& d, const timer_callback& f);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:121:89: error: ISO C++ forbids declaration of 'setInterval' with no type [-fpermissive]
int IRAM_ATTR setInterval(const unsigned long& d, const timer_callback_p& f, void* p);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:126:9: error: expected ';' at end of member declaration
int IRAM_ATTR setTimeout(const unsigned long& d, const timer_callback& f);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:126:9: error: redeclaration of 'int ISRTimer::IRAM_ATTR'
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:116:9: note: previous declaration 'int ISRTimer::IRAM_ATTR'
int IRAM_ATTR setInterval(const unsigned long& d, const timer_callback& f);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:126:77: error: ISO C++ forbids declaration of 'setTimeout' with no type [-fpermissive]
int IRAM_ATTR setTimeout(const unsigned long& d, const timer_callback& f);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:131:9: error: expected ';' at end of member declaration
int IRAM_ATTR setTimeout(const unsigned long& d, const timer_callback_p& f, void* p);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:131:9: error: redeclaration of 'int ISRTimer::IRAM_ATTR'
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:116:9: note: previous declaration 'int ISRTimer::IRAM_ATTR'
int IRAM_ATTR setInterval(const unsigned long& d, const timer_callback& f);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:131:88: error: ISO C++ forbids declaration of 'setTimeout' with no type [-fpermissive]
int IRAM_ATTR setTimeout(const unsigned long& d, const timer_callback_p& f, void* p);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:136:9: error: expected ';' at end of member declaration
int IRAM_ATTR setTimer(const unsigned long& d, const timer_callback& f, const unsigned& n);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:136:9: error: redeclaration of 'int ISRTimer::IRAM_ATTR'
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:116:9: note: previous declaration 'int ISRTimer::IRAM_ATTR'
int IRAM_ATTR setInterval(const unsigned long& d, const timer_callback& f);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:136:94: error: ISO C++ forbids declaration of 'setTimer' with no type [-fpermissive]
int IRAM_ATTR setTimer(const unsigned long& d, const timer_callback& f, const unsigned& n);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:141:9: error: expected ';' at end of member declaration
int IRAM_ATTR setTimer(const unsigned long& d, const timer_callback_p& f, void* p, const unsigned& n);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:141:9: error: redeclaration of 'int ISRTimer::IRAM_ATTR'
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:116:9: note: previous declaration 'int ISRTimer::IRAM_ATTR'
int IRAM_ATTR setInterval(const unsigned long& d, const timer_callback& f);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:141:105: error: ISO C++ forbids declaration of 'setTimer' with no type [-fpermissive]
int IRAM_ATTR setTimer(const unsigned long& d, const timer_callback_p& f, void* p, const unsigned& n);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:144:10: error: expected ';' at end of member declaration
bool IRAM_ATTR changeInterval(const unsigned& numTimer, const unsigned long& d);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:144:10: error: redeclaration of 'bool ISRTimer::IRAM_ATTR'
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:116:9: note: previous declaration 'int ISRTimer::IRAM_ATTR'
int IRAM_ATTR setInterval(const unsigned long& d, const timer_callback& f);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:144:83: error: ISO C++ forbids declaration of 'changeInterval' with no type [-fpermissive]
bool IRAM_ATTR changeInterval(const unsigned& numTimer, const unsigned long& d);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:147:10: error: variable or field 'IRAM_ATTR' declared void
void IRAM_ATTR deleteTimer(const unsigned& timerId);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:147:10: error: expected ';' at end of member declaration
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:147:55: error: ISO C++ forbids declaration of 'deleteTimer' with no type [-fpermissive]
void IRAM_ATTR deleteTimer(const unsigned& timerId);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:150:10: error: variable or field 'IRAM_ATTR' declared void
void IRAM_ATTR restartTimer(const unsigned& numTimer);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:150:10: error: expected ';' at end of member declaration
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:150:57: error: ISO C++ forbids declaration of 'restartTimer' with no type [-fpermissive]
void IRAM_ATTR restartTimer(const unsigned& numTimer);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:153:10: error: expected ';' at end of member declaration
bool IRAM_ATTR isEnabled(const unsigned& numTimer);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:153:10: error: redeclaration of 'bool ISRTimer::IRAM_ATTR'
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:116:9: note: previous declaration 'int ISRTimer::IRAM_ATTR'
int IRAM_ATTR setInterval(const unsigned long& d, const timer_callback& f);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:153:54: error: ISO C++ forbids declaration of 'isEnabled' with no type [-fpermissive]
bool IRAM_ATTR isEnabled(const unsigned& numTimer);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:156:10: error: variable or field 'IRAM_ATTR' declared void
void IRAM_ATTR enable(const unsigned& numTimer);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:156:10: error: expected ';' at end of member declaration
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:156:51: error: ISO C++ forbids declaration of 'enable' with no type [-fpermissive]
void IRAM_ATTR enable(const unsigned& numTimer);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:159:10: error: variable or field 'IRAM_ATTR' declared void
void IRAM_ATTR disable(const unsigned& numTimer);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:159:10: error: expected ';' at end of member declaration
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:159:52: error: ISO C++ forbids declaration of 'disable' with no type [-fpermissive]
void IRAM_ATTR disable(const unsigned& numTimer);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:162:10: error: variable or field 'IRAM_ATTR' declared void
void IRAM_ATTR enableAll();
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:162:10: error: expected ';' at end of member declaration
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:162:30: error: ISO C++ forbids declaration of 'enableAll' with no type [-fpermissive]
void IRAM_ATTR enableAll();
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:165:10: error: variable or field 'IRAM_ATTR' declared void
void IRAM_ATTR disableAll();
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:165:10: error: expected ';' at end of member declaration
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:165:31: error: ISO C++ forbids declaration of 'disableAll' with no type [-fpermissive]
void IRAM_ATTR disableAll();
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:169:10: error: variable or field 'IRAM_ATTR' declared void
void IRAM_ATTR toggle(const unsigned& numTimer);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:169:10: error: expected ';' at end of member declaration
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:169:51: error: ISO C++ forbids declaration of 'toggle' with no type [-fpermissive]
void IRAM_ATTR toggle(const unsigned& numTimer);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:172:12: error: expected ';' at end of member declaration
int8_t IRAM_ATTR getNumTimers();
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:172:12: error: redeclaration of 'int8_t ISRTimer::IRAM_ATTR'
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:116:9: note: previous declaration 'int ISRTimer::IRAM_ATTR'
int IRAM_ATTR setInterval(const unsigned long& d, const timer_callback& f);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:172:35: error: ISO C++ forbids declaration of 'getNumTimers' with no type [-fpermissive]
int8_t IRAM_ATTR getNumTimers();
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:175:12: error: expected ';' at end of member declaration
int8_t IRAM_ATTR getNumAvailableTimers()
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:175:12: error: redeclaration of 'int8_t ISRTimer::IRAM_ATTR'
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:116:9: note: previous declaration 'int ISRTimer::IRAM_ATTR'
int IRAM_ATTR setInterval(const unsigned long& d, const timer_callback& f);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:175:44: error: ISO C++ forbids declaration of 'getNumAvailableTimers' with no type [-fpermissive]
int8_t IRAM_ATTR getNumAvailableTimers()
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:191:12: error: expected ';' at end of member declaration
int8_t IRAM_ATTR setupTimer(const unsigned long& d, void* f, void* p, bool h, const unsigned& n);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:191:12: error: redeclaration of 'int8_t ISRTimer::IRAM_ATTR'
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:116:9: note: previous declaration 'int ISRTimer::IRAM_ATTR'
int IRAM_ATTR setInterval(const unsigned long& d, const timer_callback& f);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:191:100: error: ISO C++ forbids declaration of 'setupTimer' with no type [-fpermissive]
int8_t IRAM_ATTR setupTimer(const unsigned long& d, void* f, void* p, bool h, const unsigned& n);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:194:12: error: expected ';' at end of member declaration
int8_t IRAM_ATTR findFirstFreeSlot();
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:194:12: error: redeclaration of 'int8_t ISRTimer::IRAM_ATTR'
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:116:9: note: previous declaration 'int ISRTimer::IRAM_ATTR'
int IRAM_ATTR setInterval(const unsigned long& d, const timer_callback& f);
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:194:40: error: ISO C++ forbids declaration of 'findFirstFreeSlot' with no type [-fpermissive]
int8_t IRAM_ATTR findFirstFreeSlot();
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer.hpp:88:27: error: expected initializer before 'ISRTimer'
#define ESP8266_ISR_Timer ISRTimer
^
/home/builder/Arduino/libraries/esp8266timerinterrupt_1_6_0/src/ESP8266_ISR_Timer-Impl.h:69:16: note: in expansion of macro 'ESP8266_ISR_Timer'
void IRAM_ATTR ESP8266_ISR_Timer::init()
^
Error during build: exit status 1
If I remove ESP8266_ISR_Timer.h and ESP8266_ISR_Timer.hpp, there are far fewer errors, but it still fails to compile:
/tmp/717681372/TimerInterruptTest/TimerInterruptTest.ino:61:16: error: expected initializer before 'TimerHandler'
void IRAM_ATTR TimerHandler()
^
/tmp/717681372/TimerInterruptTest/TimerInterruptTest.ino:61:16: error: expected initializer before 'TimerHandler'
void IRAM_ATTR TimerHandler()
^
Error during build: exit status 1