This repository was archived by the owner on Jan 29, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +50
-0
lines changed
examples/multiFileProject Expand file tree Collapse file tree 3 files changed +50
-0
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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 ();
Original file line number Diff line number Diff line change 2222#include " ESP8266TimerInterrupt.h"
2323#include " ESP8266_ISR_Timer.h"
2424
25+ void doingSomething1 ()
26+ {
27+ Serial.println (" doingSomething1 triggered" );
28+ }
2529
2630void 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
4351void loop ()
You can’t perform that action at this time.
0 commit comments