Pages: [1]   Go Down
Author Topic: project: simpleThreads only generated with macros and some global variables  (Read 892 times)
0 Members and 1 Guest are viewing this topic.
Germany, Osnabrück
Offline Offline
God Member
*****
Karma: 30
Posts: 654
E-Technik Student - Master
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey,
I wrote a lib, that can be create simple Threads only with Makros.

The following functions are supported
  
 sequence control:
 * __simpleThread_START(thread_name):
 * __simpleThread_STOP(thread_name):
 * __simpleThread_RESET(thread_name):
 * __simpleThread_RESTART(thread_name): reset + start
 * __simpleThread_IS_RUNNING(thread_name): check if a therad is started
 * __simpleThread_SET_DYN_TIME(thread_name, loop time in ms):  set new loop time, is only available when the thread is with
      __simpleThread_dyn initialized
 * __simpleThread_GET_DYN_TIME(thread_name): get loop time, is only available when the thread is with __simpleThread_dyn initialized
 
 initialization:
 * __simpleThread(thread_name, loop_time): create a new static thread with a name and a default loop time
 * __simpleThread_dyn(thread_name, loop_time on start): create a new dynamic thread with a name and a default loop time
 * __simpleThread_PTR(thread_name): containes the function pointer
 * __simpleThread_LOOP(thread_name): thread loop, same feature as in the arduino software
 * __simpleThread_SETUP(thread_name): thread setup, same feature as in the arduino software
 * __simpleThread_IN_LOOP(): this macro must be called from the orginal arduino loop function
 
 Futures:
 * - the lib contains only macros and one typedef
 * - the first thread need about 300 byte flash memory, ever next need about 90 byte flash memory
 * - threads can be controlled from other threads
 * - a thread must be started befor it runs
 * - the thread call is standardized
 * - the ram use is as small as possible. Every static thread needs 4 byte and a few bits
 * - few bits: for the first 1 - 8 threads 3 bytes are needed for the thread management. For the next 9 - 16 threads 3 new bytes are required
 * - the dynamic threads needs 4 additional bytes ram for the unsigned long loop time value
 * - the loop time from dynamic threads can be changed in the programm running
 * - the loop to call the thread functions needs some bytes on ram, this value is ever the same

What do you think ?

I come from Germany and presented this lib already in the forum. A user said that it might be useful for arduino :: std :: Lib.
PS: Sorry for my "brocken" english, i hope you can read and understand it.

Update 13.05.2013
- add two examples:
--- example: blinking of two leds with different frequences (2 threads)
--- example: thread control with three threads, output over serial monitor

* simpleThread.rar (5.21 KB - downloaded 18 times.)
« Last Edit: May 14, 2013, 01:48:50 am by Jomelo » Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 217
Posts: 13718
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for sharing,

Can you give a small example sketch e.g. to blink two leds at a different frequency?

and no worries your English is fine!
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Germany, Osnabrück
Offline Offline
God Member
*****
Karma: 30
Posts: 654
E-Technik Student - Master
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey,
i have updated the first thread. There are now two examples in the lib archiv:

- led blinking with two different frequenys on digital pin 12 and 13
- thread control with three threads and an output over serial monitor

Examples under:  File->examples->simpleThread->...  in arduino software
Logged

Pages: [1]   Go Up
Jump to: