Skip to content

Commit

Permalink
release 1.0.0 preparation
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksei Tertychnyi committed Sep 27, 2024
1 parent 32eb24b commit 4c5f34c
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 1 deletion.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,31 @@ put where you want (here example of 2 functions put into queue):
```cpp
F5.tick(); // execute for 'ticks' in timer so the queue class instance will know then to initiate execution
```

### Delayed functions with parameters
Do you need just to delay some function from execution? Do not wait any more!
Initialize:
```cpp
del_fQP<float> F6(8); // // maximum 8 'delayed' functions pointers with parameters in queue

```
put where you want (here example of 2 functions put into queue):
```cpp
F6.push_delayed(your_func_1, 3.14, 1000); // function your_func_1(3.14) will be delayed for 1000 'ticks'
F6.push_delayed(your_func_2, 3.15, 2000); // function your_func_2(3.15) will be delayed for 2000 'ticks'
```

in main loop (or other periodic loop) just need to:
```cpp
void loop() {
.......
F6.pull(); //execute in loop just this super fast function;
}
```
in some timer or periodic function:
```cpp
F6.tick(); // execute for 'ticks' in timer so the queue class instance will know then to initiate execution
```
That's it. Enjoy!


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include <antirtos.h>

typedef
struct pinOut{ // structure (index - pin number, logic - 1/0 = ON/OFF)
int index;
bool logic;
} pinout ;

del_fQP<pinout> Q1(8); // maximum 8 function pointers with parameters in queue

void writePin(pinout cmd){ // write a pin true =- ON

digitalWrite(cmd.index, cmd.logic);

}

void setup() {
// put your setup code here, to run once:
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);

TCCR1A = 0x00; //Normal Mode
TCCR1B = 0x00; //TC1 is OFF
TCNT1 = 0;
OCR1A = 6250; //0.1s delay; prescaler 256
bitSet(TIMSK1, OCIE1A); //local intterupt is active
TCCR1B |= bit(CS12); //Start TC1 with prescale 256

Q1.push_delayed(writePin,{12,true},20); //yellow led ON after 2 sec. (0.1*20 = 2 seconds)
Q1.push_delayed(writePin,{12,false},30); //yellow led OFF after 3 sec.
Q1.push_delayed(writePin,{13,true},50); //red led ON after 5 sec.
Q1.push_delayed(writePin,{13,false},80); //red led OFF after 8 sec.

}

void loop() {
// put your main code here, to run repeatedly:
Q1.pull(); // pull from the queue

}

ISR(TIMER1_COMPA_vect) // timer interrupt ticks one per 0.1 sec
{
TCNT1 = 0;
OCR1A = 6250;
Q1.tick(); // execute tick method for make delayed functionality works
}

10 changes: 10 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ANTIRTOS KEYWORD1
fQ KEYWORD1
fQP KEYWORD1
del_fQ KEYWORD1
del_fQP KEYWORD1

#######################################
# Methods and Functions (KEYWORD2)
Expand All @@ -26,5 +27,14 @@ pull KEYWORD2
# Class del_fQ
###################################
push_delayed KEYWORD2
push KEYWORD2
pull KEYWORD2
tick KEYWORD2

###################################
# Class del_fQP
###################################
push_delayed KEYWORD2
push KEYWORD2
pull KEYWORD2
tick KEYWORD2
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=ANTIRTOS
version=0.2.1
version=1.0.0
author=Aleksei Tertychnyi <[email protected]>
maintainer=Aleksei Tertychnyi <[email protected]>
sentence= No any RTOS needed, you will see...
Expand Down

0 comments on commit 4c5f34c

Please sign in to comment.