This repository was archived by the owner on Jan 29, 2023. It is now read-only.
File tree 3 files changed +50
-0
lines changed
examples/multiFileProject
3 files changed +50
-0
lines changed Original file line number Diff line number Diff line change 10
10
// To demo how to include files in multi-file Projects
11
11
12
12
#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 11
11
12
12
#pragma once
13
13
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
+
14
26
// Can be included as many times as necessary, without `Multiple Definitions` Linker Error
15
27
#include "ESP8266TimerInterrupt.h"
16
28
#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 22
22
#include " ESP8266TimerInterrupt.h"
23
23
#include " ESP8266_ISR_Timer.h"
24
24
25
+ void doingSomething1 ()
26
+ {
27
+ Serial.println (" doingSomething1 triggered" );
28
+ }
25
29
26
30
void setup ()
27
31
{
@@ -38,6 +42,10 @@ void setup()
38
42
Serial.println (ESP8266_TIMER_INTERRUPT_VERSION_MIN_TARGET);
39
43
}
40
44
#endif
45
+
46
+ setupISR (); // in multifileProject.cpp
47
+
48
+ ISR_Timer.setTimeout (5000 , doingSomething1);
41
49
}
42
50
43
51
void loop ()
You can’t perform that action at this time.
0 commit comments