Skip to content

Commit 20eb075

Browse files
committed
upd
1 parent 78230ec commit 20eb075

File tree

5 files changed

+29
-29
lines changed

5 files changed

+29
-29
lines changed

docs/0.main.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,9 @@ T* getData();
275275
Таймер, наследует `LoopTask` и `SimpleTimer`
276276
277277
```cpp
278-
LoopTimer(uint32_t ms, TaskCallback callback, bool states = false, bool events = false);
279-
LoopTimer(const char* id, uint32_t ms, TaskCallback callback, bool states = false, bool events = false);
280-
LoopTimer(hash_t id, uint32_t ms, TaskCallback callback, bool states = false, bool events = false);
278+
LoopTimer(uint32_t ms, TaskCallback callback, bool start = true, bool states = false, bool events = false);
279+
LoopTimer(const char* id, uint32_t ms, TaskCallback callback, bool start = true, bool states = false, bool events = false);
280+
LoopTimer(hash_t id, uint32_t ms, TaskCallback callback, bool start = true, bool states = false, bool events = false);
281281
282282
// опрос таймера
283283
void poll();
@@ -287,9 +287,9 @@ void poll();
287287
Таймер для создания своих классов
288288

289289
```cpp
290-
LoopTimerBase(uint32_t ms);
291-
LoopTimerBase(const char* id, uint32_t ms);
292-
LoopTimerBase(hash_t id, uint32_t ms);
290+
LoopTimerBase(uint32_t ms, bool start = true);
291+
LoopTimerBase(const char* id, uint32_t ms, bool start = true);
292+
LoopTimerBase(hash_t id, uint32_t ms, bool start = true);
293293

294294
// выполняется при срабатывании таймера
295295
virtual void exec() = 0;
@@ -299,9 +299,9 @@ virtual void exec() = 0;
299299
Таймер с данными
300300
301301
```cpp
302-
LoopTimerData(uint32_t ms, T* data, DataCallback callback);
303-
LoopTimerData(const char* id, uint32_t ms, T* data, DataCallback callback);
304-
LoopTimerData(hash_t id, uint32_t ms, T* data, DataCallback callback);
302+
LoopTimerData(uint32_t ms, T* data, DataCallback callback, bool start = true);
303+
LoopTimerData(const char* id, uint32_t ms, T* data, DataCallback callback, bool start = true);
304+
LoopTimerData(hash_t id, uint32_t ms, T* data, DataCallback callback, bool start = true);
305305
306306
// подключить новые данные
307307
void setData(T* data);

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Looper
2-
version=1.1.3
2+
version=1.1.4
33
author=AlexGyver <[email protected]>
44
maintainer=AlexGyver <[email protected]>
55
sentence=Simple task, thread and event manager for Arduino

src/Looper.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@
1616
// отложить отправку события
1717
#define LP_PUSH_EVENT(id, data) Looper.pushEvent(LPH(id), data)
1818

19-
#define LP_MAKE(type, ...) static type _LP_CONCAT(__loop_obj_, __COUNTER__)(__VA_ARGS__)
20-
#define LP_MAKE_(id, type, ...) static type _LP_CONCAT(__loop_obj_, __COUNTER__)(LPH(id), __VA_ARGS__)
19+
#define LP_MAKE(type, ...) type _LP_CONCAT(__loop_obj_, __COUNTER__)(__VA_ARGS__)
20+
#define LP_MAKE_(id, type, ...) type _LP_CONCAT(__loop_obj_, __COUNTER__)(LPH(id), __VA_ARGS__)
2121
#define LP_NEW(type, ...) new type(__VA_ARGS__)
2222
#define LP_NEW_(id, type, ...) new type(LPH(id), __VA_ARGS__)
2323

2424
// LISTENER
25-
#define LP_LISTENER_(id, func) LP_MAKE_(id, LoopListener, func)
25+
#define LP_LISTENER_(id, ...) LP_MAKE_(id, LoopListener, __VA_ARGS__)
2626

2727
// TICKER
28-
#define LP_TICKER(func) LP_MAKE(LoopTicker, func)
29-
#define LP_TICKER_(id, func) LP_MAKE_(id, LoopTicker, func)
28+
#define LP_TICKER(...) LP_MAKE(LoopTicker, __VA_ARGS__)
29+
#define LP_TICKER_(id, ...) LP_MAKE_(id, LoopTicker, __VA_ARGS__)
3030

3131
// TIMER
32-
#define LP_TIMER(ms, func) LP_MAKE(LoopTimer, ms, func)
33-
#define LP_TIMER_(id, ms, func) LP_MAKE_(id, LoopTimer, ms, func)
32+
#define LP_TIMER(ms, ...) LP_MAKE(LoopTimer, ms, __VA_ARGS__)
33+
#define LP_TIMER_(id, ms, ...) LP_MAKE_(id, LoopTimer, ms, __VA_ARGS__)
3434

3535
// THREAD
3636
#define _LP_THREAD_CASE Looper.thisThread()->_case

src/nodes/Timer.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#pragma once
2+
#include "../utils/SimpleTimer.h"
23
#include "CallbackData.h"
34
#include "LoopTask.h"
4-
#include "../utils/SimpleTimer.h"
55

66
// задача-интервальный таймер
77
class LoopTimer : public LoopTask, public SimpleTimer {
88
public:
9-
LoopTimer(uint32_t ms, TaskCallback callback, bool states = false, bool events = false) : LoopTimer((hash_t)0, ms, callback, states, events) {}
10-
LoopTimer(const char* id, uint32_t ms, TaskCallback callback, bool states = false, bool events = false) : LoopTimer(LPHr(id), ms, callback, states, events) {}
11-
LoopTimer(hash_t id, uint32_t ms, TaskCallback callback, bool states = false, bool events = false) : LoopTask(id, callback, TASK_IS_TIMER, states, events), SimpleTimer(ms) {}
9+
LoopTimer(uint32_t ms, TaskCallback callback, bool start = true, bool states = false, bool events = false) : LoopTimer((hash_t)0, ms, callback, start, states, events) {}
10+
LoopTimer(const char* id, uint32_t ms, TaskCallback callback, bool start = true, bool states = false, bool events = false) : LoopTimer(LPHr(id), ms, callback, start, states, events) {}
11+
LoopTimer(hash_t id, uint32_t ms, TaskCallback callback, bool start = true, bool states = false, bool events = false) : LoopTask(id, callback, TASK_IS_TIMER, states, events), SimpleTimer(ms, start) {}
1212

1313
// опрос таймера
1414
void poll() {
@@ -19,9 +19,9 @@ class LoopTimer : public LoopTask, public SimpleTimer {
1919
// таймер для создания своих классов
2020
class LoopTimerBase : public LoopTimer {
2121
public:
22-
LoopTimerBase(uint32_t ms) : LoopTimerBase((hash_t)0, ms) {}
23-
LoopTimerBase(const char* id, uint32_t ms) : LoopTimerBase(LPHr(id), ms) {}
24-
LoopTimerBase(hash_t id, uint32_t ms) : LoopTimer(id, ms, _exec) {}
22+
LoopTimerBase(uint32_t ms, bool start = true) : LoopTimerBase((hash_t)0, ms, start) {}
23+
LoopTimerBase(const char* id, uint32_t ms, bool start = true) : LoopTimerBase(LPHr(id), ms, start) {}
24+
LoopTimerBase(hash_t id, uint32_t ms, bool start = true) : LoopTimer(id, ms, _exec, start) {}
2525

2626
// выполняется при срабатывании таймера
2727
virtual void exec() = 0;
@@ -42,9 +42,9 @@ class LoopTimerData : public LoopTimer, public TaskCallbackData<T> {
4242
LP_MAKE_CALLBACK(DataCallback, void, T*);
4343

4444
public:
45-
LoopTimerData(uint32_t ms, T* data, DataCallback callback) : LoopTimerData((hash_t)0, ms, data, callback) {}
46-
LoopTimerData(const char* id, uint32_t ms, T* data, DataCallback callback) : LoopTimerData(LPHr(id), ms, data, callback) {}
47-
LoopTimerData(hash_t id, uint32_t ms, T* data, DataCallback callback) : LoopTimer(id, ms, _exec), TaskCallbackData<T>(data, callback) {}
45+
LoopTimerData(uint32_t ms, T* data, DataCallback callback, bool start = true) : LoopTimerData((hash_t)0, ms, data, callback, start) {}
46+
LoopTimerData(const char* id, uint32_t ms, T* data, DataCallback callback, bool start = true) : LoopTimerData(LPHr(id), ms, data, callback, start) {}
47+
LoopTimerData(hash_t id, uint32_t ms, T* data, DataCallback callback, bool start = true) : LoopTimer(id, ms, _exec, start), TaskCallbackData<T>(data, callback) {}
4848

4949
private:
5050
using LoopTask::attach;

src/utils/SimpleTimer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// базовый миллисекундный таймер
66
class SimpleTimer {
77
public:
8-
SimpleTimer(uint32_t ms = 0) {
9-
if (ms) restart(ms);
8+
SimpleTimer(uint32_t ms = 0, bool start = true) {
9+
if (start && ms) restart(ms);
1010
}
1111

1212
// перезапустить

0 commit comments

Comments
 (0)