Skip to content

Commit b882ed6

Browse files
author
Ivan Seidel
committed
Changed to Markdown. Added logo.
1 parent c4e502a commit b882ed6

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

README.md

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
![ArduinoThread Logo](https://raw.githubusercontent.com/ivanseidel/ArduinoThread/master/images/ArduinoThread.png)
2+
13
# ArduinoThread
24

35
A simple way to run multiple stuff in Arduino.
@@ -56,7 +58,7 @@ myThread.setInterval(10); // Setts the wanted interval to be 10ms
5658
myThread.ThreadName = "myThread tag";
5759
// This will set the callback of the Thread: "What should I run"?
5860
myThread.onRun(callback_function); // callback_function is the name of the function
59-
61+
```
6062

6163
Ok, creating Threads are not so hard. But what do we do with them now?
6264

@@ -68,6 +70,7 @@ if(myThread.shouldRun()){
6870
// Yes, the Thread should be runned, let's run it
6971
myThread.run();
7072
}
73+
```
7174

7275
Now that you got the idea, let's think a little bit: What if i have 3, 5, 100 Threads. Do I need to check EACH one?!?
7376

@@ -81,12 +84,14 @@ controller.add(&myThread); // Notice the & before the thread, IF it's not instan
8184
controller.add(&hisThread);
8285
controller.add(&sensorReadings);
8386
...
87+
```
8488

8589
* You have created, configured, grouped it. What is missing? Yes, whe should RUN it!
8690

8791
```c++
8892
// call run on a Thread or a ThreadController to run it
8993
controller.run();
94+
```
9095

9196
This will run all the Threads that NEED to be runned.
9297

@@ -134,6 +139,7 @@ for a period, after a button is pressed.
134139
noInterrupts();
135140
// Put the code that CANNOT be interrupted...
136141
interrupts(); // This will enable the interrupts egain. DO NOT FORGET!
142+
```
137143

138144

139145
## Library Reference
@@ -142,41 +148,28 @@ interrupts(); // This will enable the interrupts egain. DO NOT FORGET!
142148

143149
- `bool Thread::enabled` - Enables or disables the Thread. (do not stop it from running, but will
144150
return false when shouldRun() is called)
145-
146151
- `void Thread::setInterval()` - Setts the desired interval for the Thread (in Ms).
147-
148152
- `bool Thread::shouldRun()` - Returns true, if the Thread should be runned.
149153
(Basicaly,the logic is: (reached time AND is enabled?).
150-
151154
- `void Thread::onRun(<function>)` - The target callback function to be called.
152-
153155
- `void Thread::run()` - This will run the Thread (call the callback function).
154-
155156
- `int Thread::ThreadID` - Theoretically, it's the address of memory. It's unique, and can
156157
be used to compare if two threads are identical.
157-
158158
- `int Thread::ThreadName` - A human-redable thread name. Default is "Thread ThreadID"
159159
eg.: "Thread 141515"; Note that to enable this attribute, you must uncomment the line that disables it on 'Thread.h';
160-
161160
- protected: `void Thread::runned()` - Used to reset internal timer of the Thread.
162161
This is automaticaly called AFTER a call to `run()`.
163162

164163

165164
- `void ThreadController::run()` - This will run the all `Threads` within the `ThreadController`,
166165
only if needed (if shouldRun returns true);
167-
168166
- `bool ThreadController::add(Thread* _thread)` - This will add a the thread to the ThreadController,
169167
and return `true` if suceeded (it the array is full, returns false).
170-
171168
- `void ThreadController::remove(Thread* _thread)` - This will remove the Thread from the ThreadController.
172-
173169
- `void ThreadController::remove(int index)` - This will remove the thread on the position `index`.
174-
175170
- `void ThreadController::clear()` - This will remove ALL threads from the ThreadController array.
176-
177171
- `void ThreadController::size(bool cached = true)` - Returns how many Threads are allocated
178172
inside the ThreadController. If cached is `false`, will force the calculation of threads.
179-
180173
- `Thread* ThreadController::get(int index)` - Returns the Thread on the position `index`.
181174

182175
### You don't need to know:
@@ -187,4 +180,4 @@ interrupts(); // This will enable the interrupts egain. DO NOT FORGET!
187180
* `(Jun/2014): New Example: ControllerWithTimer`
188181
* `1.0 (2013-05-11): Initial release.`
189182

190-
!https://d2weczhvl823v0.cloudfront.net/ivanseidel/ArduinoThread/trend.png(ArduinoThread)!
183+
![ArduinoThread](https://d2weczhvl823v0.cloudfront.net/ivanseidel/ArduinoThread/trend.png)

0 commit comments

Comments
 (0)