Skip to content
This repository was archived by the owner on Jan 29, 2023. It is now read-only.

Commit 8a00389

Browse files
authored
Update multiFileProject
1 parent 9238f6e commit 8a00389

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

examples/multiFileProject/multiFileProject.cpp

+26
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,29 @@
1010
// To demo how to include files in multi-file Projects
1111

1212
#include "multiFileProject.h"
13+
14+
ESP8266Timer ITimer;
15+
ESP8266_ISR_Timer ISR_Timer;
16+
17+
void IRAM_ATTR TimerHandler()
18+
{
19+
ISR_Timer.run();
20+
Serial.println("TimerHandler triggered");
21+
}
22+
23+
void doingSomething0()
24+
{
25+
Serial.println("doingSomething0 triggered");
26+
}
27+
28+
void setupISR()
29+
{
30+
if (ITimer.attachInterruptInterval(1000 * 1000, TimerHandler))
31+
{
32+
Serial.print(F("Starting ITimer OK"));
33+
}
34+
else
35+
Serial.println(F("Can't set ITimer. Select another freq. or timer"));
36+
37+
ISR_Timer.setInterval(3000, doingSomething0);
38+
}

examples/multiFileProject/multiFileProject.h

+16
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@
1111

1212
#pragma once
1313

14+
// These define's must be placed at the beginning before #include "ESP8266TimerInterrupt.h"
15+
// _TIMERINTERRUPT_LOGLEVEL_ from 0 to 4
16+
// Don't define _TIMERINTERRUPT_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
17+
// Don't define TIMER_INTERRUPT_DEBUG > 2. Only for special ISR debugging only. Can hang the system.
18+
#define TIMER_INTERRUPT_DEBUG 2
19+
#define _TIMERINTERRUPT_LOGLEVEL_ 0
20+
21+
// Select a Timer Clock
22+
#define USING_TIM_DIV1 false // for shortest and most accurate timer
23+
#define USING_TIM_DIV16 false // for medium time and medium accurate timer
24+
#define USING_TIM_DIV256 true // for longest timer but least accurate. Default
25+
1426
// Can be included as many times as necessary, without `Multiple Definitions` Linker Error
1527
#include "ESP8266TimerInterrupt.h"
1628
#include "ESP8266_ISR_Timer.hpp"
29+
30+
extern ESP8266_ISR_Timer ISR_Timer; // declaration of the global variable ISRTimer
31+
32+
void setupISR();

examples/multiFileProject/multiFileProject.ino

+8
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
#include "ESP8266TimerInterrupt.h"
2323
#include "ESP8266_ISR_Timer.h"
2424

25+
void doingSomething1()
26+
{
27+
Serial.println("doingSomething1 triggered");
28+
}
2529

2630
void setup()
2731
{
@@ -38,6 +42,10 @@ void setup()
3842
Serial.println(ESP8266_TIMER_INTERRUPT_VERSION_MIN_TARGET);
3943
}
4044
#endif
45+
46+
setupISR(); // in multifileProject.cpp
47+
48+
ISR_Timer.setTimeout(5000, doingSomething1);
4149
}
4250

4351
void loop()

0 commit comments

Comments
 (0)